workaround for endless loop in default feature tree
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / PreferencesUtil.java
index 6e8733952b0e69d8a895eaf4bf54a134453aae27..6b995400ed69bfa447205927c3306d6248829f62 100644 (file)
@@ -17,15 +17,16 @@ 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;
 import java.util.Properties;
-import java.util.Set;
 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,14 +51,22 @@ 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.IPreferencePredicate;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
+import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
 import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
+import eu.etaxonomy.cdm.strategy.match.FieldMatcher;
 import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
 import eu.etaxonomy.cdm.strategy.match.MatchException;
 import eu.etaxonomy.cdm.strategy.match.MatchMode;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
+import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
@@ -68,7 +79,6 @@ import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
  * @author p.ciardelli
  * @author n.hoffmann
  * @created 05.12.2008
- * @version 1.0
  */
 public class PreferencesUtil implements IPreferenceKeys {
 
@@ -80,6 +90,12 @@ 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
@@ -91,6 +107,259 @@ public class PreferencesUtil implements IPreferenceKeys {
                return TaxeditorStorePlugin.getDefault().getPreferenceStore();
        }
 
+       private static String prefKey(String name) {
+           return name + "_"+  ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
+       }
+
+       public static String prefOverrideKey(String name) {
+        return name + "_OVERRIDE_"+ ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
+    }
+
+       /**
+     * <p>
+     * setStringValue
+     * </p>
+     *
+     *
+     **/
+    public static void setStringValue(String name, String value) {
+        getPreferenceStore().setValue(prefKey(name), value);
+    }
+
+    /**
+     * <p>
+     * setIntValue
+     * </p>
+     *
+     *
+     **/
+    public static void setIntValue(String name, int value) {
+        getPreferenceStore().setValue(prefKey(name), value);
+    }
+
+    /**
+     * <p>
+     * setBooleanValue
+     * </p>
+     *
+     *
+     **/
+    public static void setBooleanValue(String name, boolean value) {
+        getPreferenceStore().setValue(prefKey(name), value);
+    }
+
+    /**
+     * <p>
+     * setBooleanValue
+     * </p>
+     *
+     *
+     **/
+    public static void setDoubleValue(String name, double value) {
+        getPreferenceStore().setValue(prefKey(name), value);
+    }
+
+    /**
+     * <p>
+     * setFloatValue
+     * </p>
+     *
+     *
+     **/
+    public static void setFloatValue(String name, float value) {
+        getPreferenceStore().setValue(name + ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString(), value);
+    }
+
+    /**
+     * <p>
+     * setFloatValue
+     * </p>
+     *
+     *
+     **/
+    public static void setLongValue(String name, long value) {
+        getPreferenceStore().setValue(prefKey(name), value);
+    }
+
+    /**
+     * <p>
+     * getStringValue
+     * </p>
+     *
+     *
+     **/
+    public static String getStringValue(String name, boolean local) {
+
+        String prefValue = getDBPreferenceValue(name);
+        if (prefValue == null || local){
+            String dbSpecific = prefKey(name);
+            if (getPreferenceStore().contains(dbSpecific)){
+                prefValue = getPreferenceStore().getString(dbSpecific);
+            }else{
+                prefValue = getPreferenceStore().
+                        getString(name);
+            }
+        }
+        return prefValue;
+
+    }
+
+    public static String getStringValue(String name){
+        return getStringValue(name, false);
+    }
+
+    private static String getDBPreferenceValue(String name) {
+        CdmPreferenceCache cache = CdmPreferenceCache.instance();
+        if (cache.get(name) != null){
+            CdmPreference pref = cache.get(name);
+            if (!pref.isAllowOverride() || !getBooleanValue(prefOverrideKey(name))){
+                return pref.getValue();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * <p>
+     * setIntValue
+     * </p>
+     *
+     *
+     **/
+    public static int getIntValue(String name) {
+        String prefValue = getDBPreferenceValue(name);
+        Integer result = null;
+        try{
+            result = Integer.parseInt(prefValue);
+        }catch(NumberFormatException e){
+            logger.debug("Preference value of " + name + " is not a number");
+        }
+        if (result == null){
+            String dbSpecific = prefKey(name);
+            if (getPreferenceStore().contains(dbSpecific)){
+                result = getPreferenceStore().getInt(dbSpecific);
+            }else{
+                result =  getPreferenceStore().
+                        getInt(name);
+            }
+        }
+        return result;
+
+
+    }
+
+    /**
+     * <p>
+     * setBooleanValue
+     * </p>
+     *
+     *
+     **/
+    public static boolean getBooleanValue(String name) {
+        if (CdmStore.isActive()){
+            String prefValue = getDBPreferenceValue(name);
+            if (prefValue == null){
+                String dbSpecific = prefKey(name);
+                if (getPreferenceStore().contains(dbSpecific)){
+                    return getPreferenceStore().getBoolean(dbSpecific);
+                }else{
+                    return getPreferenceStore().
+                            getBoolean(name);
+                }
+            }else{
+                return Boolean.valueOf(prefValue);
+            }
+
+        }else{
+            return getPreferenceStore().getBoolean(name);
+        }
+
+    }
+
+    /**
+     * <p>
+     * setBooleanValue
+     * </p>
+     *
+     *
+     **/
+    public static double getDoubleValue(String name) {
+        String prefValue = getDBPreferenceValue(name);
+        Double result = null;
+        try{
+            result = Double.parseDouble(prefValue);
+        }catch(NumberFormatException e){
+            logger.debug("Preference value of " + name + " is not a number");
+        }
+        if (result == null){
+            String dbSpecific = prefKey(name);
+            if (getPreferenceStore().contains(dbSpecific)){
+                result = getPreferenceStore().getDouble(dbSpecific);
+            }else{
+                result =  getPreferenceStore().
+                        getDouble(name);
+            }
+        }
+        return result;
+
+    }
+
+    /**
+     * <p>
+     * getFloatValue
+     * </p>
+     *
+     *
+     **/
+    public static float getFloatValue(String name) {
+        String prefValue = getDBPreferenceValue(name);
+        Float result = null;
+        try{
+            result = Float.parseFloat(prefValue);
+        }catch(NumberFormatException e){
+            logger.debug("Preference value of " + name + " is not a number");
+        }
+        if (result == null){
+            String dbSpecific = prefKey(name);
+            if (getPreferenceStore().contains(dbSpecific)){
+                result = getPreferenceStore().getFloat(dbSpecific);
+            }else{
+                result =  getPreferenceStore().
+                        getFloat(name);
+            }
+        }
+        return result;
+
+    }
+
+    /**
+     * <p>
+     * getLongValue
+     * </p>
+     *
+     *
+     **/
+    public static long getLongValue(String name) {
+        String prefValue = getDBPreferenceValue(name);
+        Long result = null;
+        try{
+            result = Long.parseLong(prefValue);
+        }catch(NumberFormatException e){
+            logger.debug("Preference value of " + name + " is not a number");
+        }
+        if (result == null){
+            String dbSpecific = prefKey(name);
+            if (getPreferenceStore().contains(dbSpecific)){
+                result = getPreferenceStore().getLong(dbSpecific);
+            }else{
+                result =  getPreferenceStore().
+                        getLong(name);
+            }
+        }
+        return result;
+    }
+
+
        /**
         * <p>
         * setPreferredNomenclaturalCode
@@ -100,10 +369,83 @@ 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 preferenceValue, boolean local) {
+           if (local){
+               setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+                       preferenceValue);
+           }
+           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 (preferenceValue == null){
+                       preference = controller.getPreferenceService().find(key);
+                       if (preference == null){
+                               return null;
+                       } else{
+                           setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+                                       preference.getValue());
+
+                               return preference;
+                       }
+               } else{
+                       preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferenceValue);
+                       controller.getPreferenceService().set(preference);
+
+               }
+           }
+        return null;
+
+
+
+       }
+
+       /**
+     * <p>
+     * setPreferredNomenclaturalCode
+     * </p>
+     *
+     * @param preferredCode
+     *            a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
+     *            object.
+     */
+    public static void setPreferredNomenclaturalCode(
+        CdmPreference preference) {
+
+        ICdmRepository controller;
+        controller = CdmStore.getCurrentApplicationConfiguration();
+        if (controller == null){
+            return;
+        }
+        PrefKey key = null;
+        try{
+            key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+        }catch (Exception e){
+            System.out.println(e.getStackTrace());
+        }
+
+        controller.getPreferenceService().set(preference);
+
+    }
+
+
+       public static NomenclaturalCode getPreferredNomenclaturalCode(){
+           if (getBooleanValue(prefOverrideKey(PreferencePredicate.NomenclaturalCode.getKey()))) {
+            return getPreferredNomenclaturalCode(true);
+        } else{
+            return getPreferredNomenclaturalCode(false);
+        }
        }
 
        /**
@@ -113,26 +455,109 @@ 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 = getStringValue(
+                                       PREFERRED_NOMENCLATURAL_CODE_KEY, true);
+
+           }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(){
+        boolean result = getBooleanValue(EditorPreferencePredicate.ShowTaxonAssociations.getKey());
+        return result;
+    }
+
+       public static boolean isShowLifeForm(){
+           boolean result =  getBooleanValue(EditorPreferencePredicate.ShowLifeForm.getKey());
+           return result;
+    }
+
+       public static boolean isDeterminationOnlyForFieldUnits(){
+           boolean result =  getBooleanValue(EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
+        return result;
+    }
+
+       public static boolean isCollectingAreaInGeneralSection(){
+           boolean result =  getBooleanValue(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getKey());
+        return result;
+       }
+
+       public static CdmPreference getPreferenceFromDB(IPreferencePredicate predicate){
+        ICdmRepository controller;
+        CdmPreference pref = null;
+
+        try{
+            if(CdmStore.isActive()){
+                controller = CdmStore.getCurrentApplicationConfiguration();
+                PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), 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);
+           String preferredLanguage = getStringValue(DEFAULT_LANGUAGE_EDITOR);
            if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
                return preferredLanguage;
            }
            return null;
        }
 
+       public static boolean isShowMediaPreview(){
+        boolean isShowMediaPreview = getBooleanValue(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
@@ -141,13 +566,15 @@ public class PreferencesUtil implements IPreferenceKeys {
         *            a {@link java.lang.Class} object.
         * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
         */
-       public static IMatchStrategy getMatchStrategy(Class clazz) {
+       public static IMatchStrategy getMatchStrategy(Class<?> clazz) {
                String className = clazz.getName();
-               if (getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX + className)) {
+               if (getBooleanValue(MATCH_STRATEGY_PREFIX + className)) {
                        IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
 
-                       for (String fieldName : matchStrategy.getMatchFieldPropertyNames()) {
-                               String matchModeName = getPreferenceStore().getString(
+                       //TODO CacheMatchers (or multiple field matchers in future) are missing here
+                       for (FieldMatcher fieldMatcher : matchStrategy.getMatching().getFieldMatchers(false)) {
+                               String fieldName = fieldMatcher.getPropertyName();
+                               String matchModeName = getStringValue(
                                                getMatchStrategyFieldName(className, fieldName));
                                MatchMode matchMode = MatchMode.valueOf(matchModeName);
                                try {
@@ -171,15 +598,16 @@ public class PreferencesUtil implements IPreferenceKeys {
         *            object.
         */
        public static void setMatchStrategy(IMatchStrategy matchStrategy) {
-               String className = matchStrategy.getMatchClass().getName();
-               getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX + className, true);
+               String className = "ANY class"; //FIXME was: matchStrategy.getMatchClass().getName(); seems currently not in use
+               setBooleanValue(MATCH_STRATEGY_PREFIX + className, true);
 
-               Set<String> matchFields = matchStrategy.getMatchFieldPropertyNames();
+               List<FieldMatcher> fieldMatchers = matchStrategy.getMatching().getFieldMatchers(false);
 
-               for (String fieldName : matchFields) {
-                       getPreferenceStore().setValue(
+               for (FieldMatcher fieldMatcher : fieldMatchers) {
+                       String fieldName = fieldMatcher.getPropertyName();
+                       setStringValue(
                                        getMatchStrategyFieldName(className, fieldName),
-                                       matchStrategy.getMatchMode(fieldName).name());
+                                       fieldMatcher.getMatchMode().name());
                }
        }
 
@@ -301,14 +729,15 @@ public class PreferencesUtil implements IPreferenceKeys {
        public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
                IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
 
-               configurator.setDoTaxa(getPreferenceStore().getBoolean(
+               configurator.setDoTaxa(getBooleanValue(
                                TAXON_SERVICE_CONFIGURATOR_TAXA));
-               configurator.setDoSynonyms(getPreferenceStore().getBoolean(
+               configurator.setDoSynonyms(getBooleanValue(
                                TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
-               configurator.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(
+               configurator.setDoNamesWithoutTaxa(getBooleanValue(
                                TAXON_SERVICE_CONFIGURATOR_NAMES));
-               configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
+               configurator.setDoTaxaByCommonNames(getBooleanValue(
                                TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
+               //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getStringValue(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
 
                return configurator;
        }
@@ -321,7 +750,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 +761,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
@@ -343,7 +772,7 @@ public class PreferencesUtil implements IPreferenceKeys {
                configurator.setPageNumber(0);
                // TODO currently limit results to 10000
                configurator.setPageSize(10000);
-
+               setSearchConfigurator(configurator) ;
                return configurator;
        }
 
@@ -380,6 +809,15 @@ public class PreferencesUtil implements IPreferenceKeys {
                                null, clazz);
        }
 
+       public static String createPreferenceString(String property){
+          return prefKey(property);
+
+       }
+       public static String createOverridePreferenceString(String property){
+              return prefOverrideKey(property);
+
+           }
+
        /**
         * Set default values for preferences
         */
@@ -387,15 +825,52 @@ public class PreferencesUtil implements IPreferenceKeys {
                getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
                getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
                                true);
-               getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT,
+               getPreferenceStore().setDefault(createPreferenceString(EDIT_MAP_SERVICE_ACCES_POINT),
                                "http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
                //FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
-               getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, false);
-               getPreferenceStore().setDefault(OPENURL_ACCESS_POINT,
+               getPreferenceStore().setDefault(createPreferenceString(SHOULD_CONNECT_AT_STARTUP), false);
+               getPreferenceStore().setDefault(createPreferenceString(OPENURL_ACCESS_POINT),
                                "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);
+               getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_WIDTH), "1000");
+               getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_HEIGHT), "1000");
+               //Distribution Editor:
+               getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.DistributionEditorActivated.getKey()), Boolean.valueOf(EditorPreferencePredicate.DistributionEditorActivated.getDefaultValue().toString()));
+               getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString());
+               getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.DisplayOfStatus.getKey()), EditorPreferencePredicate.DisplayOfStatus.getDefaultValue().toString());
+
+
+               //Name Details
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_HYBRID), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_LSID), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NAMECACHE), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_RANK), true);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION), true);
+               //Navigator preferences
+               getPreferenceStore().setDefault(createPreferenceString(SORT_NODES), NavigatorOrderEnum.RankAndNameOrder.getKey());
+
+               getPreferenceStore().setDefault(createPreferenceString(SORT_TAXA_BY_RANK_AND_NAME), true);
+               //override db preferences
+               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate.AbcdImportConfig.getKey())), false);
+               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate.ShowSpecimen.getKey())), false);
+               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate.NameDetailsView.getKey())), false);
+               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(EditorPreferencePredicate.DistributionEditorActivated.getKey())), false);
+
+               getPreferenceStore().setDefault(createPreferenceString(FILTER_COMMON_NAME_REFERENCES), false);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_SPECIMEN), true);
+               getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.ShowTaxonNodeWizard.getKey()), Boolean.valueOf(EditorPreferencePredicate.ShowTaxonNodeWizard.getDefaultValue().toString()));
+               getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.ShowNamespaceInSource.getKey()), Boolean.valueOf(EditorPreferencePredicate.ShowNamespaceInSource.getDefaultValue().toString()));
+               getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.ShowIdInSource.getKey()), Boolean.valueOf(EditorPreferencePredicate.ShowIdInSource.getDefaultValue().toString()));
+               getPreferenceStore().setDefault(createPreferenceString(EditorPreferencePredicate.DisableMultiClassification.getKey()), Boolean.valueOf(EditorPreferencePredicate.DisableMultiClassification.getDefaultValue().toString()));
+               getPreferenceStore().setDefault(createPreferenceString(DISABLE_SEC), false);
+               getPreferenceStore().setDefault(createPreferenceString(SHOW_SEC_DETAILS), true);
        }
 
        /**
@@ -405,32 +880,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;
+        }
+//        setBooleanValue(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();
+        setStringValue(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(){
@@ -454,7 +931,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         * @return a {@link java.lang.String} object.
         */
        public static String getMapServiceAccessPoint() {
-               return getPreferenceStore().getString(EDIT_MAP_SERVICE_ACCES_POINT);
+               return getStringValue(EDIT_MAP_SERVICE_ACCES_POINT);
        }
 
        /**
@@ -466,7 +943,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         */
        public static boolean shouldConnectAtStartUp() {
                //FIXME :  force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
-               //return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
+               //return getBooleanValue(SHOULD_CONNECT_AT_STARTUP);
                return false;
        }
 
