Subversion Repositories eFlore/Applications.del

Rev

Rev 1517 | Rev 1551 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1517 Rev 1549
Line 19... Line 19...
19
 
19
 
Line 20... Line 20...
20
public class CacheClient {
20
public class CacheClient {
Line 21... Line -...
21
 
-
 
22
	private List<Protocole> listeProtocoles;
21
 
23
	
22
	private List<Protocole> listeProtocoles;
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;
Line 37... Line 36...
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
	};
Line 48... Line 49...
48
	
49
	
49
	public void supprimerFiltreStatut() {
50
	public void supprimerFiltreStatut() {
50
		this.statut = null;
51
		this.statut = null;
Line 71... Line 72...
71
	private CacheClient() {
72
	private CacheClient() {
72
		instance = this;
73
		instance = this;
73
	}
74
	}
Line 74... Line 75...
74
 
75
 
-
 
76
	public void initialiserAvecParametres() {
-
 
77
		String urlCourante = Window.Location.getHref();
-
 
78
		Config config = new Config();
75
	public void initialiserAvecParametres() {
79
		String urlAppliImg = config.getUrl("pictoflora");
76
		
-
 
77
		if(Location.getPath().contains("identiplante")) {
80
		
78
			if(Location.getHash().contains(ConstantesNavigation.PAGE_VALIDATION)) {
81
		if (Location.getHash().contains(ConstantesNavigation.PAGE_DETAIL_OBS)) {
79
				setPageCourante(ConstantesNavigation.PAGE_VALIDATION+"~"+URLUtils.getURLSpecialParameterValue());
-
 
80
			} else {
-
 
81
				setPageCourante(ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS);
-
 
82
			}
-
 
83
		} else if(Location.getPath().contains("pictoflora")) {
82
			setPageCourante(ConstantesNavigation.PAGE_DETAIL_OBS+"~"+URLUtils.getURLSpecialParameterValue());
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);
-
 
88
			}
86
			setPageCourante("");
-
 
87
		}
Line 89... Line 88...
89
		}
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");
Line 104... Line 103...
104
		String statutParam = Location.getParameter("masque.type");
103
		String statutParam = Location.getParameter("masque.type");
Line 105... Line 104...
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;
Line 112... Line 111...
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;
Line 130... Line 129...
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);
Line 134... Line 133...
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());
Line -... Line 140...
-
 
140
		}
141
		}
141
		
-
 
142
		if (pasInt != null) {
142
		
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)) {
-
 
147
			rechercheParArguments.setMotClefCel(tagCel);
146
			rechercheParArguments.setMotClefCel(tagCel);
148
			rechercheParArguments.setMotClefDel(tagDel);
-
 
149
			if (pageInt != null) {
147
			rechercheParArguments.setMotClefDel(tagDel);
150
				setPageCouranteRechercheImages(pageInt);
-
 
151
			}
148
			if(pageInt != null) setPageCouranteRechercheImages(pageInt);
152
		} else {
-
 
153
			if (pageInt != null) {
149
		} else {
154
				setPageCouranteRechercheObservations(pageInt);
Line 150... Line 155...
150
			if(pageInt != null)	setPageCouranteRechercheObservations(pageInt);			
155
			}
151
		}
156
		}
Line 152... Line 157...
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) {
Line 157... Line 162...
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;
Line 160... Line 165...
160
			}
165
			}
161
			
166
			
162
			if(ordre != null && ordre.equals("desc")) {
167
			if (ordre != null && ordre.equals("desc")) {
Line 163... Line 168...
163
				modeTri = ModeTri.TRI_DESCENDANT;
168
				modeTri = ModeTri.TRI_DESCENDANT;
164
			}
169
			}
165
			
170
			
Line 166... Line 171...
166
			if(tri.equals("votes")) {
171
			if (tri.equals("votes")) {
167
				rechercheParArguments.setTriParNbVotes(modeTri);
172
				rechercheParArguments.setTriParNbVotes(modeTri);
168
			}
173
			}
