Subversion Repositories eFlore/Applications.del

Rev

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

Rev 2054 Rev 2077
1
package org.tela_botanica.del.client.modeles;
1
package org.tela_botanica.del.client.modeles;
2
 
2
 
3
import java.util.HashMap;
3
import java.util.HashMap;
4
 
4
 
5
import org.tela_botanica.del.client.cache.CacheClient;
5
import org.tela_botanica.del.client.cache.CacheClient;
6
import org.tela_botanica.del.client.i18n.I18n;
6
import org.tela_botanica.del.client.i18n.I18n;
7
 
7
 
8
import com.google.gwt.core.shared.GWT;
8
import com.google.gwt.core.shared.GWT;
9
 
9
 
10
 
10
 
11
public class Utilisateur {
11
public class Utilisateur {
12
 
12
 
13
	private String nom = "";
13
	private String nom = "";
14
	private String prenom = "";
14
	private String prenom = "";
15
	private String courriel = "";
15
	private String courriel = "";
16
	private String motDePasseHash = "";
-
 
17
	private String id = "0";
16
	private String id = "0";
18
	private String sessionId = "";
17
	private String sessionId = "";
19
	private String adminNiveau = "0";
18
	private String adminNiveau = "0";
20
	private boolean identifie = false;
19
	private boolean identifie = false;
21
	private HashMap<String, String> preferences = null;
20
	private HashMap<String, String> preferences = null;
22
	
21
	
23
	// TODO: avoir une liste d'activités avec des types différents
22
	// TODO: avoir une liste d'activités avec des types différents
24
	private ActiviteUtilisateur activiteUtilisateur = new ActiviteUtilisateur();
23
	private ActiviteUtilisateur activiteUtilisateur = new ActiviteUtilisateur();
25
		
24
 
-
 
25
	// Jeton encodé en base64 passé de manière automatique aux services dans un header
-
 
26
	private static String jeton = "";
-
 
27
 
26
	public Utilisateur(String sessionId, String id) {
28
	public Utilisateur(String sessionId, String id) {
27
		this.id = id;
29
		this.id = id;
28
		this.sessionId = sessionId;
30
		this.sessionId = sessionId;
29
	}
31
	}
30
	
32
	
31
	public Utilisateur(String sessionId, String id, String prenom, String nom, String courriel, 
-
 
32
			String motDePasseHash, String adminNiveau) {
33
	public Utilisateur(String sessionId, String id, String prenom, String nom, String courriel, String adminNiveau) {
33
		this(sessionId, id);
34
		this(sessionId, id);
34
		this.prenom = prenom;
35
		this.prenom = prenom;
35
		this.nom = nom;
36
		this.nom = nom;
36
		this.courriel = courriel;
37
		this.courriel = courriel;
37
		this.motDePasseHash = motDePasseHash;
-
 
38
		this.adminNiveau = adminNiveau;
38
		this.adminNiveau = adminNiveau;
39
		identifie = true;
39
		identifie = true;
40
	}
40
	}
41
	
-
 
42
	public String getMotDePasseHash() {
-
 
43
		return motDePasseHash;
-
 
44
	}
-
 
45
	
-
 
46
	public void setMotDePasseHash(String motDePasseHash) {
-
 
47
		this.motDePasseHash = motDePasseHash;
-
 
48
	}
-
 
49
	
41
	
50
	public String getNom() {
42
	public String getNom() {
51
		return nom;
43
		return nom;
52
	}
44
	}
53
	public void setNom(String nom) {
45
	public void setNom(String nom) {
54
		this.nom = nom;
46
		this.nom = nom;
55
	}
47
	}
56
	public String getPrenom() {
48
	public String getPrenom() {
57
		return prenom;
49
		return prenom;
58
	}
50
	}
59
	public void setPrenom(String prenom) {
51
	public void setPrenom(String prenom) {
60
		this.prenom = prenom;
52
		this.prenom = prenom;
61
	}
53
	}
62
	public String getCourriel() {
54
	public String getCourriel() {
63
		return courriel;
55
		return courriel;
64
	}
56
	}
65
	public void setCourriel(String courriel) {
57
	public void setCourriel(String courriel) {
66
		this.courriel = courriel;
58
		this.courriel = courriel;
67
	}
59
	}
68
	public String getId() {
60
	public String getId() {
69
		return id;
61
		return id;
70
	}
62
	}
71
	public void setId(String id) {
63
	public void setId(String id) {
72
		this.id = id;
64
		this.id = id;
73
	}
65
	}
74
	public boolean estIdentifie() {
66
	public boolean estIdentifie() {
75
		return identifie;
67
		return identifie;
76
	}
68
	}
77
	public void setIdentifie(boolean identifie) {
69
	public void setIdentifie(boolean identifie) {
78
		this.identifie = identifie;
70
		this.identifie = identifie;
79
	}
71
	}
80
	
72
	
81
	public String getNomPrenomFormate() {
73
	public String getNomPrenomFormate() {
82
		return identifie ? prenom+" "+nom : I18n.getVocabulary().anonyme();
74
		return identifie ? prenom+" "+nom : I18n.getVocabulary().anonyme();
83
	}
75
	}
84
	
76
	
85
	public HashMap<String, String> getPreferences() {
77
	public HashMap<String, String> getPreferences() {
86
		return preferences;
78
		return preferences;
87
	}
79
	}
88
	
80
	
89
	public void setPreferences(HashMap<String, String> preferences) {
81
	public void setPreferences(HashMap<String, String> preferences) {
90
		this.preferences = preferences;
82
		this.preferences = preferences;
91
	}
83
	}
92
	
84
	
93
	public boolean etreValidateur() {
85
	public boolean etreValidateur() {
94
		return etreAdmin() || this.adminNiveau.equals("1") ? true : false;
86
		return etreAdmin() || this.adminNiveau.equals("1") ? true : false;
95
	}
87
	}
96
	
88
	
97
	public boolean etreAdmin() {
89
	public boolean etreAdmin() {
98
		return this.adminNiveau.equals("2") ? true : false;
90
		return this.adminNiveau.equals("2") ? true : false;
99
	}
91
	}
100
	
92
	
101
	public String toString() {
93
	public String toString() {
102
		String utilisateur = id + "\n" + nom + "\n" + prenom + "\n" + courriel + "\n" + motDePasseHash + "\n" + 
94
		String utilisateur = id + "\n" + nom + "\n" + prenom + "\n" + courriel + "\n" + 
103
			sessionId + "\n" + adminNiveau + "\n";
95
			sessionId + "\n" + adminNiveau + "\n";
104
		return utilisateur;
96
		return utilisateur;
105
	}
97
	}
106
 
98
 
107
	public void setActivite(ActiviteUtilisateur activite) {
99
	public void setActivite(ActiviteUtilisateur activite) {
108
		this.activiteUtilisateur = activite;
100
		this.activiteUtilisateur = activite;
109
	}
101
	}
110
	
102
	
111
	public ActiviteUtilisateur getActivite() {
103
	public ActiviteUtilisateur getActivite() {
112
		return this.activiteUtilisateur;
104
		return this.activiteUtilisateur;
113
	}
105
	}
-
 
106
 
-
 
107
	public static String getJeton() {
-
 
108
		return jeton;
-
 
109
	}
-
 
110
 
-
 
111
	public static void setJeton(String jeton) {
-
 
112
		Utilisateur.jeton = jeton;
-
 
113
	}
114
}
114
}