Subversion Repositories eFlore/Applications.coel

Rev

Rev 61 | Rev 65 | 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
	}
59
 
61 jpm 60
	/**
61
	 * Retourne l'identifiant de l'utilisateur identifié ou un identifiant de session.
62
	 * @return String identifiant
63
	 */
64
	public String getIdentifiant() {
64 jpm 65
		return get("identifiant");
61 jpm 66
	}
67
 
68
	/**
64 jpm 69
	 * Retourne le login de l'utilisateur
70
	 * @return String login
71
	 */
72
	public String getLogin() {
73
		return get("login");
74
	}
75
 
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
	/**
61 jpm 85
	 * Retourne vrai si utilisateur est identifié.
86
	 * @return boolean
87
	 */
88
	public boolean isIdentifie() {
64 jpm 89
		return get("identifie");
61 jpm 90
	}
91
 
92
 
93
}