Subversion Repositories eFlore/Applications.coel

Rev

Rev 1135 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
935 jpm 1
package org.tela_botanica.client.modeles.personne;
102 jpm 2
 
350 gduche 3
import java.util.Date;
102 jpm 4
import java.util.Iterator;
5
import java.util.Set;
6
 
827 gduche 7
import org.tela_botanica.client.Mediateur;
935 jpm 8
import org.tela_botanica.client.modeles.aDonnee;
993 gduche 9
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
620 gduche 10
import org.tela_botanica.client.util.UtilString;
11
 
350 gduche 12
import com.google.gwt.core.client.GWT;
13
import com.google.gwt.i18n.client.DateTimeFormat;
102 jpm 14
import com.google.gwt.json.client.JSONObject;
15
 
16
public class Personne extends aDonnee {
208 jp_milcent 17
 
748 jpm 18
	private static final long serialVersionUID = -6974716696155349332L;
19
 
208 jp_milcent 20
	public static final String PREFIXE = "cp";
245 jp_milcent 21
	public static final String TELEPHONE_FIXE = "FIX";
22
	public static final String TELEPHONE_GSM = "GSM";
602 jp_milcent 23
	public static final String TELEPHONE_FAX = "FAX";
875 jpm 24
	public static final String ETRE_DECEDE = "30745";
25
	public static final String ETRE_VIVANT = "30746";
208 jp_milcent 26
 
993 gduche 27
	private PublicationAPersonneListe publicationsLiees= null;
28
 
103 jpm 29
	public Personne() {
30
	}
31
 
775 jpm 32
	public Personne(JSONObject personne) {
33
		initialiserModele(personne);
261 gduche 34
		//Ajout du champ courriel principal
947 gduche 35
		this.setCourrielPrinc(this.getInfoDenormaliseParPosition(this.renvoyerValeurCorrecte("truk_courriel"), 1));
102 jpm 36
	}
37
 
748 jpm 38
	@Override
39
	protected String getPrefixe() {
40
		return PREFIXE;
41
	}
42
 
875 jpm 43
	public Object obtenirValeurChamp(String nomChamp)	{
44
		return renvoyerValeurCorrecte(nomChamp);
45
	}
46
 
47
	public Date getDate(String nomChamp)	{
48
		String strDate = renvoyerValeurCorrecte(nomChamp);
49
		Date dateRetour = null;
50
		try {
51
			if ((strDate != null) && (!strDate.equals("0000-00-00"))) {
52
				dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate);
53
			}
54
		} catch (StringIndexOutOfBoundsException e)	{
55
			GWT.log("Impossible de parser la date " + strDate, e);
56
		}
57
		return dateRetour;
58
	}
59
 
60
	public String getString(String nomChamp)	{
61
		return String.valueOf(renvoyerValeurCorrecte(nomChamp));
62
	}
63
 
64
	//Traitement des truks
65
	protected void remplacerTypeDansChaineDenormalise(String champ, String type, Object valeur) {
66
		if (valeur != null && !valeur.equals("")) {
67
			ajouterChaineDenormaliseAvecType(champ, type, valeur);
68
		} else {
69
			supprimerTypeDansChaineDenormalise(champ, type);
70
		}
71
	}
72
	/**
73
	 * Ajoute un nouvel élément sans type à une chaine dénormalisée.
74
	 * Champ de type "truk" contenant seulement des valeurs séparées par ";;".
75
	 * Si l'élément existe déjà, il ne sera pas ajouté.
76
	 *
77
	 * @param champ le nom du champ dénormalisé
78
	 * @param valeur la valeur à ajouter
79
	 */
80
	protected void ajouterChaineDenormalise(String champ, Object valeur) {
81
		if (valeur instanceof String) {
82
			String chaineExistante = renvoyerValeurCorrecte(champ);
83
			if (chaineExistante.equals("")) {
84
				this.set(champ, valeur);
85
			} else {
86
				// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons
87
				if (!chaineExistante.matches("(^|"+SEPARATEUR_VALEURS+")"+valeur+"("+SEPARATEUR_VALEURS+"|$)")) {
88
					this.set(champ, chaineExistante+SEPARATEUR_VALEURS+valeur);
89
				}
90
			}
91
		}
92
	}
93
 
240 jp_milcent 94
	// ID PERSONNE
