Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 264 Rev 295
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
3
import java.util.Iterator;
3
import java.util.Iterator;
4
import java.util.List;
4
import java.util.List;
5
import java.util.Set;
5
import java.util.Set;
6
 
6
 
7
import org.apache.commons.digester.SetRootRule;
7
import org.apache.commons.digester.SetRootRule;
8
 
8
 
9
import com.extjs.gxt.ui.client.widget.form.CheckBox;
9
import com.extjs.gxt.ui.client.widget.form.CheckBox;
10
import com.google.gwt.json.client.JSONObject;
10
import com.google.gwt.json.client.JSONObject;
11
 
11
 
12
public class StructureAPersonne extends aDonnee {
12
public class StructureAPersonne extends aDonnee {
13
	public static final String FONCTION_DIRECTEUR = "2028";
13
	public static final String FONCTION_DIRECTEUR = "2028";
14
	public static final String FONCTION_CONSERVATEUR = "2029";
14
	public static final String FONCTION_CONSERVATEUR = "2029";
15
	public static final String FONCTION_TECHNICIEN = "2030";
15
	public static final String FONCTION_TECHNICIEN = "2030";
16
	public static final String ROLE_ADMIN = "2026";
16
	public static final String ROLE_ADMIN = "2026";
17
	public static final String ROLE_EQUIPE = "2027";
17
	public static final String ROLE_EQUIPE = "2027";
18
	public static final String PREFIXE = "csap";
18
	public static final String PREFIXE = "csap";
-
 
19
	public static final String ETAT_AJOUTE = "A";
19
	
20
	
20
	/**
21
	/**
21
	 * Constructeur vide
22
	 * Constructeur vide
22
	 * 
23
	 * 
23
	 */
24
	 */
24
	public StructureAPersonne() {
25
	public StructureAPersonne() {
25
		// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet
26
		// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet
26
		this.set("contact", false);
27
		this.set("contact", false);
27
		this.set("fonction", "");
28
		this.set("fonction", "");
28
		this.set("statut", "");
29
		this.set("statut", "");
29
		this.set("travail", 0);
30
		this.set("travail", 0);
30
	}
31
	}
31
	
32
	
32
	/**
33
	/**
33
	 * Constructeur avec un objet JSON
34
	 * Constructeur avec un objet JSON
34
	 * 
35
	 * 
35
	 * @param 
36
	 * @param 
36
	 */
37
	 */
37
	public StructureAPersonne(JSONObject personnel) {
38
	public StructureAPersonne(JSONObject personnel) {
38
		// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet
39
		// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet
39
		this.set("contact", false);
40
		this.set("contact", false);
40
		this.set("fonction", "");
41
		this.set("fonction", "");
41
		this.set("statut", "");
42
		this.set("statut", "");
42
		this.set("travail", 0);
43
		this.set("travail", 0);
43
		
44
		
44
		// L'objet JSON est une table de hachage
45
		// L'objet JSON est une table de hachage
45
		Set<String> im = personnel.keySet();
46
		Set<String> im = personnel.keySet();
46
 
47
 
47
		// Parcourt pour chaque clé
48
		// Parcourt pour chaque clé
48
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
49
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
49
			// Si elle est associée à une valeur, nous l'ajoutons
50
			// Si elle est associée à une valeur, nous l'ajoutons
50
			String cle = it.next();
51
			String cle = it.next();
51
			if (cle.startsWith(PREFIXE+"_")) {
52
			if (cle.startsWith(PREFIXE+"_")) {
52
				// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
53
				// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
53
				String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
54
				String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
54
				// Sinon, nous ajoutons la clé avec une valeur vide
55
				// Sinon, nous ajoutons la clé avec une valeur vide
55
				String valeur = "";
56
				String valeur = "";
56
				if (personnel.get(cle).isString() != null) {
57
				if (personnel.get(cle).isString() != null) {
57
					valeur = personnel.get(cle).isString().stringValue();
58
					valeur = personnel.get(cle).isString().stringValue();
58
				}
59
				}
59
				this.set(cleObjet, valeur);
60
				this.set(cleObjet, valeur);
60
				if (cle.equals("mark_contact")) {
61
				if (cle.equals("mark_contact")) {
61
					this.set("contact", (valeur.equals("1") ? true : false));
62
					this.set("contact", (valeur.equals("1") ? true : false));
62
				} else if (cle.equals("bota_travail_hebdo_tps")) {
63
				} else if (cle.equals("bota_travail_hebdo_tps")) {
63
					this.set("travail", Integer.parseInt(valeur));
64
					this.set("travail", Integer.parseInt(valeur));
64
				}
65
				}
65
			}
66
			}
66
			if (cle.startsWith(Personne.PREFIXE+"_")) {
67
			if (cle.startsWith(Personne.PREFIXE+"_")) {
67
				// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
68
				// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
68
				String cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
69
				String cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
69
				// Sinon, nous ajoutons la clé avec une valeur vide
70
				// Sinon, nous ajoutons la clé avec une valeur vide
70
				String valeur = "";
71
				String valeur = "";
71
				if (personnel.get(cle).isString() != null) {
72
				if (personnel.get(cle).isString() != null) {
72
					valeur = personnel.get(cle).isString().stringValue();
73
					valeur = personnel.get(cle).isString().stringValue();
73
				}
74
				}
74
				
75
				
75
				if (cleObjet.equals("truk_telephone")) {
76
				if (cleObjet.equals("truk_telephone")) {
76
					this.set("telephone", getInfoDenormaliseParType(valeur, "FIX"));
77
					this.set("telephone", getInfoDenormaliseParType(valeur, "FIX"));
77
				} else if (cleObjet.equals("truk_fax")) {
78
				} else if (cleObjet.equals("truk_fax")) {
78
					this.set("fax", getInfoDenormaliseParPosition(valeur, 1));
79
					this.set("fax", getInfoDenormaliseParPosition(valeur, 1));
79
				} else if (cleObjet.equals("truk_courriel")) {
80
				} else if (cleObjet.equals("truk_courriel")) {
80
					this.set("courriel", getInfoDenormaliseParPosition(valeur, 1));
81
					this.set("courriel", getInfoDenormaliseParPosition(valeur, 1));
81
				} else if (cleObjet.equals("ce_truk_specialite")) {
82
				} else if (cleObjet.equals("ce_truk_specialite")) {
82
					this.set("specialite", getInfoDenormaliseParPosition(valeur, 1));
83
					this.set("specialite", getInfoDenormaliseParPosition(valeur, 1));
83
				} else {
84
				} else {
84
					this.set(cleObjet, valeur);
85
					this.set(cleObjet, valeur);
85
				}
86
				}
86
			}
87
			}
87
		}
88
		}
88
	}
89
	}
