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