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