89
	
90
	
90
	/**
91
	/**
91
	 * Constructeur avec la fonction à passer en paramètre
92
	 * Constructeur avec la fonction à passer en paramètre
92
	 * 
93
	 * 
93
	 * @param fonction fonction de la personne dans la structure.
94
	 * @param fonction fonction de la personne dans la structure.
94
	 * @param role identifiant du rôle de la personne vis à vis de la structure.
95
	 * @param role identifiant du rôle de la personne vis à vis de la structure.
95
	 */
96
	 */
96
	public StructureAPersonne(String fonction, String roleId) {
97
	public StructureAPersonne(String fonction, String roleId) {
97
		setFonction(fonction);
98
		setFonction(fonction);
98
		setIdRole(roleId);
99
		setIdRole(roleId);
99
		
100
		
100
		// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet
101
		// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet
101
		this.set("contact", false);
102
		this.set("contact", false);
-
 
103
		this.set("fonction", fonction);
102
		this.set("fonction", "");
104
		this.set("statut", "");
-
 
105
		this.set("travail", 0);
-
 
106
	}
-
 
107
	
-
 
108
	/**
-
 
109
	 * Constructeur avec la fonction à passer en paramètre
-
 
110
	 * 
-
 
111
	 * @param fonction fonction de la personne dans la structure.
-
 
112
	 * @param role identifiant du rôle de la personne vis à vis de la structure.
-
 
113
	 */
-
 
114
	public StructureAPersonne(String fonction, String roleId, String codeEtat) {
-
 
115
		setFonction(fonction);
-
 
116
		setIdRole(roleId);
-
 
117
		
-
 
118
		// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet
-
 
119
		this.set("contact", false);
-
 
120
		this.set("fonction", fonction);
103
		this.set("statut", "");
121
		this.set("statut", "");
104
		this.set("travail", 0);
122
		this.set("travail", 0);
-
 
123
		this.set("etat", codeEtat);
105
	}
124
	}
