Subversion Repositories eFlore/Applications.coel

Rev

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

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