Subversion Repositories eFlore/Applications.coel

Rev

Rev 60 | Rev 69 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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