Subversion Repositories eFlore/Applications.del

Rev

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

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