106
	
125
	
107
	// ID
126
	// ID
108
	/** Génère un identifiant de StructureAPersonne.
127
	/** Génère un identifiant de StructureAPersonne.
109
	 * 
128
	 * 
110
	 * C'est une concaténation des clés primaires de la table coel_structure_a_personne séparées par un tiret "-".
129
	 * C'est une concaténation des clés primaires de la table coel_structure_a_personne séparées par un tiret "-".
111
	 * 
130
	 * 
112
	 * @return identifiant unique d'une relation "structure à personne".
131
	 * @return identifiant unique d'une relation "structure à personne".
113
	 */
132
	 */
114
	public String getId() {
133
	public String getId() {
115
		String idStructure = renvoyerValeurCorrecte("id_structure");
134
		String idStructure = renvoyerValeurCorrecte("id_structure");
116
		String idPersonne = renvoyerValeurCorrecte("id_personne");
135
		String idPersonne = renvoyerValeurCorrecte("id_personne");
117
		String idRole = renvoyerValeurCorrecte("id_role");
136
		String idRole = renvoyerValeurCorrecte("id_role");
118
		if (idStructure.equals("") && idPersonne.equals("") && idRole.equals("")) {
137
		if (idStructure.equals("") && idPersonne.equals("") && idRole.equals("")) {
119
			return null;
138
			return null;
120
		} else {
139
		} else {
121
			return (idStructure+"-"+idPersonne+"-"+idRole);
140
			return (idStructure+"-"+idPersonne+"-"+idRole);
122
		}
141
		}
123
	}
142
	}
124
	
143
	
125
	//+---------------------------------------------------------------------------------------------------------------+
144
	//+---------------------------------------------------------------------------------------------------------------+
126
	// CHAMPS PROVENANT de la TABLE COEL_STRUCTURE_A_PERSONNE
145
	// CHAMPS PROVENANT de la TABLE COEL_STRUCTURE_A_PERSONNE
127
	
146
	
128
	// ID STRUCTURE
147
	// ID STRUCTURE
129
	public String getIdStructure() {
148
	public String getIdStructure() {
130
		return renvoyerValeurCorrecte("id_structure");
149
		return renvoyerValeurCorrecte("id_structure");
131
	}
150
	}
132
	public void setIdStructure(String is) {
151
	public void setIdStructure(String is) {
133
		this.set("id_structure", is);
152
		this.set("id_structure", is);
134
	}
153
	}
135
	
154
	
136
	// ID PERSONNE
155
	// ID PERSONNE
137
	public String getIdPersonne() {
156
	public String getIdPersonne() {
138
		return renvoyerValeurCorrecte("id_personne");
157
		return renvoyerValeurCorrecte("id_personne");
139
	}
158
	}
140
	public void setIdPersonne(String ip) {
159
	public void setIdPersonne(String ip) {
141
		this.set("id_personne", ip);
160
		this.set("id_personne", ip);
142
	}
161
	}
143
	
162
	
144
	// ID RôLE
163
	// ID RôLE
145
	public String getIdRole() {
164
	public String getIdRole() {
146
		return renvoyerValeurCorrecte("id_role");
165
		return renvoyerValeurCorrecte("id_role");
147
	}
166
	}
148
	public void setIdRole(String ir) {
167
	public void setIdRole(String ir) {
149
		this.set("id_role", ir);
168
		this.set("id_role", ir);
150
	}
169
	}
151
	
170
	
152
	// FONCTION
171
	// FONCTION
