Subversion Repositories eFlore/Applications.coel

Rev

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

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