Subversion Repositories eFlore/Applications.del

Rev

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

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