153
	public String getFonction() {
172
	public String getFonction() {
154
		return renvoyerValeurCorrecte("ce_truk_fonction");
173
		return renvoyerValeurCorrecte("ce_truk_fonction");
155
	}
174
	}
156
	public void setFonction(String ctf) {
175
	public void setFonction(String ctf) {
157
		this.set("ce_truk_fonction", ctf);
176
		this.set("ce_truk_fonction", ctf);
158
	}
177
	}
159
	public void setFonction(String type, Object valeur) {
178
	public void setFonction(String type, Object valeur) {
160
		setChaineDenormaliseUnique("ce_truk_fonction", type, valeur);
179
		setChaineDenormaliseUnique("ce_truk_fonction", type, valeur);
161
	}
180
	}
162
	
181
	
163
	
182
	
164
	// SERVICE
183
	// SERVICE
165
	public String getService() {
184
	public String getService() {
166
		return renvoyerValeurCorrecte("service");
185
		return renvoyerValeurCorrecte("service");
167
	}
186
	}
168
	public void setService(String s) {
187
	public void setService(String s) {
169
		this.set("service", s);
188
		this.set("service", s);
170
	}
189
	}
171
	
190
	
172
	// STATUT
191
	// STATUT
173
	public String getStatut() {
192
	public String getStatut() {
174
		return renvoyerValeurCorrecte("ce_truk_statut");
193
		return renvoyerValeurCorrecte("ce_truk_statut");
175
	}
194
	}
176
	public void setStatut(String cts) {
195
	public void setStatut(String cts) {
177
		this.set("ce_truk_statut", cts);
196
		this.set("ce_truk_statut", cts);
178
	}
197
	}
179
	public void setStatut(String type, Object valeur) {
198
	public void setStatut(String type, Object valeur) {
180
		setChaineDenormaliseUnique("ce_truk_statut", type, valeur);
199
		setChaineDenormaliseUnique("ce_truk_statut", type, valeur);
181
	}
200
	}
182
	
201
	
183
	// CONTACT
202
	// CONTACT
184
	public String getContact() {
203
	public String getContact() {
185
		return renvoyerValeurCorrecte("mark_contact");
204
		return renvoyerValeurCorrecte("mark_contact");
186
	}
205
	}
187
	public void setContact(String c) {
206
	public void setContact(String c) {
188
		//this.set("contact", (c.equals("1") ? true : false));
207
		//this.set("contact", (c.equals("1") ? true : false));
189
		this.set("mark_contact", c);
208
		this.set("mark_contact", c);
190
	}
209
	}
191
	public void setContact(Boolean c) {
210
	public void setContact(Boolean c) {
192
		setContact((c.equals(Boolean.TRUE) ? "1" : "0"));
211
		setContact((c.equals(Boolean.TRUE) ? "1" : "0"));
193
	}
212
	}
194
	
213
	
195
	// BOTA TRAVAIL HEBDO TPS
214
	// BOTA TRAVAIL HEBDO TPS
196
	public String getBotaTravailHebdoTps() {
215
	public String getBotaTravailHebdoTps() {
197
		return renvoyerValeurCorrecte("bota_travail_hebdo_tps");
216
		return renvoyerValeurCorrecte("bota_travail_hebdo_tps");
198
	}
217
	}
199
	public void setBotaTravailHebdoTps(String btht) {
218
	public void setBotaTravailHebdoTps(String btht) {
200
		this.set("bota_travail_hebdo_tps", btht);
219
		this.set("bota_travail_hebdo_tps", btht);
201
	}
220
	}
202
	
221
	
203
	//+---------------------------------------------------------------------------------------------------------------+
222
	//+---------------------------------------------------------------------------------------------------------------+
204
	// CHAMPS PROVENANT de la TABLE COEL_PERSONNE
223
	// CHAMPS PROVENANT de la TABLE COEL_PERSONNE
205
	
224
	
206
	// PRÉNOM
225
	// PRÉNOM
207
	public String getPrenom() {
226
	public String getPrenom() {
208
		return renvoyerValeurCorrecte("prenom");
227
		return renvoyerValeurCorrecte("prenom");
209
	}
228
	}
