| 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.projet.Projet;
|
- |
|
| 12 |
import org.tela_botanica.client.modeles.projet.ProjetListe;
|
- |
|
| 13 |
import org.tela_botanica.client.modeles.structure.StructureListe;
|
- |
|
| 14 |
import org.tela_botanica.client.synchronisation.Reponse;
|
11 |
import org.tela_botanica.client.synchronisation.Reponse;
|
| 15 |
import org.tela_botanica.client.util.Debug;
|
12 |
import org.tela_botanica.client.util.Log;
|
| 16 |
import org.tela_botanica.client.util.UtilDAO;
|
13 |
import org.tela_botanica.client.util.UtilDAO;
|
| Line 17... |
Line 14... |
| 17 |
|
14 |
|
| 18 |
import com.extjs.gxt.ui.client.Registry;
|
15 |
import com.extjs.gxt.ui.client.Registry;
|
| 19 |
import com.google.gwt.core.client.GWT;
|
16 |
import com.google.gwt.core.client.GWT;
|
| Line 26... |
Line 23... |
| 26 |
|
23 |
|
| 27 |
private String utilisateurId = null;
|
24 |
private String utilisateurId = null;
|
| Line 28... |
Line 25... |
| 28 |
private Rafraichissable vueARafraichir = null;
|
25 |
private Rafraichissable vueARafraichir = null;
|
| 29 |
|
26 |
|
| 30 |
public PublicationAsyncDao(Rafraichissable vueARafraichirCourrante) {
|
27 |
public PublicationAsyncDao(Rafraichissable vueARafraichirCourrante) {
|
| 31 |
if (Mediateur.DEBUG) System.out.println("|| PublicationAsyncDao > vueARafraichir = "+vueARafraichirCourrante.getClass().toString());
|
28 |
Log.trace("|| PublicationAsyncDao > vueARafraichir = "+vueARafraichirCourrante.getClass().toString());
|
| 32 |
vueARafraichir = vueARafraichirCourrante ;
|
29 |
vueARafraichir = vueARafraichirCourrante ;
|
| Line 53... |
Line 50... |
| 53 |
|
50 |
|
| 54 |
if (nbElements != -1) {
|
51 |
if (nbElements != -1) {
|
| 55 |
restrictions.put("limit", String.valueOf(nbElements));
|
52 |
restrictions.put("limit", String.valueOf(nbElements));
|
| Line 56... |
Line -... |
| 56 |
}
|
- |
|
| 57 |
|
53 |
}
|
| 58 |
/** GESTION DE LA REQUETE dans le cas d'une liste paginée progressive **/
|
- |
|
| 59 |
if (paginationProgressive) {
|
54 |
|
| 60 |
|
55 |
if (paginationProgressive) {
|
| Line 61... |
Line -... |
| 61 |
/** DEFINITION DU TUPLE DE DEPART **/
|
- |
|
| 62 |
restrictions.put("start", String.valueOf(start));
|
56 |
// GESTION DE LA REQUETE dans le cas d'une liste paginée progressive
|
| 63 |
|
- |
|
| 64 |
/** CONSTRUCTION DE LA REQUETE **/
|
- |
|
| 65 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, param, restrictions);
|
57 |
restrictions.put("start", String.valueOf(start));
|
| 66 |
|
- |
|
| 67 |
/** ENVOI DE LA REQUETE **/
|
58 |
|
| 68 |
rb.envoyerRequete(null, new JsonRestRequestCallback()
|
59 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, param, restrictions);
|
| 69 |
{
|
- |
|
| 70 |
/** RECEPTION DE LA REPONSE **/
|
60 |
rb.envoyerRequete(null, new JsonRestRequestCallback() {
|
| 71 |
public void surReponse(JSONValue responseValue)
|
61 |
/** RECEPTION DE LA REPONSE **/
|
| 72 |
{
|
62 |
public void surReponse(JSONValue responseValue) {
|
| 73 |
/** Dans le cas d'une liste paginée, vueARafraichir est un objet Proxy.
|
63 |
/** Dans le cas d'une liste paginée, vueARafraichir est un objet Proxy.
|
| 74 |
* On retourne l'objet JSON au proxy afin que ce soit lui qui le traite **/
|
64 |
* On retourne l'objet JSON au proxy afin que ce soit lui qui le traite **/
|
| 75 |
if (seqId != null) {
|
65 |
if (seqId != null) {
|
| 76 |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAsyncDao > Liste paginée, retour au sequenceur");
|
- |
|
| 77 |
Reponse reponseRequete = new Reponse(responseValue, seqId);
|
66 |
Log.trace("<-- PublicationAsyncDao > Liste paginée, retour au sequenceur");
|
| 78 |
vueARafraichir.rafraichir(reponseRequete);
|
67 |
Reponse reponseRequete = new Reponse(responseValue, seqId);
|
| 79 |
}
|
68 |
vueARafraichir.rafraichir(reponseRequete);
|
| 80 |
else {
|
69 |
} else {
|
| 81 |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAsyncDao > Liste paginée, retour à "+vueARafraichir.getClass().toString());
|
70 |
Log.trace("<-- PublicationAsyncDao > Liste paginée, retour à "+vueARafraichir.getClass().toString());
|
| 82 |
vueARafraichir.rafraichir(responseValue);
|
71 |
vueARafraichir.rafraichir(responseValue);
|
| 83 |
}
|
72 |
}
|
| 84 |
}
|
73 |
}
|
| 85 |
});
|
- |
|
| 86 |
}
|
- |
|
| 87 |
/** GESTION DE LA REQUETE dans le cas d'une liste NON paginée progressive **/
|
- |
|
| 88 |
else {
|
74 |
});
|
| Line 89... |
Line 75... |
| 89 |
|
75 |
} else {
|
| Line 90... |
Line 76... |
| 90 |
/** DEFINITION DU TUPLE DE DEPART **/
|
76 |
// GESTION DE LA REQUETE dans le cas d'une liste NON paginée progressive
|
| 91 |
restrictions.put("start", String.valueOf(start*nbElements));
|
- |
|
| 92 |
|
77 |
restrictions.put("start", String.valueOf(start*nbElements));
|
| 93 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, param, restrictions);
|
- |
|
| 94 |
|
78 |
|
| 95 |
rb.envoyerRequete(null, new JsonRestRequestCallback() {
|
- |
|
| 96 |
|
79 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, param, restrictions);
|
| 97 |
public void surReponse(JSONValue responseValue) {
|
- |
|
| 98 |
|
80 |
|
| 99 |
if (responseValue != null) {
|
- |
|
| 100 |
|
81 |
rb.envoyerRequete(null, new JsonRestRequestCallback() {
|
| 101 |
JSONObject responseObject = responseValue.isObject();
|
82 |
public void surReponse(JSONValue responseValue) {
|
| 102 |
|
- |
|
| 103 |
if (responseObject != null) {
|
83 |
if (responseValue != null) {
|
| Line 104... |
Line 84... |
| 104 |
|
84 |
JSONObject responseObject = responseValue.isObject();
|
| 105 |
// Si la réponse est un tableau, alors c'est une liste de projets qui a été retournée
|
85 |
if (responseObject != null) {
|
| 106 |
if (responseObject.get("publications").isArray() != null) {
|
86 |
// Si la réponse est un tableau, alors c'est une liste de projets qui a été retournée
|
| Line 134... |
Line 114... |
| 134 |
} else {
|
114 |
} else {
|
| 135 |
vueARafraichir.rafraichir(publication);
|
115 |
vueARafraichir.rafraichir(publication);
|
| 136 |
}
|
116 |
}
|
| 137 |
}
|
117 |
}
|
| 138 |
} else {
|
118 |
} else {
|
| 139 |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas un objet ou un tableau JSON et vaut : "+responseValue.toString(), null);
|
119 |
Log.warn(rb.getUrl()+"\n\tLa réponse n'est pas un objet ou un tableau JSON et vaut : "+responseValue.toString());
|
| 140 |
}
|
120 |
}
|
| 141 |
} else {
|
121 |
} else {
|
| 142 |
if (publicationId == null) {
|
122 |
if (publicationId == null) {
|
| 143 |
PublicationListe publications = new PublicationListe(0);
|
123 |
PublicationListe publications = new PublicationListe(0);
|
| 144 |
vueARafraichir.rafraichir(publications);
|
124 |
vueARafraichir.rafraichir(publications);
|