| 60 |
jpm |
1 |
package org.tela_botanica.client.modeles;
|
|
|
2 |
|
|
|
3 |
import java.io.Serializable;
|
|
|
4 |
import java.util.Iterator;
|
|
|
5 |
import java.util.Set;
|
|
|
6 |
|
|
|
7 |
import com.extjs.gxt.ui.client.data.BaseModelData;
|
|
|
8 |
import com.google.gwt.json.client.JSONObject;
|
|
|
9 |
|
|
|
10 |
public class Structure extends BaseModelData implements Serializable {
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* Identifiant pour sérialisé l'objet...
|
|
|
14 |
*/
|
| 64 |
jpm |
15 |
private static final long serialVersionUID = 1;
|
| 60 |
jpm |
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Constructeur vide
|
|
|
19 |
*
|
|
|
20 |
*/
|
|
|
21 |
public Structure() {
|
|
|
22 |
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Constructeur avec un objet JSON
|
|
|
27 |
*
|
|
|
28 |
* @param image
|
|
|
29 |
*/
|
|
|
30 |
public Structure(JSONObject institution) {
|
|
|
31 |
// l'objet JSON est une table de hachage
|
|
|
32 |
Set<String> im = institution.keySet();
|
|
|
33 |
|
|
|
34 |
// Parcourt pour chaque clé
|
|
|
35 |
for (Iterator<String> it = im.iterator(); it.hasNext();) {
|
|
|
36 |
// Si elle est associée à une valeur, nous l'ajoutons
|
|
|
37 |
String cle = it.next();
|
|
|
38 |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
|
|
|
39 |
String cleObjet = cle.replaceFirst("^cs_", "");
|
|
|
40 |
if (institution.get(cle).isString() != null) {
|
|
|
41 |
String valeur = institution.get(cle).isString().stringValue();
|
|
|
42 |
this.set(cleObjet, valeur);
|
|
|
43 |
} else {
|
|
|
44 |
// Sinon, nous ajoutons la clé avec une valeur vide
|
|
|
45 |
String valeur = " ";
|
|
|
46 |
this.set(cleObjet, valeur);
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
public String getId() {
|
|
|
52 |
return (String) renvoyerValeurCorrecte("id_structure");
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
public String getNom() {
|
|
|
56 |
return (String) renvoyerValeurCorrecte("nom");
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
public String getDescription() {
|
|
|
60 |
return (String) renvoyerValeurCorrecte("description");
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public String getAdresse01() {
|
|
|
64 |
return (String) renvoyerValeurCorrecte("adresse_01");
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public String getCodePostal() {
|
|
|
68 |
return (String) renvoyerValeurCorrecte("code_postal");
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
public String getVille() {
|
|
|
72 |
return (String) renvoyerValeurCorrecte("ville");
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
public String getRegion() {
|
|
|
76 |
return (String) renvoyerValeurCorrecte("region");
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
public String getPays() {
|
|
|
80 |
return (String) renvoyerValeurCorrecte("pays");
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public String getTelephone() {
|
|
|
84 |
return (String) renvoyerValeurCorrecte("telephone");
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
public String getFax() {
|
|
|
88 |
return (String) renvoyerValeurCorrecte("fax");
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
public String getCourriel() {
|
|
|
92 |
return (String) renvoyerValeurCorrecte("courriel");
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
public String getConditionAcces() {
|
|
|
96 |
return (String) renvoyerValeurCorrecte("condition_acces");
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
/**
|
|
|
100 |
* Pour éviter que l'on traite des valeurs nulles à l'affichage on passe par
|
|
|
101 |
* cette fonction qui retire les charactères nuls qui font planter
|
|
|
102 |
* l'affichage, il ne faut pas utiliser get directement
|
|
|
103 |
*
|
|
|
104 |
* @param cle
|
|
|
105 |
* @return la valeur associée à la clé
|
|
|
106 |
*/
|
|
|
107 |
public String renvoyerValeurCorrecte(String cle) {
|
|
|
108 |
if (this.get(cle) != null) {
|
|
|
109 |
String valeur = this.get(cle);
|
|
|
110 |
if (valeur.equals("null") || valeur == null) {
|
|
|
111 |
return " ";
|
|
|
112 |
} else {
|
|
|
113 |
char nullChar = '\u0000';
|
|
|
114 |
String sNull = "" + nullChar;
|
|
|
115 |
valeur = valeur.replaceAll(sNull, "");
|
|
|
116 |
return valeur;
|
|
|
117 |
}
|
|
|
118 |
} else {
|
|
|
119 |
return " ";
|
|
|
120 |
}
|
|
|
121 |
}
|
|
|
122 |
}
|