Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 64 Rev 65
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 Utilisateur extends BaseModelData implements Serializable {
10
public class Utilisateur extends BaseModelData implements Serializable {
11
 
11
 
12
	/**
12
	/**
13
	 * Variable pour la sérialisation de l'objet.
13
	 * Variable pour la sérialisation de l'objet.
14
	 */
14
	 */
15
	private static final long serialVersionUID = 3;
15
	private static final long serialVersionUID = 3;
16
	
16
	
17
	public Utilisateur(String identifiant, boolean identifie) {
17
	public Utilisateur(String identifiant, boolean identifie) {
18
		set("identifiant", identifiant);
18
		set("identifiant", identifiant);
19
		set("identifie", identifie);
19
		set("identifie", identifie);
20
	}
20
	}
21
 
21
 
22
	/**
22
	/**
23
	 * Constructeur avec un objet JSON
23
	 * Constructeur avec un objet JSON
24
	 * 
24
	 * 
25
	 * @param image
25
	 * @param image
26
	 */
26
	 */
27
	public Utilisateur(JSONObject utilisateur) {
27
	public Utilisateur(JSONObject utilisateur) {
28
		// l'objet JSON est une table de hachage
28
		// l'objet JSON est une table de hachage
29
		Set<String> im = utilisateur.keySet();
29
		Set<String> im = utilisateur.keySet();
30
 
30
 
31
		// Parcourt pour chaque clé
31
		// Parcourt pour chaque clé
32
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
32
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
33
			// Si elle est associée à une valeur, nous l'ajoutons
33
			// Si elle est associée à une valeur, nous l'ajoutons
34
			String cle = it.next();
34
			String cle = it.next();
35
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
35
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
36
			String cleObjet = cle.replaceFirst("^cp_", "");
36
			String cleObjet = cle.replaceFirst("^cp_", "");
37
			if (utilisateur.get(cle).isString() != null) {
37
			if (utilisateur.get(cle).isString() != null) {
38
				String valeur = utilisateur.get(cle).isString().stringValue();
38
				String valeur = utilisateur.get(cle).isString().stringValue();
39
				this.set(cleObjet, valeur);
39
				this.set(cleObjet, valeur);
40
			} else {
40
			} else {
41
				// Sinon, nous ajoutons la clé avec une valeur vide
41
				// Sinon, nous ajoutons la clé avec une valeur vide
42
				String valeur = " ";
42
				String valeur = " ";
43
				this.set(cleObjet, valeur);
43
				this.set(cleObjet, valeur);
44
			}
44
			}
45
		}
45
		}
46
	}
46
	}
47
	
47
	
48
	public void setNom(String nom) {
48
	public void setNom(String nom) {
49
		set("nom", nom);
49
		set("nom", nom);
50
	}
50
	}
51
	
51
	
52
	public void setPrenom(String prenom) {
52
	public void setPrenom(String prenom) {
53
		set("prenom", prenom);
53
		set("prenom", prenom);
54
	}
54
	}
55
	
55
	
56
	public void setIdentifie(Boolean bool) {
56
	public void setIdentifie(Boolean bool) {
57
		set("identifie", bool);
57
		set("identifie", bool);
58
	}
58
	}
59
 
59
	
-
 
60
	public void setIdentifiant(String i) {
-
 
61
		set("identifiant", i);
-
 
62
	}
-
 
63
	
60
	/**
64
	/**
61
	 * Retourne l'identifiant de l'utilisateur identifié ou un identifiant de session.
65
	 * Retourne l'identifiant de l'utilisateur identifié ou un identifiant de session.
62
	 * @return String identifiant
66
	 * @return String identifiant
63
	 */
67
	 */
64
	public String getIdentifiant() {
68
	public String getIdentifiant() {
65
		return get("identifiant");
69
		return get("identifiant");
66
	}
70
	}
67
 
71
 
68
	/**
72
	/**
69
	 * Retourne le login de l'utilisateur
73
	 * Retourne le login de l'utilisateur
70
	 * @return String login
74
	 * @return String login
71
	 */
75
	 */
72
	public String getLogin() {
76
	public String getLogin() {
73
		return get("login");
77
		return get("login");
74
	}
78
	}
75
 
79
 
76
	/**
80
	/**
77
	 * Retourne le mot de passe de l'utilisateur
81
	 * Retourne le mot de passe de l'utilisateur
78
	 * @return String mot de passe
82
	 * @return String mot de passe
79
	 */
83
	 */
80
	public String getMotDePasse() {
84
	public String getMotDePasse() {
81
		return get("mot_de_passe");
85
		return get("mot_de_passe");
82
	}
86
	}
83
	
87
	
84
	/**
88
	/**
85
	 * Retourne vrai si utilisateur est identifié.
89
	 * Retourne vrai si utilisateur est identifié.
86
	 * @return boolean
90
	 * @return boolean
87
	 */
91
	 */
88
	public boolean isIdentifie() {
92
	public boolean isIdentifie() {
89
		return get("identifie");
93
		return get("identifie");
90
	}
94
	}
-
 
95
 
-
 
96
	public void setLogin(String l) {
-
 
97
		set("login", l);
-
 
98
	}
-
 
99
	
-
 
100
	public void setMotDePasse(String mdp) {
-
 
101
		set("mot_de_passe", mdp);
-
 
102
	}
91
	
103
	
92
	
104
	
93
}
105
}