Subversion Repositories eFlore/Applications.coel

Rev

Rev 212 | Go to most recent revision | Details | 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() {
131
		String fonction = 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
	}
140
	public void setFonction(String ctf) {
141
		this.set("ce_truk_fonction", ctf);
142
	}
143
	public void setFonction(String type, Object valeur) {
144
		setChaineDenormalise("ce_truk_fonction", type, valeur);
145
	}
146
 
147
 
148
	// SERVICE
149
	public String getService() {
150
		return renvoyerValeurCorrecte("service");
151
	}
152
	public void setService(String s) {
153
		this.set("service", s);
154
	}
155
 
156
	// STATUT
157
	public String getStatut() {
158
		return renvoyerValeurCorrecte("ce_truk_statut");
159
	}
160
	public void setStatut(String cts) {
161
		this.set("ce_truk_statut", cts);
162
	}
163
	public void setSatut(String type, Object valeur) {
164
		setChaineDenormalise("ce_truk_statut", type, valeur);
165
	}
166
 
167
	// CONTACT
168
	public String getContact() {
169
		return renvoyerValeurCorrecte("mark_contact");
170
	}
171
	public void setContact(String c) {
172
		this.set("contact", (c.equals("1") ? true : false));
173
		this.set("mark_contact", c);
174
	}
175
	public void setContact(Boolean c) {
176
		setContact((c.equals(Boolean.TRUE) ? "1" : "0"));
177
	}
178
 
179
	// BOTA TRAVAIL HEBDO TPS
180
	public String getBotaTravailHebdoTps() {
181
		return renvoyerValeurCorrecte("bota_travail_hebdo_tps");
182
	}
183
	public void setBotaTravailHebdoTps(String btht) {
184
		this.set("bota_travail_hebdo_tps", btht);
185
	}
186
 
187
	//+---------------------------------------------------------------------------------------------------------------+
188
	// CHAMPS PROVENANT de la TABLE COEL_PERSONNE
189
 
190
	// PRÉNOM
191
	public String getPrenom() {
192
		return renvoyerValeurCorrecte("prenom");
193
	}
194
	public void setPrenom(String p) {
195
		this.set("prenom", p);
196
	}
197
 
198
	// NOM
199
	public String getNom() {
200
		return renvoyerValeurCorrecte("nom");
201
	}
202
	public void setNom(String n) {
203
		this.set("nom", n);
204
	}
205
 
206
	// TÉLÉPHONE
207
	public String getTelephone() {
208
		return renvoyerValeurCorrecte("telephone");
209
	}
210
	public void setTelephone(String t) {
211
		this.set("telephone", t);
212
	}
213
 
214
	// FAX
215
	public String getFax() {
216
		return renvoyerValeurCorrecte("fax");
217
	}
218
	public void setFax(String f) {
219
		this.set("fax", f);
220
	}
221
 
222
	// COURRIEL
223
	public String getCourriel() {
224
		return renvoyerValeurCorrecte("courriel");
225
	}
226
	public void setCourriel(String c) {
227
		this.set("courriel", c);
228
	}
229
 
230
	// SPÉCIALITÉ
231
	public String getSpecialite() {
232
		return renvoyerValeurCorrecte("specialite");
233
	}
234
	public void setSpecialite(String s) {
235
		this.set("specialite", s);
236
	}
237
}