ref #7063: better handling of preferences for distribution editor and other places
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / PreferencesUtil.java
index 83e6756fc4caf2d40451b9b1ed628662057fc2e4..35889bca0d064cbd08c936ea3567b46a8a7944cd 100644 (file)
@@ -17,6 +17,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -26,6 +27,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 +36,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 +44,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 +52,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 +88,10 @@ 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 +112,58 @@ 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(
+                       String preferenceKey, boolean local) {
+           if (local){
+               getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+                       preferenceKey);
+           }
+           else{
+               ICdmRepository controller;
+               controller = CdmStore.getCurrentApplicationConfiguration();
+               if (controller == null){
+                return null;
+            }
+               PrefKey key = null;
+               try{
+                   key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+               }catch (Exception e){
+                   System.out.println(e.getStackTrace());
+               }
+               CdmPreference preference = null;
+
+               if (preferenceKey == 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(PREFERRED_NOMENCLATURAL_CODE_KEY,
+                                       preferenceKey);
+                               getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
+                               return preference;
+                       }
+               } else{
+                       preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferenceKey);
+                       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,18 +173,128 @@ 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(
-                                       PREFERRED_NOMENCLATURAL_CODE_KEY);
-                       if (getPreferenceKey(code).equals(preferredCode)) {
-                               return code;
-                       }
+               CdmPreference pref = null;
+               if (!useLocal){
+                   pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
                }
-               return null;
+
+           String preferredCode;
+           if(pref == null){
+               preferredCode = getPreferenceStore().getString(
+                                       PREFERRED_NOMENCLATURAL_CODE_KEY);
+
+           }else{
+               preferredCode = pref.getValue();
+           }
+
+           return getPreferredNomenclaturalCode(preferredCode);
+
        }
 
