Merge branch 'release/4.7.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / PreferencesUtil.java
index dbaec0027e96500d82ef5b56b6a8715107e2f67e..24beb44d4c279bbd46ea3a8b902ec645dc57bd6f 100644 (file)
@@ -26,6 +26,7 @@ import java.util.StringTokenizer;
 import java.util.UUID;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
 import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.window.Window;
@@ -34,6 +35,7 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.PlatformUI;
 
+import eu.etaxonomy.cdm.api.application.ICdmRepository;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
 import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
 import eu.etaxonomy.cdm.api.service.ITermService;
@@ -41,6 +43,7 @@ import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
 import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
 import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
 import eu.etaxonomy.cdm.model.common.ICdmBase;
 import eu.etaxonomy.cdm.model.common.IDefinedTerm;
 import eu.etaxonomy.cdm.model.common.ISimpleTerm;
@@ -48,6 +51,10 @@ import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.common.TermBase;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
 import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
 import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
@@ -80,6 +87,8 @@ public class PreferencesUtil implements IPreferenceKeys {
        public static final String P2_REPOSITORIES_DELIM = ",";
        public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
 
+       private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
+
        /**
         * <p>
         * getPreferenceStore
@@ -100,10 +109,52 @@ public class PreferencesUtil implements IPreferenceKeys {
         *            a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
         *            object.
         */
-       public static void setPreferredNomenclaturalCode(
-                       NomenclaturalCode preferredCode) {
-               getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
-                               getPreferenceKey(preferredCode));
+       public static CdmPreference setPreferredNomenclaturalCode(
+                       NomenclaturalCode preferredCode, boolean local) {
+           if (local){
+               getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+                    getPreferenceKey(preferredCode));
+           }
+           else{
+               ICdmRepository controller;
+               controller = CdmStore.getCurrentApplicationConfiguration();
+               PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+               CdmPreference preference = null;
+               if (controller == null){
+                       return null;
+               }
+               if (preferredCode == null){
+                       preference = controller.getPreferenceService().find(key);
+                       if (preference == null){
+                               return null;
+                       } else{
+                               int index = StringUtils.lastIndexOf(preference.getValue(), ".");
+                               UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
+                               preferredCode = NomenclaturalCode.getByUuid(uuid);
+
+                               getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
+                           getPreferenceKey(preferredCode));
+                               getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
+                               return preference;
+                       }
+               } else{
+                       preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
+                       controller.getPreferenceService().set(preference);
+
+               }
+           }
+        return null;
+
+
+
+       }
+
+       public static NomenclaturalCode getPreferredNomenclaturalCode(){
+           if (getPreferenceStore().getBoolean(OVERRIDE_NOMENCLATURAL_CODE_KEY)) {
+            return getPreferredNomenclaturalCode(true);
+        } else{
+            return getPreferredNomenclaturalCode(false);
+        }
        }
 
        /**
@@ -113,11 +164,23 @@ public class PreferencesUtil implements IPreferenceKeys {
         *
         * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
         */
