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