Subversion Repositories eFlore/Applications.del

Rev

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

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