Subversion Repositories eFlore/Applications.del

Rev

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

Rev 928 Rev 1118
1
package org.tela_botanica.del.client.modeles;
1
package org.tela_botanica.del.client.modeles;
2
 
2
 
3
import com.google.gwt.http.client.URL;
3
import com.google.gwt.http.client.URL;
4
 
4
 
5
public class InformationsRecherche {
5
public class InformationsRecherche {
6
 
6
 
7
	private String rechercheLibre;
7
	private String rechercheLibre;
8
 
8
 
9
	private String departement;
9
	private String departement;
10
 
10
 
11
	private String taxon;
11
	private String taxon;
12
 
12
 
13
	private String genre;
13
	private String genre;
14
 
14
 
15
	private String motClef;
15
	private String motClef;
16
 
16
 
17
	private String date;
17
	private String date;
18
 
18
 
19
	private String commune;
19
	private String commune;
20
 
20
 
21
	private String famille;
21
	private String famille;
22
 
22
 
23
	private String tag;
23
	private String tag;
24
 
24
 
25
	private String auteur;
25
	private String auteur;
26
 
26
 
27
	private String idProtocoleSelectionne = null;
27
	private String idProtocoleSelectionne = null;
28
 
28
 
29
	private ModeTri triParNbVotes = ModeTri.PAS_DE_TRI;
29
	private ModeTri triParNbVotes = ModeTri.PAS_DE_TRI;
30
 
30
 
31
	private ModeTri triParDate = ModeTri.PAS_DE_TRI;
31
	private ModeTri triParDate = ModeTri.PAS_DE_TRI;
32
 
32
 
33
	public String getRechercheLibre() {
33
	public String getRechercheLibre() {
34
		return rechercheLibre;
34
		return rechercheLibre;
35
	}
35
	}
36
 
36
 
37
	public void setRechercheLibre(String rechercheLibre) {
37
	public void setRechercheLibre(String rechercheLibre) {
-
 
38
		if (rechercheLibre != null) {
38
		this.rechercheLibre = rechercheLibre;
39
			this.rechercheLibre = rechercheLibre;
-
 
40
		}
39
	}
41
	}
40
 
42
 
41
	public String getDepartement() {
43
	public String getDepartement() {
42
		return departement;
44
		return departement;
43
	}
45
	}
44
 
46
 
45
	public void setDepartement(String departement) {
47
	public void setDepartement(String departement) {
-
 
48
		if (departement != null) {
46
		this.departement = departement;
49
			this.departement = departement;
-
 
50
		}
47
	}
51
	}
48
 
52
 
49
	public String getTaxon() {
53
	public String getTaxon() {
50
		return taxon;
54
		return taxon;
51
	}
55
	}
52
 
56
 
53
	public void setTaxon(String taxon) {
57
	public void setTaxon(String taxon) {
-
 
58
		if (taxon != null) {
54
		this.taxon = taxon;
59
			 this.taxon = taxon;
-
 
60
		}
55
	}
61
	}
56
 
62
 
57
	public String getGenre() {
63
	public String getGenre() {
58
		return genre;
64
		return genre;
59
	}
65
	}
60
 
66
 
61
	public void setGenre(String genre) {
67
	public void setGenre(String genre) {
-
 
68
		if (genre != null) {
62
		this.genre = genre;
69
			this.genre = genre;
-
 
70
		}
63
	}
71
	}
64
 
72
 
65
	public String getMotClef() {
73
	public String getMotClef() {
66
		return motClef;
74
		return motClef;
67
	}
75
	}
68
 
76
 
69
	public void setMotClef(String motClef) {
77
	public void setMotClef(String motClef) {
-
 
78
		if (motClef != null) {
70
		this.motClef = motClef;
79
			this.motClef = motClef;
-
 
80
		}
71
	}
81
	}
72
 
82
 
73
	public String getDate() {
83
	public String getDate() {
74
		return date;
84
		return date;
75
	}
85
	}
76
 
86
 
77
	public void setDate(String date) {
87
	public void setDate(String date) {
-
 
88
		if (date != null) {
78
		this.date = date;
89
			this.date = date;
-
 
90
		}
79
	}
91
	}
80
 
92
 
81
	public String getCommune() {
93
	public String getCommune() {
82
		return commune;
94
		return commune;
83
	}
95
	}
84
 
96
 
85
	public void setCommune(String commune) {
97
	public void setCommune(String commune) {
-
 
98
		if (commune != null) {
86
		String[] tableauCommuneDpt = commune.split(" ");
99
			String[] tableauCommuneDpt = commune.split(" ");
87
		if (tableauCommuneDpt.length == 2) {
100
			if (tableauCommuneDpt.length == 2) {
88
			String dpt = tableauCommuneDpt[1].replaceAll("\\(", "").replaceAll("\\)", "");
101
				String dpt = tableauCommuneDpt[1].replaceAll("\\(", "").replaceAll("\\)", "");
89
			setDepartement(dpt);
102
				setDepartement(dpt);
90
			this.commune = tableauCommuneDpt[0];
103
				this.commune = tableauCommuneDpt[0];
91
		} else {
104
			} else {
92
			this.commune = commune;
105
				this.commune = commune;
-
 
106
			}
93
		}
107
		}
94
 
-
 
95
	}
108
	}
96
 
109
 
97
	public String getFamille() {
110
	public String getFamille() {
98
		return famille;
111
		return famille;
99
	}
112
	}
100
 
113
 
101
	public void setFamille(String famille) {
114
	public void setFamille(String famille) {
-
 
115
		if (famille != null) {
102
		this.famille = famille;
116
			this.famille = famille;
-
 
117
		}
103
	}
118
	}
104
 
119
 
105
	public String getTag() {
120
	public String getTag() {
106
		return tag;
121
		return tag;
107
	}
122
	}
108
 
123
 
109
	public void setTag(String tag) {
124
	public void setTag(String tag) {
-
 
125
		if (tag != null) {
110
		this.tag = tag;
126
			this.tag = tag;
-
 
127
		}
111
	}
128
	}
112
 
129
 
113
	public String getAuteur() {
130
	public String getAuteur() {
114
		return auteur;
131
		return auteur;
115
	}
132
	}
116
 
133
 
117
	public void setAuteur(String auteur) {
134
	public void setAuteur(String auteur) {
-
 
135
		if (auteur != null) {
118
		this.auteur = auteur;
136
			this.auteur = auteur;
-
 
137
		}
119
	}
138
	}
120
 
139
 
121
	public ModeTri getTriParNbVotes() {
140
	public ModeTri getTriParNbVotes() {
122
		return triParNbVotes;
141
		return triParNbVotes;
123
	}
142
	}
124
 
143
 
125
	public void setTriParNbVotes(ModeTri triParNbVotes) {
144
	public void setTriParNbVotes(ModeTri triParNbVotes) {
126
		this.triParNbVotes = triParNbVotes;
145
		this.triParNbVotes = triParNbVotes;
127
	}
146
	}
128
 
147
 
129
	public void setIdProtocoleSelectionne(String idProtocoleSelectionne) {
148
	public void setIdProtocoleSelectionne(String idProtocoleSelectionne) {
130
		this.idProtocoleSelectionne = idProtocoleSelectionne;
149
		this.idProtocoleSelectionne = idProtocoleSelectionne;
131
	}
150
	}
132
 
151
 
133
	public String getIdProtocoleSelectionne() {
152
	public String getIdProtocoleSelectionne() {
134
		return idProtocoleSelectionne;
153
		return idProtocoleSelectionne;
135
	}
154
	}
136
 
155
 
137
	public ModeTri getTriParDate() {
156
	public ModeTri getTriParDate() {
138
		return triParDate;
157
		return triParDate;
139
	}
158
	}
140
 
159
 
141
	public void setTriParDate(ModeTri triParDate) {
160
	public void setTriParDate(ModeTri triParDate) {
142
		this.triParDate = triParDate;
161
		this.triParDate = triParDate;
143
	}
162
	}
144
 
163
 
145
	public String versChaineRequete() {
164
	public String versChaineRequete() {
146
		String chaine = "";
165
		String chaine = "";
147
		chaine += estNonNull(rechercheLibre) ? "&masque=" + URL.encode(rechercheLibre) : "";
166
		chaine += estNonNull(rechercheLibre) ? "&masque=" + URL.encode(rechercheLibre) : "";
148
		chaine += estNonNull(departement) ? "&masque.departement=" + URL.encode(departement) : "";
167
		chaine += estNonNull(departement) ? "&masque.departement=" + URL.encode(departement) : "";
149
		chaine += estNonNull(taxon) ? "&masque.ns=" + URL.encode(taxon) : "";
168
		chaine += estNonNull(taxon) ? "&masque.ns=" + URL.encode(taxon) : "";
150
		chaine += estNonNull(genre) ? "&masque.genre=" + URL.encode(genre) : "";
169
		chaine += estNonNull(genre) ? "&masque.genre=" + URL.encode(genre) : "";
151
		chaine += estNonNull(motClef) ? "&masque.tag=" + URL.encode(motClef) : "";
170
		chaine += estNonNull(motClef) ? "&masque.tag=" + URL.encode(motClef) : "";
152
		chaine += estNonNull(date) ? "&masque.date=" + URL.encode(date) : "";
171
		chaine += estNonNull(date) ? "&masque.date=" + URL.encode(date) : "";
153
		chaine += estNonNull(commune) ? "&masque.commune=" + URL.encode(commune) : "";
172
		chaine += estNonNull(commune) ? "&masque.commune=" + URL.encode(commune) : "";
154
		chaine += estNonNull(famille) ? "&masque.famille=" + URL.encode(famille) : "";
173
		chaine += estNonNull(famille) ? "&masque.famille=" + URL.encode(famille) : "";
155
		chaine += estNonNull(auteur) ? "&masque.auteur=" + URL.encode(auteur) : "";
174
		chaine += estNonNull(auteur) ? "&masque.auteur=" + URL.encode(auteur) : "";
156
		
175
		
157
		//TODO: réadapter les web services pour que ceux-ci prennent en compte un tri
176
		//TODO: réadapter les web services pour que ceux-ci prennent en compte un tri
158
		chaine += triParDate != ModeTri.PAS_DE_TRI ? "&tri=date_observation" : "";
177
		chaine += triParDate != ModeTri.PAS_DE_TRI ? "&tri=date_observation" : "";
159
		chaine += triParNbVotes != ModeTri.PAS_DE_TRI ? "&tri=votes" : "";
178
		chaine += triParNbVotes != ModeTri.PAS_DE_TRI ? "&tri=votes" : "";
160
		chaine += triParDate != ModeTri.PAS_DE_TRI ? "&ordre=" + triParDate : "";
179
		chaine += triParDate != ModeTri.PAS_DE_TRI ? "&ordre=" + triParDate : "";
161
		chaine += triParNbVotes != ModeTri.PAS_DE_TRI ? "&ordre=" + triParNbVotes : "";
180
		chaine += triParNbVotes != ModeTri.PAS_DE_TRI ? "&ordre=" + triParNbVotes : "";
162
		chaine += estNonNull(idProtocoleSelectionne) ? "&protocole=" + idProtocoleSelectionne : "";
181
		chaine += estNonNull(idProtocoleSelectionne) ? "&protocole=" + idProtocoleSelectionne : "";
163
 
182
 
164
		return chaine;
183
		return chaine;
165
	}
184
	}
166
 
185
 
167
	private boolean estNonNull(String critere) {
186
	private boolean estNonNull(String critere) {
168
		return critere != null && !critere.trim().isEmpty();
187
		return critere != null && !critere.trim().isEmpty();
169
	}
188
	}
170
}
189
}