Subversion Repositories eFlore/Applications.del

Rev

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

package org.tela_botanica.del.client.cache;

import java.util.List;

import org.tela_botanica.del.client.gestionhistorique.ConstantesNavigation;
import org.tela_botanica.del.client.modeles.Image;
import org.tela_botanica.del.client.modeles.InformationsRecherche;
import org.tela_botanica.del.client.modeles.Observation;
import org.tela_botanica.del.client.modeles.Protocole;
import org.tela_botanica.del.client.modeles.Utilisateur;

import com.google.gwt.user.client.Window.Location;

public class CacheClient {

        private List<Protocole> listeProtocoles;
        
        private String home = ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS;
        private Observation observationCourante;
        private Image imageCourante;
        private String taxonPourRechercheEflore;
        private Protocole protocoleCourant;
        private String referentielCourant;
        private int numPageRechercheImage = 0;
        private int nbTotalImagesRecherchees = 0;
        
        private boolean referentielNonModifiable = false;

        private int pasPagination = 12;
        private int pageCouranteRechercheImage = 1;
        private int pageCouranteRechercheObservations = 1;
        private InformationsRecherche informationsRechercheImage;
        private InformationsRecherche informationsRechercheObservation;
        private Utilisateur utilisateur;
        private String pageCourante = home;
        private String statut;
        
        public void supprimerFiltreStatut() {
                this.statut = null;
        }
        
        public void setFiltreStatut(String statut) {
                this.statut = statut;
        }
        
        public String getFiltreStatut() {
                return this.statut;
        }
        
        public String getPageCourante() {
                return pageCourante;
        }

        public void setPageCourante(String pageCourante) {
                this.pageCourante = pageCourante;
        }

        private static CacheClient instance;

        private CacheClient() {
                instance = this;
        }

        public void initialiserAvecParametres() {
                String rechercheLibre = Location.getParameter("masque");
                String famille = Location.getParameter("masque.famille");
                String taxon = Location.getParameter("masque.ns");
                String genre = Location.getParameter("masque.genre");
                String commune = Location.getParameter("masque.commune");
                String dept = Location.getParameter("masque.departement");
                String auteur = Location.getParameter("masque.auteur");
                String date = Location.getParameter("masque.date");
                String tag = Location.getParameter("masque.tag");
                String referentiel = Location.getParameter("masque.referentiel");
                
                InformationsRecherche rechercheParArguments = new InformationsRecherche();
                rechercheParArguments.setRechercheLibre(rechercheLibre);
                rechercheParArguments.setFamille(famille);
                rechercheParArguments.setTaxon(taxon);
                rechercheParArguments.setGenre(genre);
                rechercheParArguments.setCommune(commune);
                rechercheParArguments.setDepartement(dept);
                rechercheParArguments.setAuteur(auteur);
                rechercheParArguments.setDate(date);
                rechercheParArguments.setTag(tag);
                rechercheParArguments.setMotClef(tag);
                
                // si le référentiel est passé dans l'url alors il ne doit pas être modifiable
                if(referentiel != null && !referentiel.equals("")) {
                        setReferentielCourant(referentiel);
                        rechercheParArguments.setReferentiel(referentiel);
                        referentielNonModifiable = true;
                }
                
                informationsRechercheImage = rechercheParArguments;
                informationsRechercheObservation = rechercheParArguments;
        }
        
        public Utilisateur getUtilisateur() {
                if (this.utilisateur == null) {
                        this.utilisateur = new Utilisateur(null);
                }
                return this.utilisateur;
        }
        
        public void setUtilisateur(Utilisateur utilisateur) {
                this.utilisateur = utilisateur; 
        }
        
        public void setHome(String home) {
                this.home = home;
                setPageCourante(home);
        }
        
        public String getHome() {
                return home;
        }
        
        public Observation getObservationCourante() {
                return observationCourante;
        }

        public void setObservationCourante(Observation observationCourante) {
                this.observationCourante = observationCourante;
        }

        public static CacheClient getInstance() {
                if (instance == null) {
                        instance = new CacheClient();
                }
                return instance;
        }

        public String getTaxonPourRechercheEflore() {
                return taxonPourRechercheEflore;
        }

        public void setTaxonPourRechercheEflore(String taxonPourRechercheEflore) {
                this.taxonPourRechercheEflore = taxonPourRechercheEflore;
        }

        public int getNumPageRechercheImage() {
                return numPageRechercheImage;
        }

        // Pour la recherche :
        public int getPasPagination() {
                return pasPagination;
        }

        public void setPasPagination(int pasPagination) {
                this.pasPagination = pasPagination;
        }

        public void setPageCouranteRechercheImages(int pageCouranteRecherche) {
                this.pageCouranteRechercheImage = pageCouranteRecherche;
        }

        public int getPageCouranteRechercheImage() {
                return this.pageCouranteRechercheImage;
        }

        public void setNbTotalImagesRecherchees(int nbTotalImagesRecherchees) {
                this.nbTotalImagesRecherchees = nbTotalImagesRecherchees;
        }

        public int getNbTotalImagesRecherchees() {
                return this.nbTotalImagesRecherchees;
        }

        public Image getImageCourante() {
                return imageCourante;
        }

        public void setImageCourante(Image imageCourante) {
                this.imageCourante = imageCourante;
        }
        
        public void setListeProtocoles(List<Protocole> listeProtocole) {
                this.listeProtocoles = listeProtocole;
        }
        
        public List<Protocole> getListeProtocoles() {
                return this.listeProtocoles;
        }

        public Protocole getProtocoleCourant() {
                return protocoleCourant;
        }

        public void setProtocoleCourant(Protocole protocoleCourant) {
                this.protocoleCourant = protocoleCourant;
        }

        public InformationsRecherche getInformationsRechercheImage() {
                if(informationsRechercheImage == null) {
                        informationsRechercheImage = new InformationsRecherche();
                }
                return informationsRechercheImage;
        }

        public InformationsRecherche getInformationsRechercheObservation() {
                if(informationsRechercheObservation == null) {
                        informationsRechercheObservation = new InformationsRecherche();
                }
                return informationsRechercheObservation;
        }

        public void setInformationsRechercheImage(InformationsRecherche informationsRechercheImage) {
                this.informationsRechercheImage = informationsRechercheImage;
        }

        public void setInformationsRechercheObservation(InformationsRecherche informationsRechercheObservation) {
                this.informationsRechercheObservation = informationsRechercheObservation;
        }

        public int getPageCouranteRechercheObservations() {
                return pageCouranteRechercheObservations;
        }

        public void setPageCouranteRechercheObservations(int pageCouranteRechercheObservations) {
                this.pageCouranteRechercheObservations = pageCouranteRechercheObservations;
        }
        
        public void setReferentielCourant(String referentielCourant) {
                this.referentielCourant = referentielCourant;
        }
        
        public String getReferentielCourant() {
                return referentielCourant;
        }
        
        public void setReferentielNonModifiable(boolean referentielNonModifiable) {
                this.referentielNonModifiable = referentielNonModifiable;
        }
        
        public boolean getReferentielNonModifiable() {
                return referentielNonModifiable;
        }
}