Subversion Repositories eFlore/Applications.coel

Rev

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

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