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