Subversion Repositories eFlore/Applications.coel

Rev

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