Subversion Repositories eFlore/Applications.coel

Rev

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