Subversion Repositories eFlore/Applications.del

Rev

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

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