Subversion Repositories eFlore/Applications.coel

Rev

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