169
			
174
			
Line 170... Line 175...
170
			if(tri.equals("tags")) {
175
			if (tri.equals("tags")) {
Line 171... Line 176...
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
			}
Line 177... Line 182...
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
		}
Line 220... Line 225...
220
	public void setUtilisateur(Utilisateur utilisateur) {
225
	public void setUtilisateur(Utilisateur utilisateur) {
221
		this.utilisateur = utilisateur; 
226
		this.utilisateur = utilisateur; 
222
	}
227
	}
Line 223... Line 228...
223
	
228
	
224
	public void setHome(String home) {
-
 
225
		this.home = home;
229
	public void setHome(String home) {
226
		setPageCourante(home);
230
		setPageCourante(home);
Line 227... Line 231...
227
	}
231
	}
228
	
232
	
229
	public String getHome() {
233
	public String getHome() {
Line 230... Line 234...
230
		return home;
234
		return "";
231
	}
235
	}
232
	
236
	
Line 305... Line 309...
305
	public void setProtocoleCourant(Protocole protocoleCourant) {
309
	public void setProtocoleCourant(Protocole protocoleCourant) {
306
		this.protocoleCourant = protocoleCourant;
310
		this.protocoleCourant = protocoleCourant;
307
	}
311
	}
Line 308... Line 312...
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;
Line 314... Line 318...
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
		}
Line 351... Line 355...
351
	public boolean getReferentielNonModifiable() {
355
	public boolean getReferentielNonModifiable() {
352
		return referentielNonModifiable;
356
		return referentielNonModifiable;
353
	}
357
	}
Line 354... Line 358...
354
	
358
	
