Subversion Repositories eFlore/Applications.coel

Rev

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

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