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