Subversion Repositories eFlore/Applications.del

Rev

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

Rev 2054 Rev 2140
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
 
-
 
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
-
 
123
			pnInscritsSeulementBool = pnInscritsSeulement.equals("1");
-
 
124
			Del.LogVersFirebug("Il vaut : " + pnInscritsSeulementBool);
-
 
125
		}
-
 
126
 
115
		String page = Location.getParameter("page");
127
		String page = Location.getParameter("page");
116
		Integer pageInt = null;
128
		Integer pageInt = null;
117
		try {
129
		try {
118
			pageInt = Integer.parseInt(page);
130
			pageInt = Integer.parseInt(page);
119
		} catch (Exception e) {
131
		} catch (Exception e) {
120
			pageInt = null;
132
			pageInt = null;
121
		}
133
		}
122
		
134
		
123
		String pas = Location.getParameter("pas");	
135
		String pas = Location.getParameter("pas");	
124
		Integer pasInt = null;
136
		Integer pasInt = null;
125
		if (pas != null) {
137
		if (pas != null) {
126
			try {
138
			try {
127
				pasInt = Integer.parseInt(pas);
139
				pasInt = Integer.parseInt(pas);
128
			} catch (Exception e) {
140
			} catch (Exception e) {
129
				pasInt = null;
141
				pasInt = null;
130
			}
142
			}
131
		}
143
		}
132
		
144
		
133
		InformationsRecherche rechercheParArguments = new InformationsRecherche();
145
		InformationsRecherche rechercheParArguments = new InformationsRecherche();
134
		rechercheParArguments.setRechercheLibre(rechercheLibre);
146
		rechercheParArguments.setRechercheLibre(rechercheLibre);
135
		rechercheParArguments.setFamille(famille);
147
		rechercheParArguments.setFamille(famille);
136
		rechercheParArguments.setTaxon(taxon);
148
		rechercheParArguments.setTaxon(taxon);
137
		rechercheParArguments.setGenre(genre);
149
		rechercheParArguments.setGenre(genre);
138
		rechercheParArguments.setCommune(commune);
150
		rechercheParArguments.setCommune(commune);
139
		rechercheParArguments.setDepartement(dept);
151
		rechercheParArguments.setDepartement(dept);
140
		rechercheParArguments.setAuteur(auteur);
152
		rechercheParArguments.setAuteur(auteur);
141
		rechercheParArguments.setDate(date);
153
		rechercheParArguments.setDate(date);
142
		rechercheParArguments.setTag(tag);
154
		rechercheParArguments.setTag(tag);
143
		rechercheParArguments.setPays(paysParam);
155
		rechercheParArguments.setPays(paysParam);
-
 
156
		rechercheParArguments.setPnInscritsSeulement(pnInscritsSeulementBool);
144
		
157
		
145
		if (protocole != null && !protocole.equals("")) {
158
		if (protocole != null && !protocole.equals("")) {
146
			CacheClient.getInstance().setIdProtocoleEnAttente(protocole);
159
			CacheClient.getInstance().setIdProtocoleEnAttente(protocole);
147
			rechercheParArguments.setIdProtocoleSelectionne(protocole);
160
			rechercheParArguments.setIdProtocoleSelectionne(protocole);
148
		} else if (URLUtils.getURLSpecialParameterValue() != null) {
161
		} else if (URLUtils.getURLSpecialParameterValue() != null) {
149
			CacheClient.getInstance().setIdProtocoleEnAttente(URLUtils.getURLSpecialParameterValue());
162
			CacheClient.getInstance().setIdProtocoleEnAttente(URLUtils.getURLSpecialParameterValue());
150
			rechercheParArguments.setIdProtocoleSelectionne(URLUtils.getURLSpecialParameterValue());
163
			rechercheParArguments.setIdProtocoleSelectionne(URLUtils.getURLSpecialParameterValue());
151
		}
164
		}
152
		
165
		
153
		if (pasInt != null) {
166
		if (pasInt != null) {
154
			setPasPagination(pasInt);
167
			setPasPagination(pasInt);
155
		}
168
		}
156
		
169
		
