Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 772 Rev 897
Line 14... Line 14...
14
import com.google.gwt.http.client.RequestCallback;
14
import com.google.gwt.http.client.RequestCallback;
15
import com.google.gwt.http.client.RequestException;
15
import com.google.gwt.http.client.RequestException;
16
import com.google.gwt.http.client.Response;
16
import com.google.gwt.http.client.Response;
17
import com.google.gwt.json.client.JSONArray;
17
import com.google.gwt.json.client.JSONArray;
18
import com.google.gwt.json.client.JSONBoolean;
18
import com.google.gwt.json.client.JSONBoolean;
-
 
19
import com.google.gwt.json.client.JSONObject;
19
import com.google.gwt.json.client.JSONParser;
20
import com.google.gwt.json.client.JSONParser;
20
import com.google.gwt.json.client.JSONString;
21
import com.google.gwt.json.client.JSONString;
21
import com.google.gwt.json.client.JSONValue;
22
import com.google.gwt.json.client.JSONValue;
-
 
23
import com.google.gwt.user.client.Window;
Line 22... Line 24...
22
 
24
 
23
/**
25
/**
24
 * Modele DAO, specifique, permettant la validation, l'acces aux donnees distantes et la présentation des donnees en retour
26
 * Modele DAO, specifique, permettant la validation, l'acces aux donnees distantes et la présentation des donnees en retour
25
 * 
27
 * 
Line 48... Line 50...
48
			@Override
50
			@Override
49
			public void surReponse(JSONValue responseValue) {
51
			public void surReponse(JSONValue responseValue) {
50
				if (responseValue.isArray() != null) {
52
				if (responseValue.isArray() != null) {
51
					final JSONArray reponse = responseValue.isArray();
53
					final JSONArray reponse = responseValue.isArray();
52
					// Identifiant utilisateur ou identifiant de session si non identifié
54
					// Identifiant utilisateur ou identifiant de session si non identifié
53
					String login = ((JSONString) reponse.get(0)).stringValue();
55
					String login = ((JSONString) reponse.get(2)).stringValue();
54
					// Drapeau leve si utilisateur deja identifié
56
					// Drapeau leve si utilisateur deja identifié
55
					boolean identifie = ((JSONBoolean) reponse.get(1)).booleanValue();
57
					boolean identifie = ((JSONBoolean) reponse.get(3)).booleanValue();
56
					utilisateur.setIdentification(identifie);
58
					utilisateur.setIdentification(identifie);
57
					utilisateur.setLogin(login);
59
					utilisateur.setLogin(login);
58
					vueARafraichir.rafraichir(utilisateur);
60
					vueARafraichir.rafraichir(utilisateur);
59
				}
61
				}
60
			}
62
			}
Line 73... Line 75...
73
			@Override
75
			@Override
74
			public void surReponse(JSONValue responseValue) {
76
			public void surReponse(JSONValue responseValue) {
75
				if (responseValue.isArray() != null) {
77
				if (responseValue.isArray() != null) {
76
					final JSONArray reponse = responseValue.isArray();
78
					final JSONArray reponse = responseValue.isArray();
77
					// Identifiant utilisateur ou identifiant de session si non identifié
79
					// Identifiant utilisateur ou identifiant de session si non identifié
78
					String id = ((JSONString) reponse.get(0)).stringValue();
80
					String id = ((JSONString) reponse.get(2)).stringValue();
79
					// Drapeau levé si l'utilisateur est déjà identifié
81
					// Drapeau levé si l'utilisateur est déjà identifié
80
					boolean identifie = ((JSONBoolean) reponse.get(1)).booleanValue();
82
					boolean identifie = ((JSONBoolean) reponse.get(3)).booleanValue();
Line 81... Line 83...
81
					
83
					
82
					// Nous réinitialisons l'utilisateur
84
					// Nous réinitialisons l'utilisateur
Line 83... Line 85...
83
					utilisateur = new Utilisateur(id, identifie);
85
					utilisateur = new Utilisateur(id, identifie);
Line 100... Line 102...
100
		rb.envoyerRequete(null, new JsonRestRequestCallback() {
102
		rb.envoyerRequete(null, new JsonRestRequestCallback() {
101
			@Override
103
			@Override
102
			public void surReponse(JSONValue responseValue) {
104
			public void surReponse(JSONValue responseValue) {
103
				if (responseValue.isArray() != null) {
105
				if (responseValue.isArray() != null) {
104
					final JSONArray reponse = responseValue.isArray();
106
					final JSONArray reponse = responseValue.isArray();
-
 
107
					
-
 
108
					//Ajout des informations de l'annuaire
-
 
109
					if (reponse.get(0).isObject() != null)	{
-
 
110
						utilisateur.setInfosAnnuaire(reponse.get(0).isObject());
-
 
111
					}
-
 
112
					
-
 
113
					//Ajout des informations licence
-
 
114
					if (reponse.get(1).isString() != null)	{
-
 
115
						utilisateur.setLicence(reponse.get(1).isString().stringValue());
-
 
116
					} else {
-
 
117
						utilisateur.setLicence("");						
-
 
118
					}
-
 
119
					
105
					if (reponse.size() > 0) {
120
					if (reponse.size() > 0) {
106
						// Identifiant de l'utilisateur ou identifiant de session si non identifié
121
						// Identifiant de l'utilisateur ou identifiant de session si non identifié
107
						utilisateur.setId(((JSONString) reponse.get(0)).stringValue());
122
						utilisateur.setId(((JSONString) reponse.get(2)).stringValue());
Line 108... Line 123...
108
					
123
					
109
						// Drapeau levé si l'utilisateur est déjà identifié
124
						// Drapeau levé si l'utilisateur est déjà identifié
110
						GWT.log(reponse.toString(), null);
125
						GWT.log(reponse.toString(), null);
Line 111... Line 126...
111
						utilisateur.setIdentification(((JSONBoolean) reponse.get(1)).booleanValue());
126
						utilisateur.setIdentification(((JSONBoolean) reponse.get(3)).booleanValue());
112
					
127
					
113
						// Plus de deux valeurs, l'utilisateur est identifié nous récupérons des données supplémentaires
128
						// Plus de deux valeurs, l'utilisateur est identifié nous récupérons des données supplémentaires
114
						if (reponse.size() > 2) {
129
						if (reponse.size() > 4) {
115
							// Nom complet de l'utilisateur
130
							// Nom complet de l'utilisateur
116
							if (reponse.get(2).isString() != null) {
131
							if (reponse.get(4).isString() != null) {
117
								utilisateur.setNomComplet(((JSONString) reponse.get(2)).stringValue());
132
								utilisateur.setNomComplet(((JSONString) reponse.get(4)).stringValue());
118
							}
133
							}
119
							// Prénom de l'utilisateur
134
							// Prénom de l'utilisateur
120
							if (reponse.get(3).isString() != null) {
135
							if (reponse.get(5).isString() != null) {
-
 
136
								utilisateur.setPrenom(((JSONString) reponse.get(5)).stringValue());
121
								utilisateur.setPrenom(((JSONString) reponse.get(3)).stringValue());
137
							}
122
							}
138
							
123
							// Nom de l'utilisateur
139
							// Nom de l'utilisateur
124
							if (reponse.get(4).isString() != null) {
140
							if (reponse.get(6).isString() != null) {
125
								utilisateur.setNom(((JSONString) reponse.get(4)).stringValue());
-
 
-
 
141
								utilisateur.setNom(((JSONString) reponse.get(6)).stringValue());
126
							}
142
							}						
127
							GWT.log(utilisateur.toString(), null);
143
							
128
						}
144
						}
129
						vueARafraichir.rafraichir(utilisateur);
145
						vueARafraichir.rafraichir(utilisateur);
130
					}
146
					}
131
				}
147
				}
132
			}
148
			}
133
		});
-
 
134
	}
149
		});
-
 
150
	}
-
 
151
	
-
 
152
	/*
-
 
153
	 * */
-
 
154
	public void accepterLicence()	{
-
 
155
		String[] parametres = {utilisateur.getLogin(), utilisateur.getMotDePasse(), utilisateur.getId()};
-
 
156
		
-
 
157
		final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres);
-
 
158
		rb.envoyerRequete(null, new JsonRestRequestCallback() {
-
 
159
			@Override
-
 
160
			public void surReponse(JSONValue responseValue) {
-
 
161
				if (responseValue.isArray() != null) {
-
 
162
					final JSONArray reponse = responseValue.isArray();
-
 
163
					if (reponse.get(1).isString() != null)	{
-
 
164
						String licenceAcceptee = reponse.get(1).isString().stringValue();
-
 
165
						Information info = new Information("maj_licence");
-
 
166
						info.setDonnee(0, licenceAcceptee);
-
 
167
						vueARafraichir.rafraichir(info);
-
 
168
					}
-
 
169
				}
-
 
170
			}
-
 
171
		});
-
 
172
	}
135
}
173
}