Subversion Repositories eFlore/Applications.del

Rev

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

Rev 2077 Rev 2078
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 id = "0";
16
	private String id = "0";
17
	private String sessionId = "";
17
	private String sessionId = "";
18
	private String adminNiveau = "0";
18
	private String adminNiveau = "0";
19
	private boolean identifie = false;
19
	private boolean identifie = false;
20
	private HashMap<String, String> preferences = null;
20
	private HashMap<String, String> preferences = null;
21
	
21
	
22
	// 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
23
	private ActiviteUtilisateur activiteUtilisateur = new ActiviteUtilisateur();
23
	private ActiviteUtilisateur activiteUtilisateur = new ActiviteUtilisateur();
24
 
24
 
25
	// Jeton encodé en base64 passé de manière automatique aux services dans un header
25
	// Jeton encodé en base64 passé de manière automatique aux services dans un header
26
	private static String jeton = "";
26
	private static String jeton = "";
-
 
27
	// Durée de vie du jeton en secondes (sert au rafraîchissement automatique)
-
 
28
	private static int duree = 0;
27
 
29
 
28
	public Utilisateur(String sessionId, String id) {
30
	public Utilisateur(String sessionId, String id) {
29
		this.id = id;
31
		this.id = id;
30
		this.sessionId = sessionId;
32
		this.sessionId = sessionId;
31
	}
33
	}
32
	
34
	
33
	public Utilisateur(String sessionId, String id, String prenom, String nom, String courriel, String adminNiveau) {
35
	public Utilisateur(String sessionId, String id, String prenom, String nom, String courriel, String adminNiveau) {
34
		this(sessionId, id);
36
		this(sessionId, id);
35
		this.prenom = prenom;
37
		this.prenom = prenom;
36
		this.nom = nom;
38
		this.nom = nom;
37
		this.courriel = courriel;
39
		this.courriel = courriel;
38
		this.adminNiveau = adminNiveau;
40
		this.adminNiveau = adminNiveau;
39
		identifie = true;
41
		identifie = true;
40
	}
42
	}
41
	
43
	
42
	public String getNom() {
44
	public String getNom() {
43
		return nom;
45
		return nom;
44
	}
46
	}
45
	public void setNom(String nom) {
47
	public void setNom(String nom) {
46
		this.nom = nom;
48
		this.nom = nom;
47
	}
49
	}
48
	public String getPrenom() {
50
	public String getPrenom() {
49
		return prenom;
51
		return prenom;
50
	}
52
	}
51
	public void setPrenom(String prenom) {
53
	public void setPrenom(String prenom) {
52
		this.prenom = prenom;
54
		this.prenom = prenom;
53
	}
55
	}
54
	public String getCourriel() {
56
	public String getCourriel() {
55
		return courriel;
57
		return courriel;
56
	}
58
	}
57
	public void setCourriel(String courriel) {
59
	public void setCourriel(String courriel) {
58
		this.courriel = courriel;
60
		this.courriel = courriel;
59
	}
61
	}
60
	public String getId() {
62
	public String getId() {
61
		return id;
63
		return id;
62
	}
64
	}
63
	public void setId(String id) {
65
	public void setId(String id) {
64
		this.id = id;
66
		this.id = id;
65
	}
67
	}
66
	public boolean estIdentifie() {
68
	public boolean estIdentifie() {
67
		return identifie;
69
		return identifie;
68
	}
70
	}
69
	public void setIdentifie(boolean identifie) {
71
	public void setIdentifie(boolean identifie) {
70
		this.identifie = identifie;
72
		this.identifie = identifie;
71
	}
73
	}
72
	
74
	
73
	public String getNomPrenomFormate() {
75
	public String getNomPrenomFormate() {
74
		return identifie ? prenom+" "+nom : I18n.getVocabulary().anonyme();
76
		return identifie ? prenom+" "+nom : I18n.getVocabulary().anonyme();
75
	}
77
	}
76
	
78
	
77
	public HashMap<String, String> getPreferences() {
79
	public HashMap<String, String> getPreferences() {
78
		return preferences;
80
		return preferences;
79
	}
81
	}
80
	
82
	
81
	public void setPreferences(HashMap<String, String> preferences) {
83
	public void setPreferences(HashMap<String, String> preferences) {
82
		this.preferences = preferences;
84
		this.preferences = preferences;
83
	}
85
	}
84
	
86
	
85
	public boolean etreValidateur() {
87
	public boolean etreValidateur() {
86
		return etreAdmin() || this.adminNiveau.equals("1") ? true : false;
88
		return etreAdmin() || this.adminNiveau.equals("1") ? true : false;
87
	}
89
	}
88
	
90
	
89
	public boolean etreAdmin() {
91
	public boolean etreAdmin() {
90
		return this.adminNiveau.equals("2") ? true : false;
92
		return this.adminNiveau.equals("2") ? true : false;
91
	}
93
	}
92
	
94
	
93
	public String toString() {
95
	public String toString() {
94
		String utilisateur = id + "\n" + nom + "\n" + prenom + "\n" + courriel + "\n" + 
96
		String utilisateur = id + "\n" + nom + "\n" + prenom + "\n" + courriel + "\n" + 
95
			sessionId + "\n" + adminNiveau + "\n";
97
			sessionId + "\n" + adminNiveau + "\n";
96
		return utilisateur;
98
		return utilisateur;
97
	}
99
	}
98
 
100
 
99
	public void setActivite(ActiviteUtilisateur activite) {
101
	public void setActivite(ActiviteUtilisateur activite) {
100
		this.activiteUtilisateur = activite;
102
		this.activiteUtilisateur = activite;
101
	}
103
	}
102
	
104
	
103
	public ActiviteUtilisateur getActivite() {
105
	public ActiviteUtilisateur getActivite() {
104
		return this.activiteUtilisateur;
106
		return this.activiteUtilisateur;
105
	}
107
	}
106
 
108
 
107
	public static String getJeton() {
109
	public static String getJeton() {
108
		return jeton;
110
		return Utilisateur.jeton;
109
	}
111
	}
110
 
112
 
111
	public static void setJeton(String jeton) {
113
	public static void setJeton(String jeton) {
112
		Utilisateur.jeton = jeton;
114
		Utilisateur.jeton = jeton;
113
	}
115
	}
-
 
116
 
-
 
117
	public static int getDureeJeton() {
-
 
118
		return Utilisateur.duree;
-
 
119
	}
-
 
120
 
-
 
121
	public static void setDureeJeton(int duree) {
-
 
122
		Utilisateur.duree = duree;
-
 
123
	}
114
}
124
}