/trunk/src/org/tela_botanica/client/modeles/CollectionAPersonne.java |
---|
New file |
0,0 → 1,96 |
package org.tela_botanica.client.modeles; |
import com.google.gwt.json.client.JSONObject; |
public class CollectionAPersonne extends aDonnee { |
private static final long serialVersionUID = 1L; |
public static final String PREFIXE = "ccap"; |
private Personne personneLiee = null; |
public CollectionAPersonne() { |
initialiser(new JSONObject()); |
} |
public CollectionAPersonne(JSONObject collectionAPersonneListe) { |
initialiser(collectionAPersonneListe); |
} |
@Override |
protected String getPrefixe() { |
return PREFIXE; |
} |
private void initialiser(JSONObject collectionAPersonneListe) { |
setPersonne(new Personne(collectionAPersonneListe)); |
initialiserChampsPourGrille(); |
initialiserModele(collectionAPersonneListe); |
} |
// PERSONNE |
public Personne getPersonne() { |
return personneLiee; |
} |
public void setPersonne(Personne personne) { |
personneLiee = personne; |
initialiserChampsPourGrille(); |
} |
private void initialiserChampsPourGrille() { |
set("fmt_nom_complet", getPersonne().getNomComplet()); |
set("nom", getPersonne().getNom()); |
set("prenom", getPersonne().getPrenom()); |
set("naissance_date", getPersonne().getNaissanceDate()); |
set("naissance_lieu", getPersonne().getNaissanceLieu()); |
set("ce_deces", getPersonne().getDeces()); |
set("deces_date", getPersonne().getDecesDate()); |
set("deces_lieu", getPersonne().getDecesLieu()); |
} |
// ID |
/** Génère un identifiant de CollectionAPersonne. |
* |
* C'est une concaténation des clés primaires de la table coel_collection_a_personne séparées par un tiret "-". |
* |
* @return identifiant unique d'une relation "collection à personne". |
*/ |
public String getId() { |
String idCollection = getIdCollection(); |
String idPersonne = getIdPersonne(); |
String idRole = getIdRole(); |
if (idCollection.equals("") && idPersonne.equals("") && idRole.equals("")) { |
return null; |
} else { |
return (idCollection+"-"+idPersonne+"-"+idRole); |
} |
} |
//+---------------------------------------------------------------------------------------------------------------+ |
// CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_PERSONNE |
// ID COLLECTION |
public String getIdCollection() { |
return renvoyerValeurCorrecte("id_collection"); |
} |
public void setIdCollection(String idCollection) { |
set("id_collection", idCollection); |
} |
// 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); |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/Configuration.java |
---|
83,8 → 83,8 |
listesId.put("inventaireEtat", Integer.valueOf(configuration.get("listeInventaireEtat"))); |
listesId.put("groupementPrincipe", Integer.valueOf(configuration.get("listeGroupementPrincipe"))); |
listesId.put("realisationBut", Integer.valueOf(configuration.get("listeRealisationBut"))); |
listesId.put("ion", Integer.valueOf(configuration.get("listeION"))); |
listesId.put("prefixe", Integer.valueOf(configuration.get("listePrefixes"))); |
listesId.put("suffixes", Integer.valueOf(configuration.get("listeSuffixes"))); |
listesId.put("sexe", Integer.valueOf(configuration.get("listeSexe"))); |
/trunk/src/org/tela_botanica/client/modeles/CollectionAPersonneAsyncDao.java |
---|
New file |
0,0 → 1,121 |
package org.tela_botanica.client.modeles; |
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.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 CollectionAPersonneAsyncDao { |
private static final String SERVICE_NOM = "CoelCollectionAPersonne"; |
private String utilisateurId = null; |
private Rafraichissable vueARafraichir = null; |
public CollectionAPersonneAsyncDao(Rafraichissable vueARafraichirCourrante) { |
vueARafraichir = vueARafraichirCourrante; |
utilisateurId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId(); |
} |
public void selectionner(final String collectionId, final String roleId) { |
String[] parametres = {collectionId, 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_collection_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 |
CollectionAPersonneListe personnes = new CollectionAPersonneListe(reponse); |
info.setDonnee(0, personnes); |
// 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 (collectionId == null) { |
// Dans le cas, où nous demandons toutes les relations Collection à Personne et qu'il n'y en a pas, nous retournons un message d'information |
info.setMessage("Aucune relations entre la collection et les personnes"); |
vueARafraichir.rafraichir(info); |
} |
} |
} |
}); |
} |
public void ajouter(String collectionId, CollectionAPersonne personnes) { |
String postDonneesEncodees = construirePost(collectionId, personnes); |
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_collection_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(CollectionAPersonne personnes) { |
String[] parametres = {personnes.getIdCollection(), personnes.getIdPersonne(), personnes.getIdRole()}; |
final JsonRestRequestBuilder rb = UtilDAO.construireRequetePost(SERVICE_NOM, parametres); |
String postDonneesEncodees = construirePost(personnes.getIdCollection(), personnes); |
rb.envoyerRequete(postDonneesEncodees, new JsonRestRequestCallback() { |
@Override |
public void surReponse(JSONValue responseValue) { |
Information info = new Information("modif_collection_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 idCollectionAPersonne) { |
String[] parametres = {utilisateurId, idCollectionAPersonne}; |
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_collection_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 collectionId, CollectionAPersonne personne) { |
String postDonnees = "cmhl_ce_modifier_par=" + URL.encodeComponent(utilisateurId) + |
"&ccap_id_collection=" + URL.encodeComponent(collectionId) + |
"&ccap_id_personne=" + URL.encodeComponent(personne.getIdPersonne()) + |
"&ccap_id_role=" + URL.encodeComponent(personne.getIdRole()); |
return postDonnees; |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/CollectionAPersonneListe.java |
---|
New file |
0,0 → 1,39 |
package org.tela_botanica.client.modeles; |
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 CollectionAPersonneListe extends aDonneeListe<CollectionAPersonne> { |
private static final long serialVersionUID = 1L; |
public CollectionAPersonneListe() { |
super(); |
} |
public CollectionAPersonneListe(int taille) { |
super(taille); |
} |
public CollectionAPersonneListe(JSONArray structures) { |
super(structures.size()) ; |
final int taillemax = structures.size(); |
for (int i = 0; i < taillemax; i++) { |
JSONObject collectionAPersonneCourante = structures.get(i).isObject() ; |
if (collectionAPersonneCourante != null) { |
CollectionAPersonne collectionAPersonne = new CollectionAPersonne(collectionAPersonneCourante); |
this.put(collectionAPersonne.getId(), collectionAPersonne); |
} |
} |
} |
} |
/trunk/src/org/tela_botanica/client/modeles/aDonnee.java |
---|
30,6 → 30,7 |
public static final String SEPARATEUR_TYPE_VALEUR = "##"; |
public static final String SEPARATEUR_VALEURS = ";;"; |
public static final String SEPARATEUR_DONNEES = "||"; |
public static final String ETAT_AJOUTE = "A"; |
protected abstract String getPrefixe(); |
/trunk/src/org/tela_botanica/client/modeles/Personne.java |
---|
19,6 → 19,8 |
public static final String TELEPHONE_FIXE = "FIX"; |
public static final String TELEPHONE_GSM = "GSM"; |
public static final String TELEPHONE_FAX = "FAX"; |
public static final String ETRE_DECEDE = "30745"; |
public static final String ETRE_VIVANT = "30746"; |
public Personne() { |
} |
34,10 → 36,64 |
return PREFIXE; |
} |
public Object obtenirValeurChamp(String nomChamp) { |
return renvoyerValeurCorrecte(nomChamp); |
} |
public Date getDate(String nomChamp) { |
String strDate = renvoyerValeurCorrecte(nomChamp); |
Date dateRetour = null; |
try { |
if ((strDate != null) && (!strDate.equals("0000-00-00"))) { |
dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate); |
} |
} catch (StringIndexOutOfBoundsException e) { |
GWT.log("Impossible de parser la date " + strDate, e); |
} |
return dateRetour; |
} |
public String getString(String nomChamp) { |
return String.valueOf(renvoyerValeurCorrecte(nomChamp)); |
} |
//Traitement des truks |
protected void remplacerTypeDansChaineDenormalise(String champ, String type, Object valeur) { |
if (valeur != null && !valeur.equals("")) { |
ajouterChaineDenormaliseAvecType(champ, type, valeur); |
} else { |
supprimerTypeDansChaineDenormalise(champ, type); |
} |
} |
/** |
* Ajoute un nouvel élément sans type à une chaine dénormalisée. |
* Champ de type "truk" contenant seulement des valeurs séparées par ";;". |
* Si l'élément existe déjà, il ne sera pas ajouté. |
* |
* @param champ le nom du champ dénormalisé |
* @param valeur la valeur à ajouter |
*/ |
protected void ajouterChaineDenormalise(String champ, Object valeur) { |
if (valeur instanceof String) { |
String chaineExistante = renvoyerValeurCorrecte(champ); |
if (chaineExistante.equals("")) { |
this.set(champ, valeur); |
} else { |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons |
if (!chaineExistante.matches("(^|"+SEPARATEUR_VALEURS+")"+valeur+"("+SEPARATEUR_VALEURS+"|$)")) { |
this.set(champ, chaineExistante+SEPARATEUR_VALEURS+valeur); |
} |
} |
} |
} |
// ID PERSONNE |
public String getId() { |
return renvoyerValeurCorrecte("id_personne"); |
} |
public void setId(String personneId) { |
this.set("id_personne", personneId); |
} |
// ID PROJET |
public String getIdProjet() { |
48,6 → 104,26 |
public String getNomComplet() { |
return renvoyerValeurCorrecte("fmt_nom_complet"); |
} |
public void setFmtNomComplet(String prefixe, String suffixe) { |
String fmtNomComplet = ""; |
if ((prefixe != null)&&(!prefixe.trim().equals(""))) { |
fmtNomComplet += prefixe + " "; |
} |
if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals(""))) { |
fmtNomComplet += this.getPrenom() + " "; |
} |
if ((this.getNom()!=null)&&(!this.getNom().trim().equals(""))) { |
fmtNomComplet += this.getNom() + " "; |
} |
if ((suffixe!=null)&&(!suffixe.trim().equals(""))) { |
fmtNomComplet += suffixe; |
} |
this.set("fmt_nom_complet", UtilString.ucFirst(fmtNomComplet)); |
} |
// NOM |
public String getNom() { |
59,22 → 135,6 |
return renvoyerValeurCorrecte("prenom"); |
} |
public Date getDate(String nomChamp) { |
String strDate = renvoyerValeurCorrecte(nomChamp); |
Date dateRetour = null; |
try |
{ |
if ((strDate != null) && (!strDate.equals("0000-00-00"))) { |
dateRetour = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(strDate); |
} |
} catch (StringIndexOutOfBoundsException e) { |
GWT.log("Impossible de parser la date " + strDate, e); |
} |
return dateRetour; |
} |
// TÉLÉPHONE |
public String getTelephone() { |
return renvoyerValeurCorrecte("truk_telephone"); |
129,15 → 189,15 |
return getChaineDenormaliseUnique("ce_truk_specialite"); |
} |
public Object obtenirValeurChamp(String nomChamp) { |
return renvoyerValeurCorrecte(nomChamp); |
// NAISSANCE DATE |
public String getNaissanceDate() { |
String dateNaiss = ""; |
dateNaiss = get("naissance_date"); |
if (UtilString.isEmpty(dateNaiss)||dateNaiss.equals("0000-00-00")) { |
dateNaiss = Mediateur.i18nC.inconnue(); |
} |
return dateNaiss; |
} |
public String getString(String champ) { |
return String.valueOf(renvoyerValeurCorrecte(champ)); |
} |
public void setNaissanceDate(Date naissanceDate) { |
if (naissanceDate != null) { |
this.set("naissance_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(naissanceDate)); |
144,103 → 204,62 |
} |
} |
public void setDeces(Date decesDate, String lieuDeces) { |
set("ce_deces", "1"); |
setDecesDate(decesDate); |
set("deces_lieu", lieuDeces); |
// NAISSANCE LIEU |
public String getNaissanceLieu() { |
return renvoyerValeurCorrecte("naissance_lieu"); |
} |
public void setNonDecedee() { |
set("ce_deces", "0"); |
setDecesDate(null); |
set("deces_lieu", ""); |
public void setNaissanceLieu(String naissanceLieu) { |
this.set("naissance_lieu", naissanceLieu); |
} |
// DÉCÉS |
public boolean estDecedee() { |
String ceDeces = get("ce_deces"); |
if ((ceDeces == null)||(ceDeces.equals("0"))) { |
String ceDeces = getDeces(); |
if (ceDeces.isEmpty() || ceDeces.equals(ETRE_DECEDE)) { |
return false; |
} else { |
} else { |
return true; |
} |
} |
public void setDecesDate(Date decesDate) { |
if (decesDate != null) { |
this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate)); |
} else { |
this.set("deces_date", ""); |
} |
public String getDeces() { |
return renvoyerValeurCorrecte("ce_deces"); |
} |
public void setDeces(String deces) { |
set("ce_deces", deces); |
} |
public void setDeces(Date decesDate, String lieuDeces) { |
set("ce_deces", ETRE_DECEDE); |
setDecesDate(decesDate); |
setDecesLieu(lieuDeces); |
} |
public void setNonDecedee() { |
set("ce_deces", ETRE_VIVANT); |
setDecesDate(null); |
setDecesLieu(""); |
} |
// DÉCÉS DATE |
public String getDecesDate() { |
String dateDeces = ""; |
dateDeces = get("deces_date"); |
if (UtilString.isEmpty(dateDeces)||dateDeces.equals("0000-00-00")) { |
String dateDeces = renvoyerValeurCorrecte("deces_date"); |
if (UtilString.isEmpty(dateDeces) || dateDeces.equals("0000-00-00")) { |
dateDeces = Mediateur.i18nC.inconnue(); |
} |
return dateDeces; |
} |
public String getNaissanceDate() { |
String dateNaiss = ""; |
dateNaiss = get("naissance_date"); |
if (UtilString.isEmpty(dateNaiss)||dateNaiss.equals("0000-00-00")) { |
dateNaiss = Mediateur.i18nC.inconnue(); |
public void setDecesDate(Date decesDate) { |
if (decesDate != null) { |
this.set("deces_date", DateTimeFormat.getFormat("yyyy-MM-dd").format(decesDate)); |
} else { |
this.set("deces_date", ""); |
} |
return dateNaiss; |
} |
public void setFmtNomComplet(String prefixe, String suffixe) { |
String fmtNomComplet = ""; |
if ((prefixe != null)&&(!prefixe.trim().equals(""))) { |
fmtNomComplet += prefixe + " "; |
} |
if ((this.getPrenom()!=null)&&(!this.getPrenom().trim().equals(""))) { |
fmtNomComplet += this.getPrenom() + " "; |
} |
if ((this.getNom()!=null)&&(!this.getNom().trim().equals(""))) { |
fmtNomComplet += this.getNom() + " "; |
} |
if ((suffixe!=null)&&(!suffixe.trim().equals(""))) { |
fmtNomComplet += suffixe; |
} |
this.set("fmt_nom_complet", UtilString.ucFirst(fmtNomComplet)); |
// DÉCÉS LIEU |
public String getDecesLieu() { |
return renvoyerValeurCorrecte("deces_lieu"); |
} |
//Traitement des truks |
protected void remplacerTypeDansChaineDenormalise(String champ, String type, Object valeur) { |
if (valeur != null && !valeur.equals("")) { |
ajouterChaineDenormaliseAvecType(champ, type, valeur); |
} else { |
supprimerTypeDansChaineDenormalise(champ, type); |
} |
public void setDecesLieu(String decesLieu) { |
this.set("deces_lieu", decesLieu); |
} |
/** |
* Ajoute un nouvel élément sans type à une chaine dénormalisée. |
* Champ de type "truk" contenant seulement des valeurs séparées par ";;". |
* Si l'élément existe déjà, il ne sera pas ajouté. |
* |
* @param champ le nom du champ dénormalisé |
* @param valeur la valeur à ajouter |
*/ |
protected void ajouterChaineDenormalise(String champ, Object valeur) { |
if (valeur instanceof String) { |
String chaineExistante = renvoyerValeurCorrecte(champ); |
if (chaineExistante.equals("")) { |
this.set(champ, valeur); |
} else { |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons |
if (!chaineExistante.matches("(^|"+SEPARATEUR_VALEURS+")"+valeur+"("+SEPARATEUR_VALEURS+"|$)")) { |
this.set(champ, chaineExistante+SEPARATEUR_VALEURS+valeur); |
} |
} |
} |
} |
} |
} |