@@ -478,10 +955,17 @@ public class PreferencesUtil implements IPreferenceKeys {
         * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
         */
        public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
-               String uuidString = getPreferenceStore().getString(
+               String uuidString = getStringValue(
                                FEATURE_TREE_DEFAULT_TEXT);
-               return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
-                               IFeatureTreeService.class).load(UUID.fromString(uuidString));
+               if (uuidString == null) {
+            return null;
+        }
+               FeatureTree tree = CdmStore.getService(
+                       IFeatureTreeService.class).load(UUID.fromString(uuidString));
+               if (tree.getId() == 0) {
+            return null;
+        }
+               return tree;
        }
 
        /**
@@ -492,7 +976,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
         */
        public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
-               String uuidString = getPreferenceStore().getString(
+               String uuidString = getStringValue(
                                FEATURE_TREE_DEFAULT_STRUCTURE);
                return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
                                IFeatureTreeService.class).load(UUID.fromString(uuidString));
@@ -507,7 +991,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         *            a boolean.
         */
        public static void setSortRanksHierarchichally(boolean selection) {
-               getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY, selection);
+               setBooleanValue(SORT_RANKS_HIERARCHICHALLY, selection);
        }
 
        /**
@@ -518,18 +1002,18 @@ public class PreferencesUtil implements IPreferenceKeys {
         * @return a boolean.
         */
        public static boolean getSortRanksHierarchichally() {
-               return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY);
+               return getBooleanValue(SORT_RANKS_HIERARCHICHALLY);
        }
 
        public static boolean isMultilanguageTextEditingCapability() {
-               return getPreferenceStore().getBoolean(
+               return getBooleanValue(
                                MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
        }
 
        public static Language getGlobalLanguage() {
 
 
-               String languageUuidString = getPreferenceStore().getString(
+               String languageUuidString = getStringValue(
                                GLOBAL_LANGUAGE_UUID);
 
                if(!CdmStore.isActive()) {
@@ -548,7 +1032,7 @@ public class PreferencesUtil implements IPreferenceKeys {
 
        public static void setGlobalLanguage(Language language) {
            if(language != null) {
-               getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
+               setStringValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
                CdmStore.setDefaultLanguage(language);
            }
 
@@ -565,7 +1049,7 @@ public class PreferencesUtil implements IPreferenceKeys {
 
                for (MarkerType markerType : markerTypes) {
                        String name = getMarkerTypeEditingPreferenceKey(markerType);
-                       Boolean value = getPreferenceStore().getBoolean(name);
+                       Boolean value = getBooleanValue(name);
 
                        result.put(markerType, value);
                }
@@ -580,7 +1064,7 @@ public class PreferencesUtil implements IPreferenceKeys {
                        Map<MarkerType, Boolean> markerTypeEditingMap) {
                for (MarkerType markerType : markerTypeEditingMap.keySet()) {
                        String name = getMarkerTypeEditingPreferenceKey(markerType);
-                       getPreferenceStore().setValue(name,
+                       setBooleanValue(name,
                                        markerTypeEditingMap.get(markerType));
                }
 
@@ -606,7 +1090,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         */
        public static void setEditMarkerTypePreference(MarkerType markerType,
                        boolean edit) {
-               getPreferenceStore().setValue(
+               setBooleanValue(
                                getMarkerTypeEditingPreferenceKey(markerType), edit);
        }
 
@@ -638,11 +1122,11 @@ public class PreferencesUtil implements IPreferenceKeys {
         switch(setLanguage){
         case 0:
             properties.setProperty("osgi.nl", "de");
-            PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
+            setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
             break;
         case 1:
             properties.setProperty("osgi.nl", "en");
-            PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
+            setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
             break;
         default:
             break;
@@ -708,7 +1192,7 @@ public class PreferencesUtil implements IPreferenceKeys {
      */
     public static List<MetadataRepositoryElement> getP2Repositories() {
         List<MetadataRepositoryElement> p2Repos = new ArrayList<MetadataRepositoryElement>();
-        String p2ReposPref =  getPreferenceStore().getString(P2_REPOSITORY_LIST);
+        String p2ReposPref =  getStringValue(P2_REPOSITORY_LIST);
         if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
             StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
 
@@ -752,53 +1236,51 @@ public class PreferencesUtil implements IPreferenceKeys {
         }
     }
 
+
+
+
     /**
-        * <p>
-        * getSortRanksNaturally
-        * </p>
-        *
-        * @return a boolean.
-        */
-       public static boolean getSortNodesNaturally() {
-               return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY);
-       }
+     * @param orderActivated
+     */
+    public static void setSortNodes(NavigatorOrderEnum nodesOrder) {
+        setStringValue(SORT_NODES, nodesOrder.key);
 
-       /**
-        * <p>
-        * setSortRanksNaturally
-        * </p>
-        *
-        * @param selection
-        *            a boolean.
-        */
-       public static void setSortNodesNaturally(boolean selection) {
-               getPreferenceStore().setValue(SORT_NODES_NATURALLY, selection);
-       }
+    }
 
+    /**
+     * @param orderActivated
+     */
+    public static NavigatorOrderEnum getSortNodes() {
+        return NavigatorOrderEnum.valueOf(getStringValue(SORT_NODES));
 
-       /**
-        * <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);
-       }
+    /**
+     * @param orderActivated
+     */
+    public static boolean isNodesSortedNaturally() {
+        NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(SORT_NODES));
+        return value.equals(NavigatorOrderEnum.NaturalOrder);
+
+    }
+
+    /**
+     * @param orderActivated
+     */
+    public static boolean isNodesSortedByName() {
+        NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(SORT_NODES));
+        return value.equals(NavigatorOrderEnum.AlphabeticalOrder);
 
+    }
+
+    /**
+     * @param orderActivated
+     */
+    public static boolean isNodesSortedByNameAndRank() {
+        NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(SORT_NODES));
+        return value.equals(NavigatorOrderEnum.RankAndNameOrder);
+
+    }
        /**
         * <p>
         * setStoreNavigatorState
@@ -808,7 +1290,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         *            a boolean.
         */
        public static boolean isStoreNavigatorState() {
-               return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
+               return getBooleanValue(RESTORE_NAVIGATOR_STATE);
 
        }
 
@@ -821,7 +1303,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         *            a boolean.
         */
        public static void setStoreNavigatorState(boolean selection) {
-               getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
+               setBooleanValue(RESTORE_NAVIGATOR_STATE, selection);
 
        }
 
@@ -829,9 +1311,626 @@ public class PreferencesUtil implements IPreferenceKeys {
      * @return
      */
     public static boolean isShowUpWidgetIsDisposedMessages() {
-       return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED);
+       return getBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED);
     }
     public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
-        getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
+        setBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
+    }
+
+    /**
+     * @return
+     */
+    public static boolean isShowIdInVocabularyInChecklistEditor() {
+        String area_display = getStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+        if (area_display.equals(TermDisplayEnum.IdInVocabulary.getKey())) {
+            return true;
+        }else{
+            return false;
+        }
+    }
+    public static boolean isShowSymbol1InChecklistEditor() {
+        String area_display = getStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+        if (area_display.equals(TermDisplayEnum.Symbol1.getKey())) {
+            return true;
+        }else{
+            return false;
+        }
+     }
+    public static boolean isShowSymbol2InChecklistEditor() {
+        String area_display = getStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
+        if (area_display.equals(TermDisplayEnum.Symbol2.getKey())) {
+            return true;
+        }else{
+            return false;
+        }
+     }
+    public static void setAreaDisplayInChecklistEditor(String selection) {
+        setStringValue(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getKey(), selection);
+    }
+
+    public static void setOwnDescriptionForChecklistEditor(boolean selection) {
+        setBooleanValue(EditorPreferencePredicate.OwnDescriptionForDistributionEditor.getKey(), selection);
+    }
+
+    public static boolean isOwnDescriptionForChecklistEditor() {
+        return getBooleanValue(EditorPreferencePredicate.OwnDescriptionForDistributionEditor.getKey());
+    }
+
+    /**
+     * @return
+     */
+    public static String displayStatusInChecklistEditor() {
+       return getStringValue(EditorPreferencePredicate.DisplayOfStatus.getKey());
+    }
+    public static void setDisplayStatusInChecklistEditor(String selection) {
+        setStringValue(EditorPreferencePredicate.DisplayOfStatus.getKey(), selection);
+    }
+
+    /**
+     * @return
+     */
+    public static boolean isShowRankInChecklistEditor() {
+        return getBooleanValue(EditorPreferencePredicate.ShowRankInDistributionEditor.getKey());
+    }
+    public static void setShowRankInChecklistEditor(boolean selection) {
+       setBooleanValue(EditorPreferencePredicate.ShowRankInDistributionEditor.getKey(), selection);
+    }
+
+    /**
+     * @param object
+     * @param b
+     * @return
+     */
+    public static NameDetailsConfigurator getPreferredNameDetailsConfiguration( boolean local) {
+        NameDetailsConfigurator config = new NameDetailsConfigurator(true);
+        CdmPreferenceCache cache = CdmPreferenceCache.instance();
+        CdmPreference preference = null;
+
+        if (!local) {
+            preference = cache.get(EditorPreferencePredicate.NameDetailsView.getKey());
+            if (preference == null){
+                return null;
+            }
+
+            setBooleanValue(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"));
+
+            config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecEnabled"));
+            config.setSecEnabled(getValue(sectionMap, "taxon.SecDetails"));
+
+    //        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(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION));
+            config.setTaxonSectionActivated(getBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON));
+            config.setSecDetailsActivated(getBooleanValue(SHOW_SEC_DETAILS));
+            config.setSecEnabled(getBooleanValue(DISABLE_SEC));
+            config.setLSIDActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID));
+            config.setNomenclaturalCodeActived(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
+            config.setAppendedPhraseActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
+            config.setRankActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK));
+            config.setAtomisedEpithetsActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
+            config.setAuthorshipSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
+            config.setNomenclaturalReferenceSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
+            config.setNomenclaturalStatusSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
+            config.setProtologueActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
+            config.setTypeDesignationSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
+            config.setNameRelationsSectionActivated(getBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
+            config.setHybridActivated(getBooleanValue(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(), EditorPreferencePredicate.NameDetailsView, config.toString());
+
+            setPreferenceToDB(preference);
+        }
+        //also add to local preferences
+        setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_SECTION, config.isSimpleDetailsViewActivated());
+        setBooleanValue(SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
+        setBooleanValue(SHOW_SEC_DETAILS, config.isSecDetailsActivated());
+        setBooleanValue(DISABLE_SEC, config.isSecEnabled());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, config.isNomenclaturalCodeActived());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, config.isAppendedPhraseActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, config.isAtomisedEpithetsActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, config.isAuthorshipSectionActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, config.isNomenclaturalReferenceSectionActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, config.isNomenclaturalStatusSectionActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, config.isProtologueActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, config.isTypeDesignationSectionActivated());
+        setBooleanValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, config.isNameRelationsSectionActivated());
+        setBooleanValue(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 getDBAbcdImportConfigurationPreference() {
+
+        Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+        ICdmRepository controller;
+        controller = CdmStore.getCurrentApplicationConfiguration();
+        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.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 = null;
+                 if (keyValue.length>1){
+                      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 Abcd206ImportConfigurator getLocalAbcdImportConfigurator(){
+       Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+
+        config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
+
+        config.setAddMediaAsMediaSpecimen(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
+
+        config.setAllowReuseOtherClassifications(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
+        config.setDeduplicateClassifications(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
+        config.setDeduplicateReferences(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
+        config.setRemoveCountryFromLocalityText(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REMOVE_COUNTRY_FROM_LOCALITY_TEXT));
+        config.setGetSiblings(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
+        config.setIgnoreAuthorship(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
+        config.setIgnoreImportOfExistingSpecimen(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
+        config.setMapUnitIdToAccessionNumber(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
+        config.setMapUnitIdToBarcode(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
+        config.setMapUnitIdToCatalogNumber(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
+        config.setMoveNewTaxaToDefaultClassification(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
+        config.setOverwriteExistingSpecimens(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
+        config.setReuseExistingDescriptiveGroups(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
+        config.setReuseExistingMetaData(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
+        config.setReuseExistingTaxaWhenPossible(getBooleanValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
+        config.setNomenclaturalCode(NomenclaturalCode.getByKey(getStringValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)));
+
+        return config;
+
+    }
+
+
+    public static void updateAbcdImportConfigurationPreference() {
+        CdmPreferenceCache cache = CdmPreferenceCache.instance();
+        CdmPreference pref = cache.get(EditorPreferencePredicate.AbcdImportConfig.getKey());
+
+        if (!getBooleanValue(prefOverrideKey(EditorPreferencePredicate.AbcdImportConfig.getKey())) || !pref.isAllowOverride()){
+            resetToDBPreferenceAbcdCOnfigurator();
+
+        }
+    }
+
+    public static void resetToDBPreferenceAbcdCOnfigurator(){
+        Abcd206ImportConfigurator config = getDBAbcdImportConfigurationPreference();
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS, config.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN, config.isAddMediaAsMediaSpecimen());
+
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS, config.isAllowReuseOtherClassifications());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS, config.isDeduplicateClassifications());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES, config.isDeduplicateReferences());
+
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS, config.isGetSiblings());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP, config.isIgnoreAuthorship());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN, config.isIgnoreImportOfExistingSpecimen());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER, config.isMapUnitIdToAccessionNumber());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE, config.isMapUnitIdToBarcode());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER, config.isMapUnitIdToCatalogNumber());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION, config.isMoveNewTaxaToDefaultClassification());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN, config.isOverwriteExistingSpecimens());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS, config.isReuseExistingDescriptiveGroups());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA, config.isReuseExistingMetaData());
+        setBooleanValue(ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE, config.isReuseExistingTaxaWhenPossible());
+        if (config.getNomenclaturalCode() != null){
+            setStringValue(ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE, config.getNomenclaturalCode().getKey());
+        }
+    }
+
+
+    /**
+    *
+    */
+   public NameDetailsConfigurator createLocalNameDetailsViewConfig(boolean local) {
+       NameDetailsConfigurator config = new NameDetailsConfigurator(true);
+       if (local){
+          config.setSimpleDetailsViewActivated(getBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
+          config.setAppendedPhraseActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
+          config.setAtomisedEpithetsActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
+          config.setAuthorshipSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
+          config.setLSIDActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
+          config.setNameApprobiationActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION));
+          config.setNameCacheActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
+          config.setNameRelationsSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
+          config.setNomenclaturalCodeActived(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
+          config.setNomenclaturalStatusSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
+          config.setNomenclaturalReferenceSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
+          config.setProtologueActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
+          config.setRankActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
+          config.setTaxonSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
+          config.setTypeDesignationSectionActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
+          config.setHybridActivated(getBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID));
+       }else{
+
+       }
+
+      return config;
+   }
+
+
+   public static void saveConfigToPrefernceStore(NameDetailsConfigurator config) {
+       setBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION,
+               config.isSimpleDetailsViewActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
+               config.isNomenclaturalCodeActived());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE,
+               config.isNameCacheActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
+               config.isAppendedPhraseActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
+               config.isAtomisedEpithetsActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE,
+               config.isAuthorCacheActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
+               config.isAuthorshipSectionActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
+               config.isNomenclaturalReferenceSectionActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
+               config.isNomenclaturalStatusSectionActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
+               config.isProtologueActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
+               config.isTypeDesignationSectionActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
+               config.isNameRelationsSectionActivated());
+       setBooleanValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID,
+               config.isHybridActivated());
+
+   }
+
+/**
+ * @return
+ */
+public static boolean isSortTaxaByRankAndName() {
+
+    return getBooleanValue(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
+}
+
+/**
+ * @return
+ */
+public static boolean isSortNamedAreaByOrderInVocabulary() {
+
+    return getBooleanValue(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey());
+}
+
+public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder) {
+    setBooleanValue(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getKey(), isSortByVocabularyOrder);
+
+}
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static void setLastSelectedReference(
+        List<String> lastSelectedReferences) {
+
+        setStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
     }
+
+/**
+ * <p>
+ * setPreferredNamedAreasForDistributionEditor
+ * </p>
+ *
+ * @param saveCheckedElements
+ * @param saveGrayedElements
+ */
+public static List<String> getLastSelectedReferences() {
+
+        //IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
+        String lastSelected = getStringValue(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){
+        setStringValue(EditorPreferencePredicate.AvailableDistributionAreaTerms.getKey(), saveCheckedElements);
+
+    }
+    else{
+        CdmPreference preference = null;
+
+        if (saveCheckedElements == null){
+            preference = getPreferenceFromDB(EditorPreferencePredicate.AvailableDistributionAreaTerms);
+
+            if (preference == null){
+                return ;
+            } else{
+                setStringValue(EditorPreferencePredicate.AvailableDistributionAreaTerms.getKey(),
+                        saveCheckedElements);
+                preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+                setPreferenceToDB(preference);
+
+            }
+        } else{
+           preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+           setPreferenceToDB(preference);
+           setStringValue(EditorPreferencePredicate.AvailableDistributionAreaTerms.getKey(),
+                    saveCheckedElements);
+
+        }
+    }
+
+}
+
+/**
+ * @param saveCheckedElements
+ * @param saveCheckedElements2
+ * @param b
+ */
+public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
+        boolean local, boolean isOverride) {
+    if (local){
+      setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), saveCheckedElements);
+      setBooleanValue(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()), isOverride);
+    }
+    else{
+        ICdmRepository controller;
+        CdmPreference preference = null;
+
+        if (saveCheckedElements == null){
+            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+
+            if (preference == null){
+                return ;
+            } else{
+                setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
+                        saveCheckedElements);
+                preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
+                preference.setAllowOverride(isOverride);
+                setPreferenceToDB(preference);
+            }
+        } else{
+            preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
+            preference.setAllowOverride(isOverride);
+            setPreferenceToDB(preference);
+            setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
+                    saveCheckedElements);
+
+        }
+    }
+}
+
+
+
+
+/**
+ * @param saveCheckedElements
+ * @param saveCheckedElements2
+ * @param b
+ */
+public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
+    if (local){
+
+        String pref = getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), local);
+        return pref;
+    }
+    else{
+        CdmPreference preference = null;
+        preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
+        if (preference == null){
+            return null;
+        } else{
+            return preference.getValue();
+        }
+
+    }
+
+
+
+}
+
+public static boolean getFilterCommonNameReferences(){
+    return getBooleanValue(PreferencesUtil.FILTER_COMMON_NAME_REFERENCES);
+}
+
+/**
+ *
+ */
+public static void updateDBPreferences() {
+    CdmPreference preference = null;
+    CdmPreferenceCache cache = CdmPreferenceCache.instance();
+    cache.getAllTaxEditorDBPreferences();
+
+    //ABCD Configurator
+
+    updateAbcdImportConfigurationPreference();
+
+    //Name Details
+    NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
+    if (config != null ){
+        if (!getBooleanValue(OVERRIDE_NAME_DETAILS) ||  !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS)){
+            setPreferredNameDetailsConfiguration(config, false);
+        }
+    }
+
+
+
+
+
+
+
+
+}
+
+
+
+
+
+
+
+
 }