Line 17... |
Line 17... |
17 |
import com.google.gwt.json.client.JSONValue;
|
17 |
import com.google.gwt.json.client.JSONValue;
|
Line 18... |
Line 18... |
18 |
|
18 |
|
19 |
public class StructureAPersonneAsyncDao {
|
19 |
public class StructureAPersonneAsyncDao {
|
Line 20... |
Line 20... |
20 |
private static final String SERVICE_NOM = "CoelStructureAPersonne";
|
20 |
private static final String SERVICE_NOM = "CoelStructureAPersonne";
|
21 |
|
21 |
|
22 |
public void selectionner(final Rafraichissable r, String idUtilisateur, final String idStructure, final String idRole) {
|
22 |
public void selectionner(final Rafraichissable vueARafraichir, String idUtilisateur, final String idStructure, final String idRole) {
|
23 |
// Ajout des paramètres et données à selectionner dans l'URL
|
23 |
// Ajout des paramètres et données à selectionner dans l'URL
|
24 |
final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() +
|
24 |
final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() +
|
25 |
SERVICE_NOM + "/" +
|
25 |
SERVICE_NOM + "/" +
|
Line 58... |
Line 58... |
58 |
// Transformation du tableau JSON réponse en ListeInstitution
|
58 |
// Transformation du tableau JSON réponse en ListeInstitution
|
59 |
Information info = new Information("liste_structure_a_personne");
|
59 |
Information info = new Information("liste_structure_a_personne");
|
60 |
StructureAPersonneListe personnel = new StructureAPersonneListe(reponse);
|
60 |
StructureAPersonneListe personnel = new StructureAPersonneListe(reponse);
|
61 |
info.setDonnee(0, personnel);
|
61 |
info.setDonnee(0, personnel);
|
62 |
// et on met à jour le demandeur des données
|
62 |
// et on met à jour le demandeur des données
|
63 |
r.rafraichir(info);
|
63 |
vueARafraichir.rafraichir(info);
|
64 |
} else {
|
64 |
} else {
|
65 |
GWT.log(url+"\n\tLa réponse n'est pas un talbeau JSON et vaut : "+responseValue.toString(), null);
|
65 |
GWT.log(url+"\n\tLa réponse n'est pas un talbeau JSON et vaut : "+responseValue.toString(), null);
|
66 |
}
|
66 |
}
|
67 |
} else {
|
67 |
} else {
|
68 |
if (idStructure == null) {
|
68 |
if (idStructure == null) {
|
69 |
// Dans le cas, où nous demandons toutes les relations Structure à Personne et qu'il n'y en a pas, nous retournons un message d'information
|
69 |
// Dans le cas, où nous demandons toutes les relations Structure à Personne et qu'il n'y en a pas, nous retournons un message d'information
|
70 |
Information info = new Information("liste_structure_a_personne");
|
70 |
Information info = new Information("liste_structure_a_personne");
|
71 |
info.setMessage("Aucun personnel");
|
71 |
info.setMessage("Aucun personnel");
|
72 |
r.rafraichir(info);
|
72 |
vueARafraichir.rafraichir(info);
|
73 |
} else {
|
73 |
} else {
|
74 |
GWT.log(url, null);
|
74 |
GWT.log(url, null);
|
75 |
if (response.getText().length() == 0) {
|
75 |
if (response.getText().length() == 0) {
|
76 |
GWT.log("\tLa réponse a une taille de 0", null);
|
76 |
GWT.log("\tLa réponse a une taille de 0", null);
|
77 |
}
|
77 |
}
|
Line 93... |
Line 93... |
93 |
public void ajouter(final Rafraichissable vue, String utilisateurId, String structureId, StructureAPersonne personnel) {
|
93 |
public void ajouter(final Rafraichissable vue, String utilisateurId, String structureId, StructureAPersonne personnel) {
|
94 |
final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() +
|
94 |
final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() +
|
95 |
SERVICE_NOM + "/";
|
95 |
SERVICE_NOM + "/";
|
96 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
|
96 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
|
Line 97... |
Line 97... |
97 |
|
97 |
|
98 |
String postDonnees = "cmhl_ce_modifier_par=" + utilisateurId +
|
- |
|
99 |
"&csap_id_structure=" + structureId +
|
- |
|
100 |
"&csap_id_personne=" + URL.encodeComponent(personnel.getIdPersonne()) +
|
- |
|
101 |
"&csap_id_role=" + URL.encodeComponent(personnel.getIdRole()) +
|
- |
|
102 |
"&csap_ce_truk_fonction=" + URL.encodeComponent(personnel.getFonction()) +
|
- |
|
103 |
"&csap_service=" + URL.encodeComponent(personnel.getService()) +
|
- |
|
104 |
"&csap_ce_truk_statut=" + URL.encodeComponent(personnel.getStatut()) +
|
- |
|
105 |
"&csap_mark_contact=" + URL.encodeComponent(personnel.getContact()) +
|
- |
|
106 |
"&csap_bota_travail_hebdo_tps=" + URL.encodeComponent(personnel.getBotaTravailHebdoTps()) +
|
- |
|
107 |
"&cp_prenom=" + URL.encodeComponent(personnel.getPrenom()) +
|
- |
|
108 |
"&cp_nom=" + URL.encodeComponent(personnel.getNom()) +
|
- |
|
109 |
"&cp_truk_telephone=" + URL.encodeComponent(personnel.getTelephone()) +
|
- |
|
110 |
"&cp_truk_fax=" + URL.encodeComponent(personnel.getFax()) +
|
- |
|
111 |
"&cp_truk_courriel=" + URL.encodeComponent(personnel.getCourriel()) +
|
- |
|
112 |
"&cp_ce_truk_specialite=" + URL.encodeComponent(personnel.getSpecialite()) +
|
- |
|
Line 113... |
Line 98... |
113 |
"";
|
98 |
String postDonneesEncodees = construirePost(utilisateurId, structureId, personnel);
|
114 |
|
99 |
|
Line 115... |
Line 100... |
115 |
try {
|
100 |
try {
|
116 |
rb.sendRequest(postDonnees, new RequestCallback() {
|
101 |
rb.sendRequest(postDonneesEncodees, new RequestCallback() {
|
117 |
|
102 |
|
118 |
public void onError(Request request, Throwable exception) {
|
103 |
public void onError(Request request, Throwable exception) {
|
Line 171... |
Line 156... |
171 |
personnel.getIdRole()
|
156 |
personnel.getIdRole()
|
172 |
;
|
157 |
;
|
Line 173... |
Line 158... |
173 |
|
158 |
|
Line 174... |
Line 159... |
174 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
|
159 |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
|
175 |
|
- |
|
176 |
String postDonnees = "cmhl_ce_modifier_par=" + utilisateurId +
|
- |
|
177 |
"&csap_ce_truk_fonction=" + URL.encodeComponent(personnel.getFonction()) +
|
- |
|
178 |
"&csap_service=" + URL.encodeComponent(personnel.getService()) +
|
- |
|
179 |
"&csap_ce_truk_statut=" + URL.encodeComponent(personnel.getStatut()) +
|
- |
|
180 |
"&csap_mark_contact=" + URL.encodeComponent(personnel.getContact()) +
|
- |
|
181 |
"&csap_bota_travail_hebdo_tps=" + URL.encodeComponent(personnel.getBotaTravailHebdoTps()) +
|
- |
|
182 |
"&cp_prenom=" + URL.encodeComponent(personnel.getPrenom()) +
|
- |
|
183 |
"&cp_nom=" + URL.encodeComponent(personnel.getNom()) +
|
- |
|
184 |
"&cp_truk_telephone=" + URL.encodeComponent(personnel.getTelephone()) +
|
- |
|
185 |
"&cp_truk_fax=" + URL.encodeComponent(personnel.getFax()) +
|
- |
|
186 |
"&cp_truk_courriel=" + URL.encodeComponent(personnel.getCourriel()) +
|
- |
|
Line 187... |
Line 160... |
187 |
"&cp_ce_truk_specialite=" + URL.encodeComponent(personnel.getSpecialite()) +
|
160 |
|
188 |
"";
|
161 |
String postDonneesEncodees = construirePost(utilisateurId, null, personnel);
|
Line 189... |
Line 162... |
189 |
|
162 |
|
190 |
try {
|
163 |
try {
|
191 |
rb.sendRequest(postDonnees, new RequestCallback() {
|
164 |
rb.sendRequest(postDonneesEncodees, new RequestCallback() {
|
192 |
|
165 |
|
Line 299... |
Line 272... |
299 |
GWT.log("Erreur à la création du service "+SERVICE_NOM+" (suppression)", e);
|
272 |
GWT.log("Erreur à la création du service "+SERVICE_NOM+" (suppression)", e);
|
300 |
Info.display("Erreur de Requête", "Une erreur s'est produite lors de la création de la requête.");
|
273 |
Info.display("Erreur de Requête", "Une erreur s'est produite lors de la création de la requête.");
|
301 |
}
|
274 |
}
|
Line 302... |
Line 275... |
302 |
|
275 |
|
- |
|
276 |
}
|
- |
|
277 |
|
- |
|
278 |
private String construirePost(String utilisateurId, String structureId, StructureAPersonne personnel) {
|
- |
|
279 |
String postDonnees = "cmhl_ce_modifier_par=" + URL.encodeComponent(utilisateurId);
|
- |
|
280 |
if (structureId != null) {
|
- |
|
281 |
postDonnees += "&csap_id_structure=" + structureId;
|
- |
|
282 |
}
|
- |
|
283 |
postDonnees += "&csap_id_personne=" + URL.encodeComponent(personnel.getIdPersonne()) +
|
- |
|
284 |
"&csap_id_role=" + URL.encodeComponent(personnel.getIdRole()) +
|
- |
|
285 |
"&csap_ce_truk_fonction=" + URL.encodeComponent(personnel.getFonction()) +
|
- |
|
286 |
"&csap_service=" + URL.encodeComponent(personnel.getService()) +
|
- |
|
287 |
"&csap_ce_truk_statut=" + URL.encodeComponent(personnel.getStatut()) +
|
- |
|
288 |
"&csap_mark_contact=" + URL.encodeComponent(personnel.getContact()) +
|
- |
|
289 |
"&csap_bota_travail_hebdo_tps=" + URL.encodeComponent(personnel.getBotaTravailHebdoTps()) +
|
- |
|
290 |
"&cp_prenom=" + URL.encodeComponent(personnel.getPrenom()) +
|
- |
|
291 |
"&cp_nom=" + URL.encodeComponent(personnel.getNom()) +
|
- |
|
292 |
"&cp_truk_telephone=" + URL.encodeComponent(personnel.getTelephone()) +
|
- |
|
293 |
"&cp_truk_courriel=" + URL.encodeComponent(personnel.getCourriel()) +
|
- |
|
294 |
"&cp_ce_truk_specialite=" + URL.encodeComponent(personnel.getSpecialite()) +
|
- |
|
295 |
"";
|
- |
|
296 |
return postDonnees;
|
303 |
}
|
297 |
}
|