Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 676 Rev 937
Line 13... Line 13...
13
import com.google.gwt.http.client.RequestCallback;
13
import com.google.gwt.http.client.RequestCallback;
14
import com.google.gwt.http.client.RequestException;
14
import com.google.gwt.http.client.RequestException;
15
import com.google.gwt.http.client.Response;
15
import com.google.gwt.http.client.Response;
16
import com.google.gwt.json.client.JSONArray;
16
import com.google.gwt.json.client.JSONArray;
17
import com.google.gwt.json.client.JSONBoolean;
17
import com.google.gwt.json.client.JSONBoolean;
-
 
18
import com.google.gwt.json.client.JSONObject;
18
import com.google.gwt.json.client.JSONParser;
19
import com.google.gwt.json.client.JSONParser;
19
import com.google.gwt.json.client.JSONString;
20
import com.google.gwt.json.client.JSONString;
20
import com.google.gwt.json.client.JSONValue;
21
import com.google.gwt.json.client.JSONValue;
21
import com.google.gwt.user.client.Window;
22
import com.google.gwt.user.client.Window;
Line 22... Line 23...
22
 
23
 
Line 23... Line -...
23
public class UtilisateurAsynchroneDAO {
-
 
24
 
-
 
25
	
-
 
26
	
24
public class UtilisateurAsynchroneDAO {
27
	
25
 
28
	/**
26
	/**
29
	 * Le modèle associé au DAO
27
	 * Le modèle associé au DAO
Line 30... Line 28...
30
	 */
28
	 */
31
	private CarnetEnLigneModele carnetEnLigneModele = null ;
29
	private CarnetEnLigneModele carnetEnLigneModele = null ;
32
	
30
	
Line 33... Line 31...
33
	/**
31
	/**
34
	 * Constructeur 
-
 
35
	 */
32
	 * Constructeur 
36
	
-
 
37
	public UtilisateurAsynchroneDAO(CarnetEnLigneModele carnetEnLigneModele) {
33
	 */
38
		
-
 
39
		this.carnetEnLigneModele=carnetEnLigneModele;
-
 
40
		
-
 
41
	}
-
 
42
	
34
	
43
	
35
	public UtilisateurAsynchroneDAO(CarnetEnLigneModele carnetEnLigneModele) {		
44
	
36
		this.carnetEnLigneModele=carnetEnLigneModele;
45
	
37
	}
46
	/**
38
	/**
Line 69... Line 61...
69
					if(response.getText().isEmpty()) {
61
					if(response.getText().isEmpty()) {
70
						Window.alert("Impossible de contacter le serveur, veuillez vérifier la configuration du cel ou contacter un administrateur");
62
						Window.alert("Impossible de contacter le serveur, veuillez vérifier la configuration du cel ou contacter un administrateur");
71
					} else {
63
					} else {
Line 72... Line 64...
72
										
64
										
73
						JSONValue jsonValue = JSONParser.parse(response.getText());
65
						JSONValue jsonValue = JSONParser.parse(response.getText());
Line 74... Line 66...
74
						JSONArray jsonArray;
66
						JSONObject objetJsonUtilisateur;
75
						
-
 
76
						if ((jsonArray = jsonValue.isArray()) != null) {
-
 
77
							String identifiant = ((JSONString) jsonArray.get(0))
-
 
78
									.stringValue(); // Identifiant utilisateur ou
-
 
79
													// identifiant de session si non
-
 
80
													// identifie
-
 
81
							boolean identifie = ((JSONBoolean) jsonArray.get(1))
-
 
82
									.booleanValue(); // Drapeau leve si utilisateur
-
 
83
														// deja identifie
-
 
84
							boolean isAdmin = ((JSONBoolean) jsonArray.get(2))
-
 
85
							.booleanValue(); // Drapeau leve si utilisateur
-
 
86
												// est admin
-
 
87
							
-
 
88
							boolean licenceAcceptee = ((JSONBoolean) jsonArray.get(3))
-
 
89
							.booleanValue(); // Drapeau leve si utilisateur
-
 
90
												// a accepte licence
-
 
91
							
-
 
Line -... Line 67...
-
 
67
						
92
							Utilisateur utilisateur = new Utilisateur(identifiant, identifie, isAdmin);
68
						if ((objetJsonUtilisateur = jsonValue.isObject()) != null) {
93
							utilisateur.setLicenceAcceptee(licenceAcceptee);
69
							
94
							
70
							Utilisateur utilisateur = Utilisateur.InitialiserInstance(objetJsonUtilisateur);
95
							r.rafraichir(utilisateur,true);
71
							r.rafraichir(utilisateur,true);
96
						}
72
						}
97
					}
-
 
98
				}			
73
					}
99
			}) ;
74
				}			
100
			
-
 
101
			
75
			}) ;
102
		} catch (RequestException e) {
76
					
103
			
77
		} catch (RequestException e) {
Line 122... Line 96...
122
 
96
 
123
				public void onResponseReceived(Request request,
97
				public void onResponseReceived(Request request,
Line 124... Line 98...
124
						Response response) {
98
						Response response) {
125
					
99
					
126
					JSONValue jsonValue = JSONParser.parse(response.getText());
-
 
127
					JSONArray jsonArray;
-
 
128
					if ((jsonArray = jsonValue.isArray()) != null) {
-
 
129
						String identifiant = ((JSONString) jsonArray.get(0))
-
 
130
						.stringValue(); // Identifiant utilisateur ou
-
 
131
										// identifiant de session si non
-
 
132
										// identifie
-
 
133
						boolean identifie = ((JSONBoolean) jsonArray.get(1))
-
 
134
						.booleanValue(); // Drapeau leve si utilisateur
-
 
135
						
100
					JSONValue jsonValue = JSONParser.parse(response.getText());
136
											// deja identifie
101
					JSONObject objetJsonUtilisateur;
137
						
-
 
Line -... Line 102...
-
 
102
					
138
						Utilisateur utilisateur = new Utilisateur(identifiant, identifie);
103
					if ((objetJsonUtilisateur = jsonValue.isObject()) != null) {
139
						utilisateur.setLicenceAcceptee(false);
104
						
140
						
105
						Utilisateur utilisateur = Utilisateur.InitialiserInstance(objetJsonUtilisateur);
141
					r.rafraichir(utilisateur,true);
-
 
142
					}				
106
						r.rafraichir(utilisateur,true);
Line 143... Line 107...
143
				}			
107
					}		
144
				
-
 
145
			}) ;
108
				}			
146
			
109
			}) ;
147
		} catch (RequestException e) {
110
			
Line 148... Line -...
148
			
-
 
149
			
-
 
150
		}
111
		} catch (RequestException e) {
Line 151... Line 112...
151
	}
112
					
Line 152... Line 113...
152
 
113
		}
Line 167... Line 128...
167
 
128
 
168
				public void onResponseReceived(Request request,
129
				public void onResponseReceived(Request request,
Line 169... Line 130...
169
						Response response) {
130
						Response response) {
170
					
131
					
Line 171... Line 132...
171
					JSONValue jsonValue = JSONParser.parse(response.getText());
132
					JSONValue jsonValue = JSONParser.parse(response.getText());
172
					JSONArray jsonArray;
-
 
173
					
-
 
174
					if ((jsonArray = jsonValue.isArray()) != null) {
-
 
175
						String identifiant = ((JSONString) jsonArray.get(0))
-
 
176
						.stringValue(); // Identifiant utilisateur ou
-
 
177
										// identifiant de session si non
-
 
178
										// identifie
-
 
179
						boolean identifie = ((JSONBoolean) jsonArray.get(1))
-
 
180
						.booleanValue(); // Drapeau leve si utilisateur
-
 
181
											// deja identifie
-
 
182
						boolean isAdmin = ((JSONBoolean) jsonArray.get(2))
-
 
183
						.booleanValue(); // Drapeau leve si utilisateur
-
 
184
											// est admin
-
 
185
						
-
 
Line 186... Line 133...
186
						boolean licenceAcceptee = ((JSONBoolean) jsonArray.get(3))
133
					JSONObject objetJsonUtilisateur;
187
						.booleanValue(); // Drapeau leve si utilisateur
-
 
188
											// a accepte licence
-
 
189
						
-
 
190
						Utilisateur utilisateur = new Utilisateur(identifiant, identifie, isAdmin);
134
					
191
						utilisateur.setLicenceAcceptee(licenceAcceptee);
135
					if ((objetJsonUtilisateur = jsonValue.isObject()) != null) {
192
						
136
						
Line 193... Line 137...
193
 
137
						Utilisateur utilisateur = Utilisateur.InitialiserInstance(objetJsonUtilisateur);
Line 220... Line 164...
220
				}
164
				}
Line 221... Line 165...
221
 
165
 
222
				public void onResponseReceived(Request request,
166
				public void onResponseReceived(Request request,
Line 223... Line 167...
223
						Response response) {
167
						Response response) {
224
			
-
 
225
				}
-
 
226
				
168
			
Line 227... Line 169...
227
				
169
				}	
Line 228... Line 170...
228
			}) ;
170
			}) ;
229
			
171
			
230
		} catch (RequestException e) {
-
 
231
			
172
		} catch (RequestException e) {
232
			e.printStackTrace() ;
-
 
233
		}
-
 
234
		
-
 
235
	}
-
 
236
 
173
			
237
 
174
			e.printStackTrace() ;