157
		if (urlCourante.contains(urlAppliImg)) {
170
		if (urlCourante.contains(urlAppliImg)) {
158
			rechercheParArguments.setMotClefCel(tagCel);
171
			rechercheParArguments.setMotClefCel(tagCel);
159
			rechercheParArguments.setMotClefDel(tagDel);
172
			rechercheParArguments.setMotClefDel(tagDel);
160
			if (pageInt != null) {
173
			if (pageInt != null) {
161
				setPageCouranteRechercheImages(pageInt);
174
				setPageCouranteRechercheImages(pageInt);
162
			}
175
			}
163
		} else {
176
		} else {
164
			if (pageInt != null) {
177
			if (pageInt != null) {
165
				setPageCouranteRechercheObservations(pageInt);
178
				setPageCouranteRechercheObservations(pageInt);
166
			}
179
			}
167
		}
180
		}
168
		
181
		
169
		definirOrdreTriCourantParUrl();
182
		definirOrdreTriCourantParUrl();
170
		String tri = Location.getParameter("tri");
183
		String tri = Location.getParameter("tri");
171
		if (urlCourante.contains(urlAppliImg)) {
184
		if (urlCourante.contains(urlAppliImg)) {
172
			if (tri != null) {
185
			if (tri != null) {
173
				// Pour PictoFlora
186
				// Pour PictoFlora
174
				if (tri.equals("moyenne-arithmetique")) {
187
				if (tri.equals("moyenne-arithmetique")) {
175
					rechercheParArguments.setTriParMoyenneArithmetique(modeTri);
188
					rechercheParArguments.setTriParMoyenneArithmetique(modeTri);
176
				} else if (tri.equals("points")) {
189
				} else if (tri.equals("points")) {
177
					rechercheParArguments.setTriParNbPoints(modeTri);
190
					rechercheParArguments.setTriParNbPoints(modeTri);
178
				} else if (tri.equals("tags")) {
191
				} else if (tri.equals("tags")) {
179
					rechercheParArguments.setTriParNbTags(modeTri);
192
					rechercheParArguments.setTriParNbTags(modeTri);
180
				} else {
193
				} else {
181
					rechercheParArguments.setTriParDatePublication(modeTri);
194
					rechercheParArguments.setTriParDatePublication(modeTri);
182
				}
195
				}
183
			} else {
196
			} else {
184
				// Tri par défaut pour PictoFlora
197
				// Tri par défaut pour PictoFlora
185
				rechercheParArguments.setTriParDatePublication(ModeTri.TRI_DESCENDANT);
198
				rechercheParArguments.setTriParDatePublication(ModeTri.TRI_DESCENDANT);
186
			}
199
			}
187
		} else {
200
		} else {
188
			// Pour IdentiPlante
201
			// Pour IdentiPlante
189
			if (tri != null && tri.equals("date_observation")) {
202
			if (tri != null && tri.equals("date_observation")) {
190
				rechercheParArguments.setTriParDateObservation(modeTri);
203
				rechercheParArguments.setTriParDateObservation(modeTri);
191
			} else if(tri != null && tri.equals("nb_commentaires")) {
204
			} else if(tri != null && tri.equals("nb_commentaires")) {
192
				rechercheParArguments.setTriParNbCommentaires(modeTri);
205
				rechercheParArguments.setTriParNbCommentaires(modeTri);
193
			} else {
206
			} else {
194
				// Tri par défaut pour IdentiPlante
207
				// Tri par défaut pour IdentiPlante
195
				rechercheParArguments.setTriParDatePublication(ModeTri.TRI_DESCENDANT);
208
				rechercheParArguments.setTriParDatePublication(ModeTri.TRI_DESCENDANT);
196
			}
209
			}
197
		}
210
		}
198
		
211
		
199
		rechercheParArguments.setMotClef(tag);
212
		rechercheParArguments.setMotClef(tag);
200
		
213
		
201
		// 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
202
		if (referentiel != null && !referentiel.equals("")) {
215
		if (referentiel != null && !referentiel.equals("")) {
203
			setReferentielCourant(referentiel);
216
			setReferentielCourant(referentiel);
204
			rechercheParArguments.setReferentiel(referentiel);
217
			rechercheParArguments.setReferentiel(referentiel);
205
			referentielNonModifiable = true;
218
			referentielNonModifiable = true;
206
		}
219
		}
207
		
220
		
