5 |
aperonnet |
1 |
package org.tela_botanica.client.modeles;
|
|
|
2 |
|
|
|
3 |
import org.tela_botanica.client.image.ImageModele;
|
|
|
4 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
5 |
|
|
|
6 |
import com.google.gwt.http.client.Request;
|
|
|
7 |
import com.google.gwt.http.client.RequestBuilder;
|
|
|
8 |
import com.google.gwt.http.client.RequestCallback;
|
|
|
9 |
import com.google.gwt.http.client.RequestException;
|
|
|
10 |
import com.google.gwt.http.client.Response;
|
|
|
11 |
import com.google.gwt.user.client.Window;
|
|
|
12 |
|
|
|
13 |
public class LienImageAsynchroneDAO {
|
|
|
14 |
|
|
|
15 |
private ImageModele iModele = null ;
|
|
|
16 |
|
|
|
17 |
public LienImageAsynchroneDAO(ImageModele im) {
|
|
|
18 |
iModele = im;
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Setteur pour le modèle
|
|
|
23 |
*
|
|
|
24 |
* @param im
|
|
|
25 |
* le modèle à associer
|
|
|
26 |
*/
|
|
|
27 |
public void setIModele(ImageModele im) {
|
|
|
28 |
iModele = im;
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public void obtenirLiaisonsImagesObservations(Rafraichissable r,String id)
|
|
|
32 |
{
|
|
|
33 |
String paramGet = "&coi_ce_image="+id ;
|
|
|
34 |
|
|
|
35 |
// et on envoie ça au serveur
|
|
|
36 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, iModele
|
|
|
37 |
.getConfig().getServiceBaseUrl()
|
|
|
38 |
+ "/inventoryImageLink/" + iModele.getIdentifiant() + "/" + paramGet);
|
|
|
39 |
try {
|
|
|
40 |
rb.sendRequest(null, new RequestCallback() {
|
|
|
41 |
|
|
|
42 |
public void onError(Request request, Throwable exception) {
|
|
|
43 |
// TODO Auto-generated method stub
|
|
|
44 |
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public void onResponseReceived(Request request,
|
|
|
48 |
Response response) {
|
|
|
49 |
|
|
|
50 |
Window.alert(response.toString()) ;
|
|
|
51 |
|
|
|
52 |
}
|
|
|
53 |
});
|
|
|
54 |
|
|
|
55 |
} catch (RequestException e) {
|
|
|
56 |
// TODO Auto-generated catch block
|
|
|
57 |
e.printStackTrace();
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
public void lierImageBaseDeDonnees(String idsImages, String idsObs) {
|
|
|
62 |
|
|
|
63 |
String postData = "";
|
|
|
64 |
|
|
|
65 |
postData += "&coi_ce_image="+idsImages ;
|
|
|
66 |
postData += "&coi_ce_observation="+idsObs ;
|
|
|
67 |
postData += "&identifiant="+iModele.getIdentifiant() ;
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
Window.alert("data postée : "+postData) ;
|
|
|
71 |
// et on envoie ça au serveur
|
|
|
72 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, iModele
|
|
|
73 |
.getConfig().getServiceBaseUrl()
|
|
|
74 |
+ "/inventoryImageLink/");
|
|
|
75 |
try {
|
|
|
76 |
rb.sendRequest(postData, new RequestCallback() {
|
|
|
77 |
|
|
|
78 |
public void onError(Request request, Throwable exception) {
|
|
|
79 |
// TODO Auto-generated method stub
|
|
|
80 |
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public void onResponseReceived(Request request,
|
|
|
84 |
Response response) {
|
|
|
85 |
|
|
|
86 |
// quand la requête est éxecutée on le signale au modèle
|
|
|
87 |
// poru qu'il mette à jour les données
|
|
|
88 |
// et en notifie le médiateur
|
|
|
89 |
// iModele.requeteTerminee();
|
|
|
90 |
|
|
|
91 |
}
|
|
|
92 |
});
|
|
|
93 |
|
|
|
94 |
} catch (RequestException e) {
|
|
|
95 |
// TODO Auto-generated catch block
|
|
|
96 |
e.printStackTrace();
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
}
|