Subversion Repositories eFlore/Applications.coel

Rev

Rev 1135 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
935 jpm 1
package org.tela_botanica.client.modeles.collection;
875 jpm 2
 
935 jpm 3
import org.tela_botanica.client.modeles.aDonnee;
4
import org.tela_botanica.client.modeles.personne.Personne;
5
 
875 jpm 6
import com.google.gwt.json.client.JSONObject;
7
 
8
public class CollectionAPersonne extends aDonnee {
9
 
10
	private static final long serialVersionUID = 1L;
11
 
12
	public static final String PREFIXE = "ccap";
13
	private Personne personneLiee = null;
14
 
15
	public CollectionAPersonne() {
16
		initialiser(new JSONObject());
17
	}
18
 
19
	public CollectionAPersonne(JSONObject collectionAPersonneListe) {
20
		initialiser(collectionAPersonneListe);
21
	}
22
 
23
	@Override
24
	protected String getPrefixe() {
25
		return PREFIXE;
26
	}
27
 
28
	private void initialiser(JSONObject collectionAPersonneListe) {
29
		setPersonne(new Personne(collectionAPersonneListe));
883 jpm 30
		initialiserModele(collectionAPersonneListe);
875 jpm 31
		initialiserChampsPourGrille();
32
	}
33
 
34
	// PERSONNE
35
	public Personne getPersonne() {
36
		return personneLiee;
37
	}
38
	public void setPersonne(Personne personne) {
39
		personneLiee = personne;
40
		initialiserChampsPourGrille();
907 jpm 41
		if (personne != null) {
42
			setIdPersonne(personne.getId());
43
		}
875 jpm 44
	}
45
 
46
	private void initialiserChampsPourGrille() {
883 jpm 47
		set("_role_", getIdRole());
875 jpm 48
		set("fmt_nom_complet", getPersonne().getNomComplet());
49
		set("nom", getPersonne().getNom());
50
		set("prenom", getPersonne().getPrenom());
51
		set("naissance_date", getPersonne().getNaissanceDate());
52
		set("naissance_lieu", getPersonne().getNaissanceLieu());
883 jpm 53
		set("_deces_", getPersonne().getDeces());
875 jpm 54
		set("deces_date", getPersonne().getDecesDate());
55
		set("deces_lieu", getPersonne().getDecesLieu());
883 jpm 56
		set("_etat_", "");
875 jpm 57
	}
58
 
59
	// ID
60
	/** Génère un identifiant de CollectionAPersonne.
61
	 *
62
	 * C'est une concaténation des clés primaires de la table coel_collection_a_personne séparées par un tiret "-".
63
	 *
64
	 * @return identifiant unique d'une relation "collection à personne".
65
	 */
66
	public String getId() {
67
		String idCollection = getIdCollection();
68
		String idPersonne = getIdPersonne();
69
		String idRole = getIdRole();
70
		if (idCollection.equals("") && idPersonne.equals("") && idRole.equals("")) {
71
			return null;
72
		} else {
73
			return (idCollection+"-"+idPersonne+"-"+idRole);
74
		}
75
	}
76
 
77
	//+---------------------------------------------------------------------------------------------------------------+
78
	// CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_PERSONNE
79
 
80
	// ID COLLECTION
81
	public String getIdCollection() {
82
		return renvoyerValeurCorrecte("id_collection");
83
	}
84
	public void setIdCollection(String idCollection) {
85
		set("id_collection", idCollection);
86
	}
87
 
88
	// ID PERSONNE
89
	public String getIdPersonne() {
90
		return renvoyerValeurCorrecte("id_personne");
91
	}
92
	public void setIdPersonne(String ip) {
93
		set("id_personne", ip);
94
	}
95
 
96
	// ID RôLE
97
	public String getIdRole() {
98
		return renvoyerValeurCorrecte("id_role");
99
	}
100
	public void setIdRole(String ir) {
101
		set("id_role", ir);
102
	}
883 jpm 103
 
875 jpm 104
}