210
	public void setPrenom(String p) {
229
	public void setPrenom(String p) {
211
		this.set("prenom", p);
230
		this.set("prenom", p);
212
	}
231
	}
213
	
232
	
214
	// NOM
233
	// NOM
215
	public String getNom() {
234
	public String getNom() {
216
		return renvoyerValeurCorrecte("nom");
235
		return renvoyerValeurCorrecte("nom");
217
	}
236
	}
218
	public void setNom(String n) {
237
	public void setNom(String n) {
219
		this.set("nom", n);
238
		this.set("nom", n);
220
	}
239
	}
221
	
240
	
222
	// TÉLÉPHONE
241
	// TÉLÉPHONE
223
	public String getTelephone() {
242
	public String getTelephone() {
224
		return renvoyerValeurCorrecte("telephone");
243
		return renvoyerValeurCorrecte("telephone");
225
	}
244
	}
226
	public void setTelephone(String t) {
245
	public void setTelephone(String t) {
227
		// Nous remplaçons le premier numéro de Téléphone FIX de la personne
246
		// Nous remplaçons le premier numéro de Téléphone FIX de la personne
228
		this.modifierChaineDenormaliseParType("telephone", "FIX", t);
247
		this.modifierChaineDenormaliseParType("telephone", "FIX", t);
229
	}
248
	}
-
 
249
	public String selectionnerTelephone(String type) {
-
 
250
		return getInfoDenormaliseParType(renvoyerValeurCorrecte("telephone"), type);
-
 
251
	}
230
	
252
	
231
	// FAX
253
	// FAX
232
	public String getFax() {
254
	public String getFax() {
233
		return renvoyerValeurCorrecte("fax");
255
		return renvoyerValeurCorrecte("fax");
234
	}
256
	}
235
	public void setFax(String f) {
257
	public void setFax(String f) {
236
		// Nous remplaçons le numéro de Fax en position 1 (principal)
258
		// Nous remplaçons le numéro de Fax en position 1 (principal)
237
		this.modifierChaineDenormaliseParPosition("fax", 1, f);
259
		this.modifierChaineDenormaliseParPosition("fax", 1, f);
238
	}
260
	}
-
 
261
	public String selectionnerFax(int position) {
-
 
262
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("fax"), position);
-
 
263
	}
239
	
264
	
240
	// COURRIEL
265
	// COURRIEL
241
	public String getCourriel() {
266
	public String getCourriel() {
242
		return renvoyerValeurCorrecte("courriel");
267
		return renvoyerValeurCorrecte("courriel");
243
	}
268
	}
244
	public void setCourriel(String c) {
269
	public void setCourriel(String c) {
245
		// Nous remplaçons le courriel en position 1 (principal)
270
		// Nous remplaçons le courriel en position 1 (principal)
246
		this.modifierChaineDenormaliseParPosition("courriel", 1, c);
271
		this.modifierChaineDenormaliseParPosition("courriel", 1, c);
247
	}
272
	}
-
 
273
	public String selectionnerCourriel(int position) {
-
 
274
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("courriel"), position);
-
 
275
	}
248
	
276
	
249
	// SPÉCIALITÉ
277
	// SPÉCIALITÉ
250
	public String getSpecialite() {
278
	public String getSpecialite() {
251
		return renvoyerValeurCorrecte("specialite");
279
		return renvoyerValeurCorrecte("specialite");
252
	}
280
	}
253
	public void setSpecialite(String s) {
281
	public void setSpecialite(String s) {
254
		// Nous remplaçons le premier numéro de Téléphone FIX de la personne
282
		// Nous remplaçons le premier numéro de Téléphone FIX de la personne
255
		this.setChaineDenormaliseUnique("specialite", "AUTRE", s);
283
		this.setChaineDenormaliseUnique("specialite", "AUTRE", s);
256
	}
284
	}
-
 
285
	public String afficherSpecialite() {
-
 
286
		return getChaineDenormaliseUnique("specialite");
-
 
287
	}
257
}
288
}
258
289