Subversion Repositories eFlore/Applications.coel

Rev

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

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