Subversion Repositories eFlore/Applications.del

Rev

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

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