Subversion Repositories eFlore/Applications.coel

Rev

Rev 620 | Rev 775 | 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
 
350 gduche 3
import java.util.Date;
102 jpm 4
import java.util.Iterator;
5
import java.util.Set;
6
 
620 gduche 7
import org.tela_botanica.client.util.UtilString;
8
 
350 gduche 9
import com.google.gwt.core.client.GWT;
10
import com.google.gwt.i18n.client.DateTimeFormat;
102 jpm 11
import com.google.gwt.json.client.JSONObject;
12
 
13
public class Personne extends aDonnee {
208 jp_milcent 14
 
748 jpm 15
	private static final long serialVersionUID = -6974716696155349332L;
16
 
208 jp_milcent 17
	public static final String PREFIXE = "cp";
245 jp_milcent 18
	public static final String TELEPHONE_FIXE = "FIX";
19
	public static final String TELEPHONE_GSM = "GSM";
602 jp_milcent 20
	public static final String TELEPHONE_FAX = "FAX";
208 jp_milcent 21
 
103 jpm 22
	public Personne() {
23
	}
24
 
102 jpm 25
	public Personne(JSONObject liste) {
26
		// l'objet JSON est une table de hachage
27
		Set<String> im = liste.keySet();
28
 
29
		// Parcourt pour chaque clé
30
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
431 gduche 31
 
102 jpm 32
			// Si elle est associée à une valeur, nous l'ajoutons
33
			String cle = it.next();
431 gduche 34
			if (cle.startsWith(PREFIXE+"_")) {
35
 
36
				// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
37
				String cleObjet = cle.replaceFirst("^" + PREFIXE + "_", "");
38
				if (liste.get(cle).isString() != null) {
39
					String valeur = liste.get(cle).isString().stringValue();
40
					this.set(cleObjet, valeur);
41
				} else {
42
					// Sinon, nous ajoutons la clé avec une valeur vide
43
					String valeur = " ";
44
					this.set(cleObjet, valeur);
45
				}
102 jpm 46
			}
47
		}
261 gduche 48
 
49
		//Ajout du champ courriel principal
50
		this.set("courriel_princ", this.getInfoDenormaliseParPosition(this.renvoyerValeurCorrecte("truk_courriel"), 1));
102 jpm 51
	}
52
 
748 jpm 53
	@Override
54
	protected String getPrefixe() {
55
		return PREFIXE;
56
	}
57
 
240 jp_milcent 58
	// ID PERSONNE
102 jpm 59
	public String getId() {
240 jp_milcent 60
		return renvoyerValeurCorrecte("id_personne");
102 jpm 61
	}
62
 
609 jp_milcent 63
	// ID PROJET
64
	public String getIdProjet() {
65
		return renvoyerValeurCorrecte("ce_projet");
66
	}
67
 
240 jp_milcent 68
	// NOM COMPLET
69
	public String getNomComplet() {
70
		return renvoyerValeurCorrecte("fmt_nom_complet");
181 gduche 71
	}
72
 
240 jp_milcent 73
	// NOM
74
	public String getNom() {
75
		return renvoyerValeurCorrecte("nom");
181 gduche 76
	}
77
 
240 jp_milcent 78
	// PRÉNOM
79
	public String getPrenom() {
80
		return renvoyerValeurCorrecte("prenom");
238 aurelien 81
	}
82
 
350 gduche 83
	public Date getDate(String nomChamp)	{
84
 
85
		String strDate = renvoyerValeurCorrecte(nomChamp);
86
 
87
		Date dateRetour = null;
88
		try
89
		{
90
			if ((strDate != null) && (!strDate.equals("0000-00-00"))) {
91
				dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate);
92
			}
93
		} catch (StringIndexOutOfBoundsException e)	{
94
			GWT.log("Impossible de parser la date " + strDate, e);
95
		}
96
		return dateRetour;
97
	}
98
 
240 jp_milcent 99
	// TÉLÉPHONE
100
	public String getTelephone() {
101
		return renvoyerValeurCorrecte("truk_telephone");
102
	}
103
	public void setTelephone(String t) {
104
		this.set("truk_telephone", t);
105
	}
245 jp_milcent 106
	public void ajouterTelephone(String type, Object valeur) {
240 jp_milcent 107
		ajouterChaineDenormaliseAvecType("truk_telephone", type, valeur);
108
	}
245 jp_milcent 109
	public String selectionnerTelephone(String type) {
110
		return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), type);
111
	}
240 jp_milcent 112
 
113
	// FAX
114
	public String getFax() {
115
		return renvoyerValeurCorrecte("truk_fax");
116
	}
117
	public void setFax(String f) {
118
		this.set("truk_fax", f);
119
	}
245 jp_milcent 120
	public void ajouterFax(Object valeur) {
240 jp_milcent 121
		ajouterChaineDenormalise("truk_fax", valeur);
122
	}
245 jp_milcent 123
	public String selectionnerFax(int position) {
124
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_fax"), position);
125
	}
240 jp_milcent 126
 
127
	// COURRIEL
128
	public String getCourriel() {
129
		return renvoyerValeurCorrecte("truk_courriel");
130
	}
131
	public void setCourriel(String c) {
132
		this.set("truk_courriel", c);
133
	}
245 jp_milcent 134
	public void ajouterCourriel(String c) {
240 jp_milcent 135
		ajouterChaineDenormalise("truk_courriel", c);
136
	}
245 jp_milcent 137
	public String selectionnerCourriel(int position) {
138
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_courriel"), position);
139
	}
240 jp_milcent 140
 
141
	// SPÉCIALITÉ
142
	public String getSpecialite() {
143
		return renvoyerValeurCorrecte("ce_truk_specialite");
144
	}
145
	public void setSpecialite(String s) {
146
		// Pas de liste pour l'instant, donc tout passe dans "Autre".
147
		setChaineDenormaliseUnique("ce_truk_specialite", "AUTRE", s);
148
	}
245 jp_milcent 149
	public String afficherSpecialite() {
150
		return getChaineDenormaliseUnique("ce_truk_specialite");
151
	}
240 jp_milcent 152
 
181 gduche 153
	public Object obtenirValeurChamp(String nomChamp)	{
154
		return renvoyerValeurCorrecte(nomChamp);
155
	}
431 gduche 156
 
157
 
158
	public String getString(String champ)	{
159
		return String.valueOf(renvoyerValeurCorrecte(champ));
160
	}
455 gduche 161
 
162
	public void setNaissanceDate(Date naissanceDate) {
163
		if (naissanceDate != null) {
164
			this.set("naissance_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(naissanceDate));
165
		}
166
	}
167
 
168
	public void setDecesDate(Date decesDate) {
169
		if (decesDate != null) {
170
			this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate));
171
		}
172
	}
173
 
174
	public void setFmtNomComplet(String prefixe, String suffixe)	{
175
		String fmtNomComplet = "";
176
		if ((prefixe != null)&&(!prefixe.trim().equals("")))	{
177
			fmtNomComplet += prefixe + " ";
178
		}
179
 
180
		if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals("")))	{
181
			fmtNomComplet += this.getPrenom() + " ";
182
		}
183
 
184
		if ((this.getNom()!=null)&&(!this.getNom().trim().equals("")))	{
185
			fmtNomComplet += this.getNom() + " ";
186
		}
187
 
188
		if ((suffixe!=null)&&(!suffixe.trim().equals("")))	{
189
			fmtNomComplet += suffixe;
190
		}
191
 
620 gduche 192
		this.set("fmt_nom_complet", UtilString.ucFirst(fmtNomComplet));
455 gduche 193
	}
181 gduche 194
 
102 jpm 195
}