Subversion Repositories eFlore/Applications.coel

Rev

Rev 212 | Rev 231 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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