Subversion Repositories eFlore/Applications.coel

Rev

Rev 277 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
147 gduche 1
package org.tela_botanica.client.modeles;
2
 
751 jpm 3
import org.tela_botanica.client.http.JsonRestRequestBuilder;
4
import org.tela_botanica.client.http.JsonRestRequestCallback;
147 gduche 5
import org.tela_botanica.client.interfaces.Rafraichissable;
6
import org.tela_botanica.client.util.UtilDAO;
7
 
8
import com.google.gwt.json.client.JSONArray;
9
import com.google.gwt.json.client.JSONValue;
10
 
268 jp_milcent 11
public class ProjetAsyncDao {
12
	private static final String SERVICE_NOM = "CoelProjet";
147 gduche 13
 
751 jpm 14
	private Rafraichissable vueARafraichir = null;
147 gduche 15
 
751 jpm 16
	public ProjetAsyncDao(Rafraichissable vueARafraichirCourrante) {
17
		vueARafraichir = vueARafraichirCourrante;
147 gduche 18
	}
19
 
268 jp_milcent 20
	public void selectionner()	{
751 jpm 21
		final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM);
22
		rb.envoyerRequete(null, new JsonRestRequestCallback() {
23
			@Override
24
			public void surReponse(JSONValue responseValue) {
25
				ProjetListe projets;
26
				// Si la requête est un succès, reception d'un tableau
27
				if (responseValue.isArray() != null)	{
28
					final JSONArray reponse = responseValue.isArray();
29
					// Transformation du tableau JSON réponse en ListePersonnes
30
					projets = new ProjetListe(reponse);
31
				} else {
32
					projets = new ProjetListe();
147 gduche 33
				}
751 jpm 34
				// Mise à jour du demandeur des données
35
				vueARafraichir.rafraichir(projets);
36
			}
37
		});
147 gduche 38
	}
151 jpm 39
}