Subversion Repositories eFlore/Applications.cel

Rev

Rev 596 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 596 Rev 937
Line 1... Line 1...
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
Line -... Line 2...
-
 
2
 
-
 
3
import com.google.gwt.json.client.JSONObject;
-
 
4
import com.google.gwt.json.client.JSONString;
2
 
5
 
Line -... Line 6...
-
 
6
public class Utilisateur {
-
 
7
 
Line 3... Line 8...
3
public class Utilisateur {
8
	private String loginUtilisateurConnecte = null;
4
 
9
	private String loginUtilisateurConsulte = null;
5
	
-
 
6
	private String identifiant=null;
-
 
7
	private String identite=null;
-
 
8
	private boolean identifie=false;
-
 
9
	private boolean isAdmin=false;
-
 
10
	private boolean licenceAcceptee=false;
-
 
11
 
-
 
12
	public Utilisateur(String identifiant, boolean identifie) {
-
 
13
		this.identifiant=identifiant;
-
 
Line -... Line 10...
-
 
10
	
-
 
11
	private String identifiantUtilisateurConnecte = null;
-
 
12
	private String identifiantUtilisateurConsulte = null;
-
 
13
	
-
 
14
	private boolean identifie = false;
-
 
15
	private boolean isAdmin = false;
14
		this.identifie=identifie;
16
	private boolean licenceAcceptee = false;
-
 
17
	
-
 
18
	private static Utilisateur thisUtilisateur = null;
15
		this.identite=identifiant;
19
	
-
 
20
	public static Utilisateur InitialiserInstance(JSONObject objetJsonUtilisateur) {
-
 
21
		thisUtilisateur = new Utilisateur(objetJsonUtilisateur);
16
	}
22
		
17
	
23
		return thisUtilisateur;
-
 
24
	}
-
 
25
	
-
 
26
	public static Utilisateur getInstance() {
-
 
27
		return thisUtilisateur;
18
	public Utilisateur(String identifiant, boolean identifie, boolean isAdmin) {
28
	}
-
 
29
	
-
 
30
	private Utilisateur(JSONObject objetJsonUtilisateur) {
-
 
31
		
-
 
32
		// login utilisateur ou vide si non identifie
-
 
33
		loginUtilisateurConnecte = ((JSONString) objetJsonUtilisateur.get("courriel")).stringValue(); 
-
 
34
		loginUtilisateurConsulte = loginUtilisateurConnecte; 
-
 
35
		
-
 
36
		// identifiant utilisateur ou bien identifiant de session si non identifie
-
 
37
		identifiantUtilisateurConnecte = ((JSONString) objetJsonUtilisateur.get("id_utilisateur")).stringValue(); 
-
 
38
		identifiantUtilisateurConsulte = identifiantUtilisateurConnecte;
-
 
39
				
-
 
40
		// Drapeau leve si utilisateur deja identifie
-
 
41
		identifie = objetJsonUtilisateur.get("connecte").isBoolean().booleanValue();
-
 
42
		
-
 
43
		// Drapeau leve si utilisateur est admin
19
		this.identifiant=identifiant;
44
		isAdmin = objetJsonUtilisateur.get("admin").isBoolean().booleanValue();
20
		this.identifie=identifie;
-
 
21
		this.isAdmin=isAdmin;
45
		
22
		this.identite=identifiant;
-
 
23
	}
-
 
24
 
-
 
25
	
-
 
26
	/**
-
 
27
	 * Retourne l'identifiant de l'utilisateur identifie ou un identifiant de session
-
 
28
	 * @return String identifiant
-
 
29
	 */
-
 
30
	
-
 
31
	public String getIdentifiant() {
46
		// Drapeau leve si utilisateur a accepte licence
32
		return identifiant;
47
		licenceAcceptee = objetJsonUtilisateur.get("licence_acceptee").isBoolean().booleanValue();
33
	}
48
	}
34
 
49
		
35
	/**
50
	/**
Line 50... Line 65...
50
	
65
	
51
	/**
66
	/**
52
	 * Met à jour l'identité utilisée (dans le cas où l'utilisateur est admin)
67
	 * Met à jour l'identité utilisée (dans le cas où l'utilisateur est admin)
53
	 * @param identite la nouvelle identité
68
	 * @param identite la nouvelle identité
54
	 */
69
	 */
55
	public void setIdentite(String identite) {
70
	public void setUtilisateurConsulte(String identifiantUtilisateurConsulte, String loginUtilisateurConsulte) {
-
 
71
		if(isAdmin()) {
56
		if(isAdmin()) {
72
			this.identifiantUtilisateurConsulte = identifiantUtilisateurConsulte;
57
			this.identite = identite;
73
			this.loginUtilisateurConsulte = loginUtilisateurConsulte;
58
		}
74
		}
-
 
75
		else {
59
		else {
76
			this.identifiantUtilisateurConsulte = identifiantUtilisateurConnecte;
60
			this.identite = identifiant ;
77
			this.loginUtilisateurConsulte = loginUtilisateurConnecte;
61
		}
78
		}
Line 62... Line 79...
62
	}
79
	}
63
	
80
	
-
 
81
	/**
-
 
82
	 * Retourne l'identifiant de l'utilisateur identifie ou un identifiant de session
-
 
83
	 * @return String identifiantUtilisateurConsulte
-
 
84
	*/	
-
 
85
	public String getIdentifiantUtilisateurConnecte() {
-
 
86
		return identifiantUtilisateurConnecte;
-
 
87
	}
-
 
88
	
-
 
89
	/**
-
 
90
	 * Retourne l'identifiant de l'utilisateur consulte
-
 
91
	 * @return String identifiantUtilisateurConsulte
-
 
92
	 */	
-
 
93
	public String getIdentifiantUtilisateurConsulte() {
-
 
94
		return identifiantUtilisateurConsulte;
-
 
95
	}
-
 
96
	
-
 
97
	/**
-
 
98
	 * Retourne le login de l'utilisateur identifie ou un identifiant de session
-
 
99
	 * @return String loginUtilisateurConnecte
64
	/**
100
	*/	
-
 
101
	public String getLoginUtilisateurConnecte() {
-
 
102
		return loginUtilisateurConnecte;
-
 
103
	}
-
 
104
	
65
	 * Renvoie l'identité en cours d'utilisation (par défaut, la même valeur que l'identifiant si
105
	/**
66
	 * l'utilisateur est admin)
106
	 * Retourne le login de l'utilisateur consulte
67
	 * @return identite
107
	 * @return String loginUtilisateurConsulte
68
	 */
108
	 */	
69
	public String getIdentite() {
109
	public String getLoginUtilisateurConsulte() {
Line 70... Line 110...
70
		return identite;
110
		return loginUtilisateurConsulte;
71
	}
111
	}
72
	
112
	
Line 73... Line 113...
73
	public void setLicenceAcceptee(boolean licenceAcceptee) {
113
	public void setLicenceAcceptee(boolean licenceAcceptee) {
74
		this.licenceAcceptee = licenceAcceptee;
114
		this.licenceAcceptee = licenceAcceptee;
75
	}
115
	}
Line -... Line 116...
-
 
116
	
-
 
117
	public boolean getLicenceAcceptee() {
-
 
118
		return licenceAcceptee;
-
 
119
	}
-
 
120
	
-
 
121
	public void setLoginUtilisateurConnecte(String loginUtilisateurConnecte) {
-
 
122
		this.loginUtilisateurConnecte = loginUtilisateurConnecte;
-
 
123
	}
76
	
124