208
		if (Location.getParameterMap().size() == 0) {
221
		if (Location.getParameterMap().size() == 0) {
209
			// 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
210
			statut = ConstantesNavigation.PARAM_TYPE_DEFAUT;
223
			statut = ConstantesNavigation.PARAM_TYPE_DEFAUT;
211
		} else {
224
		} else {
212
			if (Arrays.asList(statutsPossibles).contains(statutParam)) {
225
			if (Arrays.asList(statutsPossibles).contains(statutParam)) {
213
				statut = statutParam;
226
				statut = statutParam;
214
			} else {
227
			} else {
215
				statut = ConstantesNavigation.PARAM_TYPE_DEFAUT;
228
				statut = ConstantesNavigation.PARAM_TYPE_DEFAUT;
216
			}
229
			}
217
		}
230
		}
218
		
231
		
219
		informationsRechercheImage = rechercheParArguments;
232
		informationsRechercheImage = rechercheParArguments;
220
		informationsRechercheObservation = rechercheParArguments;
233
		informationsRechercheObservation = rechercheParArguments;
221
		
234
		
222
		mettreAjourUrlCourante();
235
		mettreAjourUrlCourante();
223
	}
236
	}
224
	
237
	
225
	private void definirOrdreTriCourantParUrl() {
238
	private void definirOrdreTriCourantParUrl() {
226
		String ordre = Location.getParameter("ordre");
239
		String ordre = Location.getParameter("ordre");
227
		if (ordre != null) {
240
		if (ordre != null) {
228
			if (ordre.equals("asc")) {
241
			if (ordre.equals("asc")) {
229
				this.modeTri = ModeTri.TRI_ASCENDANT;
242
				this.modeTri = ModeTri.TRI_ASCENDANT;
230
			} else if (ordre.equals("desc")) {
243
			} else if (ordre.equals("desc")) {
231
				this.modeTri = ModeTri.TRI_DESCENDANT;
244
				this.modeTri = ModeTri.TRI_DESCENDANT;
232
			}
245
			}
233
		}
246
		}
234
	}
247
	}
235
	
248
 
236
	public void setIdProtocoleEnAttente(String idProtocole) {
249
	public void setIdProtocoleEnAttente(String idProtocole) {
237
		idProtocoleEnAttente = idProtocole;
250
		idProtocoleEnAttente = idProtocole;
238
	}
251
	}
239
	
252
 
240
	public String getIdProtocoleEnAttente() {
253
	public String getIdProtocoleEnAttente() {
241
		return idProtocoleEnAttente;
254
		return idProtocoleEnAttente;
242
	}
255
	}
243
 
256
 
244
	public Utilisateur getUtilisateur() {
257
	public Utilisateur getUtilisateur() {
245
		if (this.utilisateur == null) {
258
		if (this.utilisateur == null) {
246
			this.utilisateur = new Utilisateur(null, null);
259
			this.utilisateur = new Utilisateur(null, null);
247
		}
260
		}
248
		return this.utilisateur;
261
		return this.utilisateur;
249
	}
262
	}
250
	
263
	
251
	public void setUtilisateur(Utilisateur utilisateur) {
264
	public void setUtilisateur(Utilisateur utilisateur) {
252
		this.utilisateur = utilisateur; 
265
		this.utilisateur = utilisateur; 
253
	}
266
	}
254
	
267
	
255
	public void setHome(String home) {
268
	public void setHome(String home) {
256
		setPageCourante(home);
269
		setPageCourante(home);
257
	}
270
	}
258
	
271
	
259
	public String getHome() {
272
	public String getHome() {
260
		return "";
273
		return "";
261
	}
274
	}
262
	
275
	
263
	public Observation getObservationCourante() {
276
	public Observation getObservationCourante() {
264
		return observationCourante;
277
		return observationCourante;
265
	}
278
	}
266
 
279
 
267
	public void setObservationCourante(Observation observationCourante) {
280
	public void setObservationCourante(Observation observationCourante) {
268
		this.observationCourante = observationCourante;
281
		this.observationCourante = observationCourante;
269
	}
282
	}
270
 
283
 
271
	public static CacheClient getInstance() {
284
	public static CacheClient getInstance() {
272
		if (instance == null) {
285
		if (instance == null) {
273
			instance = new CacheClient();
286
			instance = new CacheClient();
274
		}
287
		}
275
		return instance;
288
		return instance;
276
	}
289
	}
277
 
290
 
