Subversion Repositories eFlore/Applications.coel

Rev

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

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