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);
|
62 |
jpm |
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 |
}
|
5 |
aperonnet |
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 |
// et on envoie ça au serveur
|
|
|
70 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, iModele
|
|
|
71 |
.getConfig().getServiceBaseUrl()
|
|
|
72 |
+ "/inventoryImageLink/");
|
62 |
jpm |
73 |
|
|
|
74 |
if(Window.confirm("Lier les images "+idsImages+" aux observations "+idsObs+" ?"))
|
|
|
75 |
{
|
|
|
76 |
try {
|
|
|
77 |
rb.sendRequest(postData, new RequestCallback() {
|
|
|
78 |
|
|
|
79 |
public void onError(Request request, Throwable exception) {
|
|
|
80 |
// TODO Auto-generated method stub
|
|
|
81 |
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
public void onResponseReceived(Request request,
|
|
|
85 |
Response response) {
|
|
|
86 |
|
|
|
87 |
// quand la requête est éxecutée on le signale au modèle
|
|
|
88 |
// poru qu'il mette à jour les données
|
|
|
89 |
// et en notifie le médiateur
|
|
|
90 |
// iModele.requeteTerminee();
|
|
|
91 |
|
|
|
92 |
}
|
|
|
93 |
});
|
|
|
94 |
|
|
|
95 |
} catch (RequestException e) {
|
|
|
96 |
// TODO Auto-generated catch block
|
|
|
97 |
e.printStackTrace();
|
|
|
98 |
}
|
5 |
aperonnet |
99 |
}
|
|
|
100 |
}
|
|
|
101 |
}
|