+       /**
+     * <p>
+     * getPreferredNomenclaturalCode
+     * </p>
+     *
+     * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
+     */
+    public static NomenclaturalCode getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode) {
+
+        for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
+            if (getPreferenceKey(code).equals(preferenceKeyNomenclaturalCode)) {
+                return code;
+            }
+        }
+        return null;
+    }
+
+       public static boolean isShowTaxonAssociations(){
+        if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
+            return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
+        } else{
+            CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
+
+            return pref!=null?Boolean.valueOf(pref.getValue()):false;
+        }
+    }
+
+       public static boolean isShowLifeForm(){
+        if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
+            return getPreferenceStore().getBoolean(SHOW_LIFE_FORM);
+        } else{
+            CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
+
+            return pref!=null?Boolean.valueOf(pref.getValue()):false;
+        }
+    }
+
+       public static boolean isDeterminationOnlyForFieldUnits(){
+        if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
+            return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS);
+        } else{
+            CdmPreference pref = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
+
+            return pref!=null?Boolean.valueOf(pref.getValue()):false;
+        }
+    }
+
+       public static boolean isCollectingAreaInGeneralSection(){
+        if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
+            return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
+        } else{
+            CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
+
+            return pref!=null?Boolean.valueOf(pref.getValue()):false;
+        }
+    }
+
+       public static boolean isShowSimpleDetailsView(){
+        if (getPreferenceStore().getBoolean(OVERRIDE_NAME_DETAILS) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_NAME_DETAILS)) {
+            return getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION);
+        } else{
+            CdmPreference pref = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
+
+            return pref!=null?Boolean.valueOf(pref.getValue()):false;
+        }
+    }
+
+
+
+    public static CdmPreference getPreferenceFromDB(PreferencePredicate predicate){
+        ICdmRepository controller;
+        CdmPreference pref = null;
+
+        try{
+            if(CdmStore.isActive()){
+                controller = CdmStore.getCurrentApplicationConfiguration();
+                PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate);
+                pref = controller.getPreferenceService().find(key);
+            }
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+
+        return pref;
+
+    }
+
+    public static void setPreferenceToDB(CdmPreference preference){
+        ICdmRepository controller;
+        try{
+            if(CdmStore.isActive()){
+                controller = CdmStore.getCurrentApplicationConfiguration();
+                controller.getPreferenceService().set(preference);
+            }
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+
+    }
+
+
+
        public static String getPreferredDefaultLangugae(){
            String preferredLanguage = getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR);
            if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
@@ -133,6 +303,11 @@ public class PreferencesUtil implements IPreferenceKeys {
            return null;
        }
 
+       public static boolean isShowMediaPreview(){
+        boolean isShowMediaPreview = getPreferenceStore().getBoolean(SHOW_MEDIA_PREVIEW);
+        return isShowMediaPreview;
+    }
+
        /**
         * Get the match strategy for the given class that was stored in preferences
         * or the default strategy if it was not stored in preferences
@@ -247,7 +422,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         * @return
         */
        private static String getPreferenceKey(ICdmBase cdmBase) {
-               cdmBase = (ICdmBase) HibernateProxyHelper.deproxy(cdmBase);
+               cdmBase = HibernateProxyHelper.deproxy(cdmBase);
 
                String key = cdmBase.getClass().getName().concat(".")
                                .concat(cdmBase.getUuid().toString());
@@ -264,7 +439,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         * @return
         */
        public static String getPreferenceKey(ISimpleTerm simpleTerm) {
-               simpleTerm = (ISimpleTerm) HibernateProxyHelper.deproxy(simpleTerm);
+               simpleTerm = HibernateProxyHelper.deproxy(simpleTerm);
                String key = simpleTerm.getClass().getName().concat(".")
                                .concat(simpleTerm.getUuid().toString());
                if (key.contains("javassist")) {
@@ -283,7 +458,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         * @return
         */
        public static String getPreferenceKey(IDefinedTerm definedTerm) {
-               definedTerm = (IDefinedTerm) HibernateProxyHelper.deproxy(definedTerm);
+               definedTerm = HibernateProxyHelper.deproxy(definedTerm);
                String key = definedTerm.getClass().getName().concat(".")
                                .concat(definedTerm.getUuid().toString());
                if (key.contains("javassist")) {
@@ -309,6 +484,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;
        }
@@ -321,7 +497,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         *         object.
         */
        public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
-               IFindTaxaAndNamesConfigurator configurator = new FindTaxaAndNamesConfiguratorImpl();
+               IFindTaxaAndNamesConfigurator configurator = FindTaxaAndNamesConfiguratorImpl.NewInstance();
 
                configurator.setDoTaxa(true);
                configurator.setDoSynonyms(true);
@@ -332,7 +508,7 @@ public class PreferencesUtil implements IPreferenceKeys {
                                "name", "name.$", "relationsFromThisTaxon.$"));
 
                configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
-                               "name", "name.$", "synonymRelations.relatedTo.*"));
+                               "name", "name.$", "synonyms.relatedTo.*"));
 
                // DEFAULT VALUES
                // match mode is a simple like, actually all other match modes are kind
@@ -395,7 +571,37 @@ public class PreferencesUtil implements IPreferenceKeys {
                                "http://www.biodiversitylibrary.org/openurl");
                getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
                getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
