Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 1572 → Rev 1573

/trunk/src/org/tela_botanica/client/modeles/personne/Personne.java
10,6 → 10,7
import org.tela_botanica.client.modeles.collection.CollectionAPublication;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.Log;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.data.ModelData;
22,7 → 23,6
private static final long serialVersionUID = -6974716696155349332L;
 
public static final String PREFIXE = "cp";
private boolean removePrefix = true;
public static final String TELEPHONE_FIXE = "FIX";
public static final String TELEPHONE_GSM = "GSM";
public static final String TELEPHONE_FAX = "FAX";
32,8 → 32,7
private PublicationAPersonneListe publicationsLiees= null;
public Personne() {
}
public Personne() {}
 
public Personne(ModelData model) {
creerPersonne(model, false);
44,7 → 43,6
}
private void creerPersonne(ModelData model, boolean removePrefix) {
this.removePrefix = removePrefix;
Map<String, Object> a = model.getProperties();
134,8 → 132,8
// ID PERSONNE
public String getId() {
if (removePrefix) return renvoyerValeurCorrecte("id_personne");
else return renvoyerValeurCorrecte(PREFIXE+"_id_personne");
Log.debug("Dans getId() Personne : "+this.toString());
return renvoyerValeurCorrecte("id_personne");
}
public void setId(String personneId) {
if (removePrefix) this.set("id_personne", personneId);
/trunk/src/org/tela_botanica/client/modeles/aDonnee.java
29,6 → 29,9
 
private static final long serialVersionUID = 3527760464061629791L;
public static final boolean SUPPRIMER_PREFIXE = true;
public static final boolean GARDER_PREFIXE = false;
public static final boolean INTEGRER_PROPRIETES = true;
public static final String TYPE_AUTRE = "AUTRE";
public static final String TYPE_TOTAL = "TOTAL";
public static final String SEPARATEUR_TYPE_VALEUR = "##";
100,7 → 103,7
*/
protected String renvoyerValeurCorrecte(String cle) {
String sortie = "";
cle = (removePrefix) ? cle : getPrefixe()+"_"+cle;
cle = gererPrefixe(cle);
if (this.get(cle) != null) {
String valeur = ""+this.get(cle);
if (! valeur.equals("null")) {
121,7 → 124,7
* @param la valeur associé à la clé
*/
protected void setValeurCorrecte(String cle, String valeur) {
cle = (removePrefix) ? cle : getPrefixe()+"_"+cle;
cle = gererPrefixe(cle);
set(cle, valeur);
}
199,7 → 202,7
* @param valeur la valeur à ajouter
*/
protected void setChaineDenormaliseUnique(String champ, String type, String valeur) {
champ = (removePrefix) ? champ : getPrefixe()+"_"+champ;
champ = gererPrefixe(champ);
if (valeur == null || UtilString.isEmpty(valeur)) {
this.set(champ, "");
} else if (valeur instanceof String) {
211,6 → 214,17
}
}
private String gererPrefixe(String champ) {
String champMisAJour = null;
String prefixe = getPrefixe()+"_";
if (removePrefix) {
champMisAJour = champ.replaceFirst(prefixe, "");
} else {
champMisAJour = (champ.startsWith(prefixe)) ? champ : prefixe+champ ;
}
return champMisAJour;
}
/**
* Permet de récupérer pour l'affichage une chaine dénormalisée unique (champ de type "ce_truk").
*
/trunk/src/org/tela_botanica/client/modeles/publication/PublicationAPersonne.java
7,6 → 7,7
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.util.Log;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
71,21 → 72,20
Iterator<String> it = cles.iterator();
while (it.hasNext()) {
String cle = it.next();
Object valeur = modeleProprietes.get(cle);
if (modeleProprietes.get(cle) != null) {
String cleObjet = "";
if (removePrefix) {
cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
cleObjet = cle.replaceFirst("^"+Publication.PREFIXE+"_", "");
cleObjet = cleObjet.replaceFirst("^"+getPrefixe()+"_", "");
} else {
cleObjet = cle;
}
this.set(cleObjet, modeleProprietes.get(cle));
this.set(cleObjet, valeur);
}
}
setPersonne(new Personne(modele, removePrefix));
setPublicationLiee(new Publication(modele, removePrefix));
initialiserChampsPourGrille();
this.set("_role_", modeleProprietes.get("_role_"));
this.set("_etat_", modeleProprietes.get("_etat_"));
} else {
139,6 → 139,7
public void setPersonne(Personne personne, boolean integrerProprietes) {
personneLiee = personne;
if (personne != null) {
Log.debug("Tentative ajout id personne : "+personne.getId());
setIdPersonne(personne.getId());
}
176,7 → 177,8
// ID PUBLICATION
public String getIdPublication() {
return renvoyerValeurCorrecte("id_publication");
String valeur = renvoyerValeurCorrecte("id_publication");
return UtilString.isEmpty(valeur) ? "0" : valeur;
}
public void setIdPublication(String id) {
setValeurCorrecte("id_publication", id);
195,7 → 197,8
// ID PERSONNE
public String getIdPersonne() {
return renvoyerValeurCorrecte("id_personne");
String valeur = renvoyerValeurCorrecte("id_personne");
return UtilString.isEmpty(valeur) ? "0" : valeur;
}
public void setIdPersonne(String id) {
setValeurCorrecte("id_personne", id);
203,7 → 206,8
// ID RôLE
public String getIdRole() {
return renvoyerValeurCorrecte("id_role");
String valeur = renvoyerValeurCorrecte("id_role");
return UtilString.isEmpty(valeur) ? "0" : valeur;
}
public void setIdRole(String id) {
setValeurCorrecte("id_role", id);
/trunk/src/org/tela_botanica/client/vues/publication/PublicationForm.java
480,17 → 480,18
if (personnesSaisiesComboBox.getValeur() instanceof ModelData) {
// N'ajouter l'auteur que s'il n'est pas déjà présent dans la grille et dans les valeurs initiales
Personne personneSaisieSelectionnee = new Personne(personnesSaisiesComboBox.getValeur());
PublicationAPersonne pap = new PublicationAPersonne(false);
pap.setPersonne(personneSaisieSelectionnee, true);
Log.debug("Récupération info combo :"+personneSaisieSelectionnee.toString());
PublicationAPersonne pap = new PublicationAPersonne(aDonnee.GARDER_PREFIXE);
pap.setPersonne(personneSaisieSelectionnee, aDonnee.INTEGRER_PROPRIETES);
pap.setOrdreAuteurs(String.valueOf(grilleAuteurs.getStore().getCount()+1));
if (modeDeCreation != Formulaire.MODE_AJOUTER) {
pap.setPublicationLiee(publication);
pap.setIdPublication(publicationId);
}
if (grilleAuteurs.getStore().findModel(pap) != null) {
Info.display("Information", "La personne est déjà présente dans la liste d'auteurs");
} else {
ajouterDansGrille(pap);
pap.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
Log.debug("Récupération info combo pap id :"+pap.getId());
if (ajouterDansGrille(pap)) {
personnesSaisiesComboBox.getCombo().setValue(null);
}
}
498,35 → 499,42
});
}
private void ajouterDansGrille(PublicationAPersonne pap) {
ajouterDansGrille(pap, grilleAuteurs.getStore().getCount());
private boolean ajouterDansGrille(PublicationAPersonne pap) {
return ajouterDansGrille(pap, grilleAuteurs.getStore().getCount());
}
private void ajouterDansGrille(PublicationAPersonne pap, int index) {
private boolean ajouterDansGrille(PublicationAPersonne pap, int index) {
boolean ok = false;
if (pap != null) {
if (grilleAuteurs.getStore().contains(pap)) {
InfoLogger.display("Information", "La personne choisie existe déjà dans la liste.");
Log.debug("Début ajout dans grille :"+pap.toString());
if (grilleAuteurs.getStore().contains((ModelData) pap)) {
InfoLogger.display("Information", "La personne choisie existe déjà dans la liste d'auteurs.");
} else {
// 1) si elle ne fait pas partie des initiaux, ajouter à la liste à ajouter
if (!auteursInitialListe.containsValue(pap)) {
auteursAjoutes.put(pap.getId(), pap);
Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été ajouté à la liste des ajoutés (il ne fait pas parti de la liste initiale).");
}
// L'enlever de la liste à supprimer
if (auteursSupprimes.containsValue(pap)) {
auteursSupprimes.remove(pap);
Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été retiré de la liste des supprimés.");
}
// 2) Ajouter a la grille
grilleAuteurs.getStore().insert(pap, index);
grilleAuteurs.getStore().insert((ModelData) pap, index);
grilleAuteurs.getSelectionModel().select(index, false);
ok = true;
}
}
return ok;
}
private void supprimerDansGrille() {
ModelData donneeSelectionnee = grilleAuteurs.getSelectionModel().getSelectedItem();
PublicationAPersonne personneSelectionnee = new PublicationAPersonne(donneeSelectionnee, false);
PublicationAPersonne personneSelectionnee = new PublicationAPersonne(donneeSelectionnee, aDonnee.GARDER_PREFIXE);
Log.debug("Début supprimer auteur dans grille : "+personneSelectionnee.toString());
if (personneSelectionnee.getId() == null) {
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerAuteur());
} else {
536,12 → 544,12
Log.debug("Ajout Personne à supprimer : "+auteursSupprimes.toString());
}
if (auteursAjoutes.containsValue(personneSelectionnee)) {
auteursAjoutes.remove(personneSelectionnee);
if (auteursAjoutes.containsKey(personneSelectionnee.getId())) {
auteursAjoutes.remove(personneSelectionnee.getId());
}
if (auteursModifies.containsValue(personneSelectionnee)) {
auteursModifies.remove(personneSelectionnee);
if (auteursModifies.containsKey(personneSelectionnee.getId())) {
auteursModifies.remove(personneSelectionnee.getId());
}
// 2) Supprimer la personne de la liste
612,8 → 620,9
Iterator<ModelData> itAuteurs = auteurs.iterator();
while (itAuteurs.hasNext()) {
ModelData selection = itAuteurs.next();
PublicationAPersonne auteur = new PublicationAPersonne(selection, false);
auteursInitialListe.put(auteur.getId(), auteur);
PublicationAPersonne pap = new PublicationAPersonne(selection, aDonnee.GARDER_PREFIXE);
auteursInitialListe.put(pap.getId(), pap);
Log.debug("PublicationAPersonne ajoutée à la liste initiale avec l'id :"+pap.getId()+pap.toString()+selection.getProperties().toString());
}
Log.debug("Initialisation liste auteur :"+auteursInitialListe.size());
}