Subversion Repositories eFlore/Applications.cel

Rev

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

package org.tela_botanica.client.modeles.objets;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.tela_botanica.client.i18n.Msg;

import com.gwtext.client.data.SimpleStore;
import com.gwtext.client.data.Store;

public class Ontologies {
        
        //TODO: extraire toutes ces valeurs dans des fichiers de configuration
        // ou bien via l'appel d'un web service spécialisé.
        private static HashMap<String, String> valeursCertitude = null;
        private static List<InfosReferentielNom> listeReferentielsNoms = null;

        public static Store getValeursCertitude() {
                Object[][] valeurs = {{Msg.get("certain"),"certain"}, 
                                {Msg.get("douteux"),"douteux"}, 
                                {Msg.get("a-determiner"),"aDeterminer"}
                        };
                SimpleStore storeCertitude = new SimpleStore(new String[] {"label","valeur"},valeurs);
                storeCertitude.load();
                return storeCertitude;
        }
        
        public static Store getValeursAbondance() {             
                Object[][] valeurs = {
                        {Msg.get("abondance-5"),"5"}, 
                        {Msg.get("abondance-4"),"4"}, 
                        {Msg.get("abondance-3"),"3"}, 
                        {Msg.get("abondance-2"),"2"}, 
                        {Msg.get("abondance-1"),"1"}, 
                        {Msg.get("abondance-+"),"+"},
                        {Msg.get("abondance-r"),"r"}, 
                        {Msg.get("abondance-i"),"i"},
                        {Msg.get("abondance-1-5"),"1-5"},
                        {Msg.get("abondance-5-10"),"5-10"},
                        {Msg.get("abondance-10-50"),"10-50"},
                        {Msg.get("abondance-50-100"),"50-100"},
                        {Msg.get("abondance-100-500"),"100-500"},
                        {Msg.get("abondance->500"),">500"},
                        {Msg.get("abondance-E"),"E"},
                        {Msg.get("abondance-RR"),"RR"},
                        {Msg.get("abondance-R"),"R"},
                        {Msg.get("abondance-AR"),"AR"},
                        {Msg.get("abondance-PC"),"PC"},
                        {Msg.get("abondance-AC"),"AC"},
                        {Msg.get("abondance-C"),"C"},
                        {Msg.get("abondance-CC"),"CC"}
                };
                SimpleStore storeAbondance = new SimpleStore(new String[] {"label","valeur"},valeurs);
                storeAbondance.load();
                return storeAbondance;
        }
        
        public static String getCorrespondanceCertitude(String cle) {
                if(valeursCertitude == null) {
                        valeursCertitude = new HashMap<String, String>();
                        valeursCertitude.put("certain", Msg.get("certain"));
                        valeursCertitude.put("douteux", Msg.get("douteux"));
                        valeursCertitude.put("aDeterminer", Msg.get("a-determiner"));
                }

                String valeur = valeursCertitude.get(cle);
                
                return valeur == null ? cle : valeur;
        }
        
        public static Store getValeursReferentiel() {
                List<InfosReferentielNom> listeReferentiels = Configuration.getReferentielsDispos();
                Object[][] valeurs = new Object[listeReferentiels.size()][2];
                int i = 0;
                for (Iterator<InfosReferentielNom> iterator = listeReferentiels.iterator(); iterator
                                .hasNext();) {
                        InfosReferentielNom infosReferentielNom = iterator.next();
                        
                        String referentielNom = Msg.get("referentiel-"+infosReferentielNom.getCode());  
                        String[] valeur = {referentielNom, infosReferentielNom.getCode()};
                        valeurs[i] = valeur;
                        i++;
                }
                SimpleStore storeReferentiels = new SimpleStore(new String[] {"label","valeur"},valeurs);
                storeReferentiels.load();
                return storeReferentiels;
        }

        public static InfosReferentielNom getInfosReferentielNomParCode(String code) {
                InfosReferentielNom infos = null;
                List<InfosReferentielNom> listeReferentiels = Configuration.getReferentielsDispos();
                for (Iterator<InfosReferentielNom> iterator = listeReferentiels.iterator(); iterator
                                .hasNext();) {
                        InfosReferentielNom infosReferentielNom = iterator.next();
                        if(infosReferentielNom.getCode().equals(code)) {
                                infos = infosReferentielNom;
                                break;
                        }
                }
                
                return infos;
        }
        
        public static Store getValeursPhenologie() {
                Object[][] valeurs = {
                        {Msg.get("phenologie-00-09"), "00-09"},
                        {Msg.get("phenologie-10-19"), "10-19"},
                        {Msg.get("phenologie-11"), "11"},
                        {Msg.get("phenologie-15"), "15"},
                        {Msg.get("phenologie-20-29"), "20-29"},
                        {Msg.get("phenologie-30-39"), "30-39"},
                        {Msg.get("phenologie-40-49"), "40-49"},
                        {Msg.get("phenologie-50-59"), "50-59"},
                        {Msg.get("phenologie-60-69"), "60-69"},
                        {Msg.get("phenologie-61"), "61"},
                        {Msg.get("phenologie-65"), "65"},
                        {Msg.get("phenologie-70-79"), "70-79"},
                        {Msg.get("phenologie-80-89"), "80-89"},
                        {Msg.get("phenologie-85"), "85"},
                        {Msg.get("phenologie-90-99"), "90-99"},
                        {Msg.get("phenologie-91"), "91"},
                        {Msg.get("phenologie-95"), "95"}
                };
                SimpleStore storeAbondance = new SimpleStore(new String[] {"label","valeur"},valeurs);
                storeAbondance.load();
                return storeAbondance;
        }
        
        public static HashMap<String, String> getCorrespondanceGrilleObservationChampsTri() {
                HashMap<String, String> correspondances = new HashMap<String, String>();
                correspondances.put("etat_observation", "transmission");
                correspondances.put("referentiel_taxo_observation", "nom_referentiel");
                correspondances.put("nomSaisi_observation", "nom_sel");
                correspondances.put("certitude", "certitude");
                correspondances.put("nomRetenu_observation", "nom_ret");
                correspondances.put("famille_observation", "famille");
                correspondances.put("abondance", "abondance");
                correspondances.put("phenologie", "phenologie");
                correspondances.put("etat_observation", "transmission");
                correspondances.put("lieu_observation", "ce_zone_geo");
                correspondances.put("altitude_observation", "altitude");
                correspondances.put("date_observation", "date_observation");
                correspondances.put("ordre_observation", "ordre");
                
                return correspondances;
        }
}