Subversion Repositories eFlore/Applications.coel

Rev

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

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