102 jpm 95
	public String getId() {
240 jp_milcent 96
		return renvoyerValeurCorrecte("id_personne");
102 jpm 97
	}
875 jpm 98
	public void setId(String personneId) {
99
		this.set("id_personne", personneId);
100
	}
102 jpm 101
 
609 jp_milcent 102
	// ID PROJET
103
	public String getIdProjet() {
104
		return renvoyerValeurCorrecte("ce_projet");
105
	}
106
 
240 jp_milcent 107
	// NOM COMPLET
108
	public String getNomComplet() {
109
		return renvoyerValeurCorrecte("fmt_nom_complet");
181 gduche 110
	}
912 jpm 111
	public void setNomComplet(String nomComplet) {
112
		this.set("fmt_nom_complet", nomComplet);
113
	}
875 jpm 114
	public void setFmtNomComplet(String prefixe, String suffixe)	{
115
		String fmtNomComplet = "";
912 jpm 116
 
875 jpm 117
		if ((prefixe != null)&&(!prefixe.trim().equals("")))	{
118
			fmtNomComplet += prefixe + " ";
119
		}
120
 
121
		if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals("")))	{
122
			fmtNomComplet += this.getPrenom() + " ";
123
		}
124
 
125
		if ((this.getNom()!=null)&&(!this.getNom().trim().equals("")))	{
126
			fmtNomComplet += this.getNom() + " ";
127
		}
128
 
129
		if ((suffixe!=null)&&(!suffixe.trim().equals("")))	{
130
			fmtNomComplet += suffixe;
131
		}
912 jpm 132
 
133
		setNomComplet(UtilString.ucFirst(fmtNomComplet));
875 jpm 134
	}
181 gduche 135
 
240 jp_milcent 136
	// NOM
137
	public String getNom() {
138
		return renvoyerValeurCorrecte("nom");
181 gduche 139
	}
912 jpm 140
	public void setNom(String nom) {
141
		set("nom", nom);
142
	}
181 gduche 143
 
240 jp_milcent 144
	// PRÉNOM
145
	public String getPrenom() {
146
		return renvoyerValeurCorrecte("prenom");
238 aurelien 147
	}
912 jpm 148
	public void setPrenom(String prenom) {
149
		set("prenom", prenom);
150
	}
238 aurelien 151
 
240 jp_milcent 152
	// TÉLÉPHONE
153
	public String getTelephone() {
154
		return renvoyerValeurCorrecte("truk_telephone");
155
	}
156
	public void setTelephone(String t) {
157
		this.set("truk_telephone", t);
158
	}
245 jp_milcent 159
	public void ajouterTelephone(String type, Object valeur) {
240 jp_milcent 160
		ajouterChaineDenormaliseAvecType("truk_telephone", type, valeur);
161
	}
245 jp_milcent 162
	public String selectionnerTelephone(String type) {
163
		return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), type);
164
	}
240 jp_milcent 165
 
166
	// FAX
167
	public String getFax() {
168
		return renvoyerValeurCorrecte("truk_fax");
169
	}
170
	public void setFax(String f) {
171
		this.set("truk_fax", f);
172
	}
245 jp_milcent 173
	public void ajouterFax(Object valeur) {
240 jp_milcent 174
		ajouterChaineDenormalise("truk_fax", valeur);
175
	}
245 jp_milcent 176
	public String selectionnerFax(int position) {
177
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_fax"), position);
178
	}
240 jp_milcent 179
 
180
	// COURRIEL
181
	public String getCourriel() {
182
		return renvoyerValeurCorrecte("truk_courriel");
183
	}
184
	public void setCourriel(String c) {
185
		this.set("truk_courriel", c);
186
	}
245 jp_milcent 187
	public void ajouterCourriel(String c) {
240 jp_milcent 188
		ajouterChaineDenormalise("truk_courriel", c);
189
	}
245 jp_milcent 190
	public String selectionnerCourriel(int position) {
191
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_courriel"), position);
192
	}
240 jp_milcent 193
 
194
	// SPÉCIALITÉ
195
	public String getSpecialite() {
196
		return renvoyerValeurCorrecte("ce_truk_specialite");
197
	}
198
	public void setSpecialite(String s) {
199
		// Pas de liste pour l'instant, donc tout passe dans "Autre".
200
		setChaineDenormaliseUnique("ce_truk_specialite", "AUTRE", s);
201
	}
