8,14 → 8,11 |
import org.tela_botanica.client.http.JsonRestRequestCallback; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe; |
import org.tela_botanica.client.synchronisation.Reponse; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Log; |
import org.tela_botanica.client.util.UtilDAO; |
|
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.widget.Window; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.http.client.URL; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONObject; |
29,7 → 26,7 |
private Rafraichissable vueARafraichir = null; |
|
public PublicationAPersonneAsyncDao(Rafraichissable vueARafraichirCourrante) { |
if (Mediateur.DEBUG) System.out.println("|| PublicationAPersonneAsyncDao > vueARafraichir = "+vueARafraichirCourrante.getClass().toString()); |
Log.trace("|| PublicationAPersonneAsyncDao > vueARafraichir = "+vueARafraichirCourrante.getClass().toString()); |
vueARafraichir = vueARafraichirCourrante; |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId(); |
} |
46,55 → 43,39 |
|
restrictions.put("orderby", "cpuap_ordre"); |
|
/** GESTION DE LA REQUETE dans le cas d'une liste paginée progressive **/ |
if (paginationProgressive) { |
|
/** DEFINITION DU TUPLE DE DEPART **/ |
restrictions.put("start", String.valueOf(start)); |
if (paginationProgressive) {// GESTION DE LA REQUETE dans le cas d'une liste paginée progressive |
restrictions.put("start", String.valueOf(start));// DEFINITION DU TUPLE DE DEPART |
|
/** CONSTRUCTION DE LA REQUETE **/ |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions); |
|
/** ENVOI DE LA REQUETE **/ |
rb.envoyerRequete(null, new JsonRestRequestCallback() |
{ |
rb.envoyerRequete(null, new JsonRestRequestCallback() { |
/** RECEPTION DE LA REPONSE **/ |
public void surReponse(JSONValue responseValue) |
{ |
public void surReponse(JSONValue responseValue) { |
/** Dans le cas d'une liste paginée, vueARafraichir est un objet Proxy. |
* On retourne l'objet JSON au proxy afin que ce soit lui qui le traite **/ |
|
if (seqId != null) { |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAPersonneAsyncDao > Liste paginée, retour au sequenceur"); |
Log.trace("<-- PublicationAPersonneAsyncDao > Liste paginée, retour au sequenceur"); |
Reponse reponseRequete = new Reponse(responseValue, seqId); |
vueARafraichir.rafraichir(reponseRequete); |
} |
else { |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAPersonneAsyncDao > Liste paginée, retour à "+vueARafraichir.getClass().toString()); |
} else { |
Log.trace("<-- PublicationAPersonneAsyncDao > Liste paginée, retour à "+vueARafraichir.getClass().toString()); |
vueARafraichir.rafraichir(responseValue); |
} |
} |
}); |
} |
/** GESTION DE LA REQUETE dans le cas d'une liste NON paginée progressive **/ |
else { |
|
/** DEFINITION DU TUPLE DE DEPART **/ |
} else { // GESTION DE LA REQUETE dans le cas d'une liste NON paginée progressive |
restrictions.put("start", String.valueOf(start*nbElements)); |
|
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions); |
|
rb.envoyerRequete(null, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
|
if (responseValue != null) { |
|
JSONObject responseObject = responseValue.isObject(); |
if (responseObject != null) { |
// Si la réponse est un tableau, alors c'est une liste de collections qui a été retournée |
if (responseObject.get("publicationsAPersonne").isArray() != null) { |
|
final JSONArray reponse = responseObject.get("publicationsAPersonne").isArray(); |
|
// Transformation du tableau JSON réponse en ListeInstitution |
102,17 → 83,15 |
|
// et on met à jour le demandeur des données |
if (seqId != null) { |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAPersonneAsyncDao > Liste non paginée, retour au sequenceur"); |
Log.trace("<-- PublicationAPersonneAsyncDao > Liste non paginée, retour au sequenceur"); |
Reponse reponseRequete = new Reponse(publicationsAPersonneListe, seqId); |
vueARafraichir.rafraichir(reponseRequete); |
} |
else { |
if (Mediateur.DEBUG) System.out.println("<-- PublicationAPersonneAsyncDao > Liste non paginée, retour au sequenceur"); |
} else { |
Log.trace("<-- PublicationAPersonneAsyncDao > Liste non paginée, retour au sequenceur"); |
vueARafraichir.rafraichir(publicationsAPersonneListe); |
} |
} else if (responseObject.get("publicationsAPersonne").isObject() != null) { |
// Si la réponse est un objet, alors c'est une unique collection qui a été retournée |
} else if (responseObject.get("publicationsAPersonne").isObject() != null) { |
|
final JSONObject reponse = responseObject.get("publicationsAPersonne").isObject(); |
// Transformation du tableau JSON réponse en ListeInstitution |
PublicationAPersonne publicationAPersonne = new PublicationAPersonne(reponse); |
124,7 → 103,7 |
vueARafraichir.rafraichir(publicationAPersonne); |
} |
} else { |
GWT.log("La réponse n'est pas un objet ou un tableau JSON et vaut : "+responseValue.toString(), null); |
Log.warn("La réponse n'est pas un objet ou un tableau JSON et vaut : "+responseValue.toString()); |
} |
} |
} else { |
188,7 → 167,7 |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
Log.warn(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON."); |
} |
} |
}); |