Subversion Repositories eFlore/Applications.del

Rev

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

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