Subversion Repositories eFlore/Applications.del

Rev

Rev 1551 | Rev 1557 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1551 Rev 1552
1
package org.tela_botanica.del.client.cache;
1
package org.tela_botanica.del.client.cache;
2
 
2
 
3
import java.util.Arrays;
3
import java.util.Arrays;
4
import java.util.List;
4
import java.util.List;
5
 
5
 
6
import org.tela_botanica.del.client.config.Config;
6
import org.tela_botanica.del.client.config.Config;
7
import org.tela_botanica.del.client.gestionhistorique.ConstantesNavigation;
7
import org.tela_botanica.del.client.gestionhistorique.ConstantesNavigation;
8
import org.tela_botanica.del.client.modeles.Image;
8
import org.tela_botanica.del.client.modeles.Image;
9
import org.tela_botanica.del.client.modeles.InformationsRecherche;
9
import org.tela_botanica.del.client.modeles.InformationsRecherche;
10
import org.tela_botanica.del.client.modeles.ModeTri;
10
import org.tela_botanica.del.client.modeles.ModeTri;
11
import org.tela_botanica.del.client.modeles.Observation;
11
import org.tela_botanica.del.client.modeles.Observation;
12
import org.tela_botanica.del.client.modeles.Protocole;
12
import org.tela_botanica.del.client.modeles.Protocole;
13
import org.tela_botanica.del.client.modeles.Utilisateur;
13
import org.tela_botanica.del.client.modeles.Utilisateur;
14
import org.tela_botanica.del.client.utils.URLUtils;
14
import org.tela_botanica.del.client.utils.URLUtils;
15
 
15
 
16
import com.google.gwt.core.client.GWT;
16
import com.google.gwt.core.client.GWT;
17
import com.google.gwt.user.client.Window;
17
import com.google.gwt.user.client.Window;
18
import com.google.gwt.user.client.Window.Location;
18
import com.google.gwt.user.client.Window.Location;
19
 
19
 
