Subversion Repositories eFlore/Applications.del

Rev

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

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