971 |
aurelien |
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 |
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.http.client.URL;
|
|
|
13 |
import com.google.gwt.user.client.Window;
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
* DAO d'accès à la liaison entre mots clés et observations
|
|
|
17 |
*
|
|
|
18 |
* @author aurelien
|
|
|
19 |
*
|
|
|
20 |
*/
|
|
|
21 |
public class LiaisonMotsClesImageAsynchroneDAO {
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Le modele associé au DAO
|
|
|
25 |
*/
|
|
|
26 |
private ImageModele iModele = null;
|
|
|
27 |
|
|
|
28 |
public LiaisonMotsClesImageAsynchroneDAO(ImageModele img) {
|
|
|
29 |
iModele = img;
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Setteur pour le modèle
|
|
|
34 |
*
|
|
|
35 |
* @param img
|
|
|
36 |
* le modèle à associer
|
|
|
37 |
*/
|
|
|
38 |
public void setiModele(ImageModele img) {
|
|
|
39 |
iModele = img;
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
* Envoie requete au serveur pour modifier une observations
|
|
|
44 |
*
|
|
|
45 |
* @param motcle
|
|
|
46 |
* le mots clés à ajouter avec son parent et son identifiant
|
|
|
47 |
*/
|
|
|
48 |
public void modifier(final Rafraichissable r, String utilisateur, String idImg, String idMC) {
|
|
|
49 |
|
|
|
50 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST,Configuration.getServiceBaseUrl()+ "/InventoryKeyWordImageLink/") ;
|
|
|
51 |
|
|
|
52 |
String postData = "ce_utilisateur="+utilisateur
|
|
|
53 |
+"&images="+idImg
|
|
|
54 |
+"&mots_cles="+URL.encodeComponent(""+idMC);
|
|
|
55 |
|
|
|
56 |
try {
|
|
|
57 |
|
|
|
58 |
rb.sendRequest(postData, new RequestCallback() {
|
|
|
59 |
|
|
|
60 |
public void onError(Request request, Throwable exception) {
|
|
|
61 |
// TODO Auto-generated method stub
|
|
|
62 |
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
public void onResponseReceived(Request request,
|
|
|
66 |
Response response) {
|
|
|
67 |
|
|
|
68 |
Window.alert("Liaison aux mots clés effectuée");
|
|
|
69 |
}
|
|
|
70 |
}) ;
|
|
|
71 |
|
|
|
72 |
} catch (RequestException e) {
|
|
|
73 |
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
public void supprimer(final Rafraichissable r, String utilisateur, String idImg, String idMC) {
|
|
|
78 |
|
|
|
79 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST,Configuration.getServiceBaseUrl()+ "/InventoryKeyWordImageLink/" + utilisateur + "/" +idImg+ "/" + URL.encodeComponent(""+idMC) + "/") ;
|
|
|
80 |
|
|
|
81 |
String postData = "&action=DELETE";
|
|
|
82 |
|
|
|
83 |
try {
|
|
|
84 |
|
|
|
85 |
rb.sendRequest(postData, new RequestCallback() {
|
|
|
86 |
|
|
|
87 |
public void onError(Request request, Throwable exception) {
|
|
|
88 |
// TODO Auto-generated method stub
|
|
|
89 |
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
public void onResponseReceived(Request request,
|
|
|
93 |
Response response) {
|
|
|
94 |
|
|
|
95 |
Window.alert("Liaison aux mots clés supprimée");
|
|
|
96 |
}
|
|
|
97 |
}) ;
|
|
|
98 |
|
|
|
99 |
} catch (RequestException e) {
|
|
|
100 |
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
}
|
|
|
104 |
}
|