| Line 7... |
Line 7... |
| 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.structure.StructureListe;
|
11 |
import org.tela_botanica.client.modeles.structure.StructureListe;
|
| - |
|
12 |
import org.tela_botanica.client.synchronisation.Reponse;
|
| 12 |
import org.tela_botanica.client.util.Debug;
|
13 |
import org.tela_botanica.client.util.Debug;
|
| 13 |
import org.tela_botanica.client.util.UtilDAO;
|
14 |
import org.tela_botanica.client.util.UtilDAO;
|
| Line 14... |
Line 15... |
| 14 |
|
15 |
|
| 15 |
import com.extjs.gxt.ui.client.Registry;
|
16 |
import com.extjs.gxt.ui.client.Registry;
|
| Line 27... |
Line 28... |
| 27 |
public PublicationAsyncDao(Rafraichissable vueARafraichirCourrante) {
|
28 |
public PublicationAsyncDao(Rafraichissable vueARafraichirCourrante) {
|
| 28 |
vueARafraichir = vueARafraichirCourrante ;
|
29 |
vueARafraichir = vueARafraichirCourrante ;
|
| 29 |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
|
30 |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
|
| 30 |
}
|
31 |
}
|
| Line 31... |
Line 32... |
| 31 |
|
32 |
|
| 32 |
public void selectionner(final String publicationId, String projetId, String nomComplet, final int nbElements, final int pageCourante) {
|
33 |
public void selectionner(final String publicationId, String projetId, String nomComplet, final int nbElements, final int pageCourante, final Integer seqId) {
|
| Line 33... |
Line 34... |
| 33 |
String[] parametres = {projetId, publicationId, nomComplet};
|
34 |
String[] parametres = {projetId, publicationId, nomComplet};
|
| 34 |
|
35 |
|
| 35 |
HashMap<String, String> restrictions = new HashMap<String, String>();
|
36 |
HashMap<String, String> restrictions = new HashMap<String, String>();
|
| Line 48... |
Line 49... |
| 48 |
if (responseArray.get(1).isObject() != null) {
|
49 |
if (responseArray.get(1).isObject() != null) {
|
| 49 |
final JSONObject reponse = responseArray.get(1).isObject();
|
50 |
final JSONObject reponse = responseArray.get(1).isObject();
|
| 50 |
// Transformation du tableau JSON réponse en ListeInstitution
|
51 |
// Transformation du tableau JSON réponse en ListeInstitution
|
| 51 |
Publication publication = new Publication(reponse);
|
52 |
Publication publication = new Publication(reponse);
|
| 52 |
// et on met à jour le demandeur des données
|
53 |
// et on met à jour le demandeur des données
|
| - |
|
54 |
if (seqId!=null) {
|
| - |
|
55 |
Reponse reponseRequete = new Reponse(publication, seqId);
|
| - |
|
56 |
vueARafraichir.rafraichir(reponseRequete);
|
| - |
|
57 |
} else {
|
| 53 |
vueARafraichir.rafraichir(publication);
|
58 |
vueARafraichir.rafraichir(publication);
|
| - |
|
59 |
}
|
| - |
|
60 |
|
| 54 |
} else if (responseArray.get(1).isArray() != null) {
|
61 |
} else if (responseArray.get(1).isArray() != null) {
|
| 55 |
final JSONArray reponse = responseValue.isArray();
|
62 |
final JSONArray reponse = responseValue.isArray();
|
| 56 |
PublicationListe publications;
|
63 |
PublicationListe publications;
|
| 57 |
if (reponse.get(1).isObject() != null) {
|
64 |
if (reponse.get(1).isObject() != null) {
|
| 58 |
publications = new PublicationListe(reponse.get(1).isArray());
|
65 |
publications = new PublicationListe(reponse.get(1).isArray());
|
| Line 61... |
Line 68... |
| 61 |
}
|
68 |
}
|
| Line 62... |
Line 69... |
| 62 |
|
69 |
|
| 63 |
publications.setTaillePage(nbElements);
|
70 |
publications.setTaillePage(nbElements);
|
| Line -... |
Line 71... |
| - |
|
71 |
publications.setPageCourante(pageCourante);
|
| - |
|
72 |
|
| - |
|
73 |
if (seqId!=null) {
|
| - |
|
74 |
Reponse reponseRequete = new Reponse(publications, seqId);
|
| 64 |
publications.setPageCourante(pageCourante);
|
75 |
vueARafraichir.rafraichir(reponseRequete);
|
| - |
|
76 |
} else {
|
| - |
|
77 |
vueARafraichir.rafraichir(publications);
|
| 65 |
|
78 |
}
|
| 66 |
vueARafraichir.rafraichir(publications);
|
79 |
|
| 67 |
} else {
|
80 |
} else {
|
| 68 |
GWT.log("La réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null);
|
81 |
GWT.log("La réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null);
|
| 69 |
}
|
82 |
}
|
| Line 76... |
Line 89... |
| 76 |
}
|
89 |
}
|
| 77 |
}
|
90 |
}
|
| 78 |
});
|
91 |
});
|
| 79 |
}
|
92 |
}
|
| Line 80... |
Line 93... |
| 80 |
|
93 |
|
| 81 |
public void ajouter(Publication publication) {
|
94 |
public void ajouter(Publication publication, final Integer seqId) {
|
| Line 82... |
Line 95... |
| 82 |
String postDonneesEncodees = publication.obtenirChainePOST()+"&cmhl_ce_modifier_par="+utilisateurId;
|
95 |
String postDonneesEncodees = publication.obtenirChainePOST()+"&cmhl_ce_modifier_par="+utilisateurId;
|
| Line 83... |
Line 96... |
| 83 |
|
96 |
|
| 84 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM);
|
97 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM);
|
| 85 |
|
98 |
|
| 86 |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() {
|
99 |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() {
|
| 87 |
@Override
|
100 |
@Override
|
| 88 |
public void surReponse(JSONValue reponseValeur) {
|
101 |
public void surReponse(JSONValue reponseValeur) {
|
| 89 |
traiterReponse(reponseValeur, "ajout_publication");
|
102 |
traiterReponse(reponseValeur, "ajout_publication", seqId);
|
| Line 90... |
Line 103... |
| 90 |
}
|
103 |
}
|
| 91 |
}) ;
|
104 |
}) ;
|
| 92 |
}
|
105 |
}
|
| Line 93... |
Line 106... |
| 93 |
|
106 |
|
| Line 94... |
Line 107... |
| 94 |
public void modifier(Publication publication) {
|
107 |
public void modifier(Publication publication, final Integer seqId) {
|
| 95 |
String[] parametres = {publication.getId()};
|
108 |
String[] parametres = {publication.getId()};
|
| 96 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres);
|
109 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres);
|
| 97 |
|
110 |
|
| 98 |
String postDonneesEncodees = publication.obtenirChainePOST()+"&cmhl_ce_modifier_par="+utilisateurId;
|
111 |
String postDonneesEncodees = publication.obtenirChainePOST()+"&cmhl_ce_modifier_par="+utilisateurId;
|
| 99 |
|
112 |
|
| 100 |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() {
|
113 |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() {
|
| Line 101... |
Line 114... |
| 101 |
@Override
|
114 |
@Override
|
| 102 |
public void surReponse(JSONValue reponseValeur) {
|
115 |
public void surReponse(JSONValue reponseValeur) {
|
| 103 |
traiterReponse(reponseValeur, "modif_publication");
|
116 |
traiterReponse(reponseValeur, "modif_publication", seqId);
|
| 104 |
}
|
117 |
}
|
| 105 |
});
|
118 |
});
|
| 106 |
}
|
119 |
}
|
| 107 |
|
120 |
|
| 108 |
public void supprimer(String publicationsId) {
|
121 |
public void supprimer(String publicationsId) {
|
| 109 |
String[] parametres = {utilisateurId, publicationsId};
|
122 |
String[] parametres = {utilisateurId, publicationsId};
|
| 110 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres);
|
123 |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres);
|
| Line 111... |
Line 124... |
| 111 |
rb.envoyerRequeteSuppression(new JsonRestRequestCallback() {
|
124 |
rb.envoyerRequeteSuppression(new JsonRestRequestCallback() {
|
| 112 |
@Override
|
125 |
@Override
|
| 113 |
public void surReponse(JSONValue reponseValeur) {
|
126 |
public void surReponse(JSONValue reponseValeur) {
|
| 114 |
traiterReponse(reponseValeur, "suppression_publication");
|
127 |
traiterReponse(reponseValeur, "suppression_publication", null);
|
| 115 |
}
|
128 |
}
|
| 116 |
});
|
129 |
});
|
| Line 127... |
Line 140... |
| 127 |
info.setMessage(idOuMessage);
|
140 |
info.setMessage(idOuMessage);
|
| 128 |
}
|
141 |
}
|
| 129 |
} else {
|
142 |
} else {
|
| 130 |
info.setDeboguage("La réponse n'est pas une chaine JSON.");
|
143 |
info.setDeboguage("La réponse n'est pas une chaine JSON.");
|
| 131 |
}
|
144 |
}
|
| - |
|
145 |
|
| - |
|
146 |
System.out.println("la PASD 1");
|
| - |
|
147 |
if (seqId!=null) {
|
| - |
|
148 |
System.out.println("la PASD 2");
|
| - |
|
149 |
Reponse retourRequete = new Reponse(info, seqId);
|
| - |
|
150 |
vueARafraichir.rafraichir(retourRequete);
|
| - |
|
151 |
} else {
|
| 132 |
vueARafraichir.rafraichir(info);
|
152 |
vueARafraichir.rafraichir(info);
|
| - |
|
153 |
}
|
| 133 |
}
|
154 |
}
|
| Line 134... |
Line 155... |
| 134 |
|
155 |
|