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