Subversion Repositories eFlore/Applications.coel

Rev

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

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