Subversion Repositories eFlore/Applications.coel

Rev

Rev 993 | Rev 1189 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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