Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1417 Rev 1513
1
package org.tela_botanica.client.modeles.collection;
1
package org.tela_botanica.client.modeles.collection;
-
 
2
 
-
 
3
import java.util.Iterator;
-
 
4
import java.util.Map;
-
 
5
import java.util.Set;
2
 
6
 
3
import org.tela_botanica.client.modeles.aDonnee;
7
import org.tela_botanica.client.modeles.aDonnee;
-
 
8
import org.tela_botanica.client.modeles.commentaire.Commentaire;
-
 
9
import org.tela_botanica.client.modeles.personne.Personne;
-
 
10
import org.tela_botanica.client.modeles.publication.Publication;
4
import org.tela_botanica.client.modeles.commentaire.Commentaire;
11
 
5
 
12
import com.extjs.gxt.ui.client.data.ModelData;
6
import com.google.gwt.json.client.JSONObject;
13
import com.google.gwt.json.client.JSONObject;
7
 
14
 
8
public class CollectionACommentaire extends aDonnee {
15
public class CollectionACommentaire extends aDonnee {
9
	
16
	
10
	private static final long serialVersionUID = 8751553802444398035L;
17
	private static final long serialVersionUID = 8751553802444398035L;
11
	public static final String PREFIXE = "ccac";
18
	public static final String PREFIXE = "ccac";
-
 
19
	private boolean removePrefix = true;
12
	private Commentaire commentaireLiee = null;
20
	private Commentaire commentaireLiee = null;
13
	public static String[] champsObligatoires = {"cc_id_collection", "ccac_id_commentaire"};
21
	public static String[] champsObligatoires = {"cc_id_collection", "ccac_id_commentaire"};
14
	
22
	
15
	public CollectionACommentaire() {
23
	public CollectionACommentaire() {
16
		initialiser(new JSONObject(), false);
24
		initialiser(new JSONObject(), false);
17
	}
25
	}
18
			
26
			
19
	public CollectionACommentaire(JSONObject collectionACommentaireListe) {
27
	public CollectionACommentaire(JSONObject collectionACommentaireListe) {
20
		initialiser(collectionACommentaireListe, true);
28
		initialiser(collectionACommentaireListe, true);
21
	}
29
	}
22
	
30
	
23
	public CollectionACommentaire(JSONObject collectionACommentaireListe, boolean chargerCommentaire) {
31
	public CollectionACommentaire(JSONObject collectionACommentaireListe, boolean chargerCommentaire) {
24
		initialiser(collectionACommentaireListe, chargerCommentaire);
32
		initialiser(collectionACommentaireListe, chargerCommentaire);
25
	}
33
	}
-
 
34
	
-
 
35
	public CollectionACommentaire(ModelData model, boolean removePrefix)
-
 
36
	{
-
 
37
		this.removePrefix = removePrefix;
-
 
38
		
-
 
39
		Map<String, Object> a = model.getProperties();
-
 
40
		
-
 
41
		Set<String> cles = a.keySet();
-
 
42
		Iterator<String> it = cles.iterator();
-
 
43
		while (it.hasNext()) {
-
 
44
			String cle = it.next();
-
 
45
			if (a.get(cle) != null) {
-
 
46
				String cleObjet = "";
-
 
47
				if (removePrefix) {
-
 
48
					cleObjet = cle.replaceFirst("^"+CollectionACommentaire.PREFIXE+"_", "");
-
 
49
					cleObjet = cleObjet.replaceFirst("^"+Commentaire.PREFIXE+"_", "");
-
 
50
				}
-
 
51
				else {
-
 
52
					cleObjet = cle;
-
 
53
				}
-
 
54
				this.set(cleObjet, a.get(cle));
-
 
55
			}
-
 
56
		}
-
 
57
 
-
 
58
		setCommentaire(new Commentaire(model));
-
 
59
		this.set("_etat_", a.get("_etat_"));
-
 
60
		this.set("_type_", a.get("_type_"));
-
 
61
	}
26
	
62
	
27
	@Override
63
	@Override
28
	protected String getPrefixe() {
64
	protected String getPrefixe() {
29
		return PREFIXE;
65
		return PREFIXE;
30
	}
66
	}
31
	
67
	
32
	protected String[] getChampsObligatoires()	{
68
	protected String[] getChampsObligatoires()	{
33
		return champsObligatoires;
69
		return champsObligatoires;
34
	}
70
	}
35
	
71
	
36
	private void initialiser(JSONObject collectionACommentaireListe, boolean chargerCommentaire) {
72
	private void initialiser(JSONObject collectionACommentaireListe, boolean chargerCommentaire) {
37
		if (chargerCommentaire) {
73
		if (chargerCommentaire) {
38
			setCommentaire(new Commentaire(collectionACommentaireListe, false));
74
			setCommentaire(new Commentaire(collectionACommentaireListe, false));
39
		} else {
75
		} else {
40
			setCommentaire(new Commentaire());
76
			setCommentaire(new Commentaire());
41
		}
77
		}
42
		initialiserModele(collectionACommentaireListe);
78
		initialiserModele(collectionACommentaireListe);
43
		initialiserChampsPourGrille();
79
		initialiserChampsPourGrille();
44
	}
80
	}
45
	
81
	
46
	// COMMENTAIRE
82
	// COMMENTAIRE
47
	public Commentaire getCommentaire() {
83
	public Commentaire getCommentaire() {
48
		return commentaireLiee;
84
		return commentaireLiee;
49
	}
85
	}
50
	public void setCommentaire(Commentaire commentaire) {
86
	public void setCommentaire(Commentaire commentaire) {
51
		commentaireLiee = commentaire;
87
		commentaireLiee = commentaire;
52
		initialiserChampsPourGrille();
88
		initialiserChampsPourGrille();
53
		if (commentaire != null) {
89
		if (commentaire != null) {
54
			setIdCommentaire(commentaire.getId());
90
			setIdCommentaire(commentaire.getId());
55
		}
91
		}
56
	}
92
	}
57
	
93
	
58
	private void initialiserChampsPourGrille() {
94
	private void initialiserChampsPourGrille() {
59
		set("_type_", getType());
95
		set("_type_", getType());
60
		set("_titre_", getCommentaire().getTitre());
96
		set("_titre_", getCommentaire().getTitre());
61
		set("_texte_", getCommentaire().getTexte());
97
		set("_texte_", getCommentaire().getTexte());
62
		set("_ponderation_", getCommentaire().getPonderation());
98
		set("_ponderation_", getCommentaire().getPonderation());
63
		set("_public_", getCommentaire().getPublic());
99
		set("_public_", getCommentaire().getPublic());
64
		set("_etat_", "");
100
		set("_etat_", "");
65
	}
101
	}
66
	
102
	
67
	// ID
103
	// ID
68
	/** Génère un identifiant de CollectionACommentaire.
104
	/** Génère un identifiant de CollectionACommentaire.
69
	 * 
105
	 * 
70
	 * C'est une concaténation des clés primaires de la table coel_collection_a_commentaire séparées par un tiret "-".
106
	 * C'est une concaténation des clés primaires de la table coel_collection_a_commentaire séparées par un tiret "-".
71
	 * 
107
	 * 
72
	 * @return identifiant unique d'une relation "collection à commentaire".
108
	 * @return identifiant unique d'une relation "collection à commentaire".
73
	 */
109
	 */
74
	public String getId() {
110
	public String getId() {
75
		String idCollection = getIdCollection();
111
		String idCollection = getIdCollection();
76
		String idCommentaire = getIdCommentaire();
112
		String idCommentaire = getIdCommentaire();
77
		if (idCollection.equals("") && idCommentaire.equals("")) {
113
		if (idCollection.equals("") && idCommentaire.equals("")) {
78
			return null;
114
			return null;
79
		} else {
115
		} else {
80
			return (idCollection+"-"+idCommentaire);
116
			return (idCollection+"-"+idCommentaire);
81
		}
117
		}
82
	}
118
	}
83
	
119
	
84
	//+---------------------------------------------------------------------------------------------------------------+
120
	//+---------------------------------------------------------------------------------------------------------------+
85
	// CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_COMMENTAIRE
121
	// CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_COMMENTAIRE
86
	
122
	
87
	// ID COLLECTION
123
	// ID COLLECTION
88
	public String getIdCollection() {
124
	public String getIdCollection() {
89
		return renvoyerValeurCorrecte("id_collection");
125
		return renvoyerValeurCorrecte("id_collection");
90
	}
126
	}
91
	public void setIdCollection(String idCollection) {
127
	public void setIdCollection(String idCollection) {
92
		set("id_collection", idCollection);
128
		set("id_collection", idCollection);
93
	}
129
	}
94
	
130
	
95
	// ID COMENTAIRE
131
	// ID COMENTAIRE
96
	public String getIdCommentaire() {
132
	public String getIdCommentaire() {
97
		return renvoyerValeurCorrecte("id_commentaire");
133
		return renvoyerValeurCorrecte("id_commentaire");
98
	}
134
	}
99
	public void setIdCommentaire(String ic) {
135
	public void setIdCommentaire(String ic) {
100
		set("id_commentaire", ic);
136
		set("id_commentaire", ic);
101
	}
137
	}
102
	
138
	
103
	// TRUCK TYPE
139
	// TRUCK TYPE
104
	public String getType() {
140
	public String getType() {
105
		return renvoyerValeurCorrecte("truk_type");
141
		return renvoyerValeurCorrecte("truk_type");
106
	}
142
	}
107
	public void setType(String type) {
143
	public void setType(String type) {
108
		set("truk_type", type);
144
		set("truk_type", type);
109
	}
145
	}
110
}
146
}