Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
102 jpm 1
package org.tela_botanica.client.modeles;
2
 
3
import java.util.Iterator;
4
import java.util.Set;
5
 
6
import com.google.gwt.json.client.JSONObject;
7
 
8
public class Personne extends aDonnee {
208 jp_milcent 9
 
10
	public static final String PREFIXE = "cp";
245 jp_milcent 11
	public static final String TELEPHONE_FIXE = "FIX";
12
	public static final String TELEPHONE_GSM = "GSM";
208 jp_milcent 13
 
102 jpm 14
	/**
103 jpm 15
	 * Constructeur vide
16
	 */
17
	public Personne() {
208 jp_milcent 18
 
103 jpm 19
	}
20
 
21
	/**
102 jpm 22
	 * Constructeur avec un objet JSON
23
	 *
24
	 * @param image
25
	 */
26
	public Personne(JSONObject liste) {
27
		// l'objet JSON est une table de hachage
28
		Set<String> im = liste.keySet();
29
 
30
		// Parcourt pour chaque clé
31
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
32
			// Si elle est associée à une valeur, nous l'ajoutons
33
			String cle = it.next();
34
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
35
			String cleObjet = cle.replaceFirst("^cp_", "");
36
			if (liste.get(cle).isString() != null) {
37
				String valeur = liste.get(cle).isString().stringValue();
38
				this.set(cleObjet, valeur);
39
			} else {
40
				// Sinon, nous ajoutons la clé avec une valeur vide
41
				String valeur = " ";
42
				this.set(cleObjet, valeur);
43
			}
44
		}
261 gduche 45
 
46
		//Ajout du champ courriel principal
47
		this.set("courriel_princ", this.getInfoDenormaliseParPosition(this.renvoyerValeurCorrecte("truk_courriel"), 1));
102 jpm 48
	}
49
 
240 jp_milcent 50
	// ID PERSONNE
102 jpm 51
	public String getId() {
240 jp_milcent 52
		return renvoyerValeurCorrecte("id_personne");
102 jpm 53
	}
54
 
240 jp_milcent 55
	// NOM COMPLET
56
	public String getNomComplet() {
57
		return renvoyerValeurCorrecte("fmt_nom_complet");
181 gduche 58
	}
59
 
240 jp_milcent 60
	// NOM
61
	public String getNom() {
62
		return renvoyerValeurCorrecte("nom");
181 gduche 63
	}
64
 
240 jp_milcent 65
	// PRÉNOM
66
	public String getPrenom() {
67
		return renvoyerValeurCorrecte("prenom");
238 aurelien 68
	}
69
 
240 jp_milcent 70
	// TÉLÉPHONE
71
	public String getTelephone() {
72
		return renvoyerValeurCorrecte("truk_telephone");
73
	}
74
	public void setTelephone(String t) {
75
		this.set("truk_telephone", t);
76
	}
245 jp_milcent 77
	public void ajouterTelephone(String type, Object valeur) {
240 jp_milcent 78
		ajouterChaineDenormaliseAvecType("truk_telephone", type, valeur);
79
	}
245 jp_milcent 80
	public String selectionnerTelephone(String type) {
81
		return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), type);
82
	}
240 jp_milcent 83
 
84
	// FAX
85
	public String getFax() {
86
		return renvoyerValeurCorrecte("truk_fax");
87
	}
88
	public void setFax(String f) {
89
		this.set("truk_fax", f);
90
	}
245 jp_milcent 91
	public void ajouterFax(Object valeur) {
240 jp_milcent 92
		ajouterChaineDenormalise("truk_fax", valeur);
93
	}
245 jp_milcent 94
	public String selectionnerFax(int position) {
95
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_fax"), position);
96
	}
240 jp_milcent 97
 
98
	// COURRIEL
99
	public String getCourriel() {
100
		return renvoyerValeurCorrecte("truk_courriel");
101
	}
102
	public void setCourriel(String c) {
103
		this.set("truk_courriel", c);
104
	}
245 jp_milcent 105
	public void ajouterCourriel(String c) {
240 jp_milcent 106
		ajouterChaineDenormalise("truk_courriel", c);
107
	}
245 jp_milcent 108
	public String selectionnerCourriel(int position) {
109
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_courriel"), position);
110
	}
240 jp_milcent 111
 
112
	// SPÉCIALITÉ
113
	public String getSpecialite() {
114
		return renvoyerValeurCorrecte("ce_truk_specialite");
115
	}
116
	public void setSpecialite(String s) {
117
		// Pas de liste pour l'instant, donc tout passe dans "Autre".
118
		setChaineDenormaliseUnique("ce_truk_specialite", "AUTRE", s);
119
	}
245 jp_milcent 120
	public String afficherSpecialite() {
121
		return getChaineDenormaliseUnique("ce_truk_specialite");
122
	}
240 jp_milcent 123
 
181 gduche 124
	public Object obtenirValeurChamp(String nomChamp)	{
125
		return renvoyerValeurCorrecte(nomChamp);
126
	}
127
 
102 jpm 128
}