Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 245 Rev 261
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
3
import java.util.Iterator;
3
import java.util.Iterator;
4
import java.util.Set;
4
import java.util.Set;
5
 
5
 
6
import com.google.gwt.json.client.JSONObject;
6
import com.google.gwt.json.client.JSONObject;
7
 
7
 
8
public class Personne extends aDonnee {
8
public class Personne extends aDonnee {
9
 
9
 
10
	public static final String PREFIXE = "cp";
10
	public static final String PREFIXE = "cp";
11
	public static final String TELEPHONE_FIXE = "FIX";
11
	public static final String TELEPHONE_FIXE = "FIX";
12
	public static final String TELEPHONE_GSM = "GSM";
12
	public static final String TELEPHONE_GSM = "GSM";
13
	
13
	
14
	/**
14
	/**
15
	 * Constructeur vide
15
	 * Constructeur vide
16
	 */
16
	 */
17
	public Personne() {
17
	public Personne() {
18
		
18
		
19
	}
19
	}
20
	
20
	
21
	/**
21
	/**
22
	 * Constructeur avec un objet JSON
22
	 * Constructeur avec un objet JSON
23
	 * 
23
	 * 
24
	 * @param image
24
	 * @param image
25
	 */
25
	 */
26
	public Personne(JSONObject liste) {
26
	public Personne(JSONObject liste) {
27
		// l'objet JSON est une table de hachage
27
		// l'objet JSON est une table de hachage
28
		Set<String> im = liste.keySet();
28
		Set<String> im = liste.keySet();
29
 
29
 
30
		// Parcourt pour chaque clé
30
		// Parcourt pour chaque clé
31
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
31
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
32
			// Si elle est associée à une valeur, nous l'ajoutons
32
			// Si elle est associée à une valeur, nous l'ajoutons
33
			String cle = it.next();
33
			String cle = it.next();
34
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
34
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
35
			String cleObjet = cle.replaceFirst("^cp_", "");
35
			String cleObjet = cle.replaceFirst("^cp_", "");
36
			if (liste.get(cle).isString() != null) {
36
			if (liste.get(cle).isString() != null) {
37
				String valeur = liste.get(cle).isString().stringValue();
37
				String valeur = liste.get(cle).isString().stringValue();
38
				this.set(cleObjet, valeur);
38
				this.set(cleObjet, valeur);
39
			} else {
39
			} else {
40
				// Sinon, nous ajoutons la clé avec une valeur vide
40
				// Sinon, nous ajoutons la clé avec une valeur vide
41
				String valeur = " ";
41
				String valeur = " ";
42
				this.set(cleObjet, valeur);
42
				this.set(cleObjet, valeur);
43
			}
43
			}
44
		}
44
		}
-
 
45
		
-
 
46
		//Ajout du champ courriel principal
-
 
47
		this.set("courriel_princ", this.getInfoDenormaliseParPosition(this.renvoyerValeurCorrecte("truk_courriel"), 1));
45
	}
48
	}
46
	
49
	
47
	// ID PERSONNE
50
	// ID PERSONNE
48
	public String getId() {
51
	public String getId() {
49
		return renvoyerValeurCorrecte("id_personne");
52
		return renvoyerValeurCorrecte("id_personne");
50
	}
53
	}
51
	
54
	
52
	// NOM COMPLET
55
	// NOM COMPLET
53
	public String getNomComplet() {
56
	public String getNomComplet() {
54
		return renvoyerValeurCorrecte("fmt_nom_complet");
57
		return renvoyerValeurCorrecte("fmt_nom_complet");
55
	}
58
	}
56
	
59
	
57
	// NOM
60
	// NOM
58
	public String getNom() {
61
	public String getNom() {
59
		return renvoyerValeurCorrecte("nom");
62
		return renvoyerValeurCorrecte("nom");
60
	}
63
	}
61
	
64
	
62
	// PRÉNOM
65
	// PRÉNOM
63
	public String getPrenom() {
66
	public String getPrenom() {
64
		return renvoyerValeurCorrecte("prenom");
67
		return renvoyerValeurCorrecte("prenom");
65
	}
68
	}
66
	
69
	
67
	// TÉLÉPHONE
