Subversion Repositories eFlore/Applications.del

Rev

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

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