278
	public String getTaxonPourRechercheEflore() {
291
	public String getTaxonPourRechercheEflore() {
279
		return taxonPourRechercheEflore;
292
		return taxonPourRechercheEflore;
280
	}
293
	}
281
 
294
 
282
	public void setTaxonPourRechercheEflore(String taxonPourRechercheEflore) {
295
	public void setTaxonPourRechercheEflore(String taxonPourRechercheEflore) {
283
		this.taxonPourRechercheEflore = taxonPourRechercheEflore;
296
		this.taxonPourRechercheEflore = taxonPourRechercheEflore;
284
	}
297
	}
285
 
298
 
286
	public int getNumPageRechercheImage() {
299
	public int getNumPageRechercheImage() {
287
		return numPageRechercheImage;
300
		return numPageRechercheImage;
288
	}
301
	}
289
 
302
 
290
	// Pour la recherche :
303
	// Pour la recherche :
291
	public int getPasPagination() {
304
	public int getPasPagination() {
292
		return pasPagination;
305
		return pasPagination;
293
	}
306
	}
294
 
307
 
295
	public void setPasPagination(int pasPagination) {
308
	public void setPasPagination(int pasPagination) {
296
		this.pasPagination = pasPagination;
309
		this.pasPagination = pasPagination;
297
	}
310
	}
298
 
311
 
299
	public void setPageCouranteRechercheImages(int pageCouranteRecherche) {
312
	public void setPageCouranteRechercheImages(int pageCouranteRecherche) {
300
		this.pageCouranteRechercheImage = pageCouranteRecherche;
313
		this.pageCouranteRechercheImage = pageCouranteRecherche;
301
	}
314
	}
302
 
315
 
303
	public int getPageCouranteRechercheImage() {
316
	public int getPageCouranteRechercheImage() {
304
		return this.pageCouranteRechercheImage;
317
		return this.pageCouranteRechercheImage;
305
	}
318
	}
306
 
319
 
307
	public void setNbTotalImagesRecherchees(int nbTotalImagesRecherchees) {
320
	public void setNbTotalImagesRecherchees(int nbTotalImagesRecherchees) {
308
		this.nbTotalImagesRecherchees = nbTotalImagesRecherchees;
321
		this.nbTotalImagesRecherchees = nbTotalImagesRecherchees;
309
	}
322
	}
310
 
323
 
311
	public int getNbTotalImagesRecherchees() {
324
	public int getNbTotalImagesRecherchees() {
312
		return this.nbTotalImagesRecherchees;
325
		return this.nbTotalImagesRecherchees;
313
	}
326
	}
314
 
327
 
315
	public Image getImageCourante() {
328
	public Image getImageCourante() {
316
		return imageCourante;
329
		return imageCourante;
317
	}
330
	}
318
 
331
 
319
	public void setImageCourante(Image imageCourante) {
332
	public void setImageCourante(Image imageCourante) {
320
		this.imageCourante = imageCourante;
333
		this.imageCourante = imageCourante;
321
	}
334
	}
322
	
335
	
323
	public void setListeProtocoles(List<Protocole> listeProtocole) {
336
	public void setListeProtocoles(List<Protocole> listeProtocole) {
324
		this.listeProtocoles = listeProtocole;
337
		this.listeProtocoles = listeProtocole;
325
	}
338
	}
326
	
339
	
327
	public List<Protocole> getListeProtocoles() {
340
	public List<Protocole> getListeProtocoles() {
328
		return this.listeProtocoles;
341
		return this.listeProtocoles;
329
	}
342
	}
330
 
343
 
331
	public Protocole getProtocoleCourant() {
344
	public Protocole getProtocoleCourant() {
332
		return protocoleCourant;
345
		return protocoleCourant;
333
	}
346
	}
334
 
347
 
335
	public void setProtocoleCourant(Protocole protocoleCourant) {
348
	public void setProtocoleCourant(Protocole protocoleCourant) {
336
		this.protocoleCourant = protocoleCourant;
349
		this.protocoleCourant = protocoleCourant;
337
	}
350
	}
338
 
351
 
339
	public InformationsRecherche getInformationsRechercheImage() {
352
	public InformationsRecherche getInformationsRechercheImage() {
340
		if (informationsRechercheImage == null) {
353
		if (informationsRechercheImage == null) {
341
			informationsRechercheImage = new InformationsRecherche();
354
			informationsRechercheImage = new InformationsRecherche();
342
		}
355
		}
343
		return informationsRechercheImage;
356
		return informationsRechercheImage;
344
	}
357
	}