70
	// TÉLÉPHONE
68
	public String getTelephone() {
71
	public String getTelephone() {
69
		return renvoyerValeurCorrecte("truk_telephone");
72
		return renvoyerValeurCorrecte("truk_telephone");
70
	}
73
	}
71
	public void setTelephone(String t) {
74
	public void setTelephone(String t) {
72
		this.set("truk_telephone", t);
75
		this.set("truk_telephone", t);
73
	}
76
	}
74
	public void ajouterTelephone(String type, Object valeur) {
77
	public void ajouterTelephone(String type, Object valeur) {
75
		ajouterChaineDenormaliseAvecType("truk_telephone", type, valeur);
78
		ajouterChaineDenormaliseAvecType("truk_telephone", type, valeur);
76
	}
79
	}
77
	public String selectionnerTelephone(String type) {
80
	public String selectionnerTelephone(String type) {
78
		return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), type);
81
		return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), type);
79
	}
82
	}
80
	
83
	
81
	// FAX
84
	// FAX
82
	public String getFax() {
85
	public String getFax() {
83
		return renvoyerValeurCorrecte("truk_fax");
86
		return renvoyerValeurCorrecte("truk_fax");
84
	}
87
	}
85
	public void setFax(String f) {
88
	public void setFax(String f) {
86
		this.set("truk_fax", f);
89
		this.set("truk_fax", f);
87
	}
90
	}
88
	public void ajouterFax(Object valeur) {
91
	public void ajouterFax(Object valeur) {
89
		ajouterChaineDenormalise("truk_fax", valeur);
92
		ajouterChaineDenormalise("truk_fax", valeur);
90
	}
93
	}
91
	public String selectionnerFax(int position) {
94
	public String selectionnerFax(int position) {
92
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_fax"), position);
95
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_fax"), position);
93
	}
96
	}
94
	
97
	
95
	// COURRIEL
98
	// COURRIEL
96
	public String getCourriel() {
99
	public String getCourriel() {
97
		return renvoyerValeurCorrecte("truk_courriel");
100
		return renvoyerValeurCorrecte("truk_courriel");
98
	}
101
	}
99
	public void setCourriel(String c) {
102
	public void setCourriel(String c) {
100
		this.set("truk_courriel", c);
103
		this.set("truk_courriel", c);
101
	}
104
	}
102
	public void ajouterCourriel(String c) {
105
	public void ajouterCourriel(String c) {
103
		ajouterChaineDenormalise("truk_courriel", c);
106
		ajouterChaineDenormalise("truk_courriel", c);
104
	}
107
	}
105
	public String selectionnerCourriel(int position) {
108
	public String selectionnerCourriel(int position) {
106
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_courriel"), position);
109
		return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("truk_courriel"), position);
107
	}
110
	}
108
	
111
	
109
	// SPÉCIALITÉ
112
	// SPÉCIALITÉ
110
	public String getSpecialite() {
113
	public String getSpecialite() {
111
		return renvoyerValeurCorrecte("ce_truk_specialite");
114
		return renvoyerValeurCorrecte("ce_truk_specialite");
112
	}
115
	}
113
	public void setSpecialite(String s) {
116
	public void setSpecialite(String s) {
114
		// Pas de liste pour l'instant, donc tout passe dans "Autre".
117
		// Pas de liste pour l'instant, donc tout passe dans "Autre".
115
		setChaineDenormaliseUnique("ce_truk_specialite", "AUTRE", s);
118
		setChaineDenormaliseUnique("ce_truk_specialite", "AUTRE", s);
116
	}
119
	}
117
	public String afficherSpecialite() {
120
	public String afficherSpecialite() {
118
		return getChaineDenormaliseUnique("ce_truk_specialite");
121
		return getChaineDenormaliseUnique("ce_truk_specialite");
119
	}
122
	}
120
	
123
	
121
	public Object obtenirValeurChamp(String nomChamp)	{
124
	public Object obtenirValeurChamp(String nomChamp)	{
122
		return renvoyerValeurCorrecte(nomChamp);
125
		return renvoyerValeurCorrecte(nomChamp);
123
	}
126
	}
124
 
127
 
125
}
128
}