Subversion Repositories eFlore/Applications.coel

Rev

Rev 985 | Rev 1173 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
985 jpm 1
package org.tela_botanica.client.modeles.collection;
2
 
3
import org.tela_botanica.client.modeles.aDonnee;
4
import org.tela_botanica.client.modeles.commentaire.Commentaire;
5
 
6
import com.google.gwt.json.client.JSONObject;
7
 
8
public class CollectionACommentaire extends aDonnee {
9
 
10
	private static final long serialVersionUID = 8751553802444398035L;
11
	public static final String PREFIXE = "ccac";
12
	private Commentaire commentaireLiee = null;
13
 
14
	public CollectionACommentaire() {
15
		initialiser(new JSONObject(), false);
16
	}
17
 
18
	public CollectionACommentaire(JSONObject collectionACommentaireListe) {
997 jpm 19
		initialiser(collectionACommentaireListe, true);
985 jpm 20
	}
21
 
22
	public CollectionACommentaire(JSONObject collectionACommentaireListe, boolean chargerCommentaire) {
23
		initialiser(collectionACommentaireListe, chargerCommentaire);
24
	}
25
 
26
	@Override
27
	protected String getPrefixe() {
28
		return PREFIXE;
29
	}
30
 
31
	private void initialiser(JSONObject collectionACommentaireListe, boolean chargerCommentaire) {
32
		if (chargerCommentaire) {
33
			setCommentaire(new Commentaire(collectionACommentaireListe, false));
34
		} else {
35
			setCommentaire(new Commentaire());
36
		}
37
		initialiserModele(collectionACommentaireListe);
38
		initialiserChampsPourGrille();
39
	}
40
 
41
	// COMMENTAIRE
42
	public Commentaire getCommentaire() {
43
		return commentaireLiee;
44
	}
45
	public void setCommentaire(Commentaire commentaire) {
46
		commentaireLiee = commentaire;
47
		initialiserChampsPourGrille();
48
		if (commentaire != null) {
49
			setIdCommentaire(commentaire.getId());
50
		}
51
	}
52
 
53
	private void initialiserChampsPourGrille() {
54
		set("_type_", getType());
55
		set("_titre_", getCommentaire().getTitre());
56
		set("_texte_", getCommentaire().getTexte());
57
		set("_ponderation_", getCommentaire().getPonderation());
58
		set("_public_", getCommentaire().getPublic());
59
		set("_etat_", "");
60
	}
61
 
62
	// ID
63
	/** Génère un identifiant de CollectionACommentaire.
64
	 *
65
	 * C'est une concaténation des clés primaires de la table coel_collection_a_commentaire séparées par un tiret "-".
66
	 *
67
	 * @return identifiant unique d'une relation "collection à commentaire".
68
	 */
69
	public String getId() {
70
		String idCollection = getIdCollection();
71
		String idCommentaire = getIdCommentaire();
72
		if (idCollection.equals("") && idCommentaire.equals("")) {
73
			return null;
74
		} else {
75
			return (idCollection+"-"+idCommentaire);
76
		}
77
	}
78
 
79
	//+---------------------------------------------------------------------------------------------------------------+
80
	// CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_COMMENTAIRE
81
 
82
	// ID COLLECTION
83
	public String getIdCollection() {
84
		return renvoyerValeurCorrecte("id_collection");
85
	}
86
	public void setIdCollection(String idCollection) {
87
		set("id_collection", idCollection);
88
	}
89
 
90
	// ID COMENTAIRE
91
	public String getIdCommentaire() {
92
		return renvoyerValeurCorrecte("id_commentaire");
93
	}
94
	public void setIdCommentaire(String ic) {
95
		set("id_commentaire", ic);
96
	}
97
 
98
	// TRUCK TYPE
99
	public String getType() {
100
		return renvoyerValeurCorrecte("truk_type");
101
	}
102
	public void setType(String type) {
103
		set("truk_type", type);
104
	}
105
}