Subversion Repositories eFlore/Applications.coel

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1369 → Rev 1382

/tags/v1.1-aramon/src/org/tela_botanica/client/modeles/structure/StructureAPersonne.java
New file
0,0 → 1,354
package org.tela_botanica.client.modeles.structure;
 
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
 
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.util.UtilString;
 
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 static String[] champsObligatoires = {"csap_id_personne", "csap_id_structure", "csap_id_role", "cp_id_personne"};
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);
}
}
}
}
public StructureAPersonne(Personne personne, String fonction, String roleId, String codeEtat) {
Map<String, Object> a = personne.getProperties();
Set<String> cles = a.keySet();
Iterator<String> it = cles.iterator();
while (it.hasNext()) {
String cle = it.next();
String cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
String valeur = (String)a.get(cle);
if (a.get(cle) != null) {
if (cle.equals("truk_telephone")) {
set("telephone", a.get(cle));
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 {
this.set(cleObjet, a.get(cle));
}
}
}
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);
}
 
/**
* 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;
}
protected String[] getChampsObligatoires() {
return champsObligatoires;
}
// 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);
}
// NOM COMPLET
public String getNomComplet() {
return renvoyerValeurCorrecte("fmt_nom_complet");
}
public void setNomComplet(String nomComplet) {
set("fmt_nom_complet", nomComplet);
}
// 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 FIXE 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");
}
public String getDeces() {
return renvoyerValeurCorrecte("ce_deces");
}
public void setDeces(String etat) {
set("ce_deces", etat);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureAPersonne.java:r1136-1368
/tags/v1.1-aramon/src/org/tela_botanica/client/modeles/structure/StructureConservation.java
New file
0,0 → 1,236
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 static String[] champsObligatoires = {"csc_id_structure"};
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;
}
protected String[] getChampsObligatoires() {
return champsObligatoires;
}
// 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);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureConservation.java:r1136-1368
/tags/v1.1-aramon/src/org/tela_botanica/client/modeles/structure/StructureValorisation.java
New file
0,0 → 1,167
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 static String[] champsObligatoires = {"csv_id_structure"};
 
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;
}
protected String[] getChampsObligatoires() {
return champsObligatoires;
}
// 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);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureValorisation.java:r1136-1368
/tags/v1.1-aramon/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);
}
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureAPersonneListe.java:r1136-1368
/tags/v1.1-aramon/src/org/tela_botanica/client/modeles/structure/StructureAPersonneAsyncDao.java
New file
0,0 → 1,147
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.synchronisation.Reponse;
import org.tela_botanica.client.util.Debug;
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) {
if (Mediateur.DEBUG) System.out.println("|| StructureAPersonneAsyncDao > vueARafraichir = "+vueARafraichirCourrante.getClass().toString());
vueARafraichir = vueARafraichirCourrante;
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
}
public void selectionner(final String structureId, final String roleId, final Integer seqId) {
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
if (seqId !=null) {
Reponse reponseSequenceur = new Reponse(info, seqId);
vueARafraichir.rafraichir(reponseSequenceur);
} else {
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_fmt_nom_complet=" + URL.encodeComponent(personnel.getNomComplet()) +
"&cp_truk_telephone=" + URL.encodeComponent(personnel.getTelephone()) +
"&cp_truk_courriel=" + URL.encodeComponent(personnel.getCourriel()) +
"&cp_ce_truk_specialite=" + URL.encodeComponent(personnel.getSpecialite()) +
"&cp_ce_deces=" + URL.encodeComponent(personnel.getDeces()) +
"";
return postDonnees;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureAPersonneAsyncDao.java:r1136-1368
/tags/v1.1-aramon/src/org/tela_botanica/client/modeles/structure/Structure.java
New file
0,0 → 1,416
package org.tela_botanica.client.modeles.structure;
 
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
 
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelData;
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 static String[] champsObligatoires = {"cs_id_structure", "csc_id_structure", "csv_id_structure"};
public Structure() {
// Constructions du tableau des urls interne
urls = new BaseModelData();
}
public Structure(ModelData model)
{
Map<String, Object> a = model.getProperties();
 
Set<String> cles = a.keySet();
Iterator<String> it = cles.iterator();
while (it.hasNext()) {
String cle = it.next();
if (a.get(cle) != null) {
String cleObjet = cle.replaceFirst("^"+getPrefixe()+"_", "");
this.set(cleObjet, a.get(cle));
}
}
}
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;
}
protected String[] getChampsObligatoires() {
return champsObligatoires;
}
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 void setDescription(String description) {
this.set("description", 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 getAbreviationProjet() {
return renvoyerValeurCorrecte("_abreviationprojet_");
}
public void setAbreviationProjet(String abreviation) {
this.set("_abreviationprojet_", abreviation);
}
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 void setAdresseComplement(String adr) {
this.set("adresse_02", adr);
}
 
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 String getAnneOuDateFondationFormatLong() {
String dateFormatee = "";
String dateFondation = renvoyerValeurCorrecte("date_fondation");
if (!dateFondation.equals("")) {
if (dateFondation.endsWith("00-00")) {
dateFormatee = dateFondation.substring(0, 4);
} else {
Date date = DateTimeFormat.getFormat("yyyy-MM-dd").parse(dateFondation);
dateFormatee = DateTimeFormat.getLongDateFormat().format(date);
}
}
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 String getAnneeOuDateFondation() {
String valeurDateFondation = get("date_fondation");
if (!UtilString.isEmpty(valeurDateFondation) && valeurDateFondation.endsWith("00-00")) {
valeurDateFondation = valeurDateFondation.substring(0, 4);
} else if (UtilString.isEmpty(valeurDateFondation) && valeurDateFondation.equals("0000-00-00")) {
valeurDateFondation = "";
}
return valeurDateFondation;
}
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 void setLatitude(String latitude) {
if (latitude != null) {
latitude = latitude.replace(".", ",");
}
this.set("latitude", latitude);
}
 
public String getLongitude() {
return renvoyerValeurCorrecte("longitude");
}
public void setLongitude(String longitude) {
if (longitude != null) {
longitude = longitude.replace(".", ",");
}
this.set("longitude", 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 = 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 void setConditionAcces(String acces) {
this.set("condition_acces", acces);
}
 
public String getConditionUsage() {
return renvoyerValeurCorrecte("condition_usage");
}
public void setConditionUsage(String usage) {
this.set("condition_usage", 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;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/Structure.java:r1136-1368
/tags/v1.1-aramon/src/org/tela_botanica/client/modeles/structure/StructureListe.java
New file
0,0 → 1,128
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 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;
 
/**
* Classe contenant les informations sur les Structures renvoyées par un objet de type DAO.
*
* @author Jean-Pascal MILCENT
*
*/
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);
}
public StructureListe(JSONArray ListeDeStructures) {
super(ListeDeStructures.size()) ;
initialiserStructureListe(ListeDeStructures);
}
public StructureListe(JSONArray ListeDeStructures, JSONNumber nbElements, Rafraichissable vueARafraichir) {
super(ListeDeStructures.size());
this.nbElementsTotal = Integer.valueOf(nbElements.toString());
this.vueARafraichir = vueARafraichir;
initialiserStructureListe(ListeDeStructures);
}
private void initialiserStructureListe(JSONArray ListeDeStructures) {
final int taillemax = ListeDeStructures.size();
for (int i = 0; i < taillemax; i++) {
JSONObject structureCourante = ListeDeStructures.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 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() {
// À cause de la bétise 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 supérieur.
double nPage = (1.0 * nbElementsTotal) / (1.0 * nbElementsPage);
double nPageRound = Math.ceil(nPage);
Double nPageInt = new Double(nPageRound);
 
// Convertion en entier
return nPageInt.intValue();
}
public void selectionnerStructure() {
Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
mediateur.selectionnerStructure(vueARafraichir, null, mediateur.getProjetId(), null, currentPage, nbElementsPage, null);
}
public void filtrerParNom(String nom) {
Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
mediateur.selectionnerStructure(vueARafraichir, mediateur.getProjetId(), null, "%" + nom + "%", 0, nbElementsPage, null);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureListe.java:r1136-1368
/tags/v1.1-aramon/src/org/tela_botanica/client/modeles/structure/StructureAsyncDao.java
New file
0,0 → 1,291
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.synchronisation.Reponse;
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) {
if (Mediateur.DEBUG) System.out.println("|| StructureAsyncDao > vueARafraichir = "+vue.getClass().toString());
vueARafraichir = vue;
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId();
}
 
/**
*
* @param paginationProgressive : définit le mode de consultation de la base de données
* - True : la consultation des données est progressive, ce qui signifie que la liste est chargée (paginée) au
* fur et à mesure de la consultation des données par l'utilisateur.
* - False : la consultation des données est classique : un seul appel à la base de données est effectué, le retour
* est renvoyé à l'appelant
* // FIXME : si la taille de la liste est supérieure à la limite du JREST (150), ce deuxieme mode ne fonctionne pas
*/
public void selectionner(final boolean paginationProgressive, final String projetId, final String structureId, final String nomStructure, final int start, final int nbElements, final Integer seqId) {
String nom = (nomStructure == null) ? "%" : nomStructure+"%";
String[] parametres = {projetId, structureId, nom};
HashMap<String, String> restrictions = new HashMap<String, String>();
restrictions.put("orderby", "cs_ville");
if (nbElements != -1) {
restrictions.put("limit", String.valueOf(nbElements));
}
/** 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));
/** CONSTRUCTION DE LA REQUETE **/
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions);
 
/** ENVOI DE LA REQUETE **/
rb.envoyerRequete(null, new JsonRestRequestCallback()
{
/** RECEPTION DE LA REPONSE **/
public void surReponse(JSONValue responseValue)
{
if (seqId != null) {
Reponse reponseRequete = new Reponse(responseValue, seqId);
vueARafraichir.rafraichir(reponseRequete);
}
/** 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 **/
else vueARafraichir.rafraichir(responseValue);
}
});
}
/** GESTION DE LA REQUETE dans le cas d'une liste NON paginée progressive **/
else {
/** DEFINITION DU TUPLE DE DEPART **/
restrictions.put("start", String.valueOf(start*nbElements));
final JsonRestRequestBuilder rb = UtilDAO.construireRequete(SERVICE_NOM, parametres, restrictions);
rb.envoyerRequete(null, new JsonRestRequestCallback() {
 
public void surReponse(JSONValue responseValue) {
if (responseValue != null) {
Information info = new Information("selection_structure");
JSONObject responseObject = responseValue.isObject();
if (responseObject != null) {
// Si la réponse est un tableau, alors c'est une liste de structure qui a été retournée
if (responseObject.get("structures").isArray() != null) {
JSONObject reponse = responseObject;
StructureListe structures;
structures = new StructureListe(reponse.get("structures").isArray(), reponse.get("nbElements").isNumber(), vueARafraichir);
structures.setTaillePage(nbElements);
structures.setPageCourante(start);
info.setDonnee(0, structures);
if (seqId != null) {
Reponse reponseRequete = new Reponse(info, seqId);
vueARafraichir.rafraichir(reponseRequete);
}
else vueARafraichir.rafraichir(structures);
// Si la réponse est un objet, alors c'est une unique structure qui a été retournée
} else if (responseObject.get("structures").isObject() != null) {
JSONObject reponse = responseObject.get("structures").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);
if (seqId != null) {
Reponse reponseRequete = new Reponse(info, seqId);
vueARafraichir.rafraichir(reponseRequete);
}
else vueARafraichir.rafraichir(info);
}
} 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(str.getAbreviationProjet());
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_description=" + URL.encodeComponent(str.getDescription()) +
"&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_latitude=" + URL.encodeComponent(str.getLatitude()) +
"&cs_longitude=" + URL.encodeComponent(str.getLongitude()) +
"&cs_truk_telephone=" + URL.encodeComponent(str.getTelephone()) +
"&cs_truk_url=" + URL.encodeComponent(str.getUrl()) +
"&cs_nbre_personne=" + URL.encodeComponent(Integer.toString(str.getNbrePersonne())) +
"&cs_condition_acces=" + URL.encodeComponent(str.getConditionAcces())+
"&cs_condition_usage=" + URL.encodeComponent(str.getConditionUsage())+
"&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;
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/StructureAsyncDao.java:r1136-1368