345
 
358
 
346
	public InformationsRecherche getInformationsRechercheObservation() {
359
	public InformationsRecherche getInformationsRechercheObservation() {
347
		if (informationsRechercheObservation == null) {
360
		if (informationsRechercheObservation == null) {
348
			informationsRechercheObservation = new InformationsRecherche();
361
			informationsRechercheObservation = new InformationsRecherche();
349
		}
362
		}
350
		return informationsRechercheObservation;
363
		return informationsRechercheObservation;
351
	}
364
	}
352
 
365
 
353
	public void setInformationsRechercheImage(InformationsRecherche informationsRechercheImage) {
366
	public void setInformationsRechercheImage(InformationsRecherche informationsRechercheImage) {
354
		this.informationsRechercheImage = informationsRechercheImage;
367
		this.informationsRechercheImage = informationsRechercheImage;
355
	}
368
	}
356
 
369
 
357
	public void setInformationsRechercheObservation(InformationsRecherche informationsRechercheObservation) {
370
	public void setInformationsRechercheObservation(InformationsRecherche informationsRechercheObservation) {
358
		this.informationsRechercheObservation = informationsRechercheObservation;
371
		this.informationsRechercheObservation = informationsRechercheObservation;
359
	}
372
	}
360
 
373
 
361
	public int getPageCouranteRechercheObservations() {
374
	public int getPageCouranteRechercheObservations() {
362
		return pageCouranteRechercheObservations;
375
		return pageCouranteRechercheObservations;
363
	}
376
	}
364
 
377
 
365
	public void setPageCouranteRechercheObservations(int pageCouranteRechercheObservations) {
378
	public void setPageCouranteRechercheObservations(int pageCouranteRechercheObservations) {
366
		this.pageCouranteRechercheObservations = pageCouranteRechercheObservations;
379
		this.pageCouranteRechercheObservations = pageCouranteRechercheObservations;
367
	}
380
	}
368
	
381
	
369
	public void setReferentielCourant(String referentielCourant) {
382
	public void setReferentielCourant(String referentielCourant) {
370
		this.referentielCourant = referentielCourant;
383
		this.referentielCourant = referentielCourant;
371
	}
384
	}
372
	
385
	
373
	public String getReferentielCourant() {
386
	public String getReferentielCourant() {
374
		return referentielCourant;
387
		return referentielCourant;
375
	}
388
	}
376
	
389
	
377
	public void setReferentielNonModifiable(boolean referentielNonModifiable) {
390
	public void setReferentielNonModifiable(boolean referentielNonModifiable) {
378
		this.referentielNonModifiable = referentielNonModifiable;
391
		this.referentielNonModifiable = referentielNonModifiable;
379
	}
392
	}
380
	
393
	
381
	public boolean getReferentielNonModifiable() {
394
	public boolean getReferentielNonModifiable() {
382
		return referentielNonModifiable;
395
		return referentielNonModifiable;
383
	}
396
	}
384
	
397
	
385
	public String getUrlPageSignalerMauvaiseId(String id) {
398
	public String getUrlPageSignalerMauvaiseId(String id) {
386
		Config config = new Config();
399
		Config config = new Config();
387
		String urlSignalerMauvaiseId = config.getUrl("identiplante");
400
		String urlSignalerMauvaiseId = config.getUrl("identiplante");
388
		if (!GWT.isScript()) {
401
		if (!GWT.isScript()) {
389
			urlSignalerMauvaiseId += "?gwt.codesvr="+Location.getParameter("gwt.codesvr")+"";
402
			urlSignalerMauvaiseId += "?gwt.codesvr="+Location.getParameter("gwt.codesvr")+"";
390
		}
403
		}
391
		return urlSignalerMauvaiseId+"#"+ConstantesNavigation.PAGE_DETAIL_OBS+"~"+id;
404
		return urlSignalerMauvaiseId+"#"+ConstantesNavigation.PAGE_DETAIL_OBS+"~"+id;
392
		
405
		
393
	}
406
	}
394
	
407
	
