Subversion Repositories eFlore/Applications.coel

Rev

Rev 64 | Rev 66 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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