Subversion Repositories eFlore/Applications.del

Rev

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

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