395
	public void setListePays(Map<String, String> listePays) {
408
	public void setListePays(Map<String, String> listePays) {
396
		this.listePays = listePays;
409
		this.listePays = listePays;
397
		listePaysInversee = new HashMap<String, String>();
410
		listePaysInversee = new HashMap<String, String>();
398
		for(Map.Entry<String, String> entry : listePays.entrySet()){
411
		for(Map.Entry<String, String> entry : listePays.entrySet()){
399
			listePaysInversee.put(entry.getValue(), entry.getKey());
412
			listePaysInversee.put(entry.getValue(), entry.getKey());
400
		}
413
		}
401
	}
414
	}
402
	
415
	
403
	public Map<String, String> getListePays() {
416
	public Map<String, String> getListePays() {
404
		return listePays;
417
		return listePays;
405
	}
418
	}
406
	
419
	
407
	public Map<String, String> getListePaysInversee() {
420
	public Map<String, String> getListePaysInversee() {
408
		return listePaysInversee;
421
		return listePaysInversee;
409
	}
422
	}
410
	
423
	
411
	public String genererUrlCourante() {
424
	public String genererUrlCourante() {
412
		String urlCourante = Window.Location.getHref();
425
		String urlCourante = Window.Location.getHref();
413
		Config config = new Config();
426
		Config config = new Config();
414
		String urlAppliObs = config.getUrl("identiplante");
427
		String urlAppliObs = config.getUrl("identiplante");
415
		String urlAppliImg = config.getUrl("pictoflora");
428
		String urlAppliImg = config.getUrl("pictoflora");
416
		String url = urlCourante;
429
		String url = urlCourante;
417
		String arguments = "";
430
		String arguments = "";
418
		
431
		
419
		if (urlCourante.contains(urlAppliImg)) {
432
		if (urlCourante.contains(urlAppliImg)) {
420
			InformationsRecherche infoRecherche;
433
			InformationsRecherche infoRecherche;
421
			infoRecherche = getInformationsRechercheImage();
434
			infoRecherche = getInformationsRechercheImage();
422
			
435
			
423
			if (CacheClient.getInstance().getProtocoleCourant() != null) {
436
			if (CacheClient.getInstance().getProtocoleCourant() != null) {
424
				infoRecherche.setIdProtocoleSelectionne("" + CacheClient.getInstance().getProtocoleCourant().getId());
437
				infoRecherche.setIdProtocoleSelectionne("" + CacheClient.getInstance().getProtocoleCourant().getId());
425
			}
438
			}
426
			
439
			
427
			arguments = infoRecherche.versChaineRequete();
440
			arguments = infoRecherche.versChaineRequete();
428
			arguments += (arguments.isEmpty()) ? "" : "&";
441
			arguments += (arguments.isEmpty()) ? "" : "&";
429
			arguments += "page="+getPageCouranteRechercheImage()+"&pas="+getPasPagination();
442
			arguments += "page="+getPageCouranteRechercheImage()+"&pas="+getPasPagination();
430
 
443
 
431
			url = config.getUrl("pictoflora");
444
			url = config.getUrl("pictoflora");
432
		} else if (urlCourante.contains(urlAppliObs)) {
445
		} else if (urlCourante.contains(urlAppliObs)) {
433
			InformationsRecherche infoRecherche;
446
			InformationsRecherche infoRecherche;
434
			infoRecherche = getInformationsRechercheObservation();
447
			infoRecherche = getInformationsRechercheObservation();
435
			
448
			
436
			arguments = "masque.type="+statut;
449
			arguments = "masque.type="+statut;
437
			arguments += "&page="+getPageCouranteRechercheObservations()+"&pas="+getPasPagination();
450
			arguments += "&page="+getPageCouranteRechercheObservations()+"&pas="+getPasPagination();
438
			arguments += "&"+infoRecherche.versChaineRequete();
451
			arguments += "&"+infoRecherche.versChaineRequete();
439
			
452
			
440
			url = config.getUrl("identiplante");
453
			url = config.getUrl("identiplante");
441
		}
454
		}
442
		
455
		
443
		if (!GWT.isScript()) {
456
		if (!GWT.isScript()) {
444
			arguments += "&gwt.codesvr="+Location.getParameter("gwt.codesvr")+"";
457
			arguments += "&gwt.codesvr="+Location.getParameter("gwt.codesvr")+"";
445
		}
458
		}
446
		arguments = (arguments.isEmpty()) ? "" : "?" + arguments;
459
		arguments = (arguments.isEmpty()) ? "" : "?" + arguments;
447
		String signet = getPageCourante().equals("") ? "" : "#" + getPageCourante();
460
		String signet = getPageCourante().equals("") ? "" : "#" + getPageCourante();
448
		url += arguments + signet;
461
		url += arguments + signet;
449
		
462
		
450
		// remplacements batards pour corriger l'url
463
		// remplacements batards pour corriger l'url
451
		// TODO: factoriser toute la fonction 
464
		// TODO: factoriser toute la fonction 
452
		url = url.replaceAll("&#", "#");
465
		url = url.replaceAll("&#", "#");
453
		url = url.replaceAll("&&", "&");
466
		url = url.replaceAll("&&", "&");
454
		url = url.replaceAll("\\?&", "?");
467
		url = url.replaceAll("\\?&", "?");
455
		if (url.endsWith("&")) {
468
		if (url.endsWith("&")) {
456
			url = url.substring(0, url.length()-1);
469
			url = url.substring(0, url.length()-1);
457
		}
470
		}
458
		
471
		
459
		return url;
472
		return url;
460
	}
473
	}