-       public static NomenclaturalCode getPreferredNomenclaturalCode() {
+       public static NomenclaturalCode getPreferredNomenclaturalCode(boolean useLocal) {
 
-               for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
-                       String preferredCode = getPreferenceStore().getString(
+               CdmPreference pref = null;
+               if (!useLocal){
+                   pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
+               }
+
+           String preferredCode;
+           if(pref == null){
+               preferredCode = getPreferenceStore().getString(
                                        PREFERRED_NOMENCLATURAL_CODE_KEY);
+
+           }else{
+               preferredCode = pref.getValue();
+           }
+
+               for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
                        if (getPreferenceKey(code).equals(preferredCode)) {
                                return code;
                        }
@@ -125,6 +188,24 @@ public class PreferencesUtil implements IPreferenceKeys {
                return null;
        }
 
+
+    private static CdmPreference getPreferenceFromDB(PreferencePredicate predicate){
+        ICdmRepository controller;
+        CdmPreference pref = null;
+
+        try{
+            controller = CdmStore.getCurrentApplicationConfiguration();
+            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate);
+            pref = controller.getPreferenceService().find(key);
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+
+        return pref;
+
+    }
+
+
        public static String getPreferredDefaultLangugae(){
            String preferredLanguage = getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR);
            if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
@@ -309,6 +390,7 @@ public class PreferencesUtil implements IPreferenceKeys {
                                TAXON_SERVICE_CONFIGURATOR_NAMES));
                configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
                                TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
+               //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getPreferenceStore().getString(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
 
                return configurator;
        }
@@ -396,6 +478,23 @@ public class PreferencesUtil implements IPreferenceKeys {
                getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
                getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
                getPreferenceStore().setDefault(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, false);
+               getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_HYBRID, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_LSID, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAMECACHE, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK, true);
+               getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, true);
+               getPreferenceStore().setDefault(SORT_NODES_NATURALLY, false);
+               getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY, false);
+
        }
 
        /**
@@ -407,30 +506,38 @@ public class PreferencesUtil implements IPreferenceKeys {
                // First time Editor is opened, no nomenclatural code has been set
 
 
-               if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
-                       PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP);
-                       /*
+               if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
+                       PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP, true);
+               }
 
-                       StoreUtil.info("No nomencatural code set.");
 
-                       Shell shell = StoreUtil.getShell();
 
-                Query user re: preferred nom. code
-                       Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
-                       dialog.open();
+       }
+       public static void setNomenclaturalCodePreferences(){
+           ICdmRepository controller;
+        controller = CdmStore.getCurrentApplicationConfiguration();
+        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+        CdmPreference preference = null;
+        if (controller == null){
+            return ;
+        }
+        preference = controller.getPreferenceService().find(key);
+        if (preference == null){
+            return;
+        }
+        getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
 
-                       // Short message confirming user's choice
-                       NomenclaturalCode code = PreferencesUtil
-                                       .getPreferredNomenclaturalCode();
-                       MessageDialog
-                                       .openInformation(
-                                                       shell,
-                                                       "Nomenclatural code set",
-                                                       "The following has been set as your preferred nomenclatural code:\n\n\t"
-                                                                       + NomenclaturalCodeHelper
-                                                                                       .getDescription(code)
-                                                                       + "\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");*/
-               }
+        int index = StringUtils.lastIndexOf(preference.getValue(), ".");
+        UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
+        NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
+
+        getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
+                getPreferenceKey(preferredCode));
+
+        if (!preference.isAllowOverride()){
+            getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+                    getPreferenceKey(preferredCode));
+        }
        }
 
        public static void checkDefaultLanguage(){
@@ -756,8 +863,8 @@ public class PreferencesUtil implements IPreferenceKeys {
         * <p>
         * getSortRanksNaturally
         * </p>
-        *
-        * @return a boolean.
+        *
+        * @return a boolean.
         */
        public static boolean getSortNodesNaturally() {
                return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY);
@@ -835,6 +942,259 @@ public class PreferencesUtil implements IPreferenceKeys {
         getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
     }
 
+    /**
+     * @return
+     */
+    public static boolean isShowIdInVocabularyInChecklistEditor() {
+       return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_ID_IN_VOCABULARY);
+    }
+    public static void setShowIdInVocabularyInChecklistEditor(boolean selection) {
+        getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY, selection);
+    }
+
+    /**
+     * @return
+     */
+    public static boolean isShowRankInChecklistEditor() {
+        return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SHOW_RANK);
+    }
+    public static void setShowRankInChecklistEditor(boolean selection) {
+        getPreferenceStore().setValue(CHECKLIST_SHOW_RANK, selection);
+    }
+
+    /**
+     * @param object
+     * @param b
+     * @return
+     */
+    public static NameDetailsConfigurator setPreferredNameDetailsConfiguration( boolean local) {
+        NameDetailsConfigurator config = new NameDetailsConfigurator(true);
+
+        CdmPreference preference = null;
+
+        if (!local) {
+            preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
+        }
+        if (preference == null){
+            return null;
+        }
+
+        getPreferenceStore().setValue(ALLOW_OVERRIDE_NAMEDETAILS, preference.isAllowOverride());
+
+        //the preference value is build like this:
+        //<section1>:true;<section2>:false....
+
+        String value = preference.getValue();
+        String [] sections = value.split(";");
+        Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
+        String[] sectionValues;
+        for (String sectionValue: sections){
+            sectionValues = sectionValue.split(":");
+            sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
+        }
+
+
+
+        getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
+                (sectionMap.get("taxon")));
+        config.setTaxonSectionActivated(sectionMap.get("taxon"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
+                (sectionMap.get("lsid")));
+        config.setLSIDActivated(sectionMap.get("lsid"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
+                (sectionMap.get("nc")));
+        config.setNomenclaturalCodeActived(sectionMap.get("nc"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
+                (sectionMap.get("ap")));
+        config.setAppendedPhraseActivated(sectionMap.get("ap"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
+                (sectionMap.get("rank")));
+        config.setRankActivated(sectionMap.get("rank"));
+
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
+                (sectionMap.get("atomisedEpithets")));
+        config.setAtomisedEpithetsActivated(sectionMap.get("atomisedEpithets"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
+                (sectionMap.get("author")));
+        config.setAuthorshipSectionActivated(sectionMap.get("author"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
+                (sectionMap.get("nomRef")));
+        config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
+                (sectionMap.get("nomStat")));
+        config.setNomenclaturalStatusSectionActivated(sectionMap.get("nomStat"));
+
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
+                (sectionMap.get("protologue")));
+        config.setProtologueActivated(sectionMap.get("protologue"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
+                (sectionMap.get("typeDes")));
+        config.setTypeDesignationSectionActivated(sectionMap.get("typeDes"));
+
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
+                (sectionMap.get("nameRelation")));
+        config.setNameRelationsSectionActivated(sectionMap.get("nameRelation"));
+
+        return config;
+    }
+
+    public static boolean getIsDeterminiationOnlyForFieldUnit(boolean local){
+        CdmPreference preference = null;
+
+        if (!local) {
+            preference = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
+        }
+        if (preference == null){
+            return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS);
+        }
+        return Boolean.valueOf(preference.getValue());
+    }
+
+    public static boolean getIsShowCollectingAreasInGeneralSection(boolean local){
+        CdmPreference preference = null;
+
+        if (!local) {
+            preference = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
+        }
+        if (preference == null){
+            return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
+        }
+        return Boolean.valueOf(preference.getValue());
+    }
+
+    public static boolean getIsShowTaxonAssociations(boolean local){
+        CdmPreference preference = null;
+
+        if (!local) {
+            preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
+        }
+        if (preference == null){
+            return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
+        }
+        return Boolean.valueOf(preference.getValue());
+    }
+
+//    public static boolean getBioCaseProvider(boolean local){
+//        CdmPreference preference = null;
+//
+//        if (!local) {
+//            preference = getPreferenceFromDB(PreferencePredicate.BioCaseProvider);
+//        }
+//        if (preference == null){
+//            return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
+//        }
+//        return Boolean.valueOf(preference.getValue());
+//    }
+
+
+    /**
+     * <p>
+     * setAbcdConfigurator
+     * </p>
+     *
+     * @param preferredConfiguration
+     *            a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
+     *            object.
+     */
+    public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference(boolean useLocal) {
+
+        Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+
+        if (useLocal){
+            config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
+
+            config.setAddMediaAsMediaSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
+
+            config.setAllowReuseOtherClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
+            config.setDeduplicateClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
+            config.setDeduplicateReferences(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
+
+            config.setGetSiblings(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
+            config.setIgnoreAuthorship(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
+            config.setIgnoreImportOfExistingSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
+            config.setMapUnitIdToAccessionNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
+            config.setMapUnitIdToBarcode(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
+            config.setMapUnitIdToCatalogNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
+            config.setMoveNewTaxaToDefaultClassification(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
+            config.setOverwriteExistingSpecimens(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
+            config.setReuseExistingDescriptiveGroups(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
+            config.setReuseExistingMetaData(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
+            config.setReuseExistingTaxaWhenPossible(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
+            return config;
+
+        }
+            ICdmRepository controller;
+            controller = CdmStore.getCurrentApplicationConfiguration();
+            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AbcdImportConfig);
+            CdmPreference preference = null;
+            if (controller == null){
+                return null;
+            }
+            preference = controller.getPreferenceService().find(key);
+            if (preference == null){
+                return config;
+             } else{
+             String configString = preference.getValue();
+             String[] configArray = configString.split(";");
+
+             for (String configItem: configArray){
+                 String[] keyValue = configItem.split(":");
+                 String keyString = keyValue[0];
+                 String valueString = keyValue[1];
+                 if (keyString.equals("ignoreImportOfExistingSpecimen")){
+                     config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
+                     config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("reuseExistingTaxaWhenPossible")){
+                     config.setReuseExistingTaxaWhenPossible(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("ignoreAuthorship")){
+                     config.setIgnoreAuthorship(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("addMediaAsMediaSpecimen")){
+                     config.setAddMediaAsMediaSpecimen(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("reuseExistingMetaData")){
+                     config.setReuseExistingMetaData(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("reuseExistingDescriptiveGroups")){
+                     config.setReuseExistingDescriptiveGroups(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("allowReuseOtherClassifications")){
+                     config.setAllowReuseOtherClassifications(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("deduplicateReferences")){
+                     config.setDeduplicateReferences(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("deduplicateClassifications")){
+                     config.setDeduplicateClassifications(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("moveNewTaxaToDefaultClassification")){
+                     config.setMoveNewTaxaToDefaultClassification(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("mapUnitIdToCatalogNumber")){
+                     config.setMapUnitIdToCatalogNumber(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("mapUnitIdToAccessionNumber")){
+                     config.setMapUnitIdToAccessionNumber(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("mapUnitIdToBarcode")){
+                     config.setMapUnitIdToBarcode(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("overwriteExistingSpecimens")){
+                     config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
+                 }else{
+                     logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
+                 }
+
+            }
+        }
+        return config;
+
+
+
+    }
+
+
+
 
 
 }