Subversion Repositories eFlore/Applications.coel

Rev

Rev 245 | Rev 268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 245 Rev 264
Line 16... Line 16...
16
import com.google.gwt.json.client.JSONObject;
16
import com.google.gwt.json.client.JSONObject;
17
import com.google.gwt.json.client.JSONParser;
17
import com.google.gwt.json.client.JSONParser;
18
import com.google.gwt.json.client.JSONValue;
18
import com.google.gwt.json.client.JSONValue;
Line 19... Line 19...
19
 
19
 
20
public class StructureAsyncDao {
20
public class StructureAsyncDao {
-
 
21
	
-
 
22
	private static final String SERVICE_NOM = "CoelStructureListe";
21
 
23
	
22
	public void selectionner(final Rafraichissable r, String idUtilisateur, final String projetId, final String idStr) {
24
	public void selectionner(final Rafraichissable vue, String idUtilisateur, final String projetId, final String structureId) {
23
		// Ajout des paramètres et données à selectionner dans l'URL
25
		// Ajout des paramètres et données à selectionner dans l'URL
24
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
26
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
25
			"CoelStructureListe/" +
27
			SERVICE_NOM + "/" +
26
			(projetId == null ? "*" : projetId) + "/" +
28
			(projetId == null ? "*" : projetId) + "/" +
27
			(idStr == null ? "" : idStr) +
29
			(structureId == null ? "*" : structureId) + "/" +
Line 28... Line 30...
28
			"";
30
			"";
29
		
31
		
30
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
32
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
Line 61... Line 63...
61
								StructureValorisation structureValorisation = new StructureValorisation(reponse);
63
								StructureValorisation structureValorisation = new StructureValorisation(reponse);
62
								Information info = new Information("selection_structure");
64
								Information info = new Information("selection_structure");
63
								info.setDonnee(0, structure);
65
								info.setDonnee(0, structure);
64
								info.setDonnee(1, structureConservation);
66
								info.setDonnee(1, structureConservation);
65
								info.setDonnee(2, structureValorisation);
67
								info.setDonnee(2, structureValorisation);
66
								r.rafraichir(info);
68
								vue.rafraichir(info);
67
							} else if (responseValue.isArray() != null) {
69
							} else if (responseValue.isArray() != null) {
68
								final JSONArray reponse = responseValue.isArray();
70
								final JSONArray reponse = responseValue.isArray();
69
								// Transformation du tableau JSON réponse en ListeInstitution
71
								// Transformation du tableau JSON réponse en ListeInstitution
70
								StructureListe structures = new StructureListe(reponse);
72
								StructureListe structures = new StructureListe(reponse);
71
								// et on met à jour le demandeur des données
73
								// et on met à jour le demandeur des données
72
								r.rafraichir(structures);
74
								vue.rafraichir(structures);
73
							} else {
75
							} else {
74
								GWT.log(url+"\n\tLa réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null);
76
								GWT.log(url+"\n\tLa réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null);
75
							}
77
							}
76
						} else {
78
						} else {
77
							if (idStr == null) {
79
							if (structureId == null) {
78
								// Dans le cas, où nous demandons toutes les institutions et qu'il n'y en a pas, nous retournons un objet vide
80
								// Dans le cas, où nous demandons toutes les institutions et qu'il n'y en a pas, nous retournons un objet vide
79
								StructureListe structures = new StructureListe(0);
81
								StructureListe structures = new StructureListe(0);
80
								r.rafraichir(structures);								
82
								vue.rafraichir(structures);								
81
							} else {
83
							} else {
82
								GWT.log(url, null);
84
								GWT.log(url, null);
83
								if (response.getText().length() == 0) {
85
								if (response.getText().length() == 0) {
84
									GWT.log("\tLa réponse a une taille de 0", null);
86
									GWT.log("\tLa réponse a une taille de 0", null);
85
								}
87
								}
Line 96... Line 98...
96
		}
98
		}
97
	}
99
	}
Line 98... Line 100...
98
	
100
	
99
	public void ajouter(final Rafraichissable r, String utilisateurId, final Structure str) {
101
	public void ajouter(final Rafraichissable r, String utilisateurId, final Structure str) {
100
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
102
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
-
 
103
			SERVICE_NOM + "/" +
Line 101... Line 104...
101
			"CoelStructureListe/";
104
			"";
Line 102... Line 105...
102
		
105
		
103
		RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
106
		RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
104
		
107
		
105
		String postDonnees = 	"cmhl_ce_modifier_par=" + utilisateurId +
108
		String postDonnees = 	"cmhl_ce_modifier_par=" + utilisateurId +
106
			"&cs_ce_projet =" + URL.encodeComponent(str.getIdProjet()) +
109
			"&cs_ce_projet=" + URL.encodeComponent(str.getIdProjet()) +
107
			"&cs_ce_mere =" + URL.encodeComponent(str.getIdMere()) +
110
			"&cs_ce_mere=" + URL.encodeComponent(str.getIdMere()) +
108
			"&cs_guid =" + URL.encodeComponent(str.getGuid()) +
111
			"&cs_guid=" + URL.encodeComponent(str.getGuid()) +
109
			"&cs_truk_identifiant_alternatif =" + URL.encodeComponent(str.getIdAlternatif()) +
112
			"&cs_truk_identifiant_alternatif=" + URL.encodeComponent(str.getIdAlternatif()) +
110
			"&cs_nom=" + URL.encodeComponent(str.getNom()) +
113
			"&cs_nom=" + URL.encodeComponent(str.getNom()) +
111
			"&cs_truk_nom_alternatif =" + URL.encodeComponent(str.getNomAlternatif()) +
114
			"&cs_truk_nom_alternatif=" + URL.encodeComponent(str.getNomAlternatif()) +
112
			"&cs_ce_type =" + URL.encodeComponent(str.getType()) +
115
			"&cs_ce_type=" + URL.encodeComponent(str.getType()) +
113
			"&cs_ce_truk_type_prive =" + URL.encodeComponent(str.getTypePrive()) +
116
			"&cs_ce_truk_type_prive=" + URL.encodeComponent(str.getTypePrive()) +
114
			"&cs_ce_truk_type_public =" + URL.encodeComponent(str.getTypePublic()) +
117
			"&cs_ce_truk_type_public=" + URL.encodeComponent(str.getTypePublic()) +
115
			"&cs_adresse_01 =" + URL.encodeComponent(str.getAdresse()) +
118
			"&cs_adresse_01=" + URL.encodeComponent(str.getAdresse()) +
116
			"&cs_adresse_02 =" + URL.encodeComponent(str.getAdresseComplement()) +
119
			"&cs_adresse_02=" + URL.encodeComponent(str.getAdresseComplement()) +
117
			"&cs_date_fondation =" + URL.encodeComponent(str.getDateFondationFormatMysql()) +
120
			"&cs_date_fondation=" + URL.encodeComponent(str.getDateFondationFormatMysql()) +
118
			"&cs_code_postal =" + URL.encodeComponent(str.getCodePostal()) +
121
			"&cs_code_postal=" + URL.encodeComponent(str.getCodePostal()) +
119
			"&cs_ville =" + URL.encodeComponent(str.getVille()) +
122
			"&cs_ville=" + URL.encodeComponent(str.getVille()) +
120
			"&cs_region =" + URL.encodeComponent(str.getRegion()) +
123
			"&cs_region=" + URL.encodeComponent(str.getRegion()) +
121
			"&cs_pays =" + URL.encodeComponent(str.getPays()) +
124
			"&cs_pays=" + URL.encodeComponent(str.getPays()) +
122
			"&cs_telephone =" + URL.encodeComponent(str.getTelephone()) +
125
			"&cs_telephone=" + URL.encodeComponent(str.getTelephone()) +
123
			"&cs_fax =" + URL.encodeComponent(str.getFax()) +
126
			"&cs_fax=" + URL.encodeComponent(str.getFax()) +
Line 124... Line 127...
124
			"&cs_truk_url =" + URL.encodeComponent(str.getUrl()) +
127
			"&cs_truk_url=" + URL.encodeComponent(str.getUrl()) +
125
			"&cs_nbre_personne =" + URL.encodeComponent(Integer.toString(str.getNbrePersonne())) +
128
			"&cs_nbre_personne=" + URL.encodeComponent(Integer.toString(str.getNbrePersonne())) +
Line 174... Line 177...
174
			GWT.log("Erreur à la création du service CoelProjetsListe", e);
177
			GWT.log("Erreur à la création du service CoelProjetsListe", e);
175
			Info.display("Erreur de Requête", "Une erreur s'est produite lors de la création de la requête.");
178
			Info.display("Erreur de Requête", "Une erreur s'est produite lors de la création de la requête.");
176
		}
179
		}
177
	}
180
	}
