Subversion Repositories eFlore/Applications.del

Rev

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

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