Subversion Repositories eFlore/Applications.coel

Rev

Rev 203 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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