Subversion Repositories eFlore/Applications.del

Rev

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

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