Subversion Repositories eFlore/Applications.coel

Rev

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

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