| 60 |
jpm |
1 |
package org.tela_botanica.client.modeles;
|
|
|
2 |
|
| 156 |
jp_milcent |
3 |
import java.util.Date;
|
| 60 |
jpm |
4 |
import java.util.Iterator;
|
|
|
5 |
import java.util.Set;
|
|
|
6 |
|
| 166 |
jp_milcent |
7 |
import com.extjs.gxt.ui.client.data.BaseModelData;
|
| 156 |
jp_milcent |
8 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
| 60 |
jpm |
9 |
import com.google.gwt.json.client.JSONObject;
|
|
|
10 |
|
| 69 |
jpm |
11 |
public class Structure extends aDonnee {
|
| 119 |
jpm |
12 |
|
|
|
13 |
public static final String PREFIXE = "cs";
|
| 177 |
jp_milcent |
14 |
public static final String URL_SITE = "WEB";
|
|
|
15 |
public static final String URL_LOGO = "LOGO";
|
| 166 |
jp_milcent |
16 |
private BaseModelData urls = null;
|
| 382 |
jp_milcent |
17 |
private StructureAPersonneListe personnel = null;
|
|
|
18 |
private StructureValorisation valorisation = null;
|
|
|
19 |
private StructureConservation conservation = null;
|
|
|
20 |
|
| 60 |
jpm |
21 |
/**
|
|
|
22 |
* Constructeur vide
|
|
|
23 |
*
|
|
|
24 |
*/
|
|
|
25 |
public Structure() {
|
| 177 |
jp_milcent |
26 |
// Constructions du tableau des urls interne
|
|
|
27 |
urls = new BaseModelData();
|
| 60 |
jpm |
28 |
}
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* Constructeur avec un objet JSON
|
|
|
32 |
*
|
|
|
33 |
* @param image
|
|
|
34 |
*/
|
|
|
35 |
public Structure(JSONObject institution) {
|
| 177 |
jp_milcent |
36 |
// Constructions du tableau des urls interne
|
|
|
37 |
urls = new BaseModelData();
|
|
|
38 |
|
| 60 |
jpm |
39 |
// l'objet JSON est une table de hachage
|
|
|
40 |
Set<String> im = institution.keySet();
|
|
|
41 |
|
|
|
42 |
// Parcourt pour chaque clé
|
|
|
43 |
for (Iterator<String> it = im.iterator(); it.hasNext();) {
|
|
|
44 |
// Si elle est associée à une valeur, nous l'ajoutons
|
|
|
45 |
String cle = it.next();
|
| 203 |
jp_milcent |
46 |
if (cle.startsWith(PREFIXE+"_")) {
|
|
|
47 |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
|
|
|
48 |
String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
|
|
|
49 |
// Sinon, nous ajoutons la clé avec une valeur vide
|
|
|
50 |
String valeur = "";
|
|
|
51 |
if (institution.get(cle).isString() != null) {
|
|
|
52 |
valeur = institution.get(cle).isString().stringValue();
|
|
|
53 |
}
|
|
|
54 |
if (cleObjet.equals("truk_url")) {
|
|
|
55 |
this.setUrl(valeur);
|
|
|
56 |
} else {
|
|
|
57 |
this.set(cleObjet, valeur);
|
|
|
58 |
}
|
| 166 |
jp_milcent |
59 |
}
|
| 60 |
jpm |
60 |
}
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public String getId() {
|
|
|
64 |
return (String) renvoyerValeurCorrecte("id_structure");
|
|
|
65 |
}
|
| 119 |
jpm |
66 |
public void setId(String idStructure) {
|
|
|
67 |
this.set("id_structure", idStructure);
|
|
|
68 |
}
|
| 60 |
jpm |
69 |
|
| 119 |
jpm |
70 |
public String getIdProjet() {
|
|
|
71 |
return (String) renvoyerValeurCorrecte("ce_projet");
|
|
|
72 |
}
|
|
|
73 |
public void setIdProjet(String idProjet) {
|
|
|
74 |
this.set("ce_projet", idProjet);
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
public String getIdMere() {
|
|
|
78 |
return (String) renvoyerValeurCorrecte("ce_mere");
|
|
|
79 |
}
|
|
|
80 |
public void setIdMere(String idMere) {
|
|
|
81 |
this.set("ce_mere", idMere);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
public String getGuid() {
|
|
|
85 |
return (String) renvoyerValeurCorrecte("guid");
|
|
|
86 |
}
|
|
|
87 |
public void setGuid(String guid) {
|
|
|
88 |
this.set("guid", guid);
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
public String getIdAlternatif() {
|
|
|
92 |
return (String) renvoyerValeurCorrecte("truk_identifiant_alternatif");
|
|
|
93 |
}
|
|
|
94 |
public void setIdAlternatif(String idAlter) {
|
|
|
95 |
this.set("truk_identifiant_alternatif", idAlter);
|
|
|
96 |
}
|
|
|
97 |
|
| 60 |
jpm |
98 |
public String getNom() {
|
|
|
99 |
return (String) renvoyerValeurCorrecte("nom");
|
|
|
100 |
}
|
| 119 |
jpm |
101 |
public void setNom(String nom) {
|
|
|
102 |
this.set("nom", nom);
|
|
|
103 |
}
|
| 60 |
jpm |
104 |
|
| 119 |
jpm |
105 |
public String getNomAlternatif() {
|
|
|
106 |
return (String) renvoyerValeurCorrecte("truk_nom_alternatif");
|
|
|
107 |
}
|
|
|
108 |
|
| 60 |
jpm |
109 |
public String getDescription() {
|
|
|
110 |
return (String) renvoyerValeurCorrecte("description");
|
|
|
111 |
}
|
|
|
112 |
|
| 119 |
jpm |
113 |
public String getType() {
|
|
|
114 |
return (String) renvoyerValeurCorrecte("ce_type");
|
|
|
115 |
}
|
|
|
116 |
public void setType(String type) {
|
|
|
117 |
this.set("ce_type", type);
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
public String getTypePrive() {
|
|
|
121 |
return (String) renvoyerValeurCorrecte("ce_truk_type_prive");
|
|
|
122 |
}
|
|
|
123 |
public void setTypePrive(String typePrive) {
|
|
|
124 |
this.set("ce_truk_type_prive", typePrive);
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public String getTypePublic() {
|
|
|
128 |
return (String) renvoyerValeurCorrecte("ce_truk_type_public");
|
|
|
129 |
}
|
|
|
130 |
public void setTypePublic(String typePublic) {
|
|
|
131 |
this.set("ce_truk_type_public", typePublic);
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
public String getAdresse() {
|
| 60 |
jpm |
135 |
return (String) renvoyerValeurCorrecte("adresse_01");
|
|
|
136 |
}
|
| 119 |
jpm |
137 |
public void setAdresse(String adr) {
|
|
|
138 |
this.set("adresse_01", adr);
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
public String getAdresseComplement() {
|
|
|
142 |
return (String) renvoyerValeurCorrecte("adresse_02");
|
|
|
143 |
}
|
| 60 |
jpm |
144 |
|
| 169 |
jp_milcent |
145 |
public String getDateFondationFormatMysql() {
|
|
|
146 |
return (String) renvoyerValeurCorrecte("date_fondation");
|
|
|
147 |
}
|
| 392 |
jp_milcent |
148 |
public String getDateFondationFormatLong() {
|
|
|
149 |
String dateFormatee = "";
|
|
|
150 |
Date dateFondation = getDateFondation();
|
|
|
151 |
if (dateFondation != null) {
|
|
|
152 |
dateFormatee = DateTimeFormat.getLongDateFormat().format(dateFondation);
|
|
|
153 |
}
|
|
|
154 |
return dateFormatee;
|
|
|
155 |
}
|
| 156 |
jp_milcent |
156 |
public Date getDateFondation() {
|
| 166 |
jp_milcent |
157 |
Date fondationDate = null;
|
|
|
158 |
String fondationChaine = (String) renvoyerValeurCorrecte("date_fondation");
|
| 177 |
jp_milcent |
159 |
if (!fondationChaine.isEmpty() && !fondationChaine.equals("0000-00-00")) {
|
|
|
160 |
fondationDate = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(fondationChaine);
|
| 166 |
jp_milcent |
161 |
}
|
|
|
162 |
return fondationDate;
|
| 119 |
jpm |
163 |
}
|
| 156 |
jp_milcent |
164 |
public void setDateFondation(Date dateFondation) {
|
|
|
165 |
if (dateFondation != null) {
|
| 177 |
jp_milcent |
166 |
this.set("date_fondation", DateTimeFormat.getFormat("yyyy-MM-dd").format(dateFondation));
|
| 156 |
jp_milcent |
167 |
}
|
|
|
168 |
}
|
| 119 |
jpm |
169 |
public void setDateFondation(String dateFondation) {
|
| 156 |
jp_milcent |
170 |
if (dateFondation != null) {
|
|
|
171 |
this.set("date_fondation", dateFondation);
|
|
|
172 |
}
|
| 119 |
jpm |
173 |
}
|
| 156 |
jp_milcent |
174 |
|
| 60 |
jpm |
175 |
public String getCodePostal() {
|
|
|
176 |
return (String) renvoyerValeurCorrecte("code_postal");
|
|
|
177 |
}
|
| 119 |
jpm |
178 |
public void setCodePostal(String codePostal) {
|
|
|
179 |
this.set("code_postal", codePostal);
|
|
|
180 |
}
|
|
|
181 |
|
| 60 |
jpm |
182 |
public String getVille() {
|
|
|
183 |
return (String) renvoyerValeurCorrecte("ville");
|
|
|
184 |
}
|
| 119 |
jpm |
185 |
public void setVille(String ville) {
|
|
|
186 |
this.set("ville", ville);
|
|
|
187 |
}
|
|
|
188 |
|
| 60 |
jpm |
189 |
public String getRegion() {
|
|
|
190 |
return (String) renvoyerValeurCorrecte("region");
|
|
|
191 |
}
|
| 119 |
jpm |
192 |
public void setRegion(String region) {
|
|
|
193 |
this.set("region", region);
|
|
|
194 |
}
|
|
|
195 |
|
| 60 |
jpm |
196 |
public String getPays() {
|
|
|
197 |
return (String) renvoyerValeurCorrecte("pays");
|
|
|
198 |
}
|
| 119 |
jpm |
199 |
public void setPays(String pays) {
|
|
|
200 |
this.set("pays", pays);
|
|
|
201 |
}
|
| 60 |
jpm |
202 |
|
| 119 |
jpm |
203 |
public String getLatitude() {
|
|
|
204 |
return (String) renvoyerValeurCorrecte("latitude");
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
public String getLongitude() {
|
|
|
208 |
return (String) renvoyerValeurCorrecte("longitude");
|
|
|
209 |
}
|
|
|
210 |
|
| 60 |
jpm |
211 |
public String getTelephone() {
|
|
|
212 |
return (String) renvoyerValeurCorrecte("telephone");
|
|
|
213 |
}
|
| 119 |
jpm |
214 |
public void setTelephone(String tel) {
|
|
|
215 |
this.set("telephone", tel);
|
|
|
216 |
}
|
| 60 |
jpm |
217 |
|
|
|
218 |
public String getFax() {
|
|
|
219 |
return (String) renvoyerValeurCorrecte("fax");
|
|
|
220 |
}
|
| 119 |
jpm |
221 |
public void setFax(String fax) {
|
|
|
222 |
this.set("fax", fax);
|
|
|
223 |
}
|
| 60 |
jpm |
224 |
|
|
|
225 |
public String getCourriel() {
|
|
|
226 |
return (String) renvoyerValeurCorrecte("courriel");
|
|
|
227 |
}
|
| 119 |
jpm |
228 |
public void setCourriel(String courriel) {
|
|
|
229 |
this.set("courriel", courriel);
|
|
|
230 |
}
|
| 60 |
jpm |
231 |
|
| 166 |
jp_milcent |
232 |
public String getUrl(String type) {
|
|
|
233 |
return urls.get(type);
|
|
|
234 |
}
|
| 119 |
jpm |
235 |
public String getUrl() {
|
| 166 |
jp_milcent |
236 |
String urlsDenormalise = "";
|
|
|
237 |
Set<String> proprietes = urls.getProperties().keySet();
|
|
|
238 |
for (Iterator<String> it = proprietes.iterator(); it.hasNext();) {
|
|
|
239 |
String cle = it.next();
|
|
|
240 |
urlsDenormalise += cle+"##"+urls.get(cle)+";;";
|
|
|
241 |
}
|
|
|
242 |
urlsDenormalise.replaceFirst(";;$", "");
|
|
|
243 |
return urlsDenormalise;
|
| 119 |
jpm |
244 |
}
|
| 166 |
jp_milcent |
245 |
public void setUrl(String urlsDenormalise) {
|
|
|
246 |
if (urlsDenormalise != null && !urlsDenormalise.equals("")) {
|
|
|
247 |
//GWT.log(urlsDenormalise, null);
|
|
|
248 |
String[] tableauUrls = urlsDenormalise.split(";;");
|
|
|
249 |
for (int i = 0; i < tableauUrls.length; i++) {
|
|
|
250 |
String url = tableauUrls[i];
|
|
|
251 |
//GWT.log("\t"+url, null);
|
|
|
252 |
String[] tableauUrl = url.split("##");
|
|
|
253 |
if (tableauUrl.length == 2) {
|
|
|
254 |
//GWT.log("\t\t"+tableauUrl[0]+"-"+tableauUrl[1], null);
|
|
|
255 |
urls.set(tableauUrl[0], tableauUrl[1]);
|
|
|
256 |
}
|
|
|
257 |
}
|
|
|
258 |
}
|
| 119 |
jpm |
259 |
}
|
| 166 |
jp_milcent |
260 |
public void setUrl(String type, String url) {
|
| 177 |
jp_milcent |
261 |
if (url != null) {
|
|
|
262 |
urls.set(type, url);
|
|
|
263 |
}
|
| 166 |
jp_milcent |
264 |
}
|
| 119 |
jpm |
265 |
|
| 208 |
jp_milcent |
266 |
public int getNbrePersonne() {
|
|
|
267 |
if (renvoyerValeurCorrecte("nbre_personne").equals("")) {
|
|
|
268 |
return 0;
|
|
|
269 |
} else {
|
|
|
270 |
return Integer.parseInt(renvoyerValeurCorrecte("nbre_personne"));
|
|
|
271 |
}
|
| 119 |
jpm |
272 |
}
|
| 208 |
jp_milcent |
273 |
public void setNbrePersonne(int nbrePersonne) {
|
|
|
274 |
this.set("nbre_personne", Integer.toString(nbrePersonne));
|
| 119 |
jpm |
275 |
}
|
|
|
276 |
|
| 60 |
jpm |
277 |
public String getConditionAcces() {
|
|
|
278 |
return (String) renvoyerValeurCorrecte("condition_acces");
|
|
|
279 |
}
|
| 119 |
jpm |
280 |
|
|
|
281 |
public String getConditionUsage() {
|
|
|
282 |
return (String) renvoyerValeurCorrecte("condition_usage");
|
|
|
283 |
}
|
|
|
284 |
|
| 382 |
jp_milcent |
285 |
public StructureAPersonneListe getPersonnel() {
|
|
|
286 |
return personnel;
|
|
|
287 |
}
|
|
|
288 |
public void setPersonnel(StructureAPersonneListe personnelAStocker) {
|
|
|
289 |
personnel = personnelAStocker;
|
|
|
290 |
}
|
|
|
291 |
|
|
|
292 |
public StructureValorisation getValorisation() {
|
|
|
293 |
return valorisation;
|
|
|
294 |
}
|
|
|
295 |
public void setValorisation(StructureValorisation valorisationAStocker) {
|
|
|
296 |
valorisation = valorisationAStocker;
|
|
|
297 |
}
|
|
|
298 |
|
|
|
299 |
public StructureConservation getConservation() {
|
|
|
300 |
return conservation;
|
|
|
301 |
}
|
|
|
302 |
public void setConservation(StructureConservation conservationAStocker) {
|
|
|
303 |
conservation = conservationAStocker;
|
|
|
304 |
}
|
|
|
305 |
|
| 166 |
jp_milcent |
306 |
public String toString() {
|
|
|
307 |
String sortie = "";
|
| 177 |
jp_milcent |
308 |
|
|
|
309 |
// Champs du BaseModelData
|
| 166 |
jp_milcent |
310 |
Set<String> proprietes = this.getProperties().keySet();
|
|
|
311 |
for (Iterator<String> it = proprietes.iterator(); it.hasNext();) {
|
|
|
312 |
String cle = it.next();
|
|
|
313 |
sortie += cle+" : "+this.get(cle)+"\n";
|
|
|
314 |
}
|
| 177 |
jp_milcent |
315 |
|
|
|
316 |
// Champs spéciaux
|
|
|
317 |
sortie += getUrl();
|
|
|
318 |
|
| 166 |
jp_milcent |
319 |
return sortie;
|
|
|
320 |
}
|
|
|
321 |
|
| 60 |
jpm |
322 |
}
|