Implemented some of the import/export functionality. Major refactoring of datasource...
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / store / CdmStore.java
index 083de428acb2ba2d3477c8e58229a4b595cc5d6f..708e65c6542af0c0138a91bb8a76bdc0d72ced8e 100644 (file)
@@ -12,8 +12,6 @@ package eu.etaxonomy.taxeditor.store;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Set;
-import java.util.SortedSet;
 import java.util.UUID;
 
 import org.apache.log4j.Logger;
@@ -25,22 +23,12 @@ import eu.etaxonomy.cdm.api.service.ILocationService;
 import eu.etaxonomy.cdm.api.service.INameService;
 import eu.etaxonomy.cdm.api.service.IReferenceService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
-import eu.etaxonomy.cdm.api.service.ITermService;
 import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;
 import eu.etaxonomy.cdm.api.service.config.impl.TaxonServiceConfiguratorImpl;
 import eu.etaxonomy.cdm.database.DbSchemaValidation;
 import eu.etaxonomy.cdm.database.ICdmDataSource;
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.Language;
-import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
-import eu.etaxonomy.cdm.model.common.TermVocabulary;
-import eu.etaxonomy.cdm.model.common.VocabularyEnum;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.name.NameRelationshipType;
-import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
-import eu.etaxonomy.cdm.model.name.Rank;
-import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.reference.Article;
 import eu.etaxonomy.cdm.model.reference.Book;
@@ -48,7 +36,6 @@ import eu.etaxonomy.cdm.model.reference.BookSection;
 import eu.etaxonomy.cdm.model.reference.Generic;
 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
 import eu.etaxonomy.cdm.persistence.query.MatchMode;
 import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
@@ -132,51 +119,16 @@ public class CdmStore{
                }
        }
 
-       public Set<TaxonRelationshipType> getConceptRelationshipTypes() {
-               Set<TaxonRelationshipType> conceptRelationshipTypes = getTaxonRelationshipTypes().getTerms();
-               // remove these two relations as they are considered standard taxon relations
-               conceptRelationshipTypes.remove(TaxonRelationshipType.MISAPPLIED_NAME_FOR());
-               conceptRelationshipTypes.remove(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN());
-       
-               return conceptRelationshipTypes;
-       }
 
        public ReferenceBase<?> getDefaultSec() {
                // TODO why is this returning null? and of course, replace w the real deal
                return applicationController.getReferenceService().getReferenceByUuid(
                                UUID.fromString("f3593c18-a8d2-4e51-bdad-0befbf8fb2d1"));
        }
-
-       private TermVocabulary<Feature> getFeaturesInternal() {
-               return applicationController.getTermService().getVocabulary(VocabularyEnum.Feature);
-       }
        
