Subversion Repositories eFlore/Applications.coel

Rev

Rev 166 | Rev 171 | 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
 
169 jp_milcent 136
	public String getDateFondationFormatMysql() {
137
		return (String) renvoyerValeurCorrecte("date_fondation");
138
	}
156 jp_milcent 139
	public Date getDateFondation() {
166 jp_milcent 140
		Date fondationDate = null;
141
		String fondationChaine = (String) renvoyerValeurCorrecte("date_fondation");
142
		if (!fondationChaine.equals(" ")) {
143
			fondationDate = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").parseStrict(fondationChaine);
144
		}
145
		return fondationDate;
119 jpm 146
	}
156 jp_milcent 147
	public void setDateFondation(Date dateFondation) {
148
		if (dateFondation != null) {
166 jp_milcent 149
			this.set("date_fondation", DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(dateFondation));
156 jp_milcent 150
		}
151
	}
119 jpm 152
	public void setDateFondation(String dateFondation) {
156 jp_milcent 153
		if (dateFondation != null) {
154
			this.set("date_fondation", dateFondation);
155
		}
119 jpm 156
	}
156 jp_milcent 157
 
60 jpm 158
	public String getCodePostal() {
159
		return (String) renvoyerValeurCorrecte("code_postal");
160
	}
119 jpm 161
	public void setCodePostal(String codePostal) {
162
		this.set("code_postal", codePostal);
163
	}
164
 
60 jpm 165
	public String getVille() {
166
		return (String) renvoyerValeurCorrecte("ville");
167
	}
119 jpm 168
	public void setVille(String ville) {
169
		this.set("ville", ville);
170
	}
171
 
60 jpm 172
	public String getRegion() {
173
		return (String) renvoyerValeurCorrecte("region");
174
	}
119 jpm 175
	public void setRegion(String region) {
176
		this.set("region", region);
177
	}
178
 
60 jpm 179
	public String getPays() {
180
		return (String) renvoyerValeurCorrecte("pays");
181
	}
119 jpm 182
	public void setPays(String pays) {
183
		this.set("pays", pays);
184
	}
60 jpm 185
 
119 jpm 186
	public String getLatitude() {
187
		return (String) renvoyerValeurCorrecte("latitude");
188
	}
189
 
190
	public String getLongitude() {
191
		return (String) renvoyerValeurCorrecte("longitude");
192
	}
193
 
60 jpm 194
	public String getTelephone() {
195
		return (String) renvoyerValeurCorrecte("telephone");
196
	}
119 jpm 197
	public void setTelephone(String tel) {
198
		this.set("telephone", tel);
199
	}
60 jpm 200
 
201
	public String getFax() {
202
		return (String) renvoyerValeurCorrecte("fax");
203
	}
119 jpm 204
	public void setFax(String fax) {
205
		this.set("fax", fax);
206
	}
60 jpm 207
 
208
	public String getCourriel() {
209
		return (String) renvoyerValeurCorrecte("courriel");
210
	}
119 jpm 211
	public void setCourriel(String courriel) {
212
		this.set("courriel", courriel);
213
	}
60 jpm 214
 
166 jp_milcent 215
	public String getUrl(String type) {
216
		return urls.get(type);
217
	}
119 jpm 218
	public String getUrl() {
166 jp_milcent 219
		String urlsDenormalise = "";
220
		Set<String> proprietes = urls.getProperties().keySet();
221
		for (Iterator<String> it = proprietes.iterator(); it.hasNext();) {
222
			String cle = it.next();
223
			urlsDenormalise += cle+"##"+urls.get(cle)+";;";
224
		}
225
		urlsDenormalise.replaceFirst(";;$", "");
226
		return urlsDenormalise;
119 jpm 227
	}
166 jp_milcent 228
	public void setUrl(String urlsDenormalise) {
229
		// Constructions du tableau des urls interne
230
		urls = new BaseModelData();
231
		if (urlsDenormalise != null && !urlsDenormalise.equals("")) {
232
			//GWT.log(urlsDenormalise, null);
233
			String[] tableauUrls = urlsDenormalise.split(";;");
234
			for (int i = 0; i < tableauUrls.length; i++) {
235
				String url = tableauUrls[i];
236
				//GWT.log("\t"+url, null);
237
				String[] tableauUrl = url.split("##");
238
				if (tableauUrl.length == 2) {
239
					//GWT.log("\t\t"+tableauUrl[0]+"-"+tableauUrl[1], null);
240
					urls.set(tableauUrl[0], tableauUrl[1]);
241
				}
242
			}
243
		}
119 jpm 244
	}
166 jp_milcent 245
	public void setUrl(String type, String url) {
246
		urls.set(type, url);
247
	}
119 jpm 248
 
249
	public String getNbrePersonne() {
250
		return (String) renvoyerValeurCorrecte("nbre_personne");
251
	}
252
	public void setNbrePersonne(String nbrePersonne) {
253
		this.set("nbre_personne", nbrePersonne);
254
	}
255
 
60 jpm 256
	public String getConditionAcces() {
257
		return (String) renvoyerValeurCorrecte("condition_acces");
258
	}
119 jpm 259
 
260
	public String getConditionUsage() {
261
		return (String) renvoyerValeurCorrecte("condition_usage");
262
	}
263
 
166 jp_milcent 264
	public String toString() {
265
		String sortie = "";
266
		Set<String> proprietes = this.getProperties().keySet();
267
		for (Iterator<String> it = proprietes.iterator(); it.hasNext();) {
268
			String cle = it.next();
269
			sortie += cle+" : "+this.get(cle)+"\n";
270
		}
271
		return sortie;
272
	}
273
 
60 jpm 274
}