Subversion Repositories eFlore/Applications.coel

Rev

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

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