Subversion Repositories eFlore/Applications.coel

Rev

Rev 1135 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.modeles.commentaire;

import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.collection.CollectionACommentaire;

import com.google.gwt.json.client.JSONObject;

public class Commentaire extends aDonnee {

        private static final long serialVersionUID = 7216356814682582569L;
        private static final String PREFIXE = "ccm";
        private Collection collection = null;
        private CollectionACommentaire collectionACommentaire = null;
        
        public Commentaire() {  
        }
        
        public Commentaire(JSONObject commentaire) {
                initialiserCommentaire(commentaire, false);
        }

        public Commentaire(JSONObject commentaire, boolean chargerCollectionACommentaire) {
                initialiserCommentaire(commentaire, chargerCollectionACommentaire);
        }
        
        public void initialiserCommentaire(JSONObject commentaire, boolean chargerCollectionACommentaire) {
                initialiserModele(commentaire);
                collection = new Collection(commentaire);
                if (chargerCollectionACommentaire) {
                        collectionACommentaire = new CollectionACommentaire(commentaire);
                } else {
                        collectionACommentaire = new CollectionACommentaire();
                }
                initialiserChampsPourGrille();
        }
        
        @Override
        protected String getPrefixe() {
                return PREFIXE;
        }
        
        private void initialiserChampsPourGrille() {
                set("_collection_nom_", getCollection().getNom());
                set("_type_", getCollectionACommentaire().getType());
                set("_titre_", getTitre());
                set("_texte_", getTexteResume());
                set("_ponderation_", getPonderation());
                set("_public_", getPublic());
                set("_etat_", "");
        }
        
        public Collection getCollection() {
                if (collection == null) {
                        collection = new Collection();
                }
                return collection;
        }
        public void setCollection(Collection collectionAStocker) {
                collection = collectionAStocker;
        }
        
        public CollectionACommentaire getCollectionACommentaire() {
                if (collectionACommentaire == null) {
                        collectionACommentaire = new CollectionACommentaire();
                }
                return collectionACommentaire;
        }
        public void setCollectionACommentaire(CollectionACommentaire collectionACommentaireAStocker) {
                collectionACommentaire = collectionACommentaireAStocker;
        }
        
        public String getId() {
                return renvoyerValeurCorrecte("id_commentaire");
        }
        public void setId(String idCommentaire) {
                this.set("id_commentaire", idCommentaire);
        }
        
        public String getIdProjet() {
                return renvoyerValeurCorrecte("ce_projet");
        }
        public void setIdProjet(String idProjet) {
                this.set("ce_projet", idProjet);
        }
        
        public String getCommentairePereId() {
                return renvoyerValeurCorrecte("ce_pere");
        }
        public void setCommentairePereId(String idPere) {
                this.set("ce_pere", idPere);
        }
        
        public String getTitre() {
                return renvoyerValeurCorrecte("titre");
        }
        public void setTitre(String titre) {
                this.set("titre", titre);
        }
        
        public String getTexteResume() {
                String resume = getTexte();
                if (getTexte().length() > 100) {
                        resume = getTexte().substring(0, 100);
                }
                return resume;
        }
        public String getTexte() {
                return renvoyerValeurCorrecte("texte");
        }
        public void setTexte(String texte) {
                this.set("texte", texte);
        }
        
        public String getPonderation() {
                return renvoyerValeurCorrecte("ponderation");
        }
        public void setPonderation(String ponderation) {
                this.set("ponderation", ponderation);
        }
        
        public boolean etrePublic() {
                return (getPublic().equals("1") ? true : false);
        }
        public String getPublic() {
                return renvoyerValeurCorrecte("mark_public");
        }
        public void setPublic(String publique) {
                this.set("mark_public", publique);
        }
        
}