Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 775 Rev 818
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
3
import java.util.Date;
3
import java.util.Date;
4
import java.util.Iterator;
4
import java.util.Iterator;
5
import java.util.Set;
5
import java.util.Set;
6
 
6
 
7
import org.tela_botanica.client.util.UtilString;
7
import org.tela_botanica.client.util.UtilString;
8
 
8
 
9
import com.google.gwt.core.client.GWT;
9
import com.google.gwt.core.client.GWT;
10
import com.google.gwt.i18n.client.DateTimeFormat;
10
import com.google.gwt.i18n.client.DateTimeFormat;
11
import com.google.gwt.json.client.JSONObject;
11
import com.google.gwt.json.client.JSONObject;
12
 
12
 
13
public class Personne extends aDonnee {
13
public class Personne extends aDonnee {
14
 
14
 
15
	private static final long serialVersionUID = -6974716696155349332L;
15
	private static final long serialVersionUID = -6974716696155349332L;
16
 
16
 
17
	public static final String PREFIXE = "cp";
17
	public static final String PREFIXE = "cp";
18
	public static final String TELEPHONE_FIXE = "FIX";
18
	public static final String TELEPHONE_FIXE = "FIX";
19
	public static final String TELEPHONE_GSM = "GSM";
19
	public static final String TELEPHONE_GSM = "GSM";
20
	public static final String TELEPHONE_FAX = "FAX";
20
	public static final String TELEPHONE_FAX = "FAX";
21
	
21
	
22
	public Personne() {
22
	public Personne() {
23
	}
23
	}
24
	
24
	
25
	public Personne(JSONObject personne) {
25
	public Personne(JSONObject personne) {
26
		initialiserModele(personne);
26
		initialiserModele(personne);
27
		//Ajout du champ courriel principal
27
		//Ajout du champ courriel principal
28
		this.set("courriel_princ", this.getInfoDenormaliseParPosition(this.renvoyerValeurCorrecte("truk_courriel"), 1));
28
		this.set("courriel_princ", this.getInfoDenormaliseParPosition(this.renvoyerValeurCorrecte("truk_courriel"), 1));
29
	}
29
	}
30
	
30
	
31
	@Override
31
	@Override
32
	protected String getPrefixe() {
32
	protected String getPrefixe() {
33
		return PREFIXE;
33
		return PREFIXE;
34
	}
34
	}
35
	
35
	
36
	// ID PERSONNE
36
	// ID PERSONNE
37
	public String getId() {
37
	public String getId() {
38
		return renvoyerValeurCorrecte("id_personne");
38
		return renvoyerValeurCorrecte("id_personne");
39
	}
39
	}
40
	
40
	
41
	// ID PROJET
41
	// ID PROJET
42
	public String getIdProjet() {
42
	public String getIdProjet() {
43
		return renvoyerValeurCorrecte("ce_projet");
43
		return renvoyerValeurCorrecte("ce_projet");
44
	}
44
	}
45
	
45
	
46
	// NOM COMPLET
46
	// NOM COMPLET
47
	public String getNomComplet() {
47
	public String getNomComplet() {
48
		return renvoyerValeurCorrecte("fmt_nom_complet");
48
		return renvoyerValeurCorrecte("fmt_nom_complet");
49
	}
49
	}
50
	
50
	
51
	// NOM
51
	// NOM
52
	public String getNom() {
52
	public String getNom() {
53
		return renvoyerValeurCorrecte("nom");
53
		return renvoyerValeurCorrecte("nom");
54
	}
54
	}
55
	
55
	
56
	// PRÉNOM
56
	// PRÉNOM
57
	public String getPrenom() {
57
	public String getPrenom() {
58
		return renvoyerValeurCorrecte("prenom");
58
		return renvoyerValeurCorrecte("prenom");
59
	}
59
	}
60
	
60
	
61
	public Date getDate(String nomChamp)	{
61
	public Date getDate(String nomChamp)	{
62
		
62
		
63
		String strDate = renvoyerValeurCorrecte(nomChamp);
63
		String strDate = renvoyerValeurCorrecte(nomChamp);
64
		
64
		
65
		Date dateRetour = null;
65
		Date dateRetour = null;
66
		try
66
		try
67
		{
67
		{
68
			if ((strDate != null) && (!strDate.equals("0000-00-00"))) {
68
			if ((strDate != null) && (!strDate.equals("0000-00-00"))) {
69
				dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate);
69
				dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate);
70
			}
70
			}
71
		} catch (StringIndexOutOfBoundsException e)	{
71
		} catch (StringIndexOutOfBoundsException e)	{
72
			GWT.log("Impossible de parser la date " + strDate, e);
72
			GWT.log("Impossible de parser la date " + strDate, e);
73
		}
73
		}
74
		return dateRetour;		
74
		return dateRetour;		
75
	}
75
	}