355
	public String genererUrlCourante() {
359
	public String genererUrlCourante() {
-
 
360
		String urlCourante = Window.Location.getHref();
-
 
361
		Config config = new Config();
-
 
362
		String urlAppliObs = config.getUrl("identiplante");
-
 
363
		String urlAppliImg = config.getUrl("pictoflora");
356
		String url = Window.Location.getHref();
364
		String url = urlCourante;
357
		String arguments = "";
-
 
Line -... Line 365...
-
 
365
		String arguments = "";
358
		String argumentsRecherche = "";
366
		
-
 
367
		//GWT.log("URL courante:"+urlCourante);
359
		
368
		//GWT.log("IdentiPlante:"+urlCourante.contains(urlAppliObs));
-
 
369
		//GWT.log("PictoFlora:"+urlCourante.contains(urlAppliImg));
360
		if (getPageCourante().equals(ConstantesNavigation.PAGE_RECHERCHE_IMAGES)) {
370
		
361
			
371
		if (urlCourante.contains(urlAppliImg)) {
362
			InformationsRecherche infoRecherche;
-
 
363
			infoRecherche = getInformationsRechercheImage();
-
 
364
			if (CacheClient.getInstance().getProtocoleCourant() != null) {
-
 
365
				infoRecherche.setIdProtocoleSelectionne(""+CacheClient.getInstance().getProtocoleCourant().getId());
-
 
Line 366... Line 372...
366
			}
372
			InformationsRecherche infoRecherche;
367
			argumentsRecherche = infoRecherche.versChaineRequete();
373
			infoRecherche = getInformationsRechercheImage();
368
			
374
			
Line -... Line 375...
-
 
375
			if (CacheClient.getInstance().getProtocoleCourant() != null) {
369
			if(!GWT.isScript()) {
376
				infoRecherche.setIdProtocoleSelectionne("" + CacheClient.getInstance().getProtocoleCourant().getId());
370
				argumentsRecherche += "&gwt.codesvr="+Location.getParameter("gwt.codesvr")+"";
377
			}
371
			}
378
			
372
			
-
 
373
			argumentsRecherche += (argumentsRecherche.isEmpty()) ? "" : "&";
-
 
374
			argumentsRecherche += "page="+getPageCouranteRechercheImage()+"&pas="+getPasPagination();
379
			arguments = infoRecherche.versChaineRequete();
375
			
380
			arguments += (arguments.isEmpty()) ? "" : "&";
376
			argumentsRecherche = (argumentsRecherche.isEmpty()) ? argumentsRecherche : "?" + argumentsRecherche;
-
 
377
			arguments = argumentsRecherche;
-
 
378
			url = new Config().getUrl("pictoflora") + arguments;
381
			arguments += "page="+getPageCouranteRechercheImage()+"&pas="+getPasPagination();
379
			url += "#"+ConstantesNavigation.PAGE_RECHERCHE_IMAGES;
382
 
380
		} else if (getPageCourante().equals(ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS) || getPageCourante().equals("")) {
-
 
381
			
-
 
382
			InformationsRecherche infoRecherche;
-
 
Line 383... Line 383...
383
			infoRecherche = getInformationsRechercheObservation();
383
			url = config.getUrl("pictoflora");
-
 
384
		} else if (urlCourante.contains(urlAppliObs)) {
384
			argumentsRecherche = "masque.type="+statut;
385
			InformationsRecherche infoRecherche;
385
			argumentsRecherche += "&page="+getPageCouranteRechercheObservations()+"&pas="+getPasPagination();
-
 
Line 386... Line -...
386
			argumentsRecherche += "&"+infoRecherche.versChaineRequete();
-
 
387
			
-
 
388
			if(!GWT.isScript()) {
-
 
389
				argumentsRecherche += "&gwt.codesvr="+Location.getParameter("gwt.codesvr")+"";
-
 
390
			}
-
 
391
			
-
 
392
			arguments = "?"+argumentsRecherche;
386
			infoRecherche = getInformationsRechercheObservation();
393
			url = new Config().getUrl("identiplante") + arguments;
-
 
394
			url += "#"+ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS;
-
 
395
		} else if (getPageCourante().contains(ConstantesNavigation.PAGE_VALIDATION) || getPageCourante().contains(ConstantesNavigation.PAGE_VALIDATION_PICTOFLORA)) {
387
			
-
 
388
			arguments = "masque.type="+statut;
396
			url = new Config().getUrl("del");
389
			arguments += "&page="+getPageCouranteRechercheObservations()+"&pas="+getPasPagination();
397
			if(getPageCourante().contains(ConstantesNavigation.PAGE_VALIDATION)) {
390
			arguments += "&"+infoRecherche.versChaineRequete();
398
				url = new Config().getUrl("identiplante");
-
 
399
			} else {
-
 
400
				url = new Config().getUrl("pictoflora");
391
			
-
 
392
			url = config.getUrl("identiplante");
-
 
393
		}
-
 
394
		
-
 
395
		if (!GWT.isScript()) {
401
			}
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;
Line -... Line 401...
-
 
401
		
-
 
402
		// remplacements batards pour corriger l'url
406
		}
403
		// TODO: factoriser toute la fonction 
407
		// remplacements batards pour corriger l'url
404
		url = url.replaceAll("&#", "#");
Line 408... Line -...
408
		// TODO: factoriser toute la fonction 
-
 
409
		url = url.replaceAll("&#", "#");
405
		url = url.replaceAll("&&", "&");
410
		url = url.replaceAll("&&", "&");
406
		url = url.replaceAll("\\?&", "?");
411
		url = url.replaceAll("\\?&", "?");
407
		
Line 412... Line 408...
412
		
408
		//GWT.log("URL de sortie:"+url);
413
		return url;
409
		
414
	}
410
		return url;
415
	
411
	}
416
	
412
	
417
	public void mettreAjourUrlCourante() {
413
	public void mettreAjourUrlCourante() {
418
		mettreAJourUrlCouranteSansRecharger(genererUrlCourante());
414
		mettreAJourUrlCouranteSansRecharger(genererUrlCourante());
419
	}
415
	}