| 935 | 
           jpm | 
           1 | 
           package org.tela_botanica.client.modeles.collection;
  | 
        
        
           | 875 | 
           jpm | 
           2 | 
              | 
        
        
           | 1468 | 
           jpm | 
           3 | 
           import java.util.Iterator;
  | 
        
        
            | 
            | 
           4 | 
           import java.util.Map;
  | 
        
        
            | 
            | 
           5 | 
           import java.util.Set;
  | 
        
        
            | 
            | 
           6 | 
              | 
        
        
           | 935 | 
           jpm | 
           7 | 
           import org.tela_botanica.client.modeles.aDonnee;
  | 
        
        
            | 
            | 
           8 | 
           import org.tela_botanica.client.modeles.personne.Personne;
  | 
        
        
           | 1468 | 
           jpm | 
           9 | 
           import org.tela_botanica.client.util.Debug;
  | 
        
        
            | 
            | 
           10 | 
           import org.tela_botanica.client.util.UtilString;
  | 
        
        
           | 935 | 
           jpm | 
           11 | 
              | 
        
        
           | 1468 | 
           jpm | 
           12 | 
           import com.extjs.gxt.ui.client.data.BaseModelData;
  | 
        
        
            | 
            | 
           13 | 
           import com.extjs.gxt.ui.client.data.ModelData;
  | 
        
        
           | 875 | 
           jpm | 
           14 | 
           import com.google.gwt.json.client.JSONObject;
  | 
        
        
            | 
            | 
           15 | 
              | 
        
        
            | 
            | 
           16 | 
           public class CollectionAPersonne extends aDonnee {
  | 
        
        
            | 
            | 
           17 | 
              | 
        
        
            | 
            | 
           18 | 
           	private static final long serialVersionUID = 1L;
  | 
        
        
            | 
            | 
           19 | 
              | 
        
        
            | 
            | 
           20 | 
           	public static final String PREFIXE = "ccap";
  | 
        
        
            | 
            | 
           21 | 
           	private Personne personneLiee = null;
  | 
        
        
           | 1173 | 
           jpm | 
           22 | 
           	public static String[] champsObligatoires = {"ccap_id_collection", "ccap_id_personne", "ccap_id_role"};
  | 
        
        
           | 875 | 
           jpm | 
           23 | 
              | 
        
        
            | 
            | 
           24 | 
           	public CollectionAPersonne() {
  | 
        
        
            | 
            | 
           25 | 
           		initialiser(new JSONObject());
  | 
        
        
            | 
            | 
           26 | 
           	}
  | 
        
        
           | 1468 | 
           jpm | 
           27 | 
              | 
        
        
           | 875 | 
           jpm | 
           28 | 
           	public CollectionAPersonne(JSONObject collectionAPersonneListe) {
  | 
        
        
            | 
            | 
           29 | 
           		initialiser(collectionAPersonneListe);
  | 
        
        
            | 
            | 
           30 | 
           	}
  | 
        
        
            | 
            | 
           31 | 
              | 
        
        
           | 1468 | 
           jpm | 
           32 | 
           	public CollectionAPersonne(ModelData model)
  | 
        
        
            | 
            | 
           33 | 
           	{
  | 
        
        
            | 
            | 
           34 | 
           		Map<String, Object> a = model.getProperties();
  | 
        
        
           | 1513 | 
           jpm | 
           35 | 
              | 
        
        
           | 1468 | 
           jpm | 
           36 | 
           		Set<String> cles = a.keySet();
  | 
        
        
            | 
            | 
           37 | 
           		Iterator<String> it = cles.iterator();
  | 
        
        
            | 
            | 
           38 | 
           		while (it.hasNext()) {
  | 
        
        
            | 
            | 
           39 | 
           			String cle = it.next();
  | 
        
        
            | 
            | 
           40 | 
           			if (a.get(cle) != null) {
  | 
        
        
            | 
            | 
           41 | 
           				String cleObjet = "";
  | 
        
        
            | 
            | 
           42 | 
           				cleObjet = cle.replaceFirst("^"+CollectionAPersonne.PREFIXE+"_", "");
  | 
        
        
            | 
            | 
           43 | 
           				cleObjet = cleObjet.replaceFirst("^"+Personne.PREFIXE+"_", "");
  | 
        
        
            | 
            | 
           44 | 
           				this.set(cleObjet, a.get(cle));
  | 
        
        
            | 
            | 
           45 | 
           			}
  | 
        
        
            | 
            | 
           46 | 
           		}
  | 
        
        
            | 
            | 
           47 | 
              | 
        
        
            | 
            | 
           48 | 
           		setPersonne(new Personne(model));
  | 
        
        
            | 
            | 
           49 | 
           		this.set("_etat_", a.get("_etat_"));
  | 
        
        
            | 
            | 
           50 | 
           	}
  | 
        
        
            | 
            | 
           51 | 
              | 
        
        
           | 875 | 
           jpm | 
           52 | 
           	@Override
  | 
        
        
            | 
            | 
           53 | 
           	protected String getPrefixe() {
  | 
        
        
            | 
            | 
           54 | 
           		return PREFIXE;
  | 
        
        
            | 
            | 
           55 | 
           	}
  | 
        
        
            | 
            | 
           56 | 
              | 
        
        
           | 1173 | 
           jpm | 
           57 | 
           	protected String[] getChampsObligatoires()	{
  | 
        
        
            | 
            | 
           58 | 
           		return champsObligatoires;
  | 
        
        
            | 
            | 
           59 | 
           	}
  | 
        
        
            | 
            | 
           60 | 
              | 
        
        
           | 875 | 
           jpm | 
           61 | 
           	private void initialiser(JSONObject collectionAPersonneListe) {
  | 
        
        
            | 
            | 
           62 | 
           		setPersonne(new Personne(collectionAPersonneListe));
  | 
        
        
           | 883 | 
           jpm | 
           63 | 
           		initialiserModele(collectionAPersonneListe);
  | 
        
        
           | 875 | 
           jpm | 
           64 | 
           		initialiserChampsPourGrille();
  | 
        
        
            | 
            | 
           65 | 
           	}
  | 
        
        
            | 
            | 
           66 | 
              | 
        
        
            | 
            | 
           67 | 
           	// PERSONNE
  | 
        
        
            | 
            | 
           68 | 
           	public Personne getPersonne() {
  | 
        
        
            | 
            | 
           69 | 
           		return personneLiee;
  | 
        
        
            | 
            | 
           70 | 
           	}
  | 
        
        
            | 
            | 
           71 | 
           	public void setPersonne(Personne personne) {
  | 
        
        
            | 
            | 
           72 | 
           		personneLiee = personne;
  | 
        
        
            | 
            | 
           73 | 
           		initialiserChampsPourGrille();
  | 
        
        
           | 907 | 
           jpm | 
           74 | 
           		if (personne != null) {
  | 
        
        
           | 1468 | 
           jpm | 
           75 | 
           			if (personne.getId() != null && !UtilString.isEmpty(personne.getId())) setIdPersonne(personne.getId());
  | 
        
        
           | 907 | 
           jpm | 
           76 | 
           		}
  | 
        
        
           | 875 | 
           jpm | 
           77 | 
           	}
  | 
        
        
            | 
            | 
           78 | 
              | 
        
        
           | 1468 | 
           jpm | 
           79 | 
           	public void setPersonnePourGrillePaginable(Personne personne) {
  | 
        
        
            | 
            | 
           80 | 
           		personneLiee = personne;
  | 
        
        
            | 
            | 
           81 | 
           		initialiserChampsPourGrillePaginable();
  | 
        
        
            | 
            | 
           82 | 
           		if (personne != null) {
  | 
        
        
            | 
            | 
           83 | 
           			if (personne.getId() != null && !UtilString.isEmpty(personne.getId())) setIdPersonne(personne.getId());
  | 
        
        
            | 
            | 
           84 | 
           		}
  | 
        
        
            | 
            | 
           85 | 
           	}
  | 
        
        
            | 
            | 
           86 | 
              | 
        
        
           | 875 | 
           jpm | 
           87 | 
           	private void initialiserChampsPourGrille() {
  | 
        
        
           | 883 | 
           jpm | 
           88 | 
           		set("_role_", getIdRole());
  | 
        
        
           | 875 | 
           jpm | 
           89 | 
           		set("fmt_nom_complet", getPersonne().getNomComplet());
  | 
        
        
            | 
            | 
           90 | 
           		set("nom", getPersonne().getNom());
  | 
        
        
            | 
            | 
           91 | 
           		set("prenom", getPersonne().getPrenom());
  | 
        
        
            | 
            | 
           92 | 
           		set("naissance_date", getPersonne().getNaissanceDate());
  | 
        
        
            | 
            | 
           93 | 
           		set("naissance_lieu", getPersonne().getNaissanceLieu());
  | 
        
        
           | 883 | 
           jpm | 
           94 | 
           		set("_deces_", getPersonne().getDeces());
  | 
        
        
           | 875 | 
           jpm | 
           95 | 
           		set("deces_date", getPersonne().getDecesDate());
  | 
        
        
            | 
            | 
           96 | 
           		set("deces_lieu", getPersonne().getDecesLieu());
  | 
        
        
           | 883 | 
           jpm | 
           97 | 
           		set("_etat_", "");
  | 
        
        
           | 875 | 
           jpm | 
           98 | 
           	}
  | 
        
        
            | 
            | 
           99 | 
              | 
        
        
           | 1468 | 
           jpm | 
           100 | 
           	public void initialiserChampsPourGrillePaginable() {
  | 
        
        
            | 
            | 
           101 | 
           		set("ccap_id_role", getIdRole());
  | 
        
        
            | 
            | 
           102 | 
           		set("_role_", getIdRole());
  | 
        
        
            | 
            | 
           103 | 
           		set("cp_fmt_nom_complet", getPersonne().getNomComplet());
  | 
        
        
            | 
            | 
           104 | 
           		set("cp_nom", getPersonne().getNom());
  | 
        
        
            | 
            | 
           105 | 
           		set("cp_prenom", getPersonne().getPrenom());
  | 
        
        
            | 
            | 
           106 | 
           		set("cp_naissance_date", getPersonne().getNaissanceDate());
  | 
        
        
            | 
            | 
           107 | 
           		set("cp_naissance_lieu", getPersonne().getNaissanceLieu());
  | 
        
        
            | 
            | 
           108 | 
           		set("_deces_", getPersonne().getDeces());
  | 
        
        
            | 
            | 
           109 | 
           		set("cp_deces", getPersonne().getDeces());
  | 
        
        
            | 
            | 
           110 | 
           		set("cp_deces_date", getPersonne().getDecesDate());
  | 
        
        
            | 
            | 
           111 | 
           		set("cp_deces_lieu", getPersonne().getDecesLieu());
  | 
        
        
            | 
            | 
           112 | 
           	}
  | 
        
        
            | 
            | 
           113 | 
              | 
        
        
           | 875 | 
           jpm | 
           114 | 
           	// ID
  | 
        
        
            | 
            | 
           115 | 
           	/** Génère un identifiant de CollectionAPersonne.
  | 
        
        
            | 
            | 
           116 | 
           	 *
  | 
        
        
            | 
            | 
           117 | 
           	 * C'est une concaténation des clés primaires de la table coel_collection_a_personne séparées par un tiret "-".
  | 
        
        
            | 
            | 
           118 | 
           	 *
  | 
        
        
            | 
            | 
           119 | 
           	 * @return identifiant unique d'une relation "collection à personne".
  | 
        
        
            | 
            | 
           120 | 
           	 */
  | 
        
        
            | 
            | 
           121 | 
           	public String getId() {
  | 
        
        
            | 
            | 
           122 | 
           		String idCollection = getIdCollection();
  | 
        
        
            | 
            | 
           123 | 
           		String idPersonne = getIdPersonne();
  | 
        
        
            | 
            | 
           124 | 
           		String idRole = getIdRole();
  | 
        
        
            | 
            | 
           125 | 
           		if (idCollection.equals("") && idPersonne.equals("") && idRole.equals("")) {
  | 
        
        
            | 
            | 
           126 | 
           			return null;
  | 
        
        
            | 
            | 
           127 | 
           		} else {
  | 
        
        
            | 
            | 
           128 | 
           			return (idCollection+"-"+idPersonne+"-"+idRole);
  | 
        
        
            | 
            | 
           129 | 
           		}
  | 
        
        
            | 
            | 
           130 | 
           	}
  | 
        
        
            | 
            | 
           131 | 
              | 
        
        
            | 
            | 
           132 | 
           	//+---------------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           133 | 
           	// CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_PERSONNE
  | 
        
        
            | 
            | 
           134 | 
              | 
        
        
            | 
            | 
           135 | 
           	// ID COLLECTION
  | 
        
        
            | 
            | 
           136 | 
           	public String getIdCollection() {
  | 
        
        
            | 
            | 
           137 | 
           		return renvoyerValeurCorrecte("id_collection");
  | 
        
        
            | 
            | 
           138 | 
           	}
  | 
        
        
            | 
            | 
           139 | 
           	public void setIdCollection(String idCollection) {
  | 
        
        
            | 
            | 
           140 | 
           		set("id_collection", idCollection);
  | 
        
        
            | 
            | 
           141 | 
           	}
  | 
        
        
            | 
            | 
           142 | 
              | 
        
        
            | 
            | 
           143 | 
           	// ID PERSONNE
  | 
        
        
            | 
            | 
           144 | 
           	public String getIdPersonne() {
  | 
        
        
            | 
            | 
           145 | 
           		return renvoyerValeurCorrecte("id_personne");
  | 
        
        
            | 
            | 
           146 | 
           	}
  | 
        
        
            | 
            | 
           147 | 
           	public void setIdPersonne(String ip) {
  | 
        
        
            | 
            | 
           148 | 
           		set("id_personne", ip);
  | 
        
        
            | 
            | 
           149 | 
           	}
  | 
        
        
            | 
            | 
           150 | 
              | 
        
        
            | 
            | 
           151 | 
           	// ID RôLE
  | 
        
        
            | 
            | 
           152 | 
           	public String getIdRole() {
  | 
        
        
           | 1468 | 
           jpm | 
           153 | 
           		String role = renvoyerValeurCorrecte("id_role");
  | 
        
        
           | 1513 | 
           jpm | 
           154 | 
           		return role;
  | 
        
        
            | 
            | 
           155 | 
           		/*
  | 
        
        
           | 1468 | 
           jpm | 
           156 | 
           		if (role != null && !UtilString.isEmpty(role)) return role;
  | 
        
        
           | 1513 | 
           jpm | 
           157 | 
           		else return renvoyerValeurCorrecte("_role_");*/
  | 
        
        
           | 875 | 
           jpm | 
           158 | 
           	}
  | 
        
        
            | 
            | 
           159 | 
           	public void setIdRole(String ir) {
  | 
        
        
            | 
            | 
           160 | 
           		set("id_role", ir);
  | 
        
        
            | 
            | 
           161 | 
           	}
  | 
        
        
           | 883 | 
           jpm | 
           162 | 
              | 
        
        
           | 875 | 
           jpm | 
           163 | 
           }
  |