Subversion Repositories eFlore/Applications.del

Rev

Rev 2139 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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