| Line 4... |
Line 4... |
| 4 |
import org.tela_botanica.client.RegistreId;
|
4 |
import org.tela_botanica.client.RegistreId;
|
| 5 |
import org.tela_botanica.client.http.JsonRestRequestBuilder;
|
5 |
import org.tela_botanica.client.http.JsonRestRequestBuilder;
|
| 6 |
import org.tela_botanica.client.http.JsonRestRequestCallback;
|
6 |
import org.tela_botanica.client.http.JsonRestRequestCallback;
|
| 7 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
7 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
| 8 |
import org.tela_botanica.client.modeles.Information;
|
8 |
import org.tela_botanica.client.modeles.Information;
|
| - |
|
9 |
import org.tela_botanica.client.synchronisation.Reponse;
|
| 9 |
import org.tela_botanica.client.util.Debug;
|
10 |
import org.tela_botanica.client.util.Debug;
|
| 10 |
import org.tela_botanica.client.util.UtilDAO;
|
11 |
import org.tela_botanica.client.util.UtilDAO;
|
| Line 11... |
Line 12... |
| 11 |
|
12 |
|
| - |
|
13 |
import com.extjs.gxt.ui.client.Registry;
|
| 12 |
import com.extjs.gxt.ui.client.Registry;
|
14 |
import com.extjs.gxt.ui.client.widget.Window;
|
| 13 |
import com.google.gwt.core.client.GWT;
|
15 |
import com.google.gwt.core.client.GWT;
|
| 14 |
import com.google.gwt.http.client.URL;
|
16 |
import com.google.gwt.http.client.URL;
|
| 15 |
import com.google.gwt.json.client.JSONArray;
|
17 |
import com.google.gwt.json.client.JSONArray;
|
| 16 |
import com.google.gwt.json.client.JSONObject;
|
18 |
import com.google.gwt.json.client.JSONObject;
|
| Line 26... |
Line 28... |
| 26 |
public PublicationAPersonneAsyncDao(Rafraichissable vueARafraichirCourrante) {
|
28 |
public PublicationAPersonneAsyncDao(Rafraichissable vueARafraichirCourrante) {
|
| 27 |
vueARafraichir = vueARafraichirCourrante;
|
29 |
vueARafraichir = vueARafraichirCourrante;
|
| 28 |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
|
30 |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
|
| 29 |
}
|
31 |
}
|
| Line 30... |
Line 32... |
| 30 |
|
32 |
|
| 31 |
public void selectionner(String publicationId, String personnesId, String roleId) {
|
33 |
public void selectionner(String publicationId, String personnesId, String roleId, final Integer seqId) {
|
| 32 |
String[] parametres = {publicationId, personnesId, roleId};
|
34 |
String[] parametres = {publicationId, personnesId, roleId};
|
| 33 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres);
|
35 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres);
|
| 34 |
rb.envoyerRequete(null, new JsonRestRequestCallback() {
|
36 |
rb.envoyerRequete(null, new JsonRestRequestCallback() {
|
| 35 |
@Override
|
37 |
@Override
|
| Line 39... |
Line 41... |
| 39 |
if (responseValue.isObject() != null) {
|
41 |
if (responseValue.isObject() != null) {
|
| 40 |
final JSONObject reponse = responseValue.isObject();
|
42 |
final JSONObject reponse = responseValue.isObject();
|
| 41 |
// Transformation du tableau JSON réponse en ListeInstitution
|
43 |
// Transformation du tableau JSON réponse en ListeInstitution
|
| 42 |
PublicationAPersonne publicationAPersonne = new PublicationAPersonne(reponse);
|
44 |
PublicationAPersonne publicationAPersonne = new PublicationAPersonne(reponse);
|
| 43 |
// et on met à jour le demandeur des données
|
45 |
// et on met à jour le demandeur des données
|
| - |
|
46 |
if (seqId!=null) {
|
| - |
|
47 |
Reponse reponseRequete = new Reponse(publicationAPersonne, seqId);
|
| - |
|
48 |
vueARafraichir.rafraichir(reponseRequete);
|
| - |
|
49 |
} else {
|
| 44 |
vueARafraichir.rafraichir(publicationAPersonne);
|
50 |
vueARafraichir.rafraichir(publicationAPersonne);
|
| - |
|
51 |
}
|
| 45 |
} else if (responseValue.isArray() != null) {
|
52 |
} else if (responseValue.isArray() != null) {
|
| 46 |
final JSONArray reponse = responseValue.isArray();
|
53 |
final JSONArray reponse = responseValue.isArray();
|
| 47 |
PublicationAPersonneListe publicationsAPersonneListe = new PublicationAPersonneListe(reponse);
|
54 |
PublicationAPersonneListe publicationsAPersonneListe = new PublicationAPersonneListe(reponse);
|
| - |
|
55 |
if (seqId!=null) {
|
| - |
|
56 |
Reponse reponseRequete = new Reponse(publicationsAPersonneListe, seqId);
|
| - |
|
57 |
vueARafraichir.rafraichir(reponseRequete);
|
| - |
|
58 |
} else {
|
| 48 |
vueARafraichir.rafraichir(publicationsAPersonneListe);
|
59 |
vueARafraichir.rafraichir(publicationsAPersonneListe);
|
| - |
|
60 |
}
|
| 49 |
} else {
|
61 |
} else {
|
| 50 |
GWT.log("La réponse n'est pas un objet ou un tableau JSON et vaut : "+responseValue.toString(), null);
|
62 |
GWT.log("La réponse n'est pas un objet ou un tableau JSON et vaut : "+responseValue.toString(), null);
|
| 51 |
}
|
63 |
}
|
| 52 |
} else {
|
64 |
} else {
|
| 53 |
// Dans le cas, où nous demandons toutes les publication et qu'il n'y en a pas, nous retournons un objet vide
|
65 |
// Dans le cas, où nous demandons toutes les publication et qu'il n'y en a pas, nous retournons un objet vide
|
| 54 |
PublicationAPersonneListe publicationAPersonneListe = new PublicationAPersonneListe(0);
|
66 |
PublicationAPersonneListe publicationAPersonneListe = new PublicationAPersonneListe(0);
|
| - |
|
67 |
if (seqId!=null) {
|
| - |
|
68 |
Reponse reponseRequete = new Reponse(publicationAPersonneListe, seqId);
|
| - |
|
69 |
vueARafraichir.rafraichir(reponseRequete);
|
| - |
|
70 |
} else {
|
| 55 |
vueARafraichir.rafraichir(publicationAPersonneListe);
|
71 |
vueARafraichir.rafraichir(publicationAPersonneListe);
|
| - |
|
72 |
}
|
| - |
|
73 |
|
| 56 |
}
|
74 |
}
|
| 57 |
}
|
75 |
}
|
| 58 |
});
|
76 |
});
|
| 59 |
}
|
77 |
}
|
| Line 60... |
Line 78... |
| 60 |
|
78 |
|
| 61 |
public void ajouter(String publicationId, String personnesId, String roleId) {
|
79 |
public void ajouter(String publicationId, String personnesId, String roleId, final Integer seqId) {
|
| 62 |
String postDonneesEncodees = "cpuap_id_publication="+URL.encodeComponent(publicationId)
|
80 |
String postDonneesEncodees = "cpuap_id_publication="+URL.encodeComponent(publicationId)
|
| 63 |
+"&cpuap_id_auteur="+URL.encodeComponent(personnesId)
|
81 |
+"&cpuap_id_auteur="+URL.encodeComponent(personnesId)
|
| 64 |
+"&cpuap_id_role="+URL.encodeComponent(roleId)
|
82 |
+"&cpuap_id_role="+URL.encodeComponent(roleId)
|
| 65 |
+"&cmhl_ce_modifier_par="+utilisateurId;
|
83 |
+"&cmhl_ce_modifier_par="+utilisateurId;
|
| 66 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM);
|
84 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM);
|
| 67 |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() {
|
85 |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() {
|
| 68 |
@Override
|
86 |
@Override
|
| - |
|
87 |
public void surReponse(JSONValue reponseValeur) {
|
| 69 |
public void surReponse(JSONValue reponseValeur) {
|
88 |
System.out.println("j'ai une réponse et c'est super");
|
| 70 |
traiterReponse(reponseValeur, "ajout_publication_a_personne");
|
89 |
traiterReponse(reponseValeur, "ajout_publication_a_personne", seqId);
|
| 71 |
}
|
90 |
}
|
| 72 |
});
|
91 |
});
|
| Line 73... |
Line 92... |
| 73 |
}
|
92 |
}
|
| 74 |
|
93 |
|
| Line 75... |
Line 94... |
| 75 |
public void modifier(String publicationId, String personnesId, String roleId) {
|
94 |
public void modifier(String publicationId, String personnesId, String roleId, final Integer seqId) {
|
| Line 76... |
Line 95... |
| 76 |
String[] parametres = {publicationId, personnesId, roleId};
|
95 |
String[] parametres = {publicationId, personnesId, roleId};
|
| 77 |
|
96 |
|
| Line 78... |
Line 97... |
| 78 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres);
|
97 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres);
|
| 79 |
|
98 |
|
| 80 |
String postDonneesEncodees = "cpuap_id_publication="+URL.encodeComponent(publicationId)
|
99 |
String postDonneesEncodees = "cpuap_id_publication="+URL.encodeComponent(publicationId)
|
| 81 |
+"&cmhl_ce_modifier_par="+utilisateurId;
|
100 |
+"&cmhl_ce_modifier_par="+utilisateurId;
|
| 82 |
|
101 |
|
| 83 |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() {
|
102 |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() {
|
| 84 |
@Override
|
103 |
@Override
|
| Line 85... |
Line 104... |
| 85 |
public void surReponse(JSONValue reponseValeur) {
|
104 |
public void surReponse(JSONValue reponseValeur) {
|
| Line 103... |
Line 122... |
| 103 |
}
|
122 |
}
|
| 104 |
}
|
123 |
}
|
| 105 |
});
|
124 |
});
|
| 106 |
}
|
125 |
}
|
| Line 107... |
Line 126... |
| 107 |
|
126 |
|
| - |
|
127 |
private void traiterReponse(JSONValue reponseValeur, String type, Integer seqId) {
|
| - |
|
128 |
if (seqId == null)
|
| 108 |
private void traiterReponse(JSONValue reponseValeur, String type) {
|
129 |
System.out.println("NULL SEQID");
|
| 109 |
Information info = new Information(type);
|
130 |
Information info = new Information(type);
|
| 110 |
// Si la requête est un succès, réception d'une chaîne
|
131 |
// Si la requête est un succès, réception d'une chaîne
|
| 111 |
if (reponseValeur.isBoolean() != null) {
|
132 |
if (reponseValeur.isBoolean() != null) {
|
| 112 |
info.setDonnee(reponseValeur.isBoolean().booleanValue());
|
133 |
info.setDonnee(reponseValeur.isBoolean().booleanValue());
|
| 113 |
} else if (reponseValeur.isString() != null) {
|
134 |
} else if (reponseValeur.isString() != null) {
|
| 114 |
info.setDonnee(reponseValeur.isString().stringValue());
|
135 |
info.setDonnee(reponseValeur.isString().stringValue());
|
| 115 |
} else {
|
136 |
} else {
|
| 116 |
info.setDeboguage("La réponse n'est pas une chaine JSON.");
|
137 |
info.setDeboguage("La réponse n'est pas une chaine JSON.");
|
| Line -... |
Line 138... |
| - |
|
138 |
}
|
| - |
|
139 |
|
| - |
|
140 |
if (seqId != null) {
|
| - |
|
141 |
System.out.println("retour pap");
|
| - |
|
142 |
Reponse retourRequete = new Reponse(info, seqId);
|
| 117 |
}
|
143 |
vueARafraichir.rafraichir(retourRequete);
|
| - |
|
144 |
} else {
|
| - |
|
145 |
vueARafraichir.rafraichir(info);
|
| 118 |
|
146 |
}
|
| 119 |
vueARafraichir.rafraichir(info);
|
147 |
|