Subversion Repositories eFlore/Applications.cel

Rev

Rev 235 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
140 aurelien 1
package org.tela_botanica.client.modeles;
2
 
3
import org.tela_botanica.client.Util;
4
import org.tela_botanica.client.interfaces.Rafraichissable;
5
import org.tela_botanica.client.observation.ObservationModele;
6
 
7
import com.google.gwt.http.client.Request;
8
import com.google.gwt.http.client.RequestBuilder;
9
import com.google.gwt.http.client.RequestCallback;
10
import com.google.gwt.http.client.RequestException;
11
import com.google.gwt.http.client.Response;
12
import com.google.gwt.json.client.JSONArray;
13
import com.google.gwt.json.client.JSONParser;
14
import com.google.gwt.json.client.JSONString;
15
import com.google.gwt.json.client.JSONValue;
16
import com.google.gwt.user.client.Window;
17
 
18
public class NomRetenuAsynchroneDao {
19
 
20
	private ObservationModele oModele = null ;
21
 
22
	public NomRetenuAsynchroneDao(ObservationModele observationModele) {
23
		oModele = observationModele ;
24
	}
25
 
26
	public void obtenirNomRetenu(final Rafraichissable r, final String anum) {
27
 
28
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
29
				Configuration.getServiceBaseUrl()
30
				+ "/name/"+anum);
31
 
32
		try {
33
			rb.sendRequest(null, new RequestCallback() {
34
 
35
				public void onError(Request request, Throwable exception) {
36
					// TODO Auto-generated method stub
37
				}
38
 
39
				public void onResponseReceived(Request request,
40
						Response response) {
41
 
42
					JSONValue jsonValue = JSONParser.parse(response.getText());
43
                    JSONArray jsonArray;
44
 
45
                    if ((jsonArray = jsonValue.isArray()) != null) {
46
 
47
                            String aname = Util.toCelString(((JSONString) jsonArray.get(0)).toString());
48
 
49
                            // Nom
50
                            if (aname.compareTo("null")!=0) {
51
 
52
                            	String[] numNom = {aname, anum } ;
53
                            	r.rafraichir(numNom, false);
54
                            }
55
 
56
                    }
57
                }
58
			});
59
 
60
		} catch (RequestException e) {
61
			// TODO Auto-generated catch block
62
			e.printStackTrace();
63
		}
64
 
65
 
66
	}
67
 
68
}