| 102 |
jpm |
1 |
package org.tela_botanica.client.modeles;
|
|
|
2 |
|
| 431 |
gduche |
3 |
import java.util.Collection;
|
| 350 |
gduche |
4 |
import java.util.Date;
|
| 431 |
gduche |
5 |
import java.util.HashMap;
|
| 102 |
jpm |
6 |
import java.util.Iterator;
|
|
|
7 |
import java.util.Set;
|
|
|
8 |
|
| 350 |
gduche |
9 |
import com.google.gwt.core.client.GWT;
|
| 431 |
gduche |
10 |
import com.google.gwt.http.client.URL;
|
| 350 |
gduche |
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 |
|
|
|
16 |
public static final String PREFIXE = "cp";
|
| 245 |
jp_milcent |
17 |
public static final String TELEPHONE_FIXE = "FIX";
|
|
|
18 |
public static final String TELEPHONE_GSM = "GSM";
|
| 602 |
jp_milcent |
19 |
public static final String TELEPHONE_FAX = "FAX";
|
| 208 |
jp_milcent |
20 |
|
| 102 |
jpm |
21 |
/**
|
| 103 |
jpm |
22 |
* Constructeur vide
|
|
|
23 |
*/
|
|
|
24 |
public Personne() {
|
| 208 |
jp_milcent |
25 |
|
| 103 |
jpm |
26 |
}
|
|
|
27 |
|
|
|
28 |
/**
|
| 102 |
jpm |
29 |
* Constructeur avec un objet JSON
|
|
|
30 |
*
|
|
|
31 |
* @param image
|
|
|
32 |
*/
|
|
|
33 |
public Personne(JSONObject liste) {
|
|
|
34 |
// l'objet JSON est une table de hachage
|
|
|
35 |
Set<String> im = liste.keySet();
|
|
|
36 |
|
|
|
37 |
// Parcourt pour chaque clé
|
|
|
38 |
for (Iterator<String> it = im.iterator(); it.hasNext();) {
|
| 431 |
gduche |
39 |
|
| 102 |
jpm |
40 |
// Si elle est associée à une valeur, nous l'ajoutons
|
|
|
41 |
String cle = it.next();
|
| 431 |
gduche |
42 |
if (cle.startsWith(PREFIXE+"_")) {
|
|
|
43 |
|
|
|
44 |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
|
|
|
45 |
String cleObjet = cle.replaceFirst("^" + PREFIXE + "_", "");
|
|
|
46 |
if (liste.get(cle).isString() != null) {
|
|
|
47 |
String valeur = liste.get(cle).isString().stringValue();
|
|
|
48 |
this.set(cleObjet, valeur);
|
|
|
49 |
} else {
|
|
|
50 |
// Sinon, nous ajoutons la clé avec une valeur vide
|
|
|
51 |
String valeur = " ";
|
|
|
52 |
this.set(cleObjet, valeur);
|
|
|
53 |
}
|
| 102 |
jpm |
54 |
}
|
|
|
55 |
}
|
| 261 |
gduche |
56 |
|
|
|
57 |
//Ajout du champ courriel principal
|
|
|
58 |
this.set("courriel_princ", this.getInfoDenormaliseParPosition(this.renvoyerValeurCorrecte("truk_courriel"), 1));
|
| 102 |
jpm |
59 |
}
|
|
|
60 |
|
| 240 |
jp_milcent |
61 |
// ID PERSONNE
|
| 102 |
jpm |
62 |
public String getId() {
|
| 240 |
jp_milcent |
63 |
return renvoyerValeurCorrecte("id_personne");
|
| 102 |
jpm |
64 |
}
|
|
|
65 |
|
| 240 |
jp_milcent |
66 |
// NOM COMPLET
|
|
|
67 |
public String getNomComplet() {
|
|
|
68 |
return renvoyerValeurCorrecte("fmt_nom_complet");
|
| 181 |
gduche |
69 |
}
|
|
|
70 |
|
| 240 |
jp_milcent |
71 |
// NOM
|
|
|
72 |
public String getNom() {
|
|
|
73 |
return renvoyerValeurCorrecte("nom");
|
| 181 |
gduche |
74 |
}
|
|
|
75 |
|
| 240 |
jp_milcent |
76 |
// PRÉNOM
|
|
|
77 |
public String getPrenom() {
|
|
|
78 |
return renvoyerValeurCorrecte("prenom");
|
| 238 |
aurelien |
79 |
}
|
|
|
80 |
|
| 350 |
gduche |
81 |
public Date getDate(String nomChamp) {
|
|
|
82 |
|
|
|
83 |
String strDate = renvoyerValeurCorrecte(nomChamp);
|
|
|
84 |
|
|
|
85 |
Date dateRetour = null;
|
|
|
86 |
try
|
|
|
87 |
{
|
|
|
88 |
if ((strDate != null) && (!strDate.equals("0000-00-00"))) {
|
|
|
89 |
dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate);
|
|
|
90 |
}
|
|
|
91 |
} catch (StringIndexOutOfBoundsException e) {
|
|
|
92 |
GWT.log("Impossible de parser la date " + strDate, e);
|
|
|
93 |
}
|
|
|
94 |
return dateRetour;
|
|
|
95 |
}
|
|
|
96 |
|
| 240 |
jp_milcent |
97 |
// TÉLÉPHONE
|
|
|
98 |
public String getTelephone() {
|
|
|
99 |
return renvoyerValeurCorrecte("truk_telephone");
|
|
|
100 |
}
|
|
|
101 |
public void setTelephone(String t) {
|
|
|
102 |
this.set("truk_telephone", t);
|
|
|
103 |
}
|
| 245 |
jp_milcent |
104 |
public void ajouterTelephone(String type, Object valeur) {
|
| 240 |
jp_milcent |
105 |
ajouterChaineDenormaliseAvecType("truk_telephone", type, valeur);
|
|
|
106 |
}
|
| 245 |
jp_milcent |
107 |
public String selectionnerTelephone(String type) {
|
|
|
108 |
return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), type);
|
|
|
109 |
}
|
| 240 |
jp_milcent |
110 |
|
|
|
111 |
// FAX
|
|
|
112 |
public String getFax() {
|
|
|
113 |
return renvoyerValeurCorrecte("truk_fax");
|
|
|
114 |
}
|
|
|
115 |
public void setFax(String f) {
|
|
|
116 |
this.set("truk_fax", f);
|
|
|
117 |
}
|
| 245 |
jp_milcent |
118 |
public void ajouterFax(Object valeur) {
|
| 240 |
jp_milcent |
119 |
ajouterChaineDenormalise("truk_fax", valeur);
|
|
|
120 |
}
|
| 245 |
jp_milcent |
121 |
public String selectionnerFax(int position) {
|
|
|
122 |
return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_fax"), position);
|
|
|
123 |
}
|
| 240 |
jp_milcent |
124 |
|
|
|
125 |
// COURRIEL
|
|
|
126 |
public String getCourriel() {
|
|
|
127 |
return renvoyerValeurCorrecte("truk_courriel");
|
|
|
128 |
}
|
|
|
129 |
public void setCourriel(String c) {
|
|
|
130 |
this.set("truk_courriel", c);
|
|
|
131 |
}
|
| 245 |
jp_milcent |
132 |
public void ajouterCourriel(String c) {
|
| 240 |
jp_milcent |
133 |
ajouterChaineDenormalise("truk_courriel", c);
|
|
|
134 |
}
|
| 245 |
jp_milcent |
135 |
public String selectionnerCourriel(int position) {
|
|
|
136 |
return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_courriel"), position);
|
|
|
137 |
}
|
| 240 |
jp_milcent |
138 |
|
|
|
139 |
// SPÉCIALITÉ
|
|
|
140 |
public String getSpecialite() {
|
|
|
141 |
return renvoyerValeurCorrecte("ce_truk_specialite");
|
|
|
142 |
}
|
|
|
143 |
public void setSpecialite(String s) {
|
|
|
144 |
// Pas de liste pour l'instant, donc tout passe dans "Autre".
|
|
|
145 |
setChaineDenormaliseUnique("ce_truk_specialite", "AUTRE", s);
|
|
|
146 |
}
|
| 245 |
jp_milcent |
147 |
public String afficherSpecialite() {
|
|
|
148 |
return getChaineDenormaliseUnique("ce_truk_specialite");
|
|
|
149 |
}
|
| 240 |
jp_milcent |
150 |
|
| 181 |
gduche |
151 |
public Object obtenirValeurChamp(String nomChamp) {
|
|
|
152 |
return renvoyerValeurCorrecte(nomChamp);
|
|
|
153 |
}
|
| 431 |
gduche |
154 |
|
|
|
155 |
|
|
|
156 |
public String getString(String champ) {
|
|
|
157 |
|
|
|
158 |
return String.valueOf(renvoyerValeurCorrecte(champ));
|
|
|
159 |
|
|
|
160 |
}
|
| 455 |
gduche |
161 |
|
|
|
162 |
public void setNaissanceDate(Date naissanceDate) {
|
|
|
163 |
if (naissanceDate != null) {
|
|
|
164 |
this.set("naissance_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(naissanceDate));
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
public void setDecesDate(Date decesDate) {
|
|
|
169 |
if (decesDate != null) {
|
|
|
170 |
this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate));
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
public void setFmtNomComplet(String prefixe, String suffixe) {
|
|
|
175 |
String fmtNomComplet = "";
|
|
|
176 |
if ((prefixe != null)&&(!prefixe.trim().equals(""))) {
|
|
|
177 |
fmtNomComplet += prefixe + " ";
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals(""))) {
|
|
|
181 |
fmtNomComplet += this.getPrenom() + " ";
|
|
|
182 |
}
|
|
|
183 |
|
|
|
184 |
if ((this.getNom()!=null)&&(!this.getNom().trim().equals(""))) {
|
|
|
185 |
fmtNomComplet += this.getNom() + " ";
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
if ((suffixe!=null)&&(!suffixe.trim().equals(""))) {
|
|
|
189 |
fmtNomComplet += suffixe;
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
this.set("fmt_nom_complet", fmtNomComplet);
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
|
| 181 |
gduche |
196 |
|
| 102 |
jpm |
197 |
}
|