Line 178... Line 181...
178
 
181
 
179
	public void supprimer(final Rafraichissable r, String idUtilisateur, String idStr) {
182
	public void supprimer(final Rafraichissable r, String utilisateurId, String structureId) {
180
		// Ajout des paramètres et données à supprimer dans l'URL
183
		// Ajout des paramètres et données à supprimer dans l'URL
181
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
184
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
182
			"CoelStructureListe/" +
185
			SERVICE_NOM + "/" +
183
			idUtilisateur + "/" +
186
			utilisateurId + "/" +
184
			idStr +
187
			structureId +
Line 185... Line 188...
185
			"";
188
			"";
186
		
189
		
187
		// DELETE n'étant pas disponible comme méthode HTTP, nous utilisons POST avec le paramètre action=DELETE
190
		// DELETE n'étant pas disponible comme méthode HTTP, nous utilisons POST avec le paramètre action=DELETE
Line 239... Line 242...
239
		}
242
		}
240
	}
243
	}
Line 241... Line 244...
241
 
244
 
242
	public void modifier(final Rafraichissable r, String utilisateurId, Structure str, StructureConservation conservation, StructureValorisation valorisation) {
245
	public void modifier(final Rafraichissable r, String utilisateurId, Structure str, StructureConservation conservation, StructureValorisation valorisation) {
243
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
246
		final String url = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl() + 
244
		"CoelStructureListe/" +
247
		SERVICE_NOM + "/" +
245
		str.getId()
248
		str.getId()
Line 246... Line 249...
246
		;
249
		;
Line 247... Line 250...
247
	
250
	
248
		RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
251
		RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
249
		
252
		
250
		String postDonnees = 	"cmhl_ce_modifier_par=" + utilisateurId +
253
		String postDonnees = 	"cmhl_ce_modifier_par=" + utilisateurId +
251
			"&cs_ce_projet =" + URL.encodeComponent(str.getIdProjet()) +
254
			"&cs_ce_projet=" + URL.encodeComponent(str.getIdProjet()) +
252
			"&cs_ce_mere =" + URL.encodeComponent(str.getIdMere()) +
255
			"&cs_ce_mere=" + URL.encodeComponent(str.getIdMere()) +
253
			"&cs_guid =" + URL.encodeComponent(str.getGuid()) +
256
			"&cs_guid=" + URL.encodeComponent(str.getGuid()) +
254
			"&cs_truk_identifiant_alternatif =" + URL.encodeComponent(str.getIdAlternatif()) +
257
			"&cs_truk_identifiant_alternatif=" + URL.encodeComponent(str.getIdAlternatif()) +
255
			"&cs_nom=" + URL.encodeComponent(str.getNom()) +
258
			"&cs_nom=" + URL.encodeComponent(str.getNom()) +
256
			"&cs_truk_nom_alternatif =" + URL.encodeComponent(str.getNomAlternatif()) +
259
			"&cs_truk_nom_alternatif=" + URL.encodeComponent(str.getNomAlternatif()) +
257
			"&cs_ce_type =" + URL.encodeComponent(str.getType()) +
260
			"&cs_ce_type=" + URL.encodeComponent(str.getType()) +
258
			"&cs_ce_truk_type_prive =" + URL.encodeComponent(str.getTypePrive()) +
261
			"&cs_ce_truk_type_prive=" + URL.encodeComponent(str.getTypePrive()) +
259
			"&cs_ce_truk_type_public =" + URL.encodeComponent(str.getTypePublic()) +
262
			"&cs_ce_truk_type_public=" + URL.encodeComponent(str.getTypePublic()) +
260
			"&cs_adresse_01 =" + URL.encodeComponent(str.getAdresse()) +
263
			"&cs_adresse_01=" + URL.encodeComponent(str.getAdresse()) +
261
			"&cs_adresse_02 =" + URL.encodeComponent(str.getAdresseComplement()) +
264
			"&cs_adresse_02=" + URL.encodeComponent(str.getAdresseComplement()) +
262
			"&cs_date_fondation =" + URL.encodeComponent(str.getDateFondationFormatMysql()) +
265
			"&cs_date_fondation=" + URL.encodeComponent(str.getDateFondationFormatMysql()) +
263
			"&cs_code_postal =" + URL.encodeComponent(str.getCodePostal()) +
266
			"&cs_code_postal=" + URL.encodeComponent(str.getCodePostal()) +
264
			"&cs_ville =" + URL.encodeComponent(str.getVille()) +
267
			"&cs_ville=" + URL.encodeComponent(str.getVille()) +
265
			"&cs_region =" + URL.encodeComponent(str.getRegion()) +
268
			"&cs_region=" + URL.encodeComponent(str.getRegion()) +
266
			"&cs_pays =" + URL.encodeComponent(str.getPays()) +
269
			"&cs_pays=" + URL.encodeComponent(str.getPays()) +
267
			"&cs_telephone =" + URL.encodeComponent(str.getTelephone()) +
270
			"&cs_telephone=" + URL.encodeComponent(str.getTelephone()) +
268
			"&cs_fax =" + URL.encodeComponent(str.getFax()) +
271
			"&cs_fax=" + URL.encodeComponent(str.getFax()) +
269
			"&cs_courriel =" + URL.encodeComponent(str.getCourriel()) +
272
			"&cs_courriel=" + URL.encodeComponent(str.getCourriel()) +
270
			"&cs_truk_url =" + URL.encodeComponent(str.getUrl()) +
273
			"&cs_truk_url=" + URL.encodeComponent(str.getUrl()) +
271
			"&cs_nbre_personne =" + URL.encodeComponent(Integer.toString(str.getNbrePersonne())) +
274
			"&cs_nbre_personne=" + URL.encodeComponent(Integer.toString(str.getNbrePersonne())) +
272
			"&csc_mark_formation =" + URL.encodeComponent(conservation.getFormation()) +
275
			"&csc_mark_formation=" + URL.encodeComponent(conservation.getFormation()) +
273
			"&csc_formation =" + URL.encodeComponent(conservation.getFormationInfo()) +
276
			"&csc_formation=" + URL.encodeComponent(conservation.getFormationInfo()) +
274
			"&csc_mark_formation_interet =" + URL.encodeComponent(conservation.getFormationInteret()) +
277
			"&csc_mark_formation_interet=" + URL.encodeComponent(conservation.getFormationInteret()) +
275
			"&csc_truk_stockage_local =" + URL.encodeComponent(conservation.getStockageLocal()) +
278
			"&csc_truk_stockage_local=" + URL.encodeComponent(conservation.getStockageLocal()) +
276
			"&csc_truk_stockage_meuble =" + URL.encodeComponent(conservation.getStockageMeuble()) +
279
			"&csc_truk_stockage_meuble=" + URL.encodeComponent(conservation.getStockageMeuble()) +
277
			"&csc_truk_stockage_parametre =" + URL.encodeComponent(conservation.getStockageParametre()) +
280
			"&csc_truk_stockage_parametre=" + URL.encodeComponent(conservation.getStockageParametre()) +
278
			"&csc_mark_collection_commune =" + URL.encodeComponent(conservation.getCollectionCommune()) +
281
			"&csc_mark_collection_commune=" + URL.encodeComponent(conservation.getCollectionCommune()) +
279
			"&csc_truk_collection_autre =" + URL.encodeComponent(conservation.getCollectionAutre()) +
282
			"&csc_truk_collection_autre=" + URL.encodeComponent(conservation.getCollectionAutre()) +
280
			"&csc_mark_acces_controle =" + URL.encodeComponent(conservation.getAccesControle()) +
283
			"&csc_mark_acces_controle=" + URL.encodeComponent(conservation.getAccesControle()) +
281
			"&csc_mark_restauration =" + URL.encodeComponent(conservation.getRestauration()) +
284
			"&csc_mark_restauration=" + URL.encodeComponent(conservation.getRestauration()) +
282
			"&csc_truk_restauration_operation =" + URL.encodeComponent(conservation.getRestaurationOperation()) +
285
			"&csc_truk_restauration_operation=" + URL.encodeComponent(conservation.getRestaurationOperation()) +
283
			"&csc_ce_materiel_conservation =" + URL.encodeComponent(conservation.getMaterielConservation()) +
286
			"&csc_ce_materiel_conservation=" + URL.encodeComponent(conservation.getMaterielConservation()) +
284
			"&csc_truk_materiel_autre =" + URL.encodeComponent(conservation.getMaterielAutre()) +
287
			"&csc_truk_materiel_autre=" + URL.encodeComponent(conservation.getMaterielAutre()) +
285
			"&csc_mark_traitement =" + URL.encodeComponent(conservation.getTraitement()) +
288
			"&csc_mark_traitement=" + URL.encodeComponent(conservation.getTraitement()) +
286
			"&csc_truk_traitement =" + URL.encodeComponent(conservation.getTraitements()) +
289
			"&csc_truk_traitement=" + URL.encodeComponent(conservation.getTraitements()) +
287
			"&csc_mark_acquisition_collection =" + URL.encodeComponent(conservation.getAcquisitionCollection()) +
290
			"&csc_mark_acquisition_collection=" + URL.encodeComponent(conservation.getAcquisitionCollection()) +
288
			"&csc_mark_acquisition_echantillon =" + URL.encodeComponent(conservation.getAcquisitionEchantillon()) +
291
			"&csc_mark_acquisition_echantillon=" + URL.encodeComponent(conservation.getAcquisitionEchantillon()) +
289
			"&csc_mark_acquisition_traitement =" + URL.encodeComponent(conservation.getAcquisitionTraitement()) +
292
			"&csc_mark_acquisition_traitement=" + URL.encodeComponent(conservation.getAcquisitionTraitement()) +
290
			"&csc_truk_acquisition_traitement_poison =" + URL.encodeComponent(conservation.getAcquisitionTraitementPoison()) +
293
			"&csc_truk_acquisition_traitement_poison=" + URL.encodeComponent(conservation.getAcquisitionTraitementPoison()) +
291
			"&csc_truk_acquisition_traitement_insecte =" + URL.encodeComponent(conservation.getAcquisitionTraitementInsecte()) +
294
			"&csc_truk_acquisition_traitement_insecte=" + URL.encodeComponent(conservation.getAcquisitionTraitementInsecte()) +
292
			"&csv_mark_action =" + URL.encodeComponent(valorisation.getAction()) +
295
			"&csv_mark_action=" + URL.encodeComponent(valorisation.getAction()) +
293
			"&csv_truk_action =" + URL.encodeComponent(valorisation.getActionInfo()) +
296
			"&csv_truk_action=" + URL.encodeComponent(valorisation.getActionInfo()) +
294
			"&csv_publication =" + URL.encodeComponent(valorisation.getPublication()) +
297
			"&csv_publication=" + URL.encodeComponent(valorisation.getPublication()) +
295
			"&csv_collection_autre =" + URL.encodeComponent(valorisation.getCollectionAutre()) +
298
			"&csv_collection_autre=" + URL.encodeComponent(valorisation.getCollectionAutre()) +
296
			"&csv_mark_action_future =" + URL.encodeComponent(valorisation.getActionFuture()) +
299
			"&csv_mark_action_future=" + URL.encodeComponent(valorisation.getActionFuture()) +
297
			"&csv_action_future =" + URL.encodeComponent(valorisation.getActionFutureInfo()) +
300
			"&csv_action_future=" + URL.encodeComponent(valorisation.getActionFutureInfo()) +
298
			"&csv_mark_recherche =" + URL.encodeComponent(valorisation.getRecherche()) +
301
			"&csv_mark_recherche=" + URL.encodeComponent(valorisation.getRecherche()) +
299
			"&csv_truk_recherche_provenance =" + URL.encodeComponent(valorisation.getRechercheProvenance()) +
302
			"&csv_truk_recherche_provenance=" + URL.encodeComponent(valorisation.getRechercheProvenance()) +
300
			"&csv_truk_recherche_type =" + URL.encodeComponent(valorisation.getRechercheType()) +
303
			"&csv_truk_recherche_type=" + URL.encodeComponent(valorisation.getRechercheType()) +
301
			"&csv_mark_acces_ss_motif =" + URL.encodeComponent(valorisation.getAccesSansMotif()) +
304
			"&csv_mark_acces_ss_motif=" + URL.encodeComponent(valorisation.getAccesSansMotif()) +
302
			"&csv_acces_ss_motif =" + URL.encodeComponent(valorisation.getAccesSansMotifInfo()) +
305
			"&csv_acces_ss_motif=" + URL.encodeComponent(valorisation.getAccesSansMotifInfo()) +
Line 303... Line 306...
303
			"&csv_mark_visite_avec_motif =" + URL.encodeComponent(valorisation.getVisiteAvecMotif()) +
306
			"&csv_mark_visite_avec_motif=" + URL.encodeComponent(valorisation.getVisiteAvecMotif()) +
304
			"&csv_visite_avec_motif =" + URL.encodeComponent(valorisation.getVisiteAvecMotifInfo()) +
307
			"&csv_visite_avec_motif=" + URL.encodeComponent(valorisation.getVisiteAvecMotifInfo()) +