Subversion Repositories eFlore/Applications.coel

Rev

Rev 392 | Rev 748 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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