461
	
474
	
462
	public void mettreAjourUrlCourante() {
475
	public void mettreAjourUrlCourante() {
463
		mettreAJourUrlCouranteSansRecharger(genererUrlCourante());
476
		mettreAJourUrlCouranteSansRecharger(genererUrlCourante());
464
	}
477
	}
465
	
478
	
466
	private static native void mettreAJourUrlCouranteSansRecharger(String nouvelleUrl) /*-{
479
	private static native void mettreAJourUrlCouranteSansRecharger(String nouvelleUrl) /*-{
467
		// javascript double negative trick
480
		// javascript double negative trick
468
		// 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
469
		if (!!($wnd.history && $wnd.history.pushState)) {
482
		if (!!($wnd.history && $wnd.history.pushState)) {
470
			var currentState = $wnd.history.state;
483
			var currentState = $wnd.history.state;
471
			if (currentState != nouvelleUrl) {
484
			if (currentState != nouvelleUrl) {
472
				$wnd.history.pushState(nouvelleUrl, "", nouvelleUrl);
485
				$wnd.history.pushState(nouvelleUrl, "", nouvelleUrl);
473
			}
486
			}
474
		}
487
		}
475
	}-*/;
488
	}-*/;
476
	
489
	
477
	public static void remplacerTitreOngletNavigateur(String titre) {
490
	public static void remplacerTitreOngletNavigateur(String titre) {
478
	    if (Document.get() != null) {
491
	    if (Document.get() != null) {
479
	    	titreOngletNavigateur = Document.get().getTitle();
492
	    	titreOngletNavigateur = Document.get().getTitle();
480
	        Document.get().setTitle(titre);
493
	        Document.get().setTitle(titre);
481
	    }
494
	    }
482
	}
495
	}
483
	
496
	
484
	public static void ajouterAuTitreOngletNavigateur(String titreSupplementaire) {
497
	public static void ajouterAuTitreOngletNavigateur(String titreSupplementaire) {
485
	    if (Document.get() != null) {
498
	    if (Document.get() != null) {
486
	    	titreOngletNavigateur = titreOngletNavigateur.isEmpty() ? Document.get().getTitle() : titreOngletNavigateur;
499
	    	titreOngletNavigateur = titreOngletNavigateur.isEmpty() ? Document.get().getTitle() : titreOngletNavigateur;
487
	        Document.get().setTitle(titreOngletNavigateur+titreSupplementaire);
500
	        Document.get().setTitle(titreOngletNavigateur+titreSupplementaire);
488
	    }
501
	    }
489
	}
502
	}
490
	
503
	
491
	public static void reinitialiserTitreOngletNavigateur() {
504
	public static void reinitialiserTitreOngletNavigateur() {
492
	    if (Document.get() != null) {
505
	    if (Document.get() != null) {
493
	    	titreOngletNavigateur = titreOngletNavigateur.isEmpty() ? Document.get().getTitle() : titreOngletNavigateur;
506
	    	titreOngletNavigateur = titreOngletNavigateur.isEmpty() ? Document.get().getTitle() : titreOngletNavigateur;
494
	        Document.get().setTitle(titreOngletNavigateur);
507
	        Document.get().setTitle(titreOngletNavigateur);
495
	    }
508
	    }
496
	}
509
	}
497
}
510
}