Subversion Repositories eFlore/Applications.del

Rev

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

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