-       public static SortedSet<Feature> getFeatures() {
-               return getDefault().getFeaturesInternal().getTermsOrderedByLabels(getDefaultLanguage());
-       }
-
-       public SortedSet<NameRelationshipType> getNameRelationshipTypes() {
-               return applicationController.getTermService().getVocabulary(VocabularyEnum.NameRelationshipType).getTermsOrderedByLabels(Language.DEFAULT());
-       }
-
-       public TermVocabulary<NomenclaturalStatusType> getNomenclaturalStatusTypesInternal() {
-               return applicationController.getTermService().getVocabulary(VocabularyEnum.NomenclaturalStatusType);
-       }
-       
-       public static Set<NomenclaturalStatusType> getNomenclaturalStatusTypes(){
-               // TODO sort types
-               return getDefault().getNomenclaturalStatusTypesInternal().getTerms();
-       }
-       
-       private OrderedTermVocabulary<Rank> getRanksInternal(){
-               TermVocabulary<Rank> vocabulary = applicationController.getTermService().getVocabulary(VocabularyEnum.Rank);
-               return HibernateProxyHelper.deproxy(vocabulary, OrderedTermVocabulary.class);
-       }
-       
-       public static SortedSet<Rank> getRanks(){
-               return getDefault().getRanksInternal().getOrderedTerms(null);
-       }
-
+       /**
+        * @deprecated use taxonomic tree instead
+        */
        public List<Taxon> getRootTaxa() {
                boolean onlyWithChildren = false;
                boolean withMisapplications = true;
@@ -191,26 +143,7 @@ public class CdmStore{
        public List<TaxonomicTree> getTaxonomicTrees() {
                return applicationController.getTaxonService().getAllTaxonomicTrees(10000, 0);
        }
-
-       public OrderedTermVocabulary<TaxonRelationshipType> getTaxonRelationshipTypes() {
-               TermVocabulary vocabulary = HibernateProxyHelper.deproxy
-                               (applicationController.getTermService().getVocabulary(VocabularyEnum.TaxonRelationshipType), TermVocabulary.class);
-               return (OrderedTermVocabulary<TaxonRelationshipType>) vocabulary;
-       }
-       
-       public TermVocabulary<SpecimenTypeDesignationStatus> getSpecimenTypeDesignationStatus() {
-               return applicationController.getTermService().getVocabulary(VocabularyEnum.SpecimenTypeDesignationStatus);
-       }
-       
-
-       public UUID saveTaxon(Taxon taxon) {
-               return applicationController.getTaxonService().save(taxon);
-       }
-
-       public void setApplicationController(
-                       CdmApplicationController applicationController) {
-               this.applicationController = applicationController;
-       }
+               
        
        private CdmApplicationController getApplicationControllerInternal(){
                return applicationController;
@@ -262,25 +195,20 @@ public class CdmStore{
                return getDefault().getGlobalReadOnlyConversation();
        }
        
-       public static ITaxonService getTaxonService(){
-               return getDefault().getApplicationController().getTaxonService();
-       }
+
+       /*
+        * EXPOSING SERVICES
+        */
        
-       public static INameService getNameService(){
-               return getDefault().getApplicationController().getNameService();
-       }
+       public static ITaxonService getTaxonService(){ return getDefault().getApplicationControllerInternal().getTaxonService();}
        
-       public static IReferenceService getReferenceService(){
-               return getDefault().getApplicationController().getReferenceService();
-       }
+       public static INameService getNameService(){ return getDefault().getApplicationControllerInternal().getNameService();}
        
-       public static ILocationService getLocationService(){
-               return getDefault().getApplicationController().getLocationService();
-       }
+       public static IReferenceService getReferenceService(){ return getDefault().getApplicationControllerInternal().getReferenceService();}
+       
+       public static ILocationService getLocationService(){ return getDefault().getApplicationControllerInternal().getLocationService();}
 
-       public static ProviderManager getAuthenticationManager() {
-               return getDefault().getApplicationController().getAuthenticationManager();
-       }
+       public static ProviderManager getAuthenticationManager() { return getDefault().getApplicationControllerInternal().getAuthenticationManager();}
 
        
        /**
@@ -347,21 +275,6 @@ public class CdmStore{
                }
                return resultsList;
        }
-
-
-       public static List<Language> getLanguages() {
-               ITermService termService = getDefault().getApplicationController().getTermService();
-               ArrayList<Language> languages = new ArrayList<Language>();
-               for (Language language : termService.getLanguageVocabulary()) {
-                       languages.add(language);
-               }
-               
-               // TODO sort languages
-               
-//             languages.add(Language.ENGLISH());
-//             languages.add(Language.GERMAN());
-               return languages;
-       }
        
        /**
         * FIXME mock
@@ -372,13 +285,6 @@ public class CdmStore{
                return Language.ENGLISH();
        }
 
-       /**
-        * @return
-        */
-       private static String getApplicationContextBean() {
-               return DEFAULT_APPLICATION_CONTEXT;
-       }
-
        /**
         * @return
         */
@@ -394,25 +300,4 @@ public class CdmStore{
                return nomReferenceTypeMap;
        }
 
-       /**
-        * @param feature
-        */
-       public static void saveFeature(Feature feature) {
-               TermVocabulary<Feature> vocabulary = getDefault().getFeaturesInternal();
-               
-               vocabulary.addTerm(feature);
-               
-               getDefault().getApplicationController().getTermService().saveTermVocabulary(vocabulary);
-       }
-
-       /**
-        * TODO make this more generic
-        * 
-        * @param feature
-        */
-       public static void updateFeature(Feature feature) {
-               TermVocabulary<Feature> vocabulary = getDefault().getFeaturesInternal();
-
-               getDefault().getApplicationController().getTermService().saveTermVocabulary(vocabulary);
-       }
 }