Subversion Repositories eFlore/Applications.del

Rev

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

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