Subversion Repositories eFlore/Applications.coel

Rev

Rev 1136 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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