Subversion Repositories eFlore/Applications.coel

Rev

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

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