Subversion Repositories eFlore/Applications.coel

Rev

Rev 766 | Rev 896 | 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.util.Iterator;
4
import java.util.Set;
5
 
6
import com.google.gwt.json.client.JSONObject;
7
 
69 jpm 8
public class Utilisateur extends aDonnee {
61 jpm 9
 
748 jpm 10
	private static final long serialVersionUID = -4016615552202089985L;
11
 
12
	public static final String PREFIXE = "cp";
13
 
766 jpm 14
	public Utilisateur() {
769 jpm 15
		initialiserUtilisateur(null, false);
766 jpm 16
	}
769 jpm 17
 
132 jpm 18
	public Utilisateur(String id, boolean identifie) {
769 jpm 19
		initialiserUtilisateur(id, identifie);
61 jpm 20
	}
769 jpm 21
 
61 jpm 22
	public Utilisateur(JSONObject utilisateur) {
23
		// l'objet JSON est une table de hachage
24
		Set<String> im = utilisateur.keySet();
25
 
26
		// Parcourt pour chaque clé
27
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
28
			// Si elle est associée à une valeur, nous l'ajoutons
29
			String cle = it.next();
30
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
748 jpm 31
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
32
			// Valeur est vide par défaut
33
			String valeur = "";
61 jpm 34
			if (utilisateur.get(cle).isString() != null) {
748 jpm 35
				valeur = utilisateur.get(cle).isString().stringValue();
61 jpm 36
				this.set(cleObjet, valeur);
37
			} else {
38
				this.set(cleObjet, valeur);
39
			}
40
		}
41
	}
42
 
748 jpm 43
	@Override
44
	protected String getPrefixe() {
45
		return PREFIXE;
46
	}
132 jpm 47
 
769 jpm 48
	private void initialiserUtilisateur(String id, boolean etreIdentifie) {
49
		setId(id);
50
		setIdentification(etreIdentifie);
61 jpm 51
	}
52
 
132 jpm 53
 
61 jpm 54
	/**
119 jpm 55
	 * Retourne l'id de l'utilisateur ou l'identifiant de session si la personne n'est pas identifiée.
56
	 * @return String id de l'utilisateur
57
	 */
58
	public String getId() {
769 jpm 59
		return renvoyerValeurCorrecte("id_personne");
119 jpm 60
	}
769 jpm 61
	public void setId(String id) {
62
		set("id_personne", id);
63
	}
64
 
132 jpm 65
	/**
66
	 * Retourne le nom complet et formaté de l'utilisateur
67
	 * @return String nom complet
68
	 */
69
	public String getNomComplet() {
769 jpm 70
		return renvoyerValeurCorrecte("fmt_nom_complet");
132 jpm 71
	}
769 jpm 72
	public void setNomComplet(String nom_complet) {
73
		set("fmt_nom_complet", nom_complet);
74
	}
132 jpm 75
 
76
	/**
77
	 * Retourne le prénom de l'utilisateur
78
	 * @return String prénom
79
	 */
80
	public String getPrenom() {
769 jpm 81
		return renvoyerValeurCorrecte("prenom");
132 jpm 82
	}
769 jpm 83
	public void setPrenom(String prenom) {
84
		set("prenom", prenom);
85
	}
119 jpm 86
 
87
	/**
132 jpm 88
	 * Retourne le nom de l'utilisateur
89
	 * @return String nom
90
	 */
91
	public String getNom() {
769 jpm 92
		return renvoyerValeurCorrecte("nom");
132 jpm 93
	}
769 jpm 94
	public void setNom(String nom) {
95
		set("nom", nom);
96
	}
132 jpm 97
 
98
	/**
66 jpm 99
	 * Retourne le login de l'utilisateur ou l'identifiant de session si la personne n'est pas identifiée.
64 jpm 100
	 * @return String login
101
	 */
102
	public String getLogin() {
769 jpm 103
		return renvoyerValeurCorrecte("login");
64 jpm 104
	}
769 jpm 105
	public void setLogin(String l) {
106
		set("login", l);
107
	}
108
 
64 jpm 109
	/**
110
	 * Retourne le mot de passe de l'utilisateur
111
	 * @return String mot de passe
112
	 */
113
	public String getMotDePasse() {
769 jpm 114
		return renvoyerValeurCorrecte("mot_de_passe");
64 jpm 115
	}
769 jpm 116
	public void setMotDePasse(String mdp) {
117
		set("mot_de_passe", mdp);
118
	}
119
 
64 jpm 120
 
121
	/**
61 jpm 122
	 * Retourne vrai si utilisateur est identifié.
123
	 * @return boolean
124
	 */
125
	public boolean isIdentifie() {
64 jpm 126
		return get("identifie");
61 jpm 127
	}
769 jpm 128
	public void setIdentification(Boolean bool) {
129
		set("identifie", bool);
130
	}
132 jpm 131
 
769 jpm 132
}