Subversion Repositories eFlore/Applications.coel

Rev

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

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