/branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureAPersonne.java |
---|
New file |
0,0 → 1,295 |
package org.tela_botanica.client.modeles.structure; |
import java.util.Iterator; |
import java.util.Set; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.personne.Personne; |
import com.google.gwt.json.client.JSONObject; |
public class StructureAPersonne extends aDonnee { |
private static final long serialVersionUID = -7265602594281982891L; |
public static final String PREFIXE = "csap"; |
public static final String FONCTION_DIRECTEUR = "2028"; |
public static final String FONCTION_CONSERVATEUR = "2029"; |
public static final String FONCTION_TECHNICIEN = "2030"; |
public static final String ROLE_ADMIN = "2026"; |
public static final String ROLE_EQUIPE = "2027"; |
public static final String ETAT_AJOUTE = "A"; |
public StructureAPersonne() { |
// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet |
set("contact", false); |
set("fonction", ""); |
set("statut", ""); |
set("travail", 0); |
} |
public StructureAPersonne(JSONObject personnel) { |
// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet |
set("contact", false); |
set("fonction", ""); |
set("statut", ""); |
set("travail", 0); |
// L'objet JSON est une table de hachage |
Set<String> im = personnel.keySet(); |
// Parcourt pour chaque clé |
for (Iterator<String> it = im.iterator(); it.hasNext();) { |
// Si elle est associée à une valeur, nous l'ajoutons |
String cle = it.next(); |
if (cle.startsWith(PREFIXE+"_")) { |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", ""); |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = ""; |
if (personnel.get(cle).isString() != null) { |
valeur = personnel.get(cle).isString().stringValue(); |
} |
set(cleObjet, valeur); |
if (cle.equals("mark_contact")) { |
set("contact", (valeur.equals("1") ? true : false)); |
} else if (cle.equals("bota_travail_hebdo_tps")) { |
set("travail", Integer.parseInt(valeur)); |
} |
} |
if (cle.startsWith(Personne.PREFIXE+"_")) { |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", ""); |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = ""; |
if (personnel.get(cle).isString() != null) { |
valeur = personnel.get(cle).isString().stringValue(); |
} |
if (cleObjet.equals("truk_telephone")) { |
set("telephone", valeur); |
set("tel_fix", getInfoDenormaliseParType(valeur, Personne.TELEPHONE_FIXE)); |
set("tel_fax", getInfoDenormaliseParType(valeur, Personne.TELEPHONE_FAX)); |
} else if (cleObjet.equals("truk_courriel")) { |
set("courriel", getInfoDenormaliseParPosition(valeur, 1)); |
} else if (cleObjet.equals("ce_truk_specialite")) { |
set("specialite", getInfoDenormaliseParPosition(valeur, 1)); |
} else { |
set(cleObjet, valeur); |
} |
} |
} |
} |
/** |
* Constructeur avec la fonction à passer en paramètre |
* |
* @param fonction fonction de la personne dans la structure. |
* @param role identifiant du rôle de la personne vis à vis de la structure. |
*/ |
public StructureAPersonne(String fonction, String roleId) { |
setFonction(fonction); |
setIdRole(roleId); |
// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet |
set("contact", false); |
set("fonction", fonction); |
set("statut", ""); |
set("travail", 0); |
} |
/** |
* Constructeur avec la fonction à passer en paramètre |
* |
* @param fonction fonction de la personne dans la structure. |
* @param role identifiant du rôle de la personne vis à vis de la structure. |
*/ |
public StructureAPersonne(String fonction, String roleId, String codeEtat) { |
setFonction(fonction); |
setIdRole(roleId); |
// Définition des valeurs par défaut de variables obligatoires vis à vis de l'utilisation de l'objet |
set("contact", false); |
set("fonction", fonction); |
set("statut", ""); |
set("travail", 0); |
set("etat", codeEtat); |
} |
@Override |
protected String getPrefixe() { |
return PREFIXE; |
} |
// ID |
/** Génère un identifiant de StructureAPersonne. |
* |
* C'est une concaténation des clés primaires de la table coel_structure_a_personne séparées par un tiret "-". |
* |
* @return identifiant unique d'une relation "structure à personne". |
*/ |
public String getId() { |
String idStructure = renvoyerValeurCorrecte("id_structure"); |
String idPersonne = renvoyerValeurCorrecte("id_personne"); |
String idRole = renvoyerValeurCorrecte("id_role"); |
if (idStructure.equals("") && idPersonne.equals("") && idRole.equals("")) { |
return null; |
} else { |
return (idStructure+"-"+idPersonne+"-"+idRole); |
} |
} |
//+---------------------------------------------------------------------------------------------------------------+ |
// CHAMPS PROVENANT de la TABLE COEL_STRUCTURE_A_PERSONNE |
// ID STRUCTURE |
public String getIdStructure() { |
return renvoyerValeurCorrecte("id_structure"); |
} |
public void setIdStructure(String is) { |
set("id_structure", is); |
} |
// ID PERSONNE |
public String getIdPersonne() { |
return renvoyerValeurCorrecte("id_personne"); |
} |
public void setIdPersonne(String ip) { |
set("id_personne", ip); |
} |
// ID RôLE |
public String getIdRole() { |
return renvoyerValeurCorrecte("id_role"); |
} |
public void setIdRole(String ir) { |
set("id_role", ir); |
} |
// FONCTION |
public String getFonction() { |
return renvoyerValeurCorrecte("ce_truk_fonction"); |
} |
public void setFonction(String ctf) { |
set("ce_truk_fonction", ctf); |
} |
public void setFonction(String type, String valeur) { |
setChaineDenormaliseUnique("ce_truk_fonction", type, valeur); |
} |
// SERVICE |
public String getService() { |
return renvoyerValeurCorrecte("service"); |
} |
public void setService(String s) { |
set("service", s); |
} |
// STATUT |
public String getStatut() { |
return renvoyerValeurCorrecte("ce_truk_statut"); |
} |
public void setStatut(String cts) { |
set("ce_truk_statut", cts); |
} |
public void setStatut(String type, String valeur) { |
setChaineDenormaliseUnique("ce_truk_statut", type, valeur); |
} |
// CONTACT |
public String getContact() { |
return renvoyerValeurCorrecte("mark_contact"); |
} |
public void setContact(String c) { |
//set("contact", (c.equals("1") ? true : false)); |
set("mark_contact", c); |
} |
public void setContact(Boolean c) { |
setContact((c.equals(Boolean.TRUE) ? "1" : "0")); |
} |
// BOTA TRAVAIL HEBDO TPS |
public String getBotaTravailHebdoTps() { |
return renvoyerValeurCorrecte("bota_travail_hebdo_tps"); |
} |
public void setBotaTravailHebdoTps(String btht) { |
set("bota_travail_hebdo_tps", btht); |
} |
//+---------------------------------------------------------------------------------------------------------------+ |
// CHAMPS PROVENANT de la TABLE COEL_PERSONNE |
// ID PROJET PERSONNE |
public String getIdProjetPersonne() { |
return renvoyerValeurCorrecte("ce_projet"); |
} |
public void setIdProjetPersonne(String ipp) { |
set("ce_projet", ipp); |
} |
// PRÉNOM |
public String getPrenom() { |
return renvoyerValeurCorrecte("prenom"); |
} |
public void setPrenom(String prenom) { |
set("prenom", prenom); |
} |
// NOM |
public String getNom() { |
return renvoyerValeurCorrecte("nom"); |
} |
public void setNom(String nom) { |
set("nom", nom); |
} |
// TÉLÉPHONE |
public String getTelephone() { |
return renvoyerValeurCorrecte("telephone"); |
} |
public void setTelephone(String tel) { |
set("telephone", tel); |
} |
// TÉLÉPHONE FIXE |
public String getTelephoneFixe() { |
return getInfoDenormaliseParType(renvoyerValeurCorrecte("telephone"), Personne.TELEPHONE_FIXE); |
} |
public void setTelephoneFixe(String fixe) { |
// Nous remplaçons le premier numéro de Téléphone FIX de la personne |
modifierChaineDenormaliseParType("telephone", Personne.TELEPHONE_FIXE, fixe); |
} |
// TÉLÉPHONE FAX |
public String getFax() { |
return getInfoDenormaliseParType(renvoyerValeurCorrecte("telephone"), Personne.TELEPHONE_FAX); |
} |
public void setFax(String fax) { |
// Nous remplaçons le premier numéro de FAX de la personne |
modifierChaineDenormaliseParType("telephone", Personne.TELEPHONE_FAX, fax); |
} |
// COURRIEL |
public String getCourriel() { |
return renvoyerValeurCorrecte("courriel"); |
} |
public void setCourriel(String courriel) { |
// Nous remplaçons le courriel en position 1 (principal) |
this.modifierChaineDenormaliseParPosition("courriel", 1, courriel); |
} |
public String selectionnerCourriel(int position) { |
return getInfoDenormaliseParPosition(renvoyerValeurCorrecte("courriel"), position); |
} |
// SPÉCIALITÉ |
public String getSpecialite() { |
return renvoyerValeurCorrecte("specialite"); |
} |
public void setSpecialite(String specialite) { |
setChaineDenormaliseUnique("specialite", "AUTRE", specialite); |
} |
public String afficherSpecialite() { |
return getChaineDenormaliseUnique("specialite"); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureConservation.java |
---|
New file |
0,0 → 1,231 |
package org.tela_botanica.client.modeles.structure; |
import java.util.Iterator; |
import java.util.Set; |
import org.tela_botanica.client.modeles.aDonnee; |
import com.google.gwt.json.client.JSONObject; |
public class StructureConservation extends aDonnee { |
private static final long serialVersionUID = -4556005804101933910L; |
public static final String PREFIXE = "csc"; |
public StructureConservation() { |
} |
public StructureConservation(JSONObject conservation) { |
// L'objet JSON est une table de hachage |
Set<String> im = conservation.keySet(); |
// Parcourt pour chaque clé |
for (Iterator<String> it = im.iterator(); it.hasNext();) { |
// Si elle est associée à une valeur, nous l'ajoutons |
String cle = it.next(); |
if (cle.startsWith(PREFIXE+"_")) { |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", ""); |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = ""; |
if (conservation.get(cle).isString() != null) { |
valeur = conservation.get(cle).isString().stringValue(); |
} |
this.set(cleObjet, valeur); |
} |
} |
} |
@Override |
protected String getPrefixe() { |
return PREFIXE; |
} |
// FORMATION |
public String getFormation() { |
return renvoyerValeurCorrecte("mark_formation"); |
} |
public void setFormation(String f) { |
this.set("mark_formation", f); |
} |
// FORMATION INFO |
public String getFormationInfo() { |
return renvoyerValeurCorrecte("formation"); |
} |
public void setFormationInfo(String f) { |
this.set("formation", f); |
} |
// FORMATION INTÉRÊT |
public String getFormationInteret() { |
return renvoyerValeurCorrecte("mark_formation_interet"); |
} |
public void setFormationInteret(String f) { |
this.set("mark_formation_interet", f); |
} |
// STOCKAGE LOCAL |
public String getStockageLocal() { |
return renvoyerValeurCorrecte("truk_stockage_local"); |
} |
public void setStockageLocal(String sl) { |
this.set("truk_stockage_local", sl); |
} |
public void setStockageLocal(String type, Object valeur) { |
remplacerTypeDansChaineDenormalise("truk_stockage_local", type, valeur); |
} |
// STOCKAGE MEUBLE |
public String getStockageMeuble() { |
return renvoyerValeurCorrecte("truk_stockage_meuble"); |
} |
public void setStockageMeuble(String sm) { |
this.set("truk_stockage_meuble", sm); |
} |
public void setStockageMeuble(String type, Object valeur) { |
remplacerTypeDansChaineDenormalise("truk_stockage_meuble", type, valeur); |
} |
// STOCKAGE PARAMÊTRE |
public String getStockageParametre() { |
return renvoyerValeurCorrecte("truk_stockage_parametre"); |
} |
public void setStockageParametre(String sl) { |
this.set("truk_stockage_parametre", sl); |
} |
public void setStockageParametre(String type, Object valeur) { |
remplacerTypeDansChaineDenormalise("truk_stockage_parametre", type, valeur); |
} |
// COLLECTION COMMUNE |
public String getCollectionCommune() { |
return renvoyerValeurCorrecte("mark_collection_commune"); |
} |
public void setCollectionCommune(String ccm) { |
this.set("mark_collection_commune", ccm); |
} |
// COLLECTION AUTRE |
public String getCollectionAutre() { |
return renvoyerValeurCorrecte("truk_collection_autre"); |
} |
public void setCollectionAutre(String ca) { |
this.set("truk_collection_autre", ca); |
} |
public void setCollectionAutre(String type, Object valeur) { |
remplacerTypeDansChaineDenormalise("truk_collection_autre", type, valeur); |
} |
// ACCÈS CONTROLÉ |
public String getAccesControle() { |
return renvoyerValeurCorrecte("mark_acces_controle"); |
} |
public void setAccesControle(String ac) { |
this.set("mark_acces_controle", ac); |
} |
// RESTAURATION |
public String getRestauration() { |
return renvoyerValeurCorrecte("mark_restauration"); |
} |
public void setRestauration(String ccm) { |
this.set("mark_restauration", ccm); |
} |
// RESTAURATION OPÉRATION |
public String getRestaurationOperation() { |
return renvoyerValeurCorrecte("truk_restauration_operation"); |
} |
public void setRestaurationOperation(String ro) { |
this.set("truk_restauration_operation", ro); |
} |
public void setRestaurationOperation(String type, Object valeur) { |
ajouterChaineDenormaliseAvecType("truk_restauration_operation", type, valeur); |
} |
// MATERIEL CONSERVATION |
public String getMaterielConservation() { |
return renvoyerValeurCorrecte("ce_materiel_conservation"); |
} |
public void setMaterielConservation(String mc) { |
this.set("ce_materiel_conservation", mc); |
} |
// MATERIEL AUTRE |
public String getMaterielAutre() { |
return renvoyerValeurCorrecte("truk_materiel_autre"); |
} |
public void setMaterielAutre(String ma) { |
this.set("truk_materiel_autre", ma); |
} |
public void setMaterielAutre(String type, Object valeur) { |
ajouterChaineDenormaliseAvecType("truk_materiel_autre", type, valeur); |
} |
// TRAITEMENT |
public String getTraitement() { |
return renvoyerValeurCorrecte("mark_traitement"); |
} |
public void setTraitement(String t) { |
this.set("mark_traitement", t); |
} |
// TRAITEMENTS |
public String getTraitements() { |
return renvoyerValeurCorrecte("truk_traitement"); |
} |
public void setTraitements(String t) { |
this.set("truk_traitement", t); |
} |
public void setTraitements(String type, Object valeur) { |
ajouterChaineDenormaliseAvecType("truk_traitement", type, valeur); |
} |
// ACQUISITION COLLECTION |
public String getAcquisitionCollection() { |
return renvoyerValeurCorrecte("mark_acquisition_collection"); |
} |
public void setAcquisitionCollection(String ac) { |
this.set("mark_acquisition_collection", ac); |
} |
// ACQUISITION ECHANTILLON |
public String getAcquisitionEchantillon() { |
return renvoyerValeurCorrecte("mark_acquisition_echantillon"); |
} |
public void setAcquisitionEchantillon(String ae) { |
this.set("mark_acquisition_echantillon", ae); |
} |
// ACQUISITION TRAITEMENT |
public String getAcquisitionTraitement() { |
return renvoyerValeurCorrecte("mark_acquisition_traitement"); |
} |
public void setAcquisitionTraitement(String at) { |
this.set("mark_acquisition_traitement", at); |
} |
// ACQUISITION TRAITEMENT POISON |
public String getAcquisitionTraitementPoison() { |
return renvoyerValeurCorrecte("truk_acquisition_traitement_poison"); |
} |
public void setAcquisitionTraitementPoison(String atp) { |
this.set("truk_acquisition_traitement_poison", atp); |
} |
public void setAcquisitionTraitementPoison(String type, Object valeur) { |
ajouterChaineDenormaliseAvecType("truk_acquisition_traitement_poison", type, valeur); |
} |
// ACQUISITION TRAITEMENT INSECTE |
public String getAcquisitionTraitementInsecte() { |
return renvoyerValeurCorrecte("truk_acquisition_traitement_insecte"); |
} |
public void setAcquisitionTraitementInsecte(String ati) { |
this.set("truk_acquisition_traitement_insecte", ati); |
} |
public void setAcquisitionTraitementInsecte(String type, Object valeur) { |
ajouterChaineDenormaliseAvecType("truk_acquisition_traitement_insecte", type, valeur); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureValorisation.java |
---|
New file |
0,0 → 1,162 |
package org.tela_botanica.client.modeles.structure; |
import java.util.Iterator; |
import java.util.Set; |
import org.tela_botanica.client.modeles.aDonnee; |
import com.google.gwt.json.client.JSONObject; |
public class StructureValorisation extends aDonnee { |
private static final long serialVersionUID = 8906713360999774621L; |
public static final String PREFIXE = "csv"; |
public StructureValorisation() { |
} |
public StructureValorisation(JSONObject valorisation) { |
// L'objet JSON est une table de hachage |
Set<String> im = valorisation.keySet(); |
// Parcourt pour chaque clé |
for (Iterator<String> it = im.iterator(); it.hasNext();) { |
// Si elle est associée à une valeur, nous l'ajoutons |
String cle = it.next(); |
if (cle.startsWith(PREFIXE+"_")) { |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", ""); |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = ""; |
if (valorisation.get(cle).isString() != null) { |
valeur = valorisation.get(cle).isString().stringValue(); |
} |
this.set(cleObjet, valeur); |
} |
} |
} |
@Override |
protected String getPrefixe() { |
return PREFIXE; |
} |
// ACTION |
public String getAction() { |
return renvoyerValeurCorrecte("mark_action"); |
} |
public void setAction(String a) { |
this.set("mark_action", a); |
} |
// ACTION INFO |
public String getActionInfo() { |
return renvoyerValeurCorrecte("truk_action"); |
} |
public void setActionInfo(String a) { |
this.set("truk_action", a); |
} |
public void setActionInfo(String type, Object valeur) { |
remplacerTypeDansChaineDenormalise("truk_action", type, valeur); |
} |
// PUBLICATION |
public String getPublication() { |
return renvoyerValeurCorrecte("publication"); |
} |
public void setPublication(String p) { |
this.set("publication", p); |
} |
// COLLECTION AUTRE |
public String getCollectionAutre() { |
return renvoyerValeurCorrecte("collection_autre"); |
} |
public void setCollectionAutre(String ca) { |
this.set("collection_autre", ca); |
} |
public void setCollectionAutre(String type, Object valeur) { |
remplacerTypeDansChaineDenormalise("collection_autre", type, valeur); |
} |
// ACTION FUTURE |
public String getActionFuture() { |
return renvoyerValeurCorrecte("mark_action_future"); |
} |
public void setActionFuture(String af) { |
this.set("mark_action_future", af); |
} |
// ACTION FUTURE INFO |
public String getActionFutureInfo() { |
return renvoyerValeurCorrecte("action_future"); |
} |
public void setActionFutureInfo(String af) { |
this.set("action_future", af); |
} |
// RECHERCHE |
public String getRecherche() { |
return renvoyerValeurCorrecte("mark_recherche"); |
} |
public void setRecherche(String r) { |
this.set("mark_recherche", r); |
} |
// RECHERCHE PROVENANCE |
public String getRechercheProvenance() { |
return renvoyerValeurCorrecte("truk_recherche_provenance"); |
} |
public void setRechercheProvenance(String rp) { |
this.set("truk_recherche_provenance", rp); |
} |
public void setRechercheProvenance(String type, Object valeur) { |
remplacerTypeDansChaineDenormalise("truk_recherche_provenance", type, valeur); |
} |
// RECHERCHE TYPE |
public String getRechercheType() { |
return renvoyerValeurCorrecte("truk_recherche_type"); |
} |
public void setRechercheType(String rt) { |
this.set("truk_recherche_type", rt); |
} |
public void setRechercheType(String type, Object valeur) { |
remplacerTypeDansChaineDenormalise("truk_recherche_type", type, valeur); |
} |
// ACCES SANS MOTIF |
public String getAccesSansMotif() { |
return renvoyerValeurCorrecte("mark_acces_ss_motif"); |
} |
public void setAccesSansMotif(String asm) { |
this.set("mark_acces_ss_motif", asm); |
} |
// ACCES SANS MOTIF INFO |
public String getAccesSansMotifInfo() { |
return renvoyerValeurCorrecte("acces_ss_motif"); |
} |
public void setAccesSansMotifInfo(String asm) { |
this.set("acces_ss_motif", asm); |
} |
// VISITE AVEC MOTIF |
public String getVisiteAvecMotif() { |
return renvoyerValeurCorrecte("mark_visite_avec_motif"); |
} |
public void setVisiteAvecMotif(String vam) { |
this.set("mark_visite_avec_motif", vam); |
} |
// VISITE AVEC MOTIF INFO |
public String getVisiteAvecMotifInfo() { |
return renvoyerValeurCorrecte("visite_avec_motif"); |
} |
public void setVisiteAvecMotifInfo(String vam) { |
this.set("visite_avec_motif", vam); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureAPersonneListe.java |
---|
New file |
0,0 → 1,41 |
package org.tela_botanica.client.modeles.structure; |
import org.tela_botanica.client.modeles.aDonneeListe; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONObject; |
/** |
* Table de hachage composée d'informations sur les Structures et les Personnes, renvoyé par un objet de type DAO |
* La clé est une concaténation des clés primaires de la table coel_structure_a_personne séparées par un tiret "-". |
* |
* @author david delon |
* |
*/ |
public class StructureAPersonneListe extends aDonneeListe<StructureAPersonne> { |
private static final long serialVersionUID = -2000442795474013672L; |
public StructureAPersonneListe() { |
super(); |
} |
public StructureAPersonneListe(int taille) { |
super(taille); |
} |
public StructureAPersonneListe(JSONArray structures) { |
super(structures.size()) ; |
final int taillemax = structures.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject structureAPersonneCourante = structures.get(i).isObject() ; |
if (structureAPersonneCourante != null) { |
StructureAPersonne structureAPersonne = new StructureAPersonne(structureAPersonneCourante); |
this.put(structureAPersonne.getId(), structureAPersonne); |
} |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureAPersonneAsyncDao.java |
---|
New file |
0,0 → 1,137 |
package org.tela_botanica.client.modeles.structure; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.http.JsonRestRequestBuilder; |
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.util.UtilDAO; |
import com.extjs.gxt.ui.client.Registry; |
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.JSONValue; |
public class StructureAPersonneAsyncDao { |
private static final String SERVICE_NOM = "CoelStructureAPersonne"; |
private String utilisateurId = null; |
private Rafraichissable vueARafraichir = null; |
public StructureAPersonneAsyncDao(Rafraichissable vueARafraichirCourrante) { |
vueARafraichir = vueARafraichirCourrante; |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId(); |
} |
public void selectionner(final String structureId, final String roleId) { |
String[] parametres = {structureId, roleId}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres); |
rb.envoyerRequete(null, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
Information info = new Information("liste_structure_a_personne"); |
if (responseValue != null) { |
// Si la requête est un succès, reception d'un tableau |
if (responseValue.isArray() != null) { |
final JSONArray reponse = responseValue.isArray(); |
// Transformation du tableau JSON réponse en ListeInstitution |
StructureAPersonneListe personnel = new StructureAPersonneListe(reponse); |
info.setDonnee(0, personnel); |
// et on met à jour le demandeur des données |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas un talbeau JSON et vaut : "+responseValue.toString(), null); |
} |
} else { |
if (structureId == null) { |
// 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 |
info.setMessage("Aucun personnel"); |
vueARafraichir.rafraichir(info); |
} |
} |
} |
}); |
} |
public void ajouter(String structureId, StructureAPersonne personnel) { |
String postDonneesEncodees = construirePost(structureId, personnel); |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM); |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
// Si la requête est un succès, reception d'une chaine |
if (responseValue.isString() != null) { |
Information info = new Information("ajout_structure_a_personne"); |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
public void modifier(StructureAPersonne personnel) { |
String[] parametres = {personnel.getIdStructure(), personnel.getIdPersonne(), personnel.getIdRole()}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres); |
String postDonneesEncodees = construirePost(personnel.getIdStructure(), personnel); |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
Information info = new Information("modif_structure_a_personne"); |
// Si la requête est un succès, reception d'une chaine |
if (responseValue.isString() != null) { |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
public void supprimer(String idStrAPer) { |
String[] parametres = {utilisateurId, idStrAPer}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres); |
rb.envoyerRequeteSuppression(new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
if (responseValue.isString() != null) { |
Information info = new Information("suppression_structure_a_personne"); |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
private String construirePost(String structureId, StructureAPersonne personnel) { |
String postDonnees = "cmhl_ce_modifier_par=" + URL.encodeComponent(utilisateurId); |
if (!personnel.getIdPersonne().equals("")) { |
postDonnees += "&csap_id_personne=" + URL.encodeComponent(personnel.getIdPersonne()) + |
"&cp_id_personne=" + URL.encodeComponent(personnel.getIdPersonne()); |
} |
postDonnees += "&csap_id_structure=" + URL.encodeComponent(structureId) + |
"&csap_id_role=" + URL.encodeComponent(personnel.getIdRole()) + |
"&csap_ce_truk_fonction=" + URL.encodeComponent(personnel.getFonction()) + |
"&csap_service=" + URL.encodeComponent(personnel.getService()) + |
"&csap_ce_truk_statut=" + URL.encodeComponent(personnel.getStatut()) + |
"&csap_mark_contact=" + URL.encodeComponent(personnel.getContact()) + |
"&csap_bota_travail_hebdo_tps=" + URL.encodeComponent(personnel.getBotaTravailHebdoTps()) + |
"&cp_ce_projet=" + URL.encodeComponent(personnel.getIdProjetPersonne()) + |
"&cp_prenom=" + URL.encodeComponent(personnel.getPrenom()) + |
"&cp_nom=" + URL.encodeComponent(personnel.getNom()) + |
"&cp_truk_telephone=" + URL.encodeComponent(personnel.getTelephone()) + |
"&cp_truk_courriel=" + URL.encodeComponent(personnel.getCourriel()) + |
"&cp_ce_truk_specialite=" + URL.encodeComponent(personnel.getSpecialite()) + |
""; |
return postDonnees; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/Structure.java |
---|
New file |
0,0 → 1,336 |
package org.tela_botanica.client.modeles.structure; |
import java.util.Date; |
import java.util.Iterator; |
import java.util.Set; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.personne.Personne; |
import com.extjs.gxt.ui.client.data.BaseModelData; |
import com.google.gwt.i18n.client.DateTimeFormat; |
import com.google.gwt.json.client.JSONObject; |
public class Structure extends aDonnee { |
private static final long serialVersionUID = -5623886668593288218L; |
public static final String PREFIXE = "cs"; |
public static final String URL_SITE = "WEB"; |
public static final String URL_LOGO = "LOGO"; |
private BaseModelData urls = null; |
private StructureAPersonneListe personnel = null; |
private StructureValorisation valorisation = null; |
private StructureConservation conservation = null; |
public Structure() { |
// Constructions du tableau des urls interne |
urls = new BaseModelData(); |
} |
public Structure(JSONObject institution) { |
// Constructions du tableau des urls interne |
urls = new BaseModelData(); |
// l'objet JSON est une table de hachage |
Set<String> im = institution.keySet(); |
// Parcourt pour chaque clé |
for (Iterator<String> it = im.iterator(); it.hasNext();) { |
// Si elle est associée à une valeur, nous l'ajoutons |
String cle = it.next(); |
if (cle.startsWith(PREFIXE+"_")) { |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", ""); |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = ""; |
if (institution.get(cle).isString() != null) { |
valeur = institution.get(cle).isString().stringValue(); |
} |
if (cleObjet.equals("truk_url")) { |
this.setUrl(valeur); |
} else { |
this.set(cleObjet, valeur); |
} |
} |
} |
} |
@Override |
protected String getPrefixe() { |
return PREFIXE; |
} |
public String getId() { |
return renvoyerValeurCorrecte("id_structure"); |
} |
public void setId(String idStructure) { |
this.set("id_structure", idStructure); |
} |
public String getIdProjet() { |
return renvoyerValeurCorrecte("ce_projet"); |
} |
public void setIdProjet(String idProjet) { |
this.set("ce_projet", idProjet); |
} |
public String getIdMere() { |
return renvoyerValeurCorrecte("ce_mere"); |
} |
public void setIdMere(String idMere) { |
this.set("ce_mere", idMere); |
} |
public String getGuid() { |
return renvoyerValeurCorrecte("guid"); |
} |
public void setGuid(String guid) { |
this.set("guid", guid); |
} |
public String getIdAlternatif() { |
return renvoyerValeurCorrecte("truk_identifiant_alternatif"); |
} |
public void setIdAlternatif(String idAlter) { |
this.set("truk_identifiant_alternatif", idAlter); |
} |
public String getNom() { |
return renvoyerValeurCorrecte("nom"); |
} |
public void setNom(String nom) { |
this.set("nom", nom); |
} |
public String getNomAlternatif() { |
return renvoyerValeurCorrecte("truk_nom_alternatif"); |
} |
public String getDescription() { |
return renvoyerValeurCorrecte("description"); |
} |
public String getType() { |
return renvoyerValeurCorrecte("ce_type"); |
} |
public void setType(String type) { |
this.set("ce_type", type); |
} |
public String getTypePrive() { |
return renvoyerValeurCorrecte("ce_truk_type_prive"); |
} |
public void setTypePrive(String typePrive) { |
this.set("ce_truk_type_prive", typePrive); |
} |
public String getTypePublic() { |
return renvoyerValeurCorrecte("ce_truk_type_public"); |
} |
public void setTypePublic(String typePublic) { |
this.set("ce_truk_type_public", typePublic); |
} |
public String getAdresse() { |
return (String) renvoyerValeurCorrecte("adresse_01"); |
} |
public void setAdresse(String adr) { |
this.set("adresse_01", adr); |
} |
public String getAdresseComplement() { |
return renvoyerValeurCorrecte("adresse_02"); |
} |
public String getDateFondationFormatMysql() { |
return renvoyerValeurCorrecte("date_fondation"); |
} |
public String getDateFondationFormatLong() { |
String dateFormatee = ""; |
Date dateFondation = getDateFondation(); |
if (dateFondation != null) { |
dateFormatee = DateTimeFormat.getLongDateFormat().format(dateFondation); |
} |
return dateFormatee; |
} |
public Date getDateFondation() { |
Date fondationDate = null; |
String fondationChaine = renvoyerValeurCorrecte("date_fondation"); |
if (!fondationChaine.isEmpty() && !fondationChaine.equals("0000-00-00")) { |
fondationDate = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(fondationChaine); |
} |
return fondationDate; |
} |
public void setDateFondation(Date dateFondation) { |
if (dateFondation != null) { |
this.set("date_fondation", DateTimeFormat.getFormat("yyyy-MM-dd").format(dateFondation)); |
} |
} |
public void setDateFondation(String dateFondation) { |
if (dateFondation != null) { |
this.set("date_fondation", dateFondation); |
} |
} |
public String getCodePostal() { |
return renvoyerValeurCorrecte("code_postal"); |
} |
public void setCodePostal(String codePostal) { |
this.set("code_postal", codePostal); |
} |
public String getVille() { |
return renvoyerValeurCorrecte("ville"); |
} |
public void setVille(String ville) { |
this.set("ville", ville); |
} |
public String getRegion() { |
return getChaineDenormaliseUnique("ce_truk_region"); |
} |
public void setRegion(String region) { |
this.set("ce_truk_region", region); |
} |
public String getPays() { |
return getChaineDenormaliseUnique("ce_truk_pays"); |
} |
public void setPays(String pays) { |
this.set("ce_truk_pays", pays); |
} |
public String getLatitude() { |
return renvoyerValeurCorrecte("latitude"); |
} |
public String getLongitude() { |
return renvoyerValeurCorrecte("longitude"); |
} |
// TELEPHONE |
public String getTelephone() { |
return renvoyerValeurCorrecte("truk_telephone"); |
} |
public void setTelephone(String tel) { |
this.set("truk_telephone", tel); |
} |
// TELEPHONE FIXE |
public String getTelephoneFixe() { |
return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), Personne.TELEPHONE_FIXE); |
} |
public void setTelephoneFixe(String fixe) { |
modifierChaineDenormaliseParType("truk_telephone", Personne.TELEPHONE_FIXE, fixe); |
} |
//TELEPHONE FAX |
public String getFax() { |
return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), Personne.TELEPHONE_FAX); |
} |
public void setFax(String fax) { |
modifierChaineDenormaliseParType("truk_telephone", Personne.TELEPHONE_FAX, fax); |
} |
// COURRIEL |
public String getCourriel() { |
return renvoyerValeurCorrecte("courriel"); |
} |
public void setCourriel(String courriel) { |
this.set("courriel", courriel); |
} |
// URL |
public String getUrl(String type) { |
return urls.get(type); |
} |
public String getUrl() { |
String urlsDenormalise = ""; |
Set<String> proprietes = urls.getProperties().keySet(); |
for (Iterator<String> it = proprietes.iterator(); it.hasNext();) { |
String cle = it.next(); |
urlsDenormalise += cle+"##"+urls.get(cle)+";;"; |
} |
urlsDenormalise.replaceFirst(";;$", ""); |
return urlsDenormalise; |
} |
public void setUrl(String urlsDenormalise) { |
if (urlsDenormalise != null && !urlsDenormalise.equals("")) { |
//GWT.log(urlsDenormalise, null); |
String[] tableauUrls = urlsDenormalise.split(";;"); |
for (int i = 0; i < tableauUrls.length; i++) { |
String url = tableauUrls[i]; |
//GWT.log("\t"+url, null); |
String[] tableauUrl = url.split("##"); |
if (tableauUrl.length == 2) { |
//GWT.log("\t\t"+tableauUrl[0]+"-"+tableauUrl[1], null); |
urls.set(tableauUrl[0], tableauUrl[1]); |
} |
} |
} |
} |
public void setUrl(String type, String url) { |
if (url != null) { |
urls.set(type, url); |
} |
} |
public int getNbrePersonne() { |
if (renvoyerValeurCorrecte("nbre_personne").equals("")) { |
return 0; |
} else { |
return Integer.parseInt(renvoyerValeurCorrecte("nbre_personne")); |
} |
} |
public void setNbrePersonne(int nbrePersonne) { |
this.set("nbre_personne", Integer.toString(nbrePersonne)); |
} |
public String getConditionAcces() { |
return renvoyerValeurCorrecte("condition_acces"); |
} |
public String getConditionUsage() { |
return renvoyerValeurCorrecte("condition_usage"); |
} |
public StructureAPersonneListe getPersonnel() { |
return personnel; |
} |
public void setPersonnel(StructureAPersonneListe personnelAStocker) { |
personnel = personnelAStocker; |
} |
public StructureValorisation getValorisation() { |
return valorisation; |
} |
public void setValorisation(StructureValorisation valorisationAStocker) { |
valorisation = valorisationAStocker; |
} |
public StructureConservation getConservation() { |
return conservation; |
} |
public void setConservation(StructureConservation conservationAStocker) { |
conservation = conservationAStocker; |
} |
public String toString() { |
String sortie = ""; |
// Champs du BaseModelData |
Set<String> proprietes = this.getProperties().keySet(); |
for (Iterator<String> it = proprietes.iterator(); it.hasNext();) { |
String cle = it.next(); |
sortie += cle+" : "+this.get(cle)+"\n"; |
} |
// Champs spéciaux |
sortie += getUrl(); |
return sortie; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureListe.java |
---|
New file |
0,0 → 1,150 |
package org.tela_botanica.client.modeles.structure; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.interfaces.ListePaginable; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.aDonneeListe; |
import org.tela_botanica.client.modeles.personne.Personne; |
import com.extjs.gxt.ui.client.Registry; |
import com.google.gwt.i18n.client.Dictionary; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONNumber; |
import com.google.gwt.json.client.JSONObject; |
/** |
* Table de hachage composée d'informations sur les Structures, renvoyé par un objet de type DAO |
* La clé est le nom de l'entite + le nom de l'entite parente |
* |
* @author david delon |
* |
*/ |
public class StructureListe extends aDonneeListe<Structure> implements ListePaginable{ |
private static final long serialVersionUID = 7384579567038300856L; |
private int currentPage = 0; |
private int nbElementsPage = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage")); |
private int nbElementsTotal; |
private Rafraichissable vueARafraichir; |
public StructureListe() { |
super(); |
} |
public StructureListe(int taille) { |
super(taille); |
} |
/** |
* Constructeur pour une liste d'institutions |
* @param dates |
*/ |
public StructureListe(JSONArray structures) { |
super(structures.size()) ; |
final int taillemax = structures.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject structureCourante = structures.get(i).isObject() ; |
if (structureCourante != null) { |
Structure structure = new Structure(structureCourante); |
StructureValorisation valorisation = new StructureValorisation(structureCourante); |
structure.setValorisation(valorisation); |
StructureConservation conservation = new StructureConservation(structureCourante); |
structure.setConservation(conservation); |
this.put(structure.getId(), structure); |
} |
} |
} |
public StructureListe(JSONArray structureListe, JSONNumber nbElements, Rafraichissable vueARafraichir) { |
super(structureListe.size()); |
this.nbElementsTotal = Integer.valueOf(nbElements.toString()); |
final int taillemax = structureListe.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject structure = structureListe.get(i).isObject() ; |
if (structure != null) { |
Structure structureCourante = new Structure(structure); |
this.put(structureCourante.getId(), structureCourante); |
} |
} |
this.vueARafraichir = vueARafraichir; |
} |
public void changerNumeroPage(int pageCourante) { |
currentPage = pageCourante; |
selectionnerStructure(); |
} |
public void changerTaillePage(int nouvelleTaillePage) { |
nbElementsPage = nouvelleTaillePage; |
selectionnerStructure(); |
} |
public void recharger() { |
selectionnerStructure(); |
} |
public void setPageCourante(int pageCourante) { |
this.currentPage = pageCourante; |
} |
public void setTaillePage(int taillePage) { |
this.nbElementsPage = taillePage; |
} |
public int[] getPageTable() { |
int[] page = new int[4]; |
// nombre de pages au total |
page[0] = calculerNbPages(); |
// Page En Cours |
page[1] = currentPage; |
// nbElementsParPage |
page[2] = nbElementsPage; |
// et le dernier le nombre total d'éléments |
page[3] = nbElementsTotal; |
return page; |
} |
/** |
* Calcule le nombre de pages nécessaires pour afficher un nombre d'élements |
* donnés en fonction de la taille de page en cours |
* |
* @return le nombre de pages |
*/ |
public int calculerNbPages() { |
// A cause de la betise de java pour les conversion implicite on fait |
// quelques conversions manuellement |
// pour eviter qu'il arrondisse mal la division |
// nombre de pages = (nombre d'element / taille de la page) arrondie à |
// l'entier superieur |
double nPage = (1.0 * nbElementsTotal) / (1.0 * nbElementsPage); |
double nPageRound = Math.ceil(nPage); |
Double nPageInt = new Double(nPageRound); |
// on convertit en entier |
return nPageInt.intValue(); |
} |
public void selectionnerStructure() { |
Mediateur mediateur =(Mediateur) Registry.get(RegistreId.MEDIATEUR); |
mediateur.selectionnerStructure(vueARafraichir, null, null, null, currentPage, nbElementsPage); |
} |
public void filtrerParNom(String nom) { |
Mediateur mediateur =(Mediateur) Registry.get(RegistreId.MEDIATEUR); |
mediateur.selectionnerStructure(vueARafraichir, null, null, "%" + nom + "%", 0, nbElementsPage); |
} |
} |
Property changes: |
Added: svn:mergeinfo |
/branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureAsyncDao.java |
---|
New file |
0,0 → 1,220 |
package org.tela_botanica.client.modeles.structure; |
import java.util.HashMap; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.http.JsonRestRequestBuilder; |
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.personne.PersonneListe; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.util.UtilDAO; |
import com.extjs.gxt.ui.client.Registry; |
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; |
import com.google.gwt.json.client.JSONValue; |
public class StructureAsyncDao { |
private static final String SERVICE_NOM = "CoelStructure"; |
private String utilisateurId = null; |
private Rafraichissable vueARafraichir = null; |
public StructureAsyncDao(Rafraichissable vue) { |
vueARafraichir = vue; |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId(); |
GWT.log("ID utilisateur :"+utilisateurId, null); |
} |
public void selectionner(final String projetId, final String structureId, final String nomStructure, final int pageCourante, final int nbElements) { |
String[] parametres = {projetId, structureId, nomStructure}; |
HashMap<String, String> restrictions = new HashMap<String, String>(); |
restrictions.put("start", String.valueOf(pageCourante*nbElements)); |
if (nbElements != -1) { |
restrictions.put("limit", String.valueOf(nbElements)); |
} |
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions); |
rb.envoyerRequete(null, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
if (responseValue != null) { |
Information info = new Information("selection_structure"); |
// Si la requête est un succès, reception d'un objet ou d'un tableau |
JSONArray responseArray = responseValue.isArray(); |
if (responseArray.get(1).isObject() != null) { |
final JSONObject reponse = responseArray.get(1).isObject(); |
Structure structure = new Structure(reponse); |
StructureConservation structureConservation = new StructureConservation(reponse); |
StructureValorisation structureValorisation = new StructureValorisation(reponse); |
info.setDonnee(0, structure); |
info.setDonnee(1, structureConservation); |
info.setDonnee(2, structureValorisation); |
vueARafraichir.rafraichir(info); |
} else if (responseArray.get(1).isArray() != null) { |
final JSONArray reponse = responseValue.isArray(); |
StructureListe structures; // = new StructureListe(reponse); |
if (reponse.get(1).isObject() != null) { |
structures = new StructureListe(reponse.get(1).isArray()); |
} else { |
structures = new StructureListe(reponse.get(1).isArray(), reponse.get(0).isNumber(), vueARafraichir); |
} |
structures.setTaillePage(nbElements); |
structures.setPageCourante(pageCourante); |
info.setDonnee(0, structures); |
vueARafraichir.rafraichir(structures); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas un objet ou un talbeau JSON et vaut : "+responseValue.toString(), null); |
} |
} else { |
if (structureId == null) { |
// Dans le cas, où nous demandons toutes les institutions et qu'il n'y en a pas, nous retournons un objet vide |
StructureListe structures = new StructureListe(0); |
vueARafraichir.rafraichir(structures); |
} |
} |
} |
}); |
} |
public void ajouter(final Structure str, StructureConservation conservation, StructureValorisation valorisation) { |
String postDonneesEncodees = construirePost(null, str, conservation, valorisation); |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM); |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
if (responseValue.isString() != null) { |
Information info = new Information("ajout_structure"); |
String structureIdOuMessage = responseValue.isString().stringValue(); |
if (structureIdOuMessage.matches("^[0-9]+$")) { |
info.setDonnee(structureIdOuMessage); |
} else { |
info.setMessage(structureIdOuMessage); |
} |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
public void modifier(String structureId, Structure str, StructureConservation conservation, StructureValorisation valorisation) { |
String postDonneesEncodees = construirePost(structureId, str, conservation, valorisation); |
String[] parametres = {structureId}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres); |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
// Si la requête est un succès, reception d'une chaine |
if (responseValue.isString() != null) { |
Information info = new Information("modif_structure"); |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
public void supprimer(String structuresId) { |
String[] parametres = {utilisateurId, structuresId}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres); |
rb.envoyerRequeteSuppression(new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
if (responseValue.isString() != null) { |
Information info = new Information("suppression_structure"); |
info.setMessage(responseValue.isString().stringValue()); |
vueARafraichir.rafraichir(info); |
} else { |
GWT.log(rb.getUrl()+"\n\tLa réponse n'est pas une chaine JSON.", null); |
} |
} |
}); |
} |
private String construirePost(String structureId, Structure str, StructureConservation conservation, StructureValorisation valorisation) { |
String postDonnees = "cmhl_ce_modifier_par=" + URL.encodeComponent(utilisateurId); |
if (str != null) { |
if (structureId != null) { |
postDonnees += "&cs_id_structure=" + URL.encodeComponent(structureId); |
} |
postDonnees += "&cpr_abreviation=" + URL.encodeComponent(((ProjetListe) Registry.get(RegistreId.PROJETS)).get(str.getIdProjet()).getAbreviation()); |
postDonnees += "&cs_ce_projet=" + URL.encodeComponent(str.getIdProjet()) + |
"&cs_ce_mere=" + URL.encodeComponent(str.getIdMere()) + |
"&cs_guid=" + URL.encodeComponent(str.getGuid()) + |
"&cs_truk_identifiant_alternatif=" + URL.encodeComponent(str.getIdAlternatif()) + |
"&cs_nom=" + URL.encodeComponent(str.getNom()) + |
"&cs_truk_nom_alternatif=" + URL.encodeComponent(str.getNomAlternatif()) + |
"&cs_ce_type=" + URL.encodeComponent(str.getType()) + |
"&cs_ce_truk_type_prive=" + URL.encodeComponent(str.getTypePrive()) + |
"&cs_ce_truk_type_public=" + URL.encodeComponent(str.getTypePublic()) + |
"&cs_adresse_01=" + URL.encodeComponent(str.getAdresse()) + |
"&cs_adresse_02=" + URL.encodeComponent(str.getAdresseComplement()) + |
"&cs_date_fondation=" + URL.encodeComponent(str.getDateFondationFormatMysql()) + |
"&cs_code_postal=" + URL.encodeComponent(str.getCodePostal()) + |
"&cs_ville=" + URL.encodeComponent(str.getVille()) + |
"&cs_ce_truk_region=" + URL.encodeComponent(str.get("ce_truk_region").toString()) + |
"&cs_ce_truk_pays=" + URL.encodeComponent(str.getPays()) + |
"&cs_truk_telephone=" + URL.encodeComponent(str.getTelephone()) + |
"&cs_truk_url=" + URL.encodeComponent(str.getUrl()) + |
"&cs_nbre_personne=" + URL.encodeComponent(Integer.toString(str.getNbrePersonne())) + |
"&cs_courriel=" + URL.encodeComponent(str.getCourriel()); |
} |
if (conservation != null) { |
if (structureId != null) { |
postDonnees += "&csc_id_structure=" + URL.encodeComponent(structureId); |
} |
postDonnees += "&csc_mark_formation=" + URL.encodeComponent(conservation.getFormation()) + |
"&csc_formation=" + URL.encodeComponent(conservation.getFormationInfo()) + |
"&csc_mark_formation_interet=" + URL.encodeComponent(conservation.getFormationInteret()) + |
"&csc_truk_stockage_local=" + URL.encodeComponent(conservation.getStockageLocal()) + |
"&csc_truk_stockage_meuble=" + URL.encodeComponent(conservation.getStockageMeuble()) + |
"&csc_truk_stockage_parametre=" + URL.encodeComponent(conservation.getStockageParametre()) + |
"&csc_mark_collection_commune=" + URL.encodeComponent(conservation.getCollectionCommune()) + |
"&csc_truk_collection_autre=" + URL.encodeComponent(conservation.getCollectionAutre()) + |
"&csc_mark_acces_controle=" + URL.encodeComponent(conservation.getAccesControle()) + |
"&csc_mark_restauration=" + URL.encodeComponent(conservation.getRestauration()) + |
"&csc_truk_restauration_operation=" + URL.encodeComponent(conservation.getRestaurationOperation()) + |
"&csc_ce_materiel_conservation=" + URL.encodeComponent(conservation.getMaterielConservation()) + |
"&csc_truk_materiel_autre=" + URL.encodeComponent(conservation.getMaterielAutre()) + |
"&csc_mark_traitement=" + URL.encodeComponent(conservation.getTraitement()) + |
"&csc_truk_traitement=" + URL.encodeComponent(conservation.getTraitements()) + |
"&csc_mark_acquisition_collection=" + URL.encodeComponent(conservation.getAcquisitionCollection()) + |
"&csc_mark_acquisition_echantillon=" + URL.encodeComponent(conservation.getAcquisitionEchantillon()) + |
"&csc_mark_acquisition_traitement=" + URL.encodeComponent(conservation.getAcquisitionTraitement()) + |
"&csc_truk_acquisition_traitement_poison=" + URL.encodeComponent(conservation.getAcquisitionTraitementPoison()) + |
"&csc_truk_acquisition_traitement_insecte=" + URL.encodeComponent(conservation.getAcquisitionTraitementInsecte()); |
} |
if (valorisation != null) { |
if (structureId != null) { |
postDonnees += "&csv_id_structure=" + URL.encodeComponent(structureId); |
} |
postDonnees += "&csv_mark_action=" + URL.encodeComponent(valorisation.getAction()) + |
"&csv_truk_action=" + URL.encodeComponent(valorisation.getActionInfo()) + |
"&csv_publication=" + URL.encodeComponent(valorisation.getPublication()) + |
"&csv_collection_autre=" + URL.encodeComponent(valorisation.getCollectionAutre()) + |
"&csv_mark_action_future=" + URL.encodeComponent(valorisation.getActionFuture()) + |
"&csv_action_future=" + URL.encodeComponent(valorisation.getActionFutureInfo()) + |
"&csv_mark_recherche=" + URL.encodeComponent(valorisation.getRecherche()) + |
"&csv_truk_recherche_provenance=" + URL.encodeComponent(valorisation.getRechercheProvenance()) + |
"&csv_truk_recherche_type=" + URL.encodeComponent(valorisation.getRechercheType()) + |
"&csv_mark_acces_ss_motif=" + URL.encodeComponent(valorisation.getAccesSansMotif()) + |
"&csv_acces_ss_motif=" + URL.encodeComponent(valorisation.getAccesSansMotifInfo()) + |
"&csv_mark_visite_avec_motif=" + URL.encodeComponent(valorisation.getVisiteAvecMotif()) + |
"&csv_visite_avec_motif=" + URL.encodeComponent(valorisation.getVisiteAvecMotifInfo()); |
} |
return postDonnees; |
} |
} |