76
	
76
	
77
	// TÉLÉPHONE
77
	// TÉLÉPHONE
78
	public String getTelephone() {
78
	public String getTelephone() {
79
		return renvoyerValeurCorrecte("truk_telephone");
79
		return renvoyerValeurCorrecte("truk_telephone");
80
	}
80
	}
81
	public void setTelephone(String t) {
81
	public void setTelephone(String t) {
82
		this.set("truk_telephone", t);
82
		this.set("truk_telephone", t);
83
	}
83
	}
84
	public void ajouterTelephone(String type, Object valeur) {
84
	public void ajouterTelephone(String type, Object valeur) {
85
		ajouterChaineDenormaliseAvecType("truk_telephone", type, valeur);
85
		ajouterChaineDenormaliseAvecType("truk_telephone", type, valeur);
86
	}
86
	}
87
	public String selectionnerTelephone(String type) {
87
	public String selectionnerTelephone(String type) {
88
		return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), type);
88
		return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), type);
89
	}
89
	}
90
	
90
	
91
	// FAX
91
	// FAX
92
	public String getFax() {
92
	public String getFax() {
93
		return renvoyerValeurCorrecte("truk_fax");
93
		return renvoyerValeurCorrecte("truk_fax");
94
	}
94
	}
95
	public void setFax(String f) {
95
	public void setFax(String f) {
96
		this.set("truk_fax", f);
96
		this.set("truk_fax", f);
97
	}
97
	}
98
	public void ajouterFax(Object valeur) {
98
	public void ajouterFax(Object valeur) {
99
		ajouterChaineDenormalise("truk_fax", valeur);
99
		ajouterChaineDenormalise("truk_fax", valeur);
100
	}
100
	}
101
	public String selectionnerFax(int position) {
101
	public String selectionnerFax(int position) {
102
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_fax"), position);
102
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_fax"), position);
103
	}
103
	}
104
	
104
	
105
	// COURRIEL
105
	// COURRIEL
106
	public String getCourriel() {
106
	public String getCourriel() {
107
		return renvoyerValeurCorrecte("truk_courriel");
107
		return renvoyerValeurCorrecte("truk_courriel");
108
	}
108
	}
109
	public void setCourriel(String c) {
109
	public void setCourriel(String c) {
110
		this.set("truk_courriel", c);
110
		this.set("truk_courriel", c);
111
	}
111
	}
112
	public void ajouterCourriel(String c) {
112
	public void ajouterCourriel(String c) {
113
		ajouterChaineDenormalise("truk_courriel", c);
113
		ajouterChaineDenormalise("truk_courriel", c);
114
	}
114
	}
115
	public String selectionnerCourriel(int position) {
115
	public String selectionnerCourriel(int position) {
116
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_courriel"), position);
116
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_courriel"), position);
117
	}
117
	}
118
	
118
	
119
	// SPÉCIALITÉ
119
	// SPÉCIALITÉ
120
	public String getSpecialite() {
120
	public String getSpecialite() {
121
		return renvoyerValeurCorrecte("ce_truk_specialite");
121
		return renvoyerValeurCorrecte("ce_truk_specialite");
122
	}
122
	}
123
	public void setSpecialite(String s) {
123
	public void setSpecialite(String s) {
124
		// Pas de liste pour l'instant, donc tout passe dans "Autre".
124
		// Pas de liste pour l'instant, donc tout passe dans "Autre".
125
		setChaineDenormaliseUnique("ce_truk_specialite", "AUTRE", s);
125
		setChaineDenormaliseUnique("ce_truk_specialite", "AUTRE", s);
126
	}
126
	}
127
	public String afficherSpecialite() {
127
	public String afficherSpecialite() {
128
		return getChaineDenormaliseUnique("ce_truk_specialite");
128
		return getChaineDenormaliseUnique("ce_truk_specialite");
129
	}
129
	}
130
	
130
	
131
	public Object obtenirValeurChamp(String nomChamp)	{
131
	public Object obtenirValeurChamp(String nomChamp)	{
132
		return renvoyerValeurCorrecte(nomChamp);
132
		return renvoyerValeurCorrecte(nomChamp);
133
	}
133
	}
