Subversion Repositories eFlore/Applications.coel

Rev

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

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