Subversion Repositories eFlore/Applications.coel

Rev

Rev 935 | Rev 1369 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.modeles.collection;

import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.modeles.publication.Publication;

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

public class CollectionAPublication extends aDonnee {
        
        private static final long serialVersionUID = 1L;
        
        public static final String PREFIXE = "ccapu";
        private Publication publicationLiee = null;
        public static String[] champsObligatoires = {"ccapu_id_collection", "ccapu_id_publication"};
        
        public CollectionAPublication() {
                initialiser(new JSONObject());
        }
                        
        public CollectionAPublication(JSONObject collectionAPublicationListe) {
                initialiser(collectionAPublicationListe);
        }
        
        @Override
        protected String getPrefixe() {
                return PREFIXE;
        }
        
        protected String[] getChampsObligatoires()      {
                return champsObligatoires;
        }
        
        private void initialiser(JSONObject collectionAPublicationListe) {
                setPublication(new Publication(collectionAPublicationListe));
                initialiserChampsPourGrille();
                initialiserModele(collectionAPublicationListe);
        }
        
        // PUBLICATION
        public Publication getPublication() {
                return publicationLiee;
        }
        public void setPublication(Publication publication) {
                publicationLiee = publication;
                initialiserChampsPourGrille();
                if (publication != null) {
                        setIdPublication(publication.getId());
                }
        }
        
        private void initialiserChampsPourGrille() {
                set("fmt_auteur", getPublication().getAuteur());
                set("titre", getPublication().getTitre());
                set("collection", getPublication().getCollection());
                set("_editeur_", "");
                set("_annee_", "");
                set("indication_nvt", getPublication().getIndicationNvt());
                set("fascicule", getPublication().getFascicule());
                set("truk_pages", getPublication().getPages());
                set("_etat_", "");
        }
        
        // ID
        /** Génère un identifiant de CollectionAPersonne.
         * 
         * C'est une concaténation des clés primaires de la table coel_collection_a_personne séparées par un tiret "-".
         * 
         * @return identifiant unique d'une relation "collection à personne".
         */
        public String getId() {
                String idCollection = getIdCollection();
                String idPublication = getIdPublication();
                if (idCollection.equals("") && idPublication.equals("")) {
                        return null;
                } else {
                        return (idCollection+"-"+idPublication);
                }
        }
        
        //+---------------------------------------------------------------------------------------------------------------+
        // CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_PERSONNE
        
        // ID COLLECTION
        public String getIdCollection() {
                return renvoyerValeurCorrecte("id_collection");
        }
        public void setIdCollection(String idCollection) {
                set("id_collection", idCollection);
        }
        
        // ID PUBLICATION
        public String getIdPublication() {
                return renvoyerValeurCorrecte("id_publication");
        }
        public void setIdPublication(String ip) {
                set("id_publication", ip);
        }
                        
}