134
	
134
	
135
	
135
	
136
	public String getString(String champ)	{
136
	public String getString(String champ)	{
137
		return String.valueOf(renvoyerValeurCorrecte(champ));
137
		return String.valueOf(renvoyerValeurCorrecte(champ));
138
	}
138
	}
139
	
139
	
140
	public void setNaissanceDate(Date naissanceDate) {
140
	public void setNaissanceDate(Date naissanceDate) {
141
		if (naissanceDate != null) {
141
		if (naissanceDate != null) {
142
			this.set("naissance_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(naissanceDate));
142
			this.set("naissance_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(naissanceDate));
143
		}
143
		}
144
	}
144
	}
145
	
145
	
146
	public void setDecesDate(Date decesDate) {
146
	public void setDecesDate(Date decesDate) {
147
		if (decesDate != null) {
147
		if (decesDate != null) {
148
			this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate));
148
			this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate));
149
		}
149
		}
150
	}
150
	}
151
	
151
	
152
	public void setFmtNomComplet(String prefixe, String suffixe)	{
152
	public void setFmtNomComplet(String prefixe, String suffixe)	{
153
		String fmtNomComplet = "";
153
		String fmtNomComplet = "";
154
		if ((prefixe != null)&&(!prefixe.trim().equals("")))	{
154
		if ((prefixe != null)&&(!prefixe.trim().equals("")))	{
155
			fmtNomComplet += prefixe + " ";
155
			fmtNomComplet += prefixe + " ";
156
		}
156
		}
157
		
157
		
158
		if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals("")))	{
158
		if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals("")))	{
159
			fmtNomComplet += this.getPrenom() + " ";
159
			fmtNomComplet += this.getPrenom() + " ";
160
		}
160
		}
161
		
161
		
162
		if ((this.getNom()!=null)&&(!this.getNom().trim().equals("")))	{
162
		if ((this.getNom()!=null)&&(!this.getNom().trim().equals("")))	{
163
			fmtNomComplet += this.getNom() + " ";
163
			fmtNomComplet += this.getNom() + " ";
164
		}
164
		}
165
		
165
		
166
		if ((suffixe!=null)&&(!suffixe.trim().equals("")))	{
166
		if ((suffixe!=null)&&(!suffixe.trim().equals("")))	{
167
			fmtNomComplet += suffixe;
167
			fmtNomComplet += suffixe;
168
		}
168
		}
169
		
169
		
170
		this.set("fmt_nom_complet", UtilString.ucFirst(fmtNomComplet));
170
		this.set("fmt_nom_complet", UtilString.ucFirst(fmtNomComplet));
171
	}
171
	}
-
 
172
	
-
 
173
	
-
 
174
	//Traitement des truks
-
 
175
	protected void remplacerTypeDansChaineDenormalise(String champ, String type, Object valeur) {
-
 
176
		if (valeur != null && !valeur.equals("")) {
-
 
177
			ajouterChaineDenormaliseAvecType(champ, type, valeur);
-
 
178
		} else {
-
 
179
			supprimerTypeDansChaineDenormalise(champ, type);
-
 
180
		}
-
 
181
	}
-
 
182
	/**
-
 
183
	 * Ajoute un nouvel élément sans type à une chaine dénormalisée.
-
 
184
	 * Champ de type "truk" contenant seulement des valeurs séparées par ";;".
-
 
185
	 * Si l'élément existe déjà, il ne sera pas ajouté.
-
 
186
	 * 
-
 
187
	 * @param champ le nom du champ dénormalisé
-
 
188
	 * @param valeur la valeur à ajouter
-
 
189
	 */
-
 
190
	protected void ajouterChaineDenormalise(String champ, Object valeur) {
-
 
191
		if (valeur instanceof String) {
-
 
192
			String chaineExistante = renvoyerValeurCorrecte(champ);
-
 
193
			if (chaineExistante.equals("")) {
-
 
194
				this.set(champ, valeur);
-
 
195
			} else {
-
 
196
				// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons
-
 
197
				if (!chaineExistante.matches("(^|"+SEPARATEUR_VALEURS+")"+valeur+"("+SEPARATEUR_VALEURS+"|$)")) {
-
 
198
					this.set(champ, chaineExistante+SEPARATEUR_VALEURS+valeur);
-
 
199
				}
-
 
200
			}
-
 
201
		}
-
 
202
	}
172
 
203
 
173
}
204
}