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