| Line 6... |
Line 6... |
| 6 |
import org.tela_botanica.client.RegistreId;
|
6 |
import org.tela_botanica.client.RegistreId;
|
| 7 |
import org.tela_botanica.client.http.JsonRestRequestBuilder;
|
7 |
import org.tela_botanica.client.http.JsonRestRequestBuilder;
|
| 8 |
import org.tela_botanica.client.http.JsonRestRequestCallback;
|
8 |
import org.tela_botanica.client.http.JsonRestRequestCallback;
|
| 9 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
9 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
| 10 |
import org.tela_botanica.client.modeles.Information;
|
10 |
import org.tela_botanica.client.modeles.Information;
|
| 11 |
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe;
|
- |
|
| 12 |
import org.tela_botanica.client.synchronisation.Reponse;
|
11 |
import org.tela_botanica.client.synchronisation.Reponse;
|
| 13 |
import org.tela_botanica.client.util.Debug;
|
12 |
import org.tela_botanica.client.util.Log;
|
| 14 |
import org.tela_botanica.client.util.UtilDAO;
|
13 |
import org.tela_botanica.client.util.UtilDAO;
|
| Line 15... |
Line 14... |
| 15 |
|
14 |
|
| 16 |
import com.extjs.gxt.ui.client.Registry;
|
- |
|
| 17 |
import com.extjs.gxt.ui.client.widget.Window;
|
- |
|
| 18 |
import com.google.gwt.core.client.GWT;
|
15 |
import com.extjs.gxt.ui.client.Registry;
|
| 19 |
import com.google.gwt.http.client.URL;
|
16 |
import com.google.gwt.http.client.URL;
|
| 20 |
import com.google.gwt.json.client.JSONArray;
|
17 |
import com.google.gwt.json.client.JSONArray;
|
| 21 |
import com.google.gwt.json.client.JSONObject;
|
18 |
import com.google.gwt.json.client.JSONObject;
|
| Line 27... |
Line 24... |
| 27 |
|
24 |
|
| 28 |
private String utilisateurId = null;
|
25 |
private String utilisateurId = null;
|
| Line 29... |
Line 26... |
| 29 |
private Rafraichissable vueARafraichir = null;
|
26 |
private Rafraichissable vueARafraichir = null;
|
| 30 |
|
27 |
|
| 31 |
public PublicationAPersonneAsyncDao(Rafraichissable vueARafraichirCourrante) {
|
28 |
public PublicationAPersonneAsyncDao(Rafraichissable vueARafraichirCourrante) {
|
| 32 |
if (Mediateur.DEBUG) System.out.println("|| PublicationAPersonneAsyncDao > vueARafraichir = "+vueARafraichirCourrante.getClass().toString());
|
29 |
Log.trace("|| PublicationAPersonneAsyncDao > vueARafraichir = "+vueARafraichirCourrante.getClass().toString());
|
| 33 |
vueARafraichir = vueARafraichirCourrante;
|
30 |
vueARafraichir = vueARafraichirCourrante;
|
| Line 34... |
Line 31... |
| 34 |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
|
31 |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
|
| Line 44... |
Line 41... |
| 44 |
restrictions.put("limit", String.valueOf(nbElements));
|
41 |
restrictions.put("limit", String.valueOf(nbElements));
|
| 45 |
}
|
42 |
}
|
| Line 46... |
Line 43... |
| 46 |
|
43 |
|
| Line 47... |
Line -... |
| 47 |
restrictions.put("orderby", "cpuap_ordre");
|
- |
|
| 48 |
|
- |
|
| 49 |
/** GESTION DE LA REQUETE dans le cas d'une liste paginée progressive **/
|
44 |
restrictions.put("orderby", "cpuap_ordre");
|
| 50 |
if (paginationProgressive) {
|
45 |
|
| 51 |
|
46 |
|
| Line 52... |
Line -... |
| 52 |
/** DEFINITION DU TUPLE DE DEPART **/
|
- |
|
| 53 |
restrictions.put("start", String.valueOf(start));
|
47 |
if (paginationProgressive) {// GESTION DE LA REQUETE dans le cas d'une liste paginée progressive
|
| Line 54... |
Line -... |
| 54 |
|
- |
|
| 55 |
/** CONSTRUCTION DE LA REQUETE **/
|
48 |
restrictions.put("start", String.valueOf(start));// DEFINITION DU TUPLE DE DEPART
|
| 56 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions);
|
- |
|
| 57 |
|
49 |
|
| 58 |
/** ENVOI DE LA REQUETE **/
|
50 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions);
|
| 59 |
rb.envoyerRequete(null, new JsonRestRequestCallback()
|
- |
|
| 60 |
{
|
51 |
|
| 61 |
/** RECEPTION DE LA REPONSE **/
|
52 |
rb.envoyerRequete(null, new JsonRestRequestCallback() {
|
| 62 |
public void surReponse(JSONValue responseValue)
|
- |
|
| 63 |
{
|
53 |
/** RECEPTION DE LA REPONSE **/
|
| 64 |
/** Dans le cas d'une liste paginée, vueARafraichir est un objet Proxy.
|
54 |
public void surReponse(JSONValue responseValue) {
|
| 65 |
* On retourne l'objet JSON au proxy afin que ce soit lui qui le traite **/
|
55 |
/** Dans le cas d'une liste paginée, vueARafraichir est un objet Proxy.
|
| 66 |
|
56 |
* On retourne l'objet JSON au proxy afin que ce soit lui qui le traite **/
|
| 67 |
if (seqId != null) {
|
- |
|
| 68 |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAPersonneAsyncDao > Liste paginée, retour au sequenceur");
|
57 |
if (seqId != null) {
|
| 69 |
Reponse reponseRequete = new Reponse(responseValue, seqId);
|
58 |
Log.trace("<-- PublicationAPersonneAsyncDao > Liste paginée, retour au sequenceur");
|
| 70 |
vueARafraichir.rafraichir(reponseRequete);
|
59 |
Reponse reponseRequete = new Reponse(responseValue, seqId);
|
| 71 |
}
|
60 |
vueARafraichir.rafraichir(reponseRequete);
|
| 72 |
else {
|
61 |
} else {
|
| 73 |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAPersonneAsyncDao > Liste paginée, retour à "+vueARafraichir.getClass().toString());
|
62 |
Log.trace("<-- PublicationAPersonneAsyncDao > Liste paginée, retour à "+vueARafraichir.getClass().toString());
|
| 74 |
vueARafraichir.rafraichir(responseValue);
|
- |
|
| 75 |
}
|
63 |
vueARafraichir.rafraichir(responseValue);
|
| 76 |
}
|
- |
|
| 77 |
});
|
- |
|
| 78 |
}
|
- |
|
| 79 |
/** GESTION DE LA REQUETE dans le cas d'une liste NON paginée progressive **/
|
64 |
}
|
| 80 |
else {
|
65 |
}
|
| 81 |
|
66 |
});
|
| 82 |
/** DEFINITION DU TUPLE DE DEPART **/
|
- |
|
| 83 |
restrictions.put("start", String.valueOf(start*nbElements));
|
67 |
} else { // GESTION DE LA REQUETE dans le cas d'une liste NON paginée progressive
|
| 84 |
|
68 |
restrictions.put("start", String.valueOf(start*nbElements));
|
| 85 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions);
|
69 |
|
| 86 |
|
- |
|
| 87 |
rb.envoyerRequete(null, new JsonRestRequestCallback() {
|
70 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions);
|
| 88 |
@Override
|
- |
|
| 89 |
public void surReponse(JSONValue responseValue) {
|
71 |
rb.envoyerRequete(null, new JsonRestRequestCallback() {
|
| 90 |
|
72 |
@Override
|
| 91 |
if (responseValue != null) {
|
73 |
public void surReponse(JSONValue responseValue) {
|
| 92 |
|
74 |
if (responseValue != null) {
|
| 93 |
JSONObject responseObject = responseValue.isObject();
|
- |
|
| 94 |
if (responseObject != null) {
|
75 |
JSONObject responseObject = responseValue.isObject();
|
| Line 95... |
Line 76... |
| 95 |
// Si la réponse est un tableau, alors c'est une liste de collections qui a été retournée
|
76 |
if (responseObject != null) {
|
| 96 |
if (responseObject.get("publicationsAPersonne").isArray() != null) {
|
77 |
// Si la réponse est un tableau, alors c'est une liste de collections qui a été retournée
|
| Line 97... |
Line 78... |
| 97 |
|
78 |
if (responseObject.get("publicationsAPersonne").isArray() != null) {
|
| 98 |
final JSONArray reponse = responseObject.get("publicationsAPersonne").isArray();
|
79 |
final JSONArray reponse = responseObject.get("publicationsAPersonne").isArray();
|
| 99 |
|
80 |
|
| 100 |
// Transformation du tableau JSON réponse en ListeInstitution
|
81 |
// Transformation du tableau JSON réponse en ListeInstitution
|
| 101 |
PublicationAPersonneListe publicationsAPersonneListe = new PublicationAPersonneListe(reponse);
|
82 |
PublicationAPersonneListe publicationsAPersonneListe = new PublicationAPersonneListe(reponse);
|
| 102 |
|
- |
|
| 103 |
// et on met à jour le demandeur des données
|
83 |
|
| 104 |
if (seqId != null) {
|
84 |
// et on met à jour le demandeur des données
|
| 105 |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAPersonneAsyncDao > Liste non paginée, retour au sequenceur");
|
85 |
if (seqId != null) {
|
| 106 |
Reponse reponseRequete = new Reponse(publicationsAPersonneListe, seqId);
|
86 |
Log.trace("<-- PublicationAPersonneAsyncDao > Liste non paginée, retour au sequenceur");
|
| 107 |
vueARafraichir.rafraichir(reponseRequete);
|
- |
|
| 108 |
}
|
87 |
Reponse reponseRequete = new Reponse(publicationsAPersonneListe, seqId);
|
| 109 |
else {
|
- |
|
| - |
|
88 |
vueARafraichir.rafraichir(reponseRequete);
|
| 110 |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAPersonneAsyncDao > Liste non paginée, retour au sequenceur");
|
89 |
} else {
|
| 111 |
vueARafraichir.rafraichir(publicationsAPersonneListe);
|
90 |
Log.trace("<-- PublicationAPersonneAsyncDao > Liste non paginée, retour au sequenceur");
|
| 112 |
}
|
91 |
vueARafraichir.rafraichir(publicationsAPersonneListe);
|
| 113 |
// Si la réponse est un objet, alors c'est une unique collection qui a été retournée
|
92 |
}
|
| 114 |
} else if (responseObject.get("publicationsAPersonne").isObject() != null) {
|
93 |
} else if (responseObject.get("publicationsAPersonne").isObject() != null) {
|
| Line 122... |
Line 101... |
| 122 |
vueARafraichir.rafraichir(reponseRequete);
|
101 |
vueARafraichir.rafraichir(reponseRequete);
|
| 123 |
} else {
|
102 |
} else {
|
| 124 |
vueARafraichir.rafraichir(publicationAPersonne);
|
103 |
vueARafraichir.rafraichir(publicationAPersonne);
|
| 125 |
}
|
104 |
}
|
| 126 |
} else {
|
105 |
} else {
|
| 127 |
GWT.log("La réponse n'est pas un objet ou un tableau JSON et vaut : "+responseValue.toString(), null);
|
106 |
Log.warn("La réponse n'est pas un objet ou un tableau JSON et vaut : "+responseValue.toString());
|
| 128 |
}
|
107 |
}
|
| 129 |
}
|
108 |
}
|
| 130 |
} else {
|
109 |
} else {
|
| 131 |
// Dans le cas, où nous demandons toutes les publication et qu'il n'y en a pas, nous retournons un objet vide
|
110 |
// Dans le cas, où nous demandons toutes les publication et qu'il n'y en a pas, nous retournons un objet vide
|
| 132 |
PublicationAPersonneListe publicationAPersonneListe = new PublicationAPersonneListe(0);
|
111 |
PublicationAPersonneListe publicationAPersonneListe = new PublicationAPersonneListe(0);
|
| Line 186... |
Line 165... |
| 186 |
if (responseValue.isString() != null) {
|
165 |
if (responseValue.isString() != null) {
|
| 187 |
Information info = new Information("suppression_publication_a_personne");
|
166 |
Information info = new Information("suppression_publication_a_personne");
|
| 188 |
info.setMessage(responseValue.isString().stringValue());
|
167 |
info.setMessage(responseValue.isString().stringValue());
|
| 189 |
vueARafraichir.rafraichir(info);
|
168 |
vueARafraichir.rafraichir(info);
|
| 190 |
} else {
|
169 |
} else {
|
| 191 |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null);
|
170 |
Log.warn(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.");
|
| 192 |
}
|
171 |
}
|
| 193 |
}
|
172 |
}
|
| 194 |
});
|
173 |
});
|
| 195 |
}
|
174 |
}
|