Subversion Repositories eFlore/Applications.coel

Rev

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