245 jp_milcent 202
	public String afficherSpecialite() {
203
		return getChaineDenormaliseUnique("ce_truk_specialite");
204
	}
240 jp_milcent 205
 
875 jpm 206
	// NAISSANCE DATE
207
	public String getNaissanceDate()	{
208
		String dateNaiss = "";
209
		dateNaiss = get("naissance_date");
210
		if (UtilString.isEmpty(dateNaiss)||dateNaiss.equals("0000-00-00"))	{
211
			dateNaiss = Mediateur.i18nC.inconnue();
212
		}
213
		return dateNaiss;
181 gduche 214
	}
455 gduche 215
	public void setNaissanceDate(Date naissanceDate) {
216
		if (naissanceDate != null) {
217
			this.set("naissance_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(naissanceDate));
218
		}
219
	}
220
 
875 jpm 221
	// NAISSANCE LIEU
222
	public String getNaissanceLieu() {
223
		return renvoyerValeurCorrecte("naissance_lieu");
827 gduche 224
	}
875 jpm 225
	public void setNaissanceLieu(String naissanceLieu) {
226
		this.set("naissance_lieu", naissanceLieu);
827 gduche 227
	}
228
 
875 jpm 229
	// DÉCÉS
827 gduche 230
	public boolean estDecedee()	{
875 jpm 231
		String ceDeces = getDeces();
232
		if (ceDeces.isEmpty() || ceDeces.equals(ETRE_DECEDE))	{
827 gduche 233
			return false;
875 jpm 234
		} else {
827 gduche 235
			return true;
236
		}
237
	}
875 jpm 238
	public String getDeces()	{
239
		return renvoyerValeurCorrecte("ce_deces");
455 gduche 240
	}
875 jpm 241
	public void setDeces(String deces)	{
242
		set("ce_deces", deces);
243
	}
244
	public void setDeces(Date decesDate, String lieuDeces)	{
245
		set("ce_deces", ETRE_DECEDE);
246
		setDecesDate(decesDate);
247
		setDecesLieu(lieuDeces);
248
	}
249
	public void setNonDecedee()	{
250
		set("ce_deces", ETRE_VIVANT);
251
		setDecesDate(null);
252
		setDecesLieu("");
253
	}
455 gduche 254
 
875 jpm 255
	// DÉCÉS DATE
827 gduche 256
	public String getDecesDate()	{
875 jpm 257
		String dateDeces = renvoyerValeurCorrecte("deces_date");
258
		if (UtilString.isEmpty(dateDeces) || dateDeces.equals("0000-00-00"))	{
827 gduche 259
			dateDeces = Mediateur.i18nC.inconnue();
260
		}
261
		return dateDeces;
262
	}
875 jpm 263
	public void setDecesDate(Date decesDate) {
264
		if (decesDate != null)	{
265
			this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate));
266
		}	else	{
267
			this.set("deces_date", "");
827 gduche 268
		}
269
	}
270
 
875 jpm 271
	// DÉCÉS LIEU
272
	public String getDecesLieu() {
273
		return renvoyerValeurCorrecte("deces_lieu");
455 gduche 274
	}
875 jpm 275
	public void setDecesLieu(String decesLieu) {
276
		this.set("deces_lieu", decesLieu);
818 gduche 277
	}
912 jpm 278
 
279
	// PARAMÊTRE
280
	public String getParametre() {
281
		return renvoyerValeurCorrecte("parametre");
282
	}
283
	public void setParametre(String parametre) {
284
		this.set("parametre", parametre);
285
	}
947 gduche 286
 
287
	public void setCourrielPrinc(String courriel)	{
288
		this.set("_courriel_princ_", courriel);
289
	}
290
 
291
	public String getCourrielPrinc()	{
292
		return (String) this.get("_courriel_princ_");
293
	}
993 gduche 294
 
295
	// PUBLICATIONS LIÉES
296
	public PublicationAPersonneListe getPublicationsLiees() {
297
		return publicationsLiees;
298
	}
299
 
300
	public void setPublicationsLiees(PublicationAPersonneListe relationsCollectionAPublication) {
301
		publicationsLiees = relationsCollectionAPublication;
302
	}
947 gduche 303
}
304