Subversion Repositories eFlore/Applications.del

Rev

Rev 2095 | Rev 2139 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1934 aurelien 1
package org.tela_botanica.del.client.modeles;
2
 
3
import org.tela_botanica.del.client.config.Config;
4
 
5
import com.google.gwt.http.client.URL;
6
import com.google.gwt.user.client.Window;
7
 
8
public class InformationsRecherche {
9
 
10
	private String rechercheLibre;
11
 
12
	private String departement;
13
 
14
	private String referentiel;
15
 
16
	private String taxon;
17
 
18
	private String genre;
19
 
20
	// gardé pour ancienne comptabilité
21
	private String motClef;
22
 
23
	// mots clés publics de del
24
	private String motClefDel;
25
 
26
	// mots clés privés du cel
27
	private String motClefCel;
28
 
29
	private String date;
1986 aurelien 30
 
31
	private String pays;
1934 aurelien 32
 
33
	private String commune;
34
 
2138 mathias 35
	private boolean pnInscritsSeulement;
36
 
1934 aurelien 37
	private String famille;
38
 
39
	private String tag;
40
 
41
	private String auteur;
42
 
43
	private String idProtocoleSelectionne = null;
44
 
45
	private ModeTri triParMoyenneArithmetique = ModeTri.PAS_DE_TRI;
46
 
47
	private ModeTri triParDatePublication = ModeTri.PAS_DE_TRI;
48
 
49
	private ModeTri triParDateObservation = ModeTri.PAS_DE_TRI;
50
 
51
	private ModeTri triParNbCommentaires = ModeTri.PAS_DE_TRI;
52
 
53
	private ModeTri triParNbTag = ModeTri.PAS_DE_TRI;
54
 
55
	private ModeTri triParNbPoints = ModeTri.PAS_DE_TRI;
56
 
57
	public String getRechercheLibre() {
58
		return rechercheLibre;
59
	}
60
 
61
	public void setRechercheLibre(String rechercheLibre) {
62
		if (rechercheLibre != null) {
63
			this.rechercheLibre = rechercheLibre;
64
		}
65
	}
66
 
67
	public String getDepartement() {
68
		return departement;
69
	}
70
 
71
	public void setDepartement(String departement) {
72
		if (departement != null) {
73
			this.departement = departement;
74
		}
75
	}
76
 
77
	public String getReferentiel() {
78
		return referentiel;
79
	}
80
 
81
	public void setReferentiel(String referentiel) {
82
		this.referentiel = referentiel;
83
	}
84
 
85
	public String getTaxon() {
86
		return taxon;
87
	}
88
 
89
	public void setTaxon(String taxon) {
90
		if (taxon != null) {
91
			 this.taxon = taxon;
92
		}
93
	}
94
 
95
	public String getGenre() {
96
		return genre;
97
	}
98
 
99
	public void setGenre(String genre) {
100
		if (genre != null) {
101
			this.genre = genre;
102
		}
103
	}
104
 
105
	public String getMotClef() {
106
		return motClef;
107
	}
108
 
109
	public void setMotClef(String motClef) {
110
		if (motClef != null) {
111
			this.motClef = motClef;
112
		}
113
	}
114
 
115
	public String getDate() {
116
		return date;
117
	}
118
 
119
	public void setDate(String date) {
120
		if (date != null) {
121
			this.date = date;
122
		}
123
	}
1986 aurelien 124
 
125
	public String setPays(String pays) {
126
		return this.pays = pays;
127
	}
1934 aurelien 128
 
1986 aurelien 129
	public String getPays() {
130
		return pays;
131
	}
2138 mathias 132
 
133
	public boolean getPnInscritsSeulement() {
134
		return pnInscritsSeulement;
135
	}
136
 
137
	public void setPnInscritsSeulement(boolean pnInscritsSeulement) {
138
		this.pnInscritsSeulement = pnInscritsSeulement;
139
	}
1986 aurelien 140
 
1934 aurelien 141
	public String getCommune() {
142
		return commune;
143
	}
144
 
145
	public void setCommune(String commune) {
146
		if (commune != null) {
147
			String[] tableauCommuneDpt = commune.split(" ");
148
			if (tableauCommuneDpt.length == 2) {
149
				String dpt = tableauCommuneDpt[1].replaceAll("\\(", "").replaceAll("\\)", "");
150
				setDepartement(dpt);
151
				this.commune = tableauCommuneDpt[0];
152
			} else {
153
				this.commune = commune;
154
			}
155
		}
156
	}
157
 
158
	public String getFamille() {
159
		return famille;
160
	}
161
 
162
	public void setFamille(String famille) {
163
		if (famille != null) {
164
			this.famille = famille;
165
		}
166
	}
167
 
168
	public String getTag() {
169
		return tag;
170
	}
171
 
172
	public void setTag(String tag) {
173
		if (tag != null) {
174
			this.tag = tag;
175
		}
176
	}
177
 
178
	public String getAuteur() {
179
		return auteur;
180
	}
181
 
182
	public void setAuteur(String auteur) {
183
		if (auteur != null) {
184
			this.auteur = auteur;
185
		}
186
	}
187
 
188
	public ModeTri getTriParMoyenneArithmetique() {
189
		return triParMoyenneArithmetique;
190
	}
191
 
192
	public void setTriParMoyenneArithmetique(ModeTri triParMoyenneArithmetique) {
193
		this.triParMoyenneArithmetique = triParMoyenneArithmetique;
194
	}
195
 
196
	public void setIdProtocoleSelectionne(String idProtocoleSelectionne) {
197
		this.idProtocoleSelectionne = idProtocoleSelectionne;
198
	}
199
 
200
	public String getIdProtocoleSelectionne() {
201
		return idProtocoleSelectionne;
202
	}
203
 
204
	public ModeTri getTriParDatePublication() {
205
		return triParDatePublication;
206
	}
207
 
208
	public void setTriParDatePublication(ModeTri triParDatePublication) {
209
		this.triParDatePublication = triParDatePublication;
210
	}
211
 
212
	public ModeTri getTriParDateObservation() {
213
		return triParDateObservation;
214
	}
215
 
216
	public void setTriParDateObservation(ModeTri triParDateObservation) {
217
		this.triParDateObservation = triParDateObservation;
218
	}
219
 
220
	public void setTriParNbTags(ModeTri triParTag) {
221
		this.triParNbTag = triParTag;
222
	}
223
 
224
	public ModeTri getTriParNbPoints() {
225
		return this.triParNbPoints;
226
	}
227
 
228
	public void setTriParNbPoints(ModeTri triParPoints) {
229
		this.triParNbPoints = triParPoints;
230
	}
231
 
232
	public ModeTri getTriParNbTags() {
233
		return this.triParNbTag;
234
	}
235
 
236
	public void setTriParNbCommentaires(ModeTri triParNbCommentaires) {
237
		this.triParNbCommentaires = triParNbCommentaires;
238
	}
239
 
240
	public ModeTri getTriParNbCommentaires() {
241
		return triParNbCommentaires;
242
	}
243
 
244
	public String versChaineRequete() {
245
		String chaine = "";
246
		chaine += estNonNull(rechercheLibre) ? "&masque=" + URL.encodeQueryString(rechercheLibre) : "";
247
		chaine += estNonNull(departement) ? "&masque.departement=" + URL.encodeQueryString(departement) : "";
248
		chaine += estNonNull(referentiel) && !referentiel.equals("tous") ? "&masque.referentiel=" + URL.encodeQueryString(referentiel) : "";
249
		chaine += estNonNull(taxon) ? "&masque.ns=" + URL.encodeQueryString(taxon) : "";
250
		chaine += estNonNull(genre) ? "&masque.genre=" + URL.encodeQueryString(genre) : "";
251
		chaine += estNonNull(motClef) ? "&masque.tag=" + URL.encodeQueryString(motClef) : "";
252
		chaine += estNonNull(motClefCel) ? "&masque.tag_cel=" + URL.encodeQueryString(motClefCel) : "";
253
		chaine += estNonNull(motClefDel) ? "&masque.tag_pictoflora=" + URL.encodeQueryString(motClefDel) : "";
254
		chaine += estNonNull(date) ? "&masque.date=" + URL.encodeQueryString(date) : "";
255
		chaine += estNonNull(commune) ? "&masque.commune=" + URL.encodeQueryString(commune) : "";
256
		chaine += estNonNull(famille) ? "&masque.famille=" + URL.encodeQueryString(famille) : "";
257
		chaine += estNonNull(auteur) ? "&masque.auteur=" + URL.encodeQueryString(auteur) : "";
1986 aurelien 258
		chaine += estNonNull(pays) ? "&masque.pays=" + URL.encodeQueryString(pays) : "";
2138 mathias 259
		chaine += pnInscritsSeulement ? "&masque.pninscritsseulement=" + URL.encodeQueryString("1") : "";
260
 
1934 aurelien 261
		String urlCourante = Window.Location.getHref();
262
		Config config = new Config();
263
		String urlAppliImg = config.getUrl("pictoflora");
264
		if (urlCourante.contains(urlAppliImg)) {
265
			chaine += triParMoyenneArithmetique != ModeTri.PAS_DE_TRI ? "&tri=moyenne-arithmetique" : "";
266
			chaine += triParMoyenneArithmetique != ModeTri.PAS_DE_TRI ? "&ordre=" + triParMoyenneArithmetique : "";
267
			chaine += triParNbTag != ModeTri.PAS_DE_TRI ? "&tri=tags" : "";
268
			chaine += triParNbTag != ModeTri.PAS_DE_TRI ? "&ordre=" + triParNbTag : "";
269
			chaine += triParNbPoints != ModeTri.PAS_DE_TRI ? "&tri=points" : "";
270
			chaine += triParNbPoints != ModeTri.PAS_DE_TRI ? "&ordre=" + triParNbPoints : "";
271
			chaine += estNonNull(idProtocoleSelectionne) ? "&protocole=" + idProtocoleSelectionne : "";
272
		} else {
273
			chaine += triParNbCommentaires != ModeTri.PAS_DE_TRI ? "&tri=nb_commentaires" : "";
274
			chaine += triParNbCommentaires != ModeTri.PAS_DE_TRI ? "&ordre=" + triParNbCommentaires : "";
275
		}
2138 mathias 276
 
1934 aurelien 277
		chaine += triParDateObservation != ModeTri.PAS_DE_TRI ? "&tri=date_observation" : "";
278
		chaine += triParDateObservation != ModeTri.PAS_DE_TRI ? "&ordre=" + triParDateObservation : "";
279
		chaine += triParDatePublication != ModeTri.PAS_DE_TRI ? "&tri=date_transmission" : "";
280
		chaine += triParDatePublication != ModeTri.PAS_DE_TRI ? "&ordre=" + triParDatePublication : "";
2138 mathias 281
 
1934 aurelien 282
		return chaine;
283
	}
284
 
285
	private boolean estNonNull(String critere) {
286
		return critere != null && !critere.trim().isEmpty();
287
	}
288
 
289
	public String getMotClefDel() {
290
		return motClefDel;
291
	}
292
 
293
	public void setMotClefDel(String motClefDel) {
294
		this.motClefDel = motClefDel;
295
	}
296
 
297
	public String getMotClefCel() {
298
		return motClefCel;
299
	}
300
 
301
	public void setMotClefCel(String motClefCel) {
302
		this.motClefCel = motClefCel;
303
	}
304
}