Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 230 Rev 238
Line 3... Line 3...
3
import org.tela_botanica.client.Modele;
3
import org.tela_botanica.client.Modele;
4
import org.tela_botanica.client.RegistreId;
4
import org.tela_botanica.client.RegistreId;
5
import org.tela_botanica.client.interfaces.Rafraichissable;
5
import org.tela_botanica.client.interfaces.Rafraichissable;
Line 6... Line 6...
6
 
6
 
-
 
7
import com.extjs.gxt.ui.client.Registry;
7
import com.extjs.gxt.ui.client.Registry;
8
import com.google.gwt.core.client.GWT;
8
import com.google.gwt.http.client.Request;
9
import com.google.gwt.http.client.Request;
9
import com.google.gwt.http.client.RequestBuilder;
10
import com.google.gwt.http.client.RequestBuilder;
10
import com.google.gwt.http.client.RequestCallback;
11
import com.google.gwt.http.client.RequestCallback;
11
import com.google.gwt.http.client.RequestException;
12
import com.google.gwt.http.client.RequestException;
12
import com.google.gwt.http.client.Response;
13
import com.google.gwt.http.client.Response;
-
 
14
import com.google.gwt.json.client.JSONArray;
13
import com.google.gwt.json.client.JSONArray;
15
import com.google.gwt.json.client.JSONObject;
14
import com.google.gwt.json.client.JSONParser;
16
import com.google.gwt.json.client.JSONParser;
15
import com.google.gwt.json.client.JSONValue;
17
import com.google.gwt.json.client.JSONValue;
Line 16... Line 18...
16
import com.google.gwt.user.client.Window;
18
import com.google.gwt.user.client.Window;
Line 42... Line 44...
42
					Boolean defaut = true;
44
					Boolean defaut = true;
43
					if (response.getText().length() != 0 && response.getText() != null) {
45
					if (response.getText().length() != 0 && response.getText() != null) {
44
						final JSONValue responseValue = JSONParser.parse(response.getText());
46
						final JSONValue responseValue = JSONParser.parse(response.getText());
Line 45... Line 47...
45
						
47
						
46
						// Si la requête est un succès, reception d'un tableau
48
						// Si la requête est un succès, reception d'un tableau
47
						if (responseValue.isArray() != null) {
49
						if (responseValue.isObject() != null) {
48
							final JSONArray reponse = responseValue.isArray();
50
							final JSONObject reponse = responseValue.isObject();
49
							// Transformation du tableau JSON réponse en ListeInstitution
51
							// Transformation du tableau JSON réponse en ListeInstitution
50
							publications = new PublicationListe(reponse);
52
							publications = new PublicationListe(reponse);
51
							// et on met à jour le demandeur des données
53
							// et on met à jour le demandeur des données
52
							rafraichissement.rafraichir(publications);
54
							rafraichissement.rafraichir(publications);
Line 83... Line 85...
83
					if (response.getText().length() != 0 && response.getText() != null) {
85
					if (response.getText().length() != 0 && response.getText() != null) {
84
						final JSONValue responseValue = JSONParser.parse(response.getText());
86
						final JSONValue responseValue = JSONParser.parse(response.getText());
Line 85... Line 87...
85
						
87
						
86
						// Si la requête est un succès, reception d'un tableau
88
						// Si la requête est un succès, reception d'un tableau
87
						if (responseValue.isArray() != null) {
89
						if (responseValue.isArray() != null) {
88
							final JSONArray reponse = responseValue.isArray();
90
							final JSONObject reponse = responseValue.isObject();
89
							// Transformation du tableau JSON réponse en ListeInstitution
91
							// Transformation du tableau JSON réponse en ListeInstitution
90
							publications = new PublicationListe(reponse);
92
							publications = new PublicationListe(reponse);
91
							// et on met à jour le demandeur des données
93
							// et on met à jour le demandeur des données
92
							rafraichissement.rafraichir(publications);
94
							rafraichissement.rafraichir(publications);
Line 122... Line 124...
122
					Boolean defaut = true;
124
					Boolean defaut = true;
123
					if (response.getText().length() != 0 && response.getText() != null) {
125
					if (response.getText().length() != 0 && response.getText() != null) {
124
						final JSONValue responseValue = JSONParser.parse(response.getText());
126
						final JSONValue responseValue = JSONParser.parse(response.getText());
Line 125... Line 127...
125
						
127
						
-
 
128
						// Si la requête est un succès, reception d'un tableau
-
 
129
						if (responseValue.isObject() != null) {
-
 
130
							final JSONObject reponse = responseValue.isObject();
-
 
131
							// Transformation du tableau JSON réponse en ListeInstitution
-
 
132
							publications = new PublicationListe(reponse);
-
 
133
							// et on met à jour le demandeur des données
-
 
134
							rafraichissement.rafraichir(publications);
-
 
135
							// Tout c'est bien déroulé, on courcircuite l'affichage par défaut
-
 
136
							defaut = false;
-
 
137
						}
-
 
138
					}
-
 
139
					if (defaut == true) {
-
 
140
						publications = new PublicationListe(0);
-
 
141
						rafraichissement.rafraichir(publications);
-
 
142
					}
-
 
143
				}
-
 
144
			});
-
 
145
		} catch (RequestException e) {
-
 
146
			e.printStackTrace();
-
 
147
		}
-
 
148
		
-
 
149
	}
-
 
150
 
-
 
151
	public void supprimerPublication(Modele modele, String utilisateurId,
-
 
152
			String idPubs) {
-
 
153
		String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
-
 
154
		RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url+"CoelPublicationListe/"+utilisateurId+"/"+idPubs);
-
 
155
 
-
 
156
		try {
-
 
157
			rb.sendRequest("action=DELETE", new RequestCallback() {
-
 
158
 
-
 
159
				public void onError(Request request, Throwable exception) {
-
 
160
					
-
 
161
					GWT.log("Erreur dans la requête de suppression", exception);
-
 
162
 
-
 
163
				}
-
 
164
 
-
 
165
				public void onResponseReceived(Request request, Response response) {
-
 
166
					Boolean defaut = true;
-
 
167
					if (response.getText().length() != 0 && response.getText() != null) {
-
 
168
						final JSONValue responseValue = JSONParser.parse(response.getText());
-
 
169
						
126
						// Si la requête est un succès, reception d'un tableau
170
						// Si la requête est un succès, reception d'un tableau
127
						if (responseValue.isArray() != null) {
171
						if (responseValue.isObject() != null) {
128
							final JSONArray reponse = responseValue.isArray();
172
							final JSONObject reponse = responseValue.isObject();
129
							// Transformation du tableau JSON réponse en ListeInstitution
173
							// Transformation du tableau JSON réponse en ListeInstitution
130
							publications = new PublicationListe(reponse);
174
							publications = new PublicationListe(reponse);
131
							// et on met à jour le demandeur des données
175
							// et on met à jour le demandeur des données
132
							rafraichissement.rafraichir(publications);
176
							rafraichissement.rafraichir(publications);