20
public class CacheClient {
20
public class CacheClient {
21
 
21
 
22
	private List<Protocole> listeProtocoles;
22
	private List<Protocole> listeProtocoles;
23
	
23
	
24
	private Observation observationCourante;
24
	private Observation observationCourante;
25
	private Image imageCourante;
25
	private Image imageCourante;
26
	private String taxonPourRechercheEflore;
26
	private String taxonPourRechercheEflore;
27
	private String idProtocoleEnAttente = null;
27
	private String idProtocoleEnAttente = null;
28
	private Protocole protocoleCourant;
28
	private Protocole protocoleCourant;
29
	private String referentielCourant;
29
	private String referentielCourant;
30
	private int numPageRechercheImage = 0;
30
	private int numPageRechercheImage = 0;
31
	private int nbTotalImagesRecherchees = 0;
31
	private int nbTotalImagesRecherchees = 0;
32
	
32
	
33
	private boolean referentielNonModifiable = false;
33
	private boolean referentielNonModifiable = false;
34
 
34
 
35
	private int pasPagination = 12;
35
	private int pasPagination = 12;
36
	private int pageCouranteRechercheImage = 1;
36
	private int pageCouranteRechercheImage = 1;
37
	private int pageCouranteRechercheObservations = 1;
37
	private int pageCouranteRechercheObservations = 1;
38
	private InformationsRecherche informationsRechercheImage;
38
	private InformationsRecherche informationsRechercheImage;
39
	private InformationsRecherche informationsRechercheObservation;
39
	private InformationsRecherche informationsRechercheObservation;
40
	private Utilisateur utilisateur;
40
	private Utilisateur utilisateur;
41
	private String pageCourante = "";
41
	private String pageCourante = "";
42
	private String statut;
42
	private String statut;
43
	private String[] statutsPossibles = {
43
	private String[] statutsPossibles = {
44
		ConstantesNavigation.PARAM_TYPE_TOUS, 
44
		ConstantesNavigation.PARAM_TYPE_TOUS, 
45
		ConstantesNavigation.PARAM_TYPE_A_DETERMINER,
45
		ConstantesNavigation.PARAM_TYPE_A_DETERMINER,
46
		ConstantesNavigation.PARAM_TYPE_EN_DISCUSSION,
46
		ConstantesNavigation.PARAM_TYPE_EN_DISCUSSION,
47
		ConstantesNavigation.PARAM_TYPE_VALIDEES
47
		ConstantesNavigation.PARAM_TYPE_VALIDEES
48
	};
48
	};
49
	
49
	
50
	public void supprimerFiltreStatut() {
50
	public void supprimerFiltreStatut() {
51
		this.statut = null;
51
		this.statut = null;
52
	}
52
	}
53
	
53
	
54
	public void setFiltreStatut(String statut) {
54
	public void setFiltreStatut(String statut) {
55
		this.statut = statut;
55
		this.statut = statut;
56
	}
56
	}
57
	
57
	
58
	public String getFiltreStatut() {
58
	public String getFiltreStatut() {
59
		return this.statut;
59
		return this.statut;
60
	}
60
	}
61
	
61
	
62
	public String getPageCourante() {
62
	public String getPageCourante() {
63
		return pageCourante;
63
		return pageCourante;
64
	}
64
	}
65
 
65
 
66
	public void setPageCourante(String pageCourante) {
66
	public void setPageCourante(String pageCourante) {
-
 
67
		pageCourante = pageCourante.replaceAll("#", "");
67
		this.pageCourante = pageCourante;
68
		this.pageCourante = pageCourante;
68
	}
69
	}
69
 
70
 
70
	private static CacheClient instance;
71
	private static CacheClient instance;
71
 
72
 
72
	private CacheClient() {
73
	private CacheClient() {
73
		instance = this;
74
		instance = this;
74
	}
75
	}
75
 
76
 
76
	public void initialiserAvecParametres() {
77
	public void initialiserAvecParametres() {
77
		String urlCourante = Window.Location.getHref();
78
		String urlCourante = Window.Location.getHref();
78
		Config config = new Config();
79
		Config config = new Config();
79
		String urlAppliImg = config.getUrl("pictoflora");
80
		String urlAppliImg = config.getUrl("pictoflora");
80
		
81
		
81
		setPageCourante(Location.getHash());
82
		setPageCourante(Location.getHash());
82
		GWT.log("initialiserAvecParametres:"+getPageCourante());
83
		GWT.log("initialiserAvecParametres:"+getPageCourante());
83
		
84
		
84
		String rechercheLibre = Location.getParameter("masque");
85
		String rechercheLibre = Location.getParameter("masque");
85
		String famille = Location.getParameter("masque.famille");
86
		String famille = Location.getParameter("masque.famille");
86
		String taxon = Location.getParameter("masque.ns");
87
		String taxon = Location.getParameter("masque.ns");
87
		String genre = Location.getParameter("masque.genre");
88
		String genre = Location.getParameter("masque.genre");
88
		String commune = Location.getParameter("masque.commune");
89
		String commune = Location.getParameter("masque.commune");
89
		String dept = Location.getParameter("masque.departement");
90
		String dept = Location.getParameter("masque.departement");
90
		String auteur = Location.getParameter("masque.auteur");
91
		String auteur = Location.getParameter("masque.auteur");
91
		String date = Location.getParameter("masque.date");
92
		String date = Location.getParameter("masque.date");
92
		String tag = Location.getParameter("masque.tag");
93
		String tag = Location.getParameter("masque.tag");
93
		String tagCel = Location.getParameter("masque.tag_cel");
94
		String tagCel = Location.getParameter("masque.tag_cel");
94
		String tagDel = Location.getParameter("masque.tag_pictoflora");
95
		String tagDel = Location.getParameter("masque.tag_pictoflora");
95
		String referentiel = Location.getParameter("masque.referentiel");
96
		String referentiel = Location.getParameter("masque.referentiel");
96
		String protocole = Location.getParameter("protocole");
97
		String protocole = Location.getParameter("protocole");
97
		String statutParam = Location.getParameter("masque.type");
98
		String statutParam = Location.getParameter("masque.type");
98
		
99
		
99
		String page = Location.getParameter("page");
100
		String page = Location.getParameter("page");
100
		Integer pageInt = null;
101
		Integer pageInt = null;
101
		try {
102
		try {
102
			pageInt = Integer.parseInt(page);
103
			pageInt = Integer.parseInt(page);
103
		} catch (Exception e) {
104
		} catch (Exception e) {
104
			pageInt = null;
105
			pageInt = null;
105
		}
106
		}
106
		
107
		
107
		String pas = Location.getParameter("pas");	
108
		String pas = Location.getParameter("pas");	
108
		Integer pasInt = null;
109
		Integer pasInt = null;
109
		if (pas != null) {
110
		if (pas != null) {
110
			try {
111
			try {
111
				pasInt = Integer.parseInt(pas);
112
				pasInt = Integer.parseInt(pas);
112
			} catch (Exception e) {
113
			} catch (Exception e) {
113
				pasInt = null;
114
				pasInt = null;
114
			}
115
			}
115
		}
116
		}
116
		
117
		
117
		InformationsRecherche rechercheParArguments = new InformationsRecherche();
118
		InformationsRecherche rechercheParArguments = new InformationsRecherche();
118
		rechercheParArguments.setRechercheLibre(rechercheLibre);
119
		rechercheParArguments.setRechercheLibre(rechercheLibre);
119
		rechercheParArguments.setFamille(famille);
120
		rechercheParArguments.setFamille(famille);
120
		rechercheParArguments.setTaxon(taxon);
121
		rechercheParArguments.setTaxon(taxon);
121
		rechercheParArguments.setGenre(genre);
122
		rechercheParArguments.setGenre(genre);
122
		rechercheParArguments.setCommune(commune);
123
		rechercheParArguments.setCommune(commune);
123
		rechercheParArguments.setDepartement(dept);
124
		rechercheParArguments.setDepartement(dept);
124
		rechercheParArguments.setAuteur(auteur);
125
		rechercheParArguments.setAuteur(auteur);
125
		rechercheParArguments.setDate(date);
126
		rechercheParArguments.setDate(date);
126
		rechercheParArguments.setTag(tag);
127
		rechercheParArguments.setTag(tag);
127
		
128
		
128
		if (protocole != null && !protocole.equals("")) {
129
		if (protocole != null && !protocole.equals("")) {
129
			CacheClient.getInstance().setIdProtocoleEnAttente(protocole);
130
			CacheClient.getInstance().setIdProtocoleEnAttente(protocole);
130
			rechercheParArguments.setIdProtocoleSelectionne(protocole);
131
			rechercheParArguments.setIdProtocoleSelectionne(protocole);
131
		} else if (URLUtils.getURLSpecialParameterValue() != null) {
132
		} else if (URLUtils.getURLSpecialParameterValue() != null) {
132
			CacheClient.getInstance().setIdProtocoleEnAttente(URLUtils.getURLSpecialParameterValue());
133
			CacheClient.getInstance().setIdProtocoleEnAttente(URLUtils.getURLSpecialParameterValue());
133
			rechercheParArguments.setIdProtocoleSelectionne(URLUtils.getURLSpecialParameterValue());
134
			rechercheParArguments.setIdProtocoleSelectionne(URLUtils.getURLSpecialParameterValue());
134
		}
135
		}
135
		
136
		
136
		if (pasInt != null) {
137
		if (pasInt != null) {
137
			setPasPagination(pasInt);
138
			setPasPagination(pasInt);
138
		}
139
		}
139
		
140
		
140
		if (urlCourante.contains(urlAppliImg)) {
141
		if (urlCourante.contains(urlAppliImg)) {
141
			rechercheParArguments.setMotClefCel(tagCel);
142
			rechercheParArguments.setMotClefCel(tagCel);
142
			rechercheParArguments.setMotClefDel(tagDel);
143
			rechercheParArguments.setMotClefDel(tagDel);
143
			if (pageInt != null) {
144
			if (pageInt != null) {
144
				setPageCouranteRechercheImages(pageInt);
145
				setPageCouranteRechercheImages(pageInt);
145
			}
146
			}
146
		} else {
147
		} else {
147
			if (pageInt != null) {
148
			if (pageInt != null) {
148
				setPageCouranteRechercheObservations(pageInt);
149
				setPageCouranteRechercheObservations(pageInt);
149
			}
150
			}
150
		}
151
		}
151
		
152
		
152
		String tri = Location.getParameter("tri");		
153
		String tri = Location.getParameter("tri");		
153
		String ordre = Location.getParameter("ordre");
154
		String ordre = Location.getParameter("ordre");
154
		
155
		
155
		if (tri != null) {
156
		if (tri != null) {
156
			ModeTri modeTri = ModeTri.TRI_ASCENDANT;
157
			ModeTri modeTri = ModeTri.TRI_ASCENDANT;
157
			if (ordre != null && ordre.equals("asc")) {
158
			if (ordre != null && ordre.equals("asc")) {
158
				modeTri = ModeTri.TRI_ASCENDANT;
159
				modeTri = ModeTri.TRI_ASCENDANT;
159
			}
160
			}
160
			
161
			
161
			if (ordre != null && ordre.equals("desc")) {
162
			if (ordre != null && ordre.equals("desc")) {
162
				modeTri = ModeTri.TRI_DESCENDANT;
163
				modeTri = ModeTri.TRI_DESCENDANT;
163
			}
164
			}
164
			
165
			
165
			if (tri.equals("votes")) {
166
			if (tri.equals("votes")) {
166
				rechercheParArguments.setTriParNbVotes(modeTri);
167
				rechercheParArguments.setTriParNbVotes(modeTri);
167
			}
168
			}
168
			
169
			
169
			if (tri.equals("tags")) {
170
			if (tri.equals("tags")) {
170
				rechercheParArguments.setTriParNbTags(modeTri);
171
				rechercheParArguments.setTriParNbTags(modeTri);
171
			}
172
			}
172
			
173
			
173
			if (tri.equals("date_observation")) {
174
			if (tri.equals("date_observation")) {
174
				rechercheParArguments.setTriParDate(modeTri);
175
				rechercheParArguments.setTriParDate(modeTri);
175
			}
176
			}
176
		}
177
		}
177
		
178
		
178
		rechercheParArguments.setMotClef(tag);
179
		rechercheParArguments.setMotClef(tag);
179
		
180
		
180
		// si le référentiel est passé dans l'url alors il ne doit pas être modifiable
181
		// si le référentiel est passé dans l'url alors il ne doit pas être modifiable
181
		if (referentiel != null && !referentiel.equals("")) {
182
		if (referentiel != null && !referentiel.equals("")) {
182
			setReferentielCourant(referentiel);
183
			setReferentielCourant(referentiel);
183
			rechercheParArguments.setReferentiel(referentiel);
184
			rechercheParArguments.setReferentiel(referentiel);
184
			referentielNonModifiable = true;
185
			referentielNonModifiable = true;
185
		}
186
		}
186
		
187
		
187
		if (Location.getParameterMap().size() == 0) {
188
		if (Location.getParameterMap().size() == 0) {
188
			// par défaut l'application s'ouvre sur l'onglet à déterminer
189
			// par défaut l'application s'ouvre sur l'onglet à déterminer
189
			statut = ConstantesNavigation.PARAM_TYPE_DEFAUT;
190
			statut = ConstantesNavigation.PARAM_TYPE_DEFAUT;
190
		} else {
191
		} else {
191
			if (Arrays.asList(statutsPossibles).contains(statutParam)) {
192
			if (Arrays.asList(statutsPossibles).contains(statutParam)) {
192
				statut = statutParam;
193
				statut = statutParam;
193
			} else {
194
			} else {
194
				statut = ConstantesNavigation.PARAM_TYPE_DEFAUT;
195
				statut = ConstantesNavigation.PARAM_TYPE_DEFAUT;
195
			}
196
			}
196
		}
197
		}
197
		
198
		
198
		informationsRechercheImage = rechercheParArguments;
199
		informationsRechercheImage = rechercheParArguments;
199
		informationsRechercheObservation = rechercheParArguments;
200
		informationsRechercheObservation = rechercheParArguments;
200
		
201
		
201
		mettreAjourUrlCourante();
202
		mettreAjourUrlCourante();
202
	}
203
	}
203
	
204
	
204
	public void setIdProtocoleEnAttente(String idProtocole) {
205
	public void setIdProtocoleEnAttente(String idProtocole) {
205
		idProtocoleEnAttente = idProtocole;
206
		idProtocoleEnAttente = idProtocole;
206
	}
207
	}
207
	
208
	
208
	public String getIdProtocoleEnAttente() {
209
	public String getIdProtocoleEnAttente() {
209
		return idProtocoleEnAttente;
210
		return idProtocoleEnAttente;
210
	}
211
	}
211
 
212
 
212
	public Utilisateur getUtilisateur() {
213
	public Utilisateur getUtilisateur() {
213
		if (this.utilisateur == null) {
214
		if (this.utilisateur == null) {
214
			this.utilisateur = new Utilisateur(null, null);
215
			this.utilisateur = new Utilisateur(null, null);
215
		}
216
		}
216
		return this.utilisateur;
217
		return this.utilisateur;
217
	}
218
	}
218
	
219
	
219
	public void setUtilisateur(Utilisateur utilisateur) {
220
	public void setUtilisateur(Utilisateur utilisateur) {
220
		this.utilisateur = utilisateur; 
221
		this.utilisateur = utilisateur; 
221
	}
222
	}
222
	
223
	
223
	public void setHome(String home) {
224
	public void setHome(String home) {
224
		setPageCourante(home);
225
		setPageCourante(home);
225
	}
226
	}
226
	
227
	
227
	public String getHome() {
228
	public String getHome() {
228
		return "";
229
		return "";
229
	}
230
	}
230
	
231
	
231
	public Observation getObservationCourante() {
232
	public Observation getObservationCourante() {
232
		return observationCourante;
233
		return observationCourante;
233
	}
234
	}
234
 
235
 
235
	public void setObservationCourante(Observation observationCourante) {
236
	public void setObservationCourante(Observation observationCourante) {
236
		this.observationCourante = observationCourante;
237
		this.observationCourante = observationCourante;
237
	}
238
	}
238
 
239
 
239
	public static CacheClient getInstance() {
240
	public static CacheClient getInstance() {
240
		if (instance == null) {
241
		if (instance == null) {
241
			instance = new CacheClient();
242
			instance = new CacheClient();
242
		}
243
		}
243
		return instance;
244
		return instance;
244
	}
245
	}
245
 
246
 
246
	public String getTaxonPourRechercheEflore() {
247
	public String getTaxonPourRechercheEflore() {
247
		return taxonPourRechercheEflore;
248
		return taxonPourRechercheEflore;
248
	}
249
	}
249
 
250
 
250
	public void setTaxonPourRechercheEflore(String taxonPourRechercheEflore) {
251
	public void setTaxonPourRechercheEflore(String taxonPourRechercheEflore) {
251
		this.taxonPourRechercheEflore = taxonPourRechercheEflore;
252
		this.taxonPourRechercheEflore = taxonPourRechercheEflore;
252
	}
253
	}
253
 
254
 
254
	public int getNumPageRechercheImage() {
255
	public int getNumPageRechercheImage() {
255
		return numPageRechercheImage;
256
		return numPageRechercheImage;
256
	}
257
	}
257
 
258
 
258
	// Pour la recherche :
259
	// Pour la recherche :
259
	public int getPasPagination() {
260
	public int getPasPagination() {
260
		return pasPagination;
261
		return pasPagination;
261
	}
262
	}
262
 
263
 
263
	public void setPasPagination(int pasPagination) {
264
	public void setPasPagination(int pasPagination) {
264
		this.pasPagination = pasPagination;
265
		this.pasPagination = pasPagination;
265
	}
266
	}
266
 
267
 
267
	public void setPageCouranteRechercheImages(int pageCouranteRecherche) {
268
	public void setPageCouranteRechercheImages(int pageCouranteRecherche) {
268
		this.pageCouranteRechercheImage = pageCouranteRecherche;
269
		this.pageCouranteRechercheImage = pageCouranteRecherche;
269
	}
270
	}
270
 
271
 
271
	public int getPageCouranteRechercheImage() {
272
	public int getPageCouranteRechercheImage() {
272
		return this.pageCouranteRechercheImage;
273
		return this.pageCouranteRechercheImage;
273
	}
274
	}
274
 
275
 
275
	public void setNbTotalImagesRecherchees(int nbTotalImagesRecherchees) {
276
	public void setNbTotalImagesRecherchees(int nbTotalImagesRecherchees) {
276
		this.nbTotalImagesRecherchees = nbTotalImagesRecherchees;
277
		this.nbTotalImagesRecherchees = nbTotalImagesRecherchees;
277
	}
278
	}
278
 
279
 
279
	public int getNbTotalImagesRecherchees() {
280
	public int getNbTotalImagesRecherchees() {
280
		return this.nbTotalImagesRecherchees;
281
		return this.nbTotalImagesRecherchees;
281
	}
282
	}
282
 
283
 
283
	public Image getImageCourante() {
284
	public Image getImageCourante() {
284
		return imageCourante;
285
		return imageCourante;
285
	}
286
	}
286
 
287
 
287
	public void setImageCourante(Image imageCourante) {
288
	public void setImageCourante(Image imageCourante) {
288
		this.imageCourante = imageCourante;
289
		this.imageCourante = imageCourante;
289
	}
290
	}
290
	
291
	
291
	public void setListeProtocoles(List<Protocole> listeProtocole) {
292
	public void setListeProtocoles(List<Protocole> listeProtocole) {
292
		this.listeProtocoles = listeProtocole;
293
		this.listeProtocoles = listeProtocole;
293
	}
294
	}
294
	
295
	
295
	public List<Protocole> getListeProtocoles() {
296
	public List<Protocole> getListeProtocoles() {
296
		return this.listeProtocoles;
297
		return this.listeProtocoles;
297
	}
298
	}
298
 
299
 
299
	public Protocole getProtocoleCourant() {
300
	public Protocole getProtocoleCourant() {
300
		return protocoleCourant;
301
		return protocoleCourant;
301
	}
302
	}
302
 
303
 
303
	public void setProtocoleCourant(Protocole protocoleCourant) {
304
	public void setProtocoleCourant(Protocole protocoleCourant) {
304
		this.protocoleCourant = protocoleCourant;
305
		this.protocoleCourant = protocoleCourant;
305
	}
306
	}
306
 
307
 
307
	public InformationsRecherche getInformationsRechercheImage() {
308
	public InformationsRecherche getInformationsRechercheImage() {
308
		if (informationsRechercheImage == null) {
309
		if (informationsRechercheImage == null) {
309
			informationsRechercheImage = new InformationsRecherche();
310
			informationsRechercheImage = new InformationsRecherche();
310
		}
311
		}
311
		return informationsRechercheImage;
312
		return informationsRechercheImage;
312
	}
313
	}
313
 
314
 
314
	public InformationsRecherche getInformationsRechercheObservation() {
315
	public InformationsRecherche getInformationsRechercheObservation() {
315
		if (informationsRechercheObservation == null) {
316
		if (informationsRechercheObservation == null) {
316
			informationsRechercheObservation = new InformationsRecherche();
317
			informationsRechercheObservation = new InformationsRecherche();
317
		}
318
		}
318
		return informationsRechercheObservation;
319
		return informationsRechercheObservation;
319
	}
320
	}
320
 
321
 
321
	public void setInformationsRechercheImage(InformationsRecherche informationsRechercheImage) {
322
	public void setInformationsRechercheImage(InformationsRecherche informationsRechercheImage) {
322
		this.informationsRechercheImage = informationsRechercheImage;
323
		this.informationsRechercheImage = informationsRechercheImage;
323
	}
324
	}
324
 
325
 
325
	public void setInformationsRechercheObservation(InformationsRecherche informationsRechercheObservation) {
326
	public void setInformationsRechercheObservation(InformationsRecherche informationsRechercheObservation) {
326
		this.informationsRechercheObservation = informationsRechercheObservation;
327
		this.informationsRechercheObservation = informationsRechercheObservation;
327
	}
328
	}
328
 
329
 
329
	public int getPageCouranteRechercheObservations() {
330
	public int getPageCouranteRechercheObservations() {
330
		return pageCouranteRechercheObservations;
331
		return pageCouranteRechercheObservations;
331
	}
332
	}
332
 
333
 
333
	public void setPageCouranteRechercheObservations(int pageCouranteRechercheObservations) {
334
	public void setPageCouranteRechercheObservations(int pageCouranteRechercheObservations) {
334
		this.pageCouranteRechercheObservations = pageCouranteRechercheObservations;
335
		this.pageCouranteRechercheObservations = pageCouranteRechercheObservations;
335
	}
336
	}
336
	
337
	
337
	public void setReferentielCourant(String referentielCourant) {
338
	public void setReferentielCourant(String referentielCourant) {
338
		this.referentielCourant = referentielCourant;
339
		this.referentielCourant = referentielCourant;
339
	}
340
	}
340
	
341
	
341
	public String getReferentielCourant() {
342
	public String getReferentielCourant() {
342
		return referentielCourant;
343
		return referentielCourant;
343
	}
344
	}
344
	
345
	
345
	public void setReferentielNonModifiable(boolean referentielNonModifiable) {
346
	public void setReferentielNonModifiable(boolean referentielNonModifiable) {
346
		this.referentielNonModifiable = referentielNonModifiable;
347
		this.referentielNonModifiable = referentielNonModifiable;
347
	}
348
	}
348
	
349
	
349
	public boolean getReferentielNonModifiable() {
350
	public boolean getReferentielNonModifiable() {
350
		return referentielNonModifiable;
351
		return referentielNonModifiable;
351
	}
352
	}
352
	
353
	
353
	public String genererUrlCourante() {
354
	public String genererUrlCourante() {
354
		String urlCourante = Window.Location.getHref();
355
		String urlCourante = Window.Location.getHref();
355
		Config config = new Config();
356
		Config config = new Config();
356
		String urlAppliObs = config.getUrl("identiplante");
357
		String urlAppliObs = config.getUrl("identiplante");
357
		String urlAppliImg = config.getUrl("pictoflora");
358
		String urlAppliImg = config.getUrl("pictoflora");
358
		String url = urlCourante;
359
		String url = urlCourante;
359
		String arguments = "";
360
		String arguments = "";
360
		
361
		
361
		//GWT.log("URL courante:"+urlCourante);
362
		GWT.log("URL courante:"+urlCourante);
362
		//GWT.log("IdentiPlante:"+urlCourante.contains(urlAppliObs));
363
		//GWT.log("IdentiPlante:"+urlCourante.contains(urlAppliObs));
363
		//GWT.log("PictoFlora:"+urlCourante.contains(urlAppliImg));
364
		//GWT.log("PictoFlora:"+urlCourante.contains(urlAppliImg));
364
		
365
		
365
		if (urlCourante.contains(urlAppliImg)) {
366
		if (urlCourante.contains(urlAppliImg)) {
366
			InformationsRecherche infoRecherche;
367
			InformationsRecherche infoRecherche;
367
			infoRecherche = getInformationsRechercheImage();
368
			infoRecherche = getInformationsRechercheImage();
368
			
369
			
369
			if (CacheClient.getInstance().getProtocoleCourant() != null) {
370
			if (CacheClient.getInstance().getProtocoleCourant() != null) {
370
				infoRecherche.setIdProtocoleSelectionne("" + CacheClient.getInstance().getProtocoleCourant().getId());
371
				infoRecherche.setIdProtocoleSelectionne("" + CacheClient.getInstance().getProtocoleCourant().getId());
371
			}
372
			}
372
			
373
			
373
			arguments = infoRecherche.versChaineRequete();
374
			arguments = infoRecherche.versChaineRequete();
374
			arguments += (arguments.isEmpty()) ? "" : "&";
375
			arguments += (arguments.isEmpty()) ? "" : "&";
375
			arguments += "page="+getPageCouranteRechercheImage()+"&pas="+getPasPagination();
376
			arguments += "page="+getPageCouranteRechercheImage()+"&pas="+getPasPagination();
376
 
377
 
377
			url = config.getUrl("pictoflora");
378
			url = config.getUrl("pictoflora");
378
		} else if (urlCourante.contains(urlAppliObs)) {
379
		} else if (urlCourante.contains(urlAppliObs)) {
379
			InformationsRecherche infoRecherche;
380
			InformationsRecherche infoRecherche;
380
			infoRecherche = getInformationsRechercheObservation();
381
			infoRecherche = getInformationsRechercheObservation();
381
			
382
			
382
			arguments = "masque.type="+statut;
383
			arguments = "masque.type="+statut;
383
			arguments += "&page="+getPageCouranteRechercheObservations()+"&pas="+getPasPagination();
384
			arguments += "&page="+getPageCouranteRechercheObservations()+"&pas="+getPasPagination();
384
			arguments += "&"+infoRecherche.versChaineRequete();
385
			arguments += "&"+infoRecherche.versChaineRequete();
385
			
386
			
386
			url = config.getUrl("identiplante");
387
			url = config.getUrl("identiplante");
387
		}
388
		}
388
		
389
		
389
		if (!GWT.isScript()) {
390
		if (!GWT.isScript()) {
390
			arguments += "&gwt.codesvr="+Location.getParameter("gwt.codesvr")+"";
391
			arguments += "&gwt.codesvr="+Location.getParameter("gwt.codesvr")+"";
391
		}
392
		}
392
		arguments = (arguments.isEmpty()) ? "" : "?" + arguments;
393
		arguments = (arguments.isEmpty()) ? "" : "?" + arguments;
393
		String signet = getPageCourante().equals("") ? "" : "#" + getPageCourante();
394
		String signet = getPageCourante().equals("") ? "" : "#" + getPageCourante();
394
		url += arguments + signet;
395
		url += arguments + signet;
395
		
396
		
396
		// remplacements batards pour corriger l'url
397
		// remplacements batards pour corriger l'url
397
		// TODO: factoriser toute la fonction 
398
		// TODO: factoriser toute la fonction 
398
		url = url.replaceAll("&#", "#");
399
		url = url.replaceAll("&#", "#");
399
		url = url.replaceAll("&&", "&");
400
		url = url.replaceAll("&&", "&");
400
		url = url.replaceAll("\\?&", "?");
401
		url = url.replaceAll("\\?&", "?");
401
		
402
		
402
		//GWT.log("URL de sortie:"+url);
403
		GWT.log("URL de sortie:"+url);
403
		
404
		
404
		return url;
405
		return url;
405
	}
406
	}
406
	
407
	
407
	public void mettreAjourUrlCourante() {
408
	public void mettreAjourUrlCourante() {
408
		mettreAJourUrlCouranteSansRecharger(genererUrlCourante());
409
		mettreAJourUrlCouranteSansRecharger(genererUrlCourante());
409
	}
410
	}
410
	
411
	
411
	private static native void mettreAJourUrlCouranteSansRecharger(String nouvelleUrl) /*-{
412
	private static native void mettreAJourUrlCouranteSansRecharger(String nouvelleUrl) /*-{
412
		// javascript double negative trick
413
		// javascript double negative trick
413
		// pour plus d'info http://stackoverflow.com/questions/4686583/can-someone-explain-this-double-negative-trick
414
		// pour plus d'info http://stackoverflow.com/questions/4686583/can-someone-explain-this-double-negative-trick
414
		if (!!($wnd.history && $wnd.history.pushState)) {
415
		if (!!($wnd.history && $wnd.history.pushState)) {
415
			$wnd.history.pushState(nouvelleUrl, "", nouvelleUrl);
416
			$wnd.history.pushState(nouvelleUrl, "", nouvelleUrl);
416
		}
417
		}
417
	}-*/;
418
	}-*/;
418
}
419
}