985 |
jpm |
1 |
package org.tela_botanica.client.modeles.commentaire;
|
|
|
2 |
|
1513 |
jpm |
3 |
import java.util.Iterator;
|
|
|
4 |
import java.util.Map;
|
|
|
5 |
import java.util.Set;
|
|
|
6 |
|
985 |
jpm |
7 |
import org.tela_botanica.client.Mediateur;
|
|
|
8 |
import org.tela_botanica.client.modeles.aDonnee;
|
|
|
9 |
import org.tela_botanica.client.modeles.collection.Collection;
|
|
|
10 |
import org.tela_botanica.client.modeles.collection.CollectionACommentaire;
|
1329 |
cyprien |
11 |
import org.tela_botanica.client.util.Debug;
|
985 |
jpm |
12 |
|
1513 |
jpm |
13 |
import com.extjs.gxt.ui.client.data.ModelData;
|
985 |
jpm |
14 |
import com.google.gwt.json.client.JSONObject;
|
|
|
15 |
|
|
|
16 |
public class Commentaire extends aDonnee {
|
|
|
17 |
|
|
|
18 |
private static final long serialVersionUID = 7216356814682582569L;
|
1513 |
jpm |
19 |
public static final String PREFIXE = "ccm";
|
985 |
jpm |
20 |
private Collection collection = null;
|
|
|
21 |
private CollectionACommentaire collectionACommentaire = null;
|
1173 |
jpm |
22 |
public static String[] champsObligatoires = {"ccm_id_commentaire"};
|
985 |
jpm |
23 |
|
|
|
24 |
public Commentaire() {
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public Commentaire(JSONObject commentaire) {
|
|
|
28 |
initialiserCommentaire(commentaire, false);
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public Commentaire(JSONObject commentaire, boolean chargerCollectionACommentaire) {
|
|
|
32 |
initialiserCommentaire(commentaire, chargerCollectionACommentaire);
|
|
|
33 |
}
|
|
|
34 |
|
1513 |
jpm |
35 |
public Commentaire(ModelData model)
|
|
|
36 |
{
|
|
|
37 |
Map<String, Object> a = model.getProperties();
|
|
|
38 |
|
|
|
39 |
Set<String> cles = a.keySet();
|
|
|
40 |
Iterator<String> it = cles.iterator();
|
|
|
41 |
while (it.hasNext()) {
|
|
|
42 |
String cle = it.next();
|
|
|
43 |
if (a.get(cle) != null) {
|
|
|
44 |
String cleObjet = cle.replaceFirst("^"+getPrefixe()+"_", "");
|
|
|
45 |
this.set(cleObjet, a.get(cle));
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
|
985 |
jpm |
50 |
public void initialiserCommentaire(JSONObject commentaire, boolean chargerCollectionACommentaire) {
|
|
|
51 |
initialiserModele(commentaire);
|
1329 |
cyprien |
52 |
|
985 |
jpm |
53 |
collection = new Collection(commentaire);
|
1329 |
cyprien |
54 |
|
985 |
jpm |
55 |
if (chargerCollectionACommentaire) {
|
|
|
56 |
collectionACommentaire = new CollectionACommentaire(commentaire);
|
|
|
57 |
} else {
|
|
|
58 |
collectionACommentaire = new CollectionACommentaire();
|
|
|
59 |
}
|
|
|
60 |
initialiserChampsPourGrille();
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
@Override
|
|
|
64 |
protected String getPrefixe() {
|
|
|
65 |
return PREFIXE;
|
|
|
66 |
}
|
|
|
67 |
|
1173 |
jpm |
68 |
protected String[] getChampsObligatoires() {
|
|
|
69 |
return champsObligatoires;
|
|
|
70 |
}
|
|
|
71 |
|
985 |
jpm |
72 |
private void initialiserChampsPourGrille() {
|
|
|
73 |
set("_collection_nom_", getCollection().getNom());
|
|
|
74 |
set("_type_", getCollectionACommentaire().getType());
|
|
|
75 |
set("_titre_", getTitre());
|
|
|
76 |
set("_texte_", getTexteResume());
|
|
|
77 |
set("_ponderation_", getPonderation());
|
|
|
78 |
set("_public_", getPublic());
|
|
|
79 |
set("_etat_", "");
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
public Collection getCollection() {
|
|
|
83 |
if (collection == null) {
|
|
|
84 |
collection = new Collection();
|
|
|
85 |
}
|
|
|
86 |
return collection;
|
|
|
87 |
}
|
|
|
88 |
public void setCollection(Collection collectionAStocker) {
|
|
|
89 |
collection = collectionAStocker;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
public CollectionACommentaire getCollectionACommentaire() {
|
|
|
93 |
if (collectionACommentaire == null) {
|
|
|
94 |
collectionACommentaire = new CollectionACommentaire();
|
|
|
95 |
}
|
|
|
96 |
return collectionACommentaire;
|
|
|
97 |
}
|
|
|
98 |
public void setCollectionACommentaire(CollectionACommentaire collectionACommentaireAStocker) {
|
|
|
99 |
collectionACommentaire = collectionACommentaireAStocker;
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
public String getId() {
|
|
|
103 |
return renvoyerValeurCorrecte("id_commentaire");
|
|
|
104 |
}
|
|
|
105 |
public void setId(String idCommentaire) {
|
|
|
106 |
this.set("id_commentaire", idCommentaire);
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
public String getIdProjet() {
|
|
|
110 |
return renvoyerValeurCorrecte("ce_projet");
|
|
|
111 |
}
|
|
|
112 |
public void setIdProjet(String idProjet) {
|
|
|
113 |
this.set("ce_projet", idProjet);
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
public String getCommentairePereId() {
|
|
|
117 |
return renvoyerValeurCorrecte("ce_pere");
|
|
|
118 |
}
|
|
|
119 |
public void setCommentairePereId(String idPere) {
|
|
|
120 |
this.set("ce_pere", idPere);
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
public String getTitre() {
|
|
|
124 |
return renvoyerValeurCorrecte("titre");
|
|
|
125 |
}
|
|
|
126 |
public void setTitre(String titre) {
|
|
|
127 |
this.set("titre", titre);
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
public String getTexteResume() {
|
|
|
131 |
String resume = getTexte();
|
|
|
132 |
if (getTexte().length() > 100) {
|
|
|
133 |
resume = getTexte().substring(0, 100);
|
|
|
134 |
}
|
|
|
135 |
return resume;
|
|
|
136 |
}
|
|
|
137 |
public String getTexte() {
|
|
|
138 |
return renvoyerValeurCorrecte("texte");
|
|
|
139 |
}
|
|
|
140 |
public void setTexte(String texte) {
|
|
|
141 |
this.set("texte", texte);
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
public String getPonderation() {
|
|
|
145 |
return renvoyerValeurCorrecte("ponderation");
|
|
|
146 |
}
|
|
|
147 |
public void setPonderation(String ponderation) {
|
|
|
148 |
this.set("ponderation", ponderation);
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
public boolean etrePublic() {
|
|
|
152 |
return (getPublic().equals("1") ? true : false);
|
|
|
153 |
}
|
|
|
154 |
public String getPublic() {
|
989 |
jpm |
155 |
return renvoyerValeurCorrecte("mark_public");
|
985 |
jpm |
156 |
}
|
|
|
157 |
public void setPublic(String publique) {
|
989 |
jpm |
158 |
this.set("mark_public", publique);
|
985 |
jpm |
159 |
}
|
|
|
160 |
|
|
|
161 |
}
|