Subversion Repositories eFlore/Applications.del

Rev

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

Rev 2050 Rev 2054
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 = "";
16
	private String motDePasseHash = "";
17
	private String id = "0";
17
	private String id = "0";
18
	private String sessionId = "";
18
	private String sessionId = "";
19
	private String adminNiveau = "0";
19
	private String adminNiveau = "0";
20
	private boolean identifie = false;
20
	private boolean identifie = false;
21
	private HashMap<String, String> preferences = null;
21
	private HashMap<String, String> preferences = null;
22
	
22
	
23
	private String nbEvenements = "0";
23
	// TODO: avoir une liste d'activités avec des types différents
24
	private String dateDerniereConsultationEvenements = null;
24
	private ActiviteUtilisateur activiteUtilisateur = new ActiviteUtilisateur();
25
	
25
		
26
	public Utilisateur(String sessionId, String id) {
26
	public Utilisateur(String sessionId, String id) {
27
		this.id = id;
27
		this.id = id;
28
		this.sessionId = sessionId;
28
		this.sessionId = sessionId;
29
	}
29
	}
30
	
30
	
31
	public Utilisateur(String sessionId, String id, String prenom, String nom, String courriel, 
31
	public Utilisateur(String sessionId, String id, String prenom, String nom, String courriel, 
32
			String motDePasseHash, String adminNiveau) {
32
			String motDePasseHash, String adminNiveau) {
33
		this(sessionId, id);
33
		this(sessionId, id);
34
		this.prenom = prenom;
34
		this.prenom = prenom;
35
		this.nom = nom;
35
		this.nom = nom;
36
		this.courriel = courriel;
36
		this.courriel = courriel;
37
		this.motDePasseHash = motDePasseHash;
37
		this.motDePasseHash = motDePasseHash;
38
		this.adminNiveau = adminNiveau;
38
		this.adminNiveau = adminNiveau;
39
		identifie = true;
39
		identifie = true;
40
	}
40
	}
41
	
41
	
42
	public String getMotDePasseHash() {
42
	public String getMotDePasseHash() {
43
		return motDePasseHash;
43
		return motDePasseHash;
44
	}
44
	}
45
	
45
	
46
	public void setMotDePasseHash(String motDePasseHash) {
46
	public void setMotDePasseHash(String motDePasseHash) {
47
		this.motDePasseHash = motDePasseHash;
47
		this.motDePasseHash = motDePasseHash;
48
	}
48
	}
49
	
49
	
50
	public String getNom() {
50
	public String getNom() {
51
		return nom;
51
		return nom;
52
	}
52
	}
53
	public void setNom(String nom) {
53
	public void setNom(String nom) {
54
		this.nom = nom;
54
		this.nom = nom;
55
	}
55
	}
56
	public String getPrenom() {
56
	public String getPrenom() {
57
		return prenom;
57
		return prenom;
58
	}
58
	}
59
	public void setPrenom(String prenom) {
59
	public void setPrenom(String prenom) {
60
		this.prenom = prenom;
60
		this.prenom = prenom;
61
	}
61
	}
62
	public String getCourriel() {
62
	public String getCourriel() {
63
		return courriel;
63
		return courriel;
64
	}
64
	}
65
	public void setCourriel(String courriel) {
65
	public void setCourriel(String courriel) {
66
		this.courriel = courriel;
66
		this.courriel = courriel;
67
	}
67
	}
68
	public String getId() {
68
	public String getId() {
69
		return id;
69
		return id;
70
	}
70
	}
71
	public void setId(String id) {
71
	public void setId(String id) {
72
		this.id = id;
72
		this.id = id;
73
	}
73
	}
74
	public boolean estIdentifie() {
74
	public boolean estIdentifie() {
75
		return identifie;
75
		return identifie;
76
	}
76
	}
77
	public void setIdentifie(boolean identifie) {
77
	public void setIdentifie(boolean identifie) {
78
		this.identifie = identifie;
78
		this.identifie = identifie;
79
	}
79
	}
80
	
80
	
81
	public String getNomPrenomFormate() {
81
	public String getNomPrenomFormate() {
82
		return identifie ? prenom+" "+nom : I18n.getVocabulary().anonyme();
82
		return identifie ? prenom+" "+nom : I18n.getVocabulary().anonyme();
83
	}
83
	}
84
	
84
	
85
	public HashMap<String, String> getPreferences() {
85
	public HashMap<String, String> getPreferences() {
86
		return preferences;
86
		return preferences;
87
	}
87
	}
88
	
88
	
89
	public void setPreferences(HashMap<String, String> preferences) {
89
	public void setPreferences(HashMap<String, String> preferences) {
90
		this.preferences = preferences;
90
		this.preferences = preferences;
91
	}
91
	}
92
	
92
	
93
	public boolean etreValidateur() {
93
	public boolean etreValidateur() {
94
		return etreAdmin() || this.adminNiveau.equals("1") ? true : false;
94
		return etreAdmin() || this.adminNiveau.equals("1") ? true : false;
95
	}
95
	}
96
	
96
	
97
	public boolean etreAdmin() {
97
	public boolean etreAdmin() {
98
		return this.adminNiveau.equals("2") ? true : false;
98
		return this.adminNiveau.equals("2") ? true : false;
99
	}
99
	}
100
	
100
	
101
	public String toString() {
101
	public String toString() {
102
		String utilisateur = id + "\n" + nom + "\n" + prenom + "\n" + courriel + "\n" + motDePasseHash + "\n" + 
102
		String utilisateur = id + "\n" + nom + "\n" + prenom + "\n" + courriel + "\n" + motDePasseHash + "\n" + 
103
			sessionId + "\n" + adminNiveau + "\n";
103
			sessionId + "\n" + adminNiveau + "\n";
104
		return utilisateur;
104
		return utilisateur;
105
	}
105
	}
106
	
106
 
107
	public String getNbEvenements() {
-
 
108
		return nbEvenements;
-
 
109
	}
-
 
110
	
-
 
111
	public int getNbEvenementsInt() {
-
 
112
		int nbEvents = 0;
-
 
113
		try {
-
 
114
			nbEvents = Integer.parseInt(nbEvenements);
-
 
115
		} catch (Exception e) {
-
 
116
			nbEvents = 0;
-
 
117
		} 
-
 
118
		return nbEvents;
-
 
119
	}
-
 
120
	
-
 
121
	public void setNbEvenements(String nbEvenements) {
107
	public void setActivite(ActiviteUtilisateur activite) {
122
		this.nbEvenements = nbEvenements;
108
		this.activiteUtilisateur = activite;
123
	}
-
 
124
	
-
 
125
	public String getDateDerniereConsultationEvenements() {
-
 
126
		return dateDerniereConsultationEvenements;
-
 
127
	}
109
	}
128
	
110
	
129
	public void setDateDerniereConsultationEvenements(String dateDerniereConsultationEvenements) {
111
	public ActiviteUtilisateur getActivite() {
130
		this.dateDerniereConsultationEvenements = dateDerniereConsultationEvenements;
112
		return this.activiteUtilisateur;
131
	}
113
	}
132
}
114
}