-               getPreferenceStore().setDefault(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, false);
+               //Distribution Editor:
+               getPreferenceStore().setDefault(DISTRIBUTION_AREA_PREFRENCES_ACTIVE, false);
+               getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY, true);
+               getPreferenceStore().setDefault(CHECKLIST_SYMBOL, false);
+
+
+               //Name Details
+               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);
+               //Navigator preferences
+               getPreferenceStore().setDefault(SORT_NODES_NATURALLY, false);
+               getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY, false);
+               getPreferenceStore().setDefault(SORT_TAXA_BY_RANK_AND_NAME, true);
+               //override db preferences
+               getPreferenceStore().setDefault(ABCD_IMPORT_OVERRIDE, false);
+               getPreferenceStore().setDefault(OVERRIDE_SPECIMEN_PREF, false);
+               getPreferenceStore().setDefault(OVERRIDE_NAME_DETAILS, false);
+               getPreferenceStore().setDefault(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE, false);
+
+
        }
 
        /**
@@ -405,32 +611,34 @@ public class PreferencesUtil implements IPreferenceKeys {
         */
        public static void checkNomenclaturalCode() {
                // First time Editor is opened, no nomenclatural code has been set
+               if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
+                       PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
+               }
 
 
-               if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
-                       PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP);
-                       /*
 
-                       StoreUtil.info("No nomencatural code set.");
+       }
+       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());
 
-                       Shell shell = StoreUtil.getShell();
+        int index = StringUtils.lastIndexOf(preference.getValue(), ".");
+        UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
+        NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
 
-                Query user re: preferred nom. code
-                       Dialog dialog = new InitNomenclaturalCodePrefDialog(shell);
-                       dialog.open();
+        getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+                getPreferenceKey(preferredCode));
 
-                       // 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.");*/
-               }
        }
 
        public static void checkDefaultLanguage(){
@@ -588,7 +796,7 @@ public class PreferencesUtil implements IPreferenceKeys {
 
        private static String getMarkerTypeEditingPreferenceKey(
                        MarkerType markerType) {
-               markerType = (MarkerType) HibernateProxyHelper.deproxy(markerType);
+               markerType = HibernateProxyHelper.deproxy(markerType);
                return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
        }
 
@@ -751,18 +959,18 @@ public class PreferencesUtil implements IPreferenceKeys {
             ctrl.setEnabled(enabled);
         }
     }
-    
+
     /**
         * <p>
         * getSortRanksNaturally
         * </p>
-        *
-        * @return a boolean.
+        *
+        * @return a boolean.
         */
        public static boolean getSortNodesNaturally() {
                return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY);
        }
-       
+
        /**
         * <p>
         * setSortRanksNaturally
@@ -774,4 +982,693 @@ public class PreferencesUtil implements IPreferenceKeys {
        public static void setSortNodesNaturally(boolean selection) {
                getPreferenceStore().setValue(SORT_NODES_NATURALLY, selection);
        }
+
+
+       /**
+        * <p>
+        * getSortRanksNaturally
+        * </p>
+        *
+        * @return a boolean.
+        */
+       public static boolean getSortNodesStrictlyAlphabetically() {
+               return getPreferenceStore().getBoolean(SORT_NODES_ALPHABETICALLY);
+       }
+
+       /**
+        * <p>
+        * setSortRanksNaturally
+        * </p>
+        *
+        * @param selection
+        *            a boolean.
+        */
+       public static void setSortNodesStrictlyAlphabetically(boolean selection) {
+               getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY, selection);
+       }
+
+       /**
+        * <p>
+        * setStoreNavigatorState
+        * </p>
+        *
+        * @param selection
+        *            a boolean.
+        */
+       public static boolean isStoreNavigatorState() {
+               return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
+
+       }
+
+       /**
+        * <p>
+        * setStoreNavigatorState
+        * </p>
+        *
+        * @param selection
+        *            a boolean.
+        */
+       public static void setStoreNavigatorState(boolean selection) {
+               getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
+
+       }
+
+    /**
+     * @return
+     */
+    public static boolean isShowUpWidgetIsDisposedMessages() {
+       return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED);
+    }
+    public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
+        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 isShowSymbolInChecklistEditor() {
+       return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SYMBOL);
+    }
+    public static void setShowSymbolInChecklistEditor(boolean selection) {
+        getPreferenceStore().setValue(CHECKLIST_SYMBOL, 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 getPreferredNameDetailsConfiguration( 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_NAME_DETAILS, 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]));
+            }
+            config.setAllowOverride(preference.isAllowOverride());
+            config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
+
+    //        getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
+    //                (getValue(sectionMap, "taxon")));
+            config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
+    //                (getValue(sectionMap, "lsid")));
+            config.setLSIDActivated(getValue(sectionMap, "lsid"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
+    //                (getValue(sectionMap, "nc")));
+            config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
+    //                (getValue(sectionMap, "ap")));
+            config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
+    //                (getValue(sectionMap, "rank")));
+            config.setRankActivated(getValue(sectionMap, "rank"));
+
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
+    //                (getValue(sectionMap, "atomisedEpithets")));
+            config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
+    //                (getValue(sectionMap,"author")));
+            config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
+    //                (getValue(sectionMap, "nomRef")));
+            config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
+    //                (getValue(sectionMap, "nomStat")));
+            config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
+
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
+    //                (getValue(sectionMap,"protologue")));
+            config.setProtologueActivated(getValue(sectionMap,"protologue"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
+    //                (getValue(sectionMap,"typeDes")));
+            config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
+    //                (getValue(sectionMap,"nameRelation")));
+            config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
+
+    //        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
+    //                (getValue(sectionMap, "hybrid")));
+            config.setHybridActivated(getValue(sectionMap,"hybrid"));
+        }else{
+            config.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION));
+            config.setTaxonSectionActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_TAXON));
+            config.setLSIDActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_LSID));
+            config.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
+            config.setAppendedPhraseActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
+            config.setRankActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_RANK));
+            config.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
+            config.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
+            config.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
+            config.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
+            config.setProtologueActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
+            config.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
+            config.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
+            config.setHybridActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_HYBRID));
+        }
+        return config;
+    }
+
+    /**
+     * @param object
+     * @param b
+     * @return
+     */
+    public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config, boolean local) {
+        CdmPreference preference = null;
+
+        if (!local) {
+            preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NameDetailsView, config.toString());
+
+            setPreferenceToDB(preference);
+        }
+        //also add to local preferences
+        getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_SECTION, config.isSimpleDetailsViewActivated());
+        getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, config.isNomenclaturalCodeActived());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, config.isAppendedPhraseActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, config.isAtomisedEpithetsActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, config.isAuthorshipSectionActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, config.isNomenclaturalReferenceSectionActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, config.isNomenclaturalStatusSectionActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, config.isProtologueActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, config.isTypeDesignationSectionActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, config.isNameRelationsSectionActivated());
+        getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID, config.isHybridActivated());
+
+    }
+
+    private static Boolean getValue(Map<String, Boolean> sectionMap, String string) {
+               if (sectionMap.containsKey(string)){
+                       return sectionMap.get(string);
+               }else{
+                       return true;
+               }
+
+       }
+
+
+
+    /**
+     * <p>
+     * setAbcdConfigurator
+     * </p>
+     *
+     * @param preferredConfiguration
+     *            a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
+     *            object.
+     */
+    public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference() {
+
+        Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+        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);
+        boolean allowOverride = true;
+        if (preference != null && !preference.isAllowOverride()){
+            allowOverride = false;
+        }
+        if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_OVERRIDE) && allowOverride){
+
+            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));
+            config.setNomenclaturalCode(NomenclaturalCode.getByKey(PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)));
+            return config;
+
+        }
+
+            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 if (keyString.equals("nomenclaturalCode")){
+                         config.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
+                 }else{
+                     logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
+                 }
+
+            }
+        }
+        return config;
+    }
+
+
+    public static void updateAbcdImportConfigurationPreference() {
+
+        Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+        ICdmRepository controller;
+        controller = CdmStore.getCurrentApplicationConfiguration();
+        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AbcdImportConfig);
+        CdmPreference preference = null;
+        if (controller == null){
+            return ;
+        }
+        preference = controller.getPreferenceService().find(key);
+        boolean allowOverride = true;
+        if (preference != null && !preference.isAllowOverride()){
+            allowOverride = false;
+        }
+        if (!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_OVERRIDE) || !allowOverride){
+
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS, config.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN, config.isAddMediaAsMediaSpecimen());
+
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS, config.isAllowReuseOtherClassifications());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS, config.isDeduplicateClassifications());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES, config.isDeduplicateReferences());
+
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS, config.isGetSiblings());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP, config.isIgnoreAuthorship());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN, config.isIgnoreImportOfExistingSpecimen());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER, config.isMapUnitIdToAccessionNumber());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE, config.isMapUnitIdToBarcode());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER, config.isMapUnitIdToCatalogNumber());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION, config.isMoveNewTaxaToDefaultClassification());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN, config.isOverwriteExistingSpecimens());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS, config.isReuseExistingDescriptiveGroups());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA, config.isReuseExistingMetaData());
+            getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE, config.isReuseExistingTaxaWhenPossible());
+            if (config.getNomenclaturalCode() != null){
+                getPreferenceStore().setValue(ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE, config.getNomenclaturalCode().getKey());
+            }
+
+
+        }
+    }
+
+
+    /**
+    *
+    */
+   public NameDetailsConfigurator createLocalNameDetailsViewConfig(boolean local) {
+       NameDetailsConfigurator config = new NameDetailsConfigurator(true);
+       if (local){
+          config.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
+          config.setAppendedPhraseActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
+          config.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
+          config.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
+          config.setLSIDActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
+          config.setNameApprobiationActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION));
+          config.setNameCacheActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
+          config.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
+          config.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
+          config.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
+          config.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
+          config.setProtologueActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
+          config.setRankActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
+          config.setTaxonSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
+          config.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
+          config.setHybridActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID));
+       }else{
+
+       }
+
+      return config;
+   }
+
+
+   public static void saveConfigToPrefernceStore(NameDetailsConfigurator config) {
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION,
+               config.isSimpleDetailsViewActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
+               config.isNomenclaturalCodeActived());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE,
+               config.isNameCacheActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
+               config.isAppendedPhraseActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
+               config.isAtomisedEpithetsActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE,
+               config.isAuthorCacheActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
+               config.isAuthorshipSectionActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
+               config.isNomenclaturalReferenceSectionActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
+               config.isNomenclaturalStatusSectionActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
+               config.isProtologueActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
+               config.isTypeDesignationSectionActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
+               config.isNameRelationsSectionActivated());
+       PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID,
+               config.isHybridActivated());
+
+   }
+
+/**
+ * @return
+ */
+public static boolean isSortTaxaByRankAndName() {
+
+    return getPreferenceStore().getBoolean(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
+}
+
+/**
+ * @return
+ */
+public static boolean isSortNamedAreaByOrderInVocabulary() {
+
+    return getPreferenceStore().getBoolean(IPreferenceKeys.SORT_NAMED_AREA_BY_VOCABULARY_ORDER);
+}
+
+public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder) {
+    getPreferenceStore().setValue(IPreferenceKeys.SORT_NAMED_AREA_BY_VOCABULARY_ORDER, isSortByVocabularyOrder);
+
+}
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static void setLastSelectedReference(
+        List<String> lastSelectedReferences) {
+
+        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+        preferenceStore.setValue(PreferencesUtil.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
+    }
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static List<String> getLastSelectedReferences() {
+
+        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+        String lastSelected = preferenceStore.getString(PreferencesUtil.LAST_SELECTED_REFERENCES);
+        List<String> result = new ArrayList<>();
+        if (!StringUtils.isBlank(lastSelected)){
+            Collections.addAll(result, lastSelected.substring(1,lastSelected.length()-1).split(", "));
+        }
+        return result;
+    }
+
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static void setPreferredNamedAreasForDistributionEditor(
+        String saveCheckedElements, String saveGrayedElements, boolean local) {
+    if (local){
+        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+        preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS, saveCheckedElements);
+        preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED, saveGrayedElements);
+
+    }
+    else{
+//        ICdmRepository controller;
+
+//        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms);
+        CdmPreference preference = null;
+
+        if (saveCheckedElements == null){
+            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
+
+            if (preference == null){
+                return ;
+            } else{
+                getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
+                        saveCheckedElements);
+                preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+                setPreferenceToDB(preference);
+
+            }
+        } else{
+           preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+           setPreferenceToDB(preference);
+           getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
+                    saveCheckedElements);
+
+        }
+    }
+
+}
+
+/**
+ * @param saveCheckedElements
+ * @param saveCheckedElements2
+ * @param b
+ */
+public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
+        boolean local) {
+    if (local){
+        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+        preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_VOCABULARIES, saveCheckedElements);
+
+
+    }
+    else{
+        ICdmRepository controller;
+        CdmPreference preference = null;
+
+        if (saveCheckedElements == null){
+            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+
+            if (preference == null){
+                return ;
+            } else{
+                getPreferenceStore().setValue(DISTRIBUTION_VOCABULARIES,
+                        saveCheckedElements);
+                preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
+                setPreferenceToDB(preference);
+
+
+            }
+        } else{
+            preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
+            setPreferenceToDB(preference);
+            getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
+                    saveCheckedElements);
+
+        }
+    }
+
+
+
+}
+
+/**
+ * @param saveCheckedElements
+ * @param saveCheckedElements2
+ * @param b
+ */
+public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
+    if (local){
+        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+        String pref = preferenceStore.getString(DISTRIBUTION_VOCABULARIES);
+        return pref;
+
+    }
+    else{
+
+        CdmPreference preference = null;
+
+        preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+
+            if (preference == null){
+                return null;
+            } else{
+                return preference.getValue();
+            }
+
+    }
+
+
+
+}
+
+/**
+ *
+ */
+public static void updateDBPreferences() {
+    CdmPreference preference = null;
+    IPreferenceStore prefStore = getPreferenceStore();
+
+    //ABCD Configurator
+
+    updateAbcdImportConfigurationPreference();
+
+    //Specimen Details
+    preference = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
+    if (preference != null){
+        if(!prefStore.getBoolean(SHOW_TAXON_ASSOCIATIONS_OVERRIDE) ||  !preference.isAllowOverride()){
+            prefStore.setValue(SHOW_TAXON_ASSOCIATIONS, preference.getValue());
+        }
+    }
+    preference = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
+    if (preference != null){
+        if(!prefStore.getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION_OVERRIDE) ||  !preference.isAllowOverride()){
+            prefStore.setValue(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION, preference.getValue());
+        }
+    }
+    preference = getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
+    if (preference != null){
+        if(!prefStore.getBoolean(SHOW_LIFE_FORM_OVERRIDE) ||  !preference.isAllowOverride()){
+            prefStore.setValue(SHOW_LIFE_FORM, preference.getValue());
+        }
+    }
+    preference = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
+    if (preference != null){
+        if(!prefStore.getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS_OVERRIDE) ||  !preference.isAllowOverride()){
+            prefStore.setValue(DETERMINATION_ONLY_FOR_FIELD_UNITS, preference.getValue());
+        }
+    }
+
+
+    //Name Details
+    NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
+    if (config != null ){
+        if (!prefStore.getBoolean(OVERRIDE_NAME_DETAILS) ||  !prefStore.getBoolean(ALLOW_OVERRIDE_NAME_DETAILS)){
+            setPreferredNameDetailsConfiguration(config, false);
+        }
+    }
+
+    //Distribution Editor
+    preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+    if (preference != null){
+        if (!prefStore.getBoolean(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE) ||  !preference.isAllowOverride()){
+            prefStore.setValue(DISTRIBUTION_VOCABULARIES, preference.getValue());
+        }
+    }
+
+    preference = getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
+    if (preference != null){
+        if (!prefStore.getBoolean(DISTRIBUTION_AREA_PREFRENCES_ACTIVE_OVERRIDE) || !preference.isAllowOverride()){
+            prefStore.setValue(DISTRIBUTION_AREA_PREFRENCES_ACTIVE, preference.getValue());
+        }
+    }
+
+}
+
+
+
+
+
+
+
 }