sort taxon nodes in taxon filter of DDS editor
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / PreferencesUtil.java
index 32eb38bb865af00d2758b4887a94910d4c527f22..2a2412bc40384137376eb6412cff64a319970ecb 100644 (file)
@@ -13,20 +13,24 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.net.URI;
+import java.lang.reflect.Field;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 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.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
 import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.window.Window;
@@ -34,40 +38,59 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.PlatformUI;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
 
 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;
+import eu.etaxonomy.cdm.api.service.ITermTreeService;
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
 import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
 import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
+import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator;
 import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.cdm.common.URI;
 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.Language;
 import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
 import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
+import eu.etaxonomy.cdm.model.metadata.EnabledComputedDescription;
 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.SecReferenceHandlingEnum;
+import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingSwapEnum;
 import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
+import eu.etaxonomy.cdm.model.metadata.TermOrder;
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
-import eu.etaxonomy.cdm.model.term.FeatureTree;
 import eu.etaxonomy.cdm.model.term.IDefinedTerm;
 import eu.etaxonomy.cdm.model.term.ISimpleTerm;
 import eu.etaxonomy.cdm.model.term.TermBase;
+import eu.etaxonomy.cdm.model.term.TermTree;
+import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.cdm.model.term.TermVocabulary;
+import eu.etaxonomy.cdm.model.term.VocabularyEnum;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByRankAndNameComparator;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoNaturalComparator;
 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.editor.definedterm.input.TermEditorInput;
 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.remoting.source.ICdmRemoteSource;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.TermStore;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
 
@@ -81,139 +104,167 @@ import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
  * @created 05.12.2008
  */
 public class PreferencesUtil implements IPreferenceKeys {
+    private final static String EDITOR_PREFERENCES_NODE = "eu.etaxonomy.taxeditor";
 
-       /**
-        *
-        */
-       public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
+    public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
 
-       public static final String P2_REPOSITORIES_DELIM = ",";
-       public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
+    public static final String P2_REPOSITORIES_DELIM = ",";
+    public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
+    public static final String SUBJECT_DELIM = "/";
 
-       private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
+    private static TermTree<Feature> preferredNameFeatureTree;
 
+    private static TermTree<Feature> preferredTaxonFeatureTree;
 
 
 
+    private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
 
-       /**
-        * <p>
-        * getPreferenceStore
-        * </p>
-        *
-        * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
-        */
-       public static IPreferenceStore getPreferenceStore() {
-               return TaxeditorStorePlugin.getDefault().getPreferenceStore();
-       }
+    public static IPreferenceStore getPreferenceStore() {
+       return TaxeditorStorePlugin.getDefault().getPreferenceStore();
+    }
 
-       private static String prefKey(String name) {
-           return name + "_"+  ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
-       }
+    public static String[] extractSubjectParts(String subject){
+       String[] result = subject.split("/");
+       return result;
+    }
+
+    public static IEclipsePreferences getEditorPreferences(){
+        return ConfigurationScope.INSTANCE.getNode(EDITOR_PREFERENCES_NODE);
+    }
+
+    public static String getPreferenceValue(PrefKey prefKey){
+        try {
+            //check if there exist a node for the predicate
+            if(getEditorPreferences().nodeExists(prefKey.getPredicate())){
+                Preferences predicateNode = getEditorPreferences().node(prefKey.getPredicate());
+                String[] splittedSubject = extractSubjectParts(prefKey.getSubject());
+                //check if the predicate node contains a node for the subject, this should be the last part
+                String value = predicateNode.get(splittedSubject[splittedSubject.length-1], PreferencePredicate.getByKey(prefKey.getPredicate()).getDefaultValue() != null? PreferencePredicate.getByKey(prefKey.getPredicate()).getDefaultValue().toString(): "");
+                int index = splittedSubject.length -2;
+                while (value != null && index >= 0){
+                   value = predicateNode.get(splittedSubject[index], prefKey.getPredicate());
+                   index--;
+                }
+                return value;
+            }
+
+        } catch (BackingStoreException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static List<CdmPreference> getPreference(PreferencePredicate prefPredicate){
+        try {
+            List<CdmPreference> prefs = new ArrayList<>();
+            CdmPreference pref;
+            PreferenceSubject subject;
+            if(getEditorPreferences().nodeExists(prefPredicate.getKey())){
+                Preferences predicateNode = getEditorPreferences().node(prefPredicate.getKey());
+                for (String childName: predicateNode.childrenNames()){
+                    Preferences child = predicateNode.node(childName);
+                    String subjectString = "";
+                    subjectString = createSubjectStringForChildNodes(childName, child);
+                    String value = child.get(subjectString, "");
+                    subject = PreferenceSubject.NewInstance(subjectString);
+                    pref = CdmPreference.NewInstance(subject, prefPredicate, value);
+                    prefs.add(pref);
+                }
+            }
+        } catch (BackingStoreException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private static String createSubjectStringForChildNodes(String subject, Preferences parent) {
+        try {
+            for (String childName: parent.childrenNames()){
+                subject = childName+SUBJECT_DELIM+subject;
+                Preferences child = parent.node(childName);
+                createSubjectStringForChildNodes(subject, child);
+            }
+        } catch (BackingStoreException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return subject;
+
+    }
 
-       public static String prefOverrideKey(String name) {
+    private static String prefKey(String name) {
+        return name + "_"+  ((ICdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
+    }
+
+    public static String prefOverrideKey(String name) {
         return name + "_OVERRIDE_";
     }
 
-       /**
-     * <p>
-     * setStringValue
-     * </p>
-     *
-     *
-     **/
     public static void setStringValue(String name, String value) {
         if (value != null){
             getPreferenceStore().setValue(prefKey(name), value);
         }else{
-            getPreferenceStore().setToDefault(name);
+            getPreferenceStore().setToDefault(prefKey(name));
         }
     }
 
-    /**
-     * <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(prefKey(name), 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) {
 
         CdmPreference pref = getDBPreferenceValue(name);
-        String prefValue = null;
-        String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
-        boolean override = true;
-        if (getPreferenceStore().contains(overrideKey)){
-            override = getPreferenceStore().getBoolean(overrideKey);
-        }
-        if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
+
+        boolean override = getOverrideForPreference(name);
+
+        if (local || (pref == null && override)|| (pref != null && pref.isAllowOverride() && override)){
+            //local preference
             String dbSpecific = prefKey(name);
             if (getPreferenceStore().contains(dbSpecific)){
-                prefValue = getPreferenceStore().getString(dbSpecific);
-            }else{
-                prefValue = getPreferenceStore().
-                        getString(name);
+                return getPreferenceStore().getString(dbSpecific);
             }
-       }else if (pref != null){
-           prefValue = pref.getValue();
-       }
-        return prefValue;
-
+         }else if (pref != null){
+             //db preference
+             if (pref.getValue() == null){
+                 Object result = PreferencePredicate.getByKey(pref.getPredicate()).getDefaultValue();
+                 if (result instanceof String){
+                     return (String)result;
+                 }else{
+                     return result != null?result.toString(): null;
+                 }
+             }
+            return pref.getValue();
+        }
+        //no override but default value
+        IPreferencePredicate<?> pred = PreferencePredicate.getByKey(name);
+        if (pred != null){
+            if (pred.getDefaultValue() instanceof String){
+                return (String)pred.getDefaultValue();
+            }else if (pred.getDefaultValue() != null){
+                return pred.getDefaultValue().toString();
+            }
+        }
+        return null;
     }
 
     public static String getStringValue(String name){
@@ -223,31 +274,12 @@ public class PreferencesUtil implements IPreferenceKeys {
     private static CdmPreference getDBPreferenceValue(String name) {
         CdmPreferenceCache cache = CdmPreferenceCache.instance();
         CdmPreference pref = null;
-//
         pref = cache.get(name);
-        if (pref == null ){
-            //get default value for Predicate
-            IPreferencePredicate pred = PreferencePredicate.getByKey(name);
-            if (pred != null){
-                if (pred.getDefaultValue() != null){
-                    pref = CdmPreference.NewTaxEditorInstance(pred, pred.getDefaultValue().toString());
-                }else{
-                    pref = CdmPreference.NewTaxEditorInstance(pred, null);
-                }
-                pref.setAllowOverride(true);
-            }
-        }
+
         return pref;
     }
 
-    /**
-     * <p>
-     * setIntValue
-     * </p>
-     *
-     *
-     **/
-    public static int getIntValue(String name) {
+    public static int getIntValue(String name, boolean local) {
         CdmPreference pref= getDBPreferenceValue(name);
         String prefValue = null;
         if (pref != null){
@@ -257,211 +289,160 @@ public class PreferencesUtil implements IPreferenceKeys {
         try{
             result = Integer.parseInt(prefValue);
         }catch(NumberFormatException e){
-            logger.debug("Preference value of " + name + " is not a number");
+            logger.debug("Preference value of " + name + " is not an integer");
         }
-        if (result == null){
+
+        boolean override = getOverrideForPreference(name);
+        if (local || (pref == null && override) || (pref != null && pref.isAllowOverride() && override)){
             String dbSpecific = prefKey(name);
             if (getPreferenceStore().contains(dbSpecific)){
                 result = getPreferenceStore().getInt(dbSpecific);
-            }else{
-                result =  getPreferenceStore().
-                        getInt(name);
+            }
+        }
+        if (result == null){
+            IPreferencePredicate<?> pred = PreferencePredicate.getByKey(name);
+            if (pred != null){
+                if (pred.getDefaultValue() instanceof Integer){
+                    result = (Integer)pred.getDefaultValue();
+                }else if (pred.getDefaultValue() != null){
+                    try{
+                        result = Integer.valueOf(pred.getDefaultValue().toString());
+                    }catch(NumberFormatException e){
+                        logger.debug("Preference value of " + name + " is not a number");
+                        result = 0;
+                    }
+                }
+            }
+            //if no default value available
+            if (result == null){
+                result = 0;
             }
         }
         return result;
-
-
     }
 
     public static boolean getBooleanValue(String name) {
-        return getBooleanValue(name, false);
+        Boolean result = getBooleanValue(name, false);
+        if (result == null){
+            return false;
+        }else{
+            return result;
+        }
     }
 
-    /**
-     * <p>
-     * getBooleanValue
-     * </p>
-     *
-     *
-     **/
-    public static boolean getBooleanValue(String name, boolean local) {
+    public static Boolean getBooleanValue(String name, boolean local) {
         if (CdmStore.isActive()){
             CdmPreference pref = getDBPreferenceValue(name);
-            String prefValue = null;
-            if (pref == null || local){
+            String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
+            boolean override = getPreferenceStore().getBoolean(overrideKey);
+            if (local || (pref == null && override)|| (pref != null && pref.isAllowOverride() && override)){
+                //local preference
                 String dbSpecific = prefKey(name);
-                if (getPreferenceStore().contains(dbSpecific)){
-                    return getPreferenceStore().getBoolean(dbSpecific);
-                }else{
-                    return getPreferenceStore().
-                            getBoolean(name);
-                }
-            }else{
+                return getPreferenceStore().getBoolean(dbSpecific);
+
+             }else if (pref != null){
+                 //db preference is available and override == false
+                 if (pref.getValue() == null){
+                     Object result = PreferencePredicate.getByKey(pref.getPredicate()).getDefaultValue();
+                     if (result instanceof Boolean){
+                         return (Boolean)result;
+                     }else{
+                         return Boolean.valueOf(result.toString());
+                     }
+                 }
                 return Boolean.valueOf(pref.getValue());
             }
-
+            //no override but default value
+            IPreferencePredicate<?> pred = PreferencePredicate.getByKey(name);
+            if (pred != null){
+                if (pred.getDefaultValue() instanceof Boolean){
+                    return (Boolean)pred.getDefaultValue();
+                }else if (pred.getDefaultValue() != null){
+                    return Boolean.valueOf(pred.getDefaultValue().toString());
+                }
+            }
+            return false;
         }else{
+            // no connection to db, use local preference
             return getPreferenceStore().getBoolean(name);
         }
-
     }
 
-    /**
-     * <p>
-     * setBooleanValue
-     * </p>
-     *
-     *
-     **/
-    public static double getDoubleValue(String name) {
+    public static float getFloatValue(String name, boolean local) {
         CdmPreference pref = getDBPreferenceValue(name);
         String prefValue = null;
         if (pref != null){
             prefValue = pref.getValue();
         }
-        Double result = null;
+        Float 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);
+            if (prefValue != null){
+                result = Float.parseFloat(prefValue);
             }
+        }catch(NumberFormatException e){
+            logger.debug("Preference value of " + name + " is not a float");
         }
-        return result;
 
-    }
+        boolean override = getOverrideForPreference(name);
 
-    /**
-     * <p>
-     * getFloatValue
-     * </p>
-     *
-     *
-     **/
-    public static float getFloatValue(String name) {
-        CdmPreference pref = getDBPreferenceValue(name);
-        String prefValue = null;
-        if (pref != null){
-            prefValue = pref.getValue();
-        }
-        Float result = null;
-        try{
-            result = Float.parseFloat(prefValue);
-        }catch(NumberFormatException e){
-            logger.debug("Preference value of " + name + " is not a number");
-        }
-        if (result == null){
+        if (local || pref == null || (pref.isAllowOverride() && override)){
             String dbSpecific = prefKey(name);
             if (getPreferenceStore().contains(dbSpecific)){
                 result = getPreferenceStore().getFloat(dbSpecific);
             }else{
-                result =  getPreferenceStore().
-                        getFloat(name);
+                IPreferencePredicate<?> pred = PreferencePredicate.getByKey(name);
+                if (pred != null){
+                    if (pred.getDefaultValue() instanceof Float){
+                        return (float)pred.getDefaultValue();
+                    }else if (pred.getDefaultValue() != null){
+                        return Float.valueOf(pred.getDefaultValue().toString());
+                    }
+                }
+                return 0;
             }
         }
         return result;
-
     }
 
-    /**
-     * <p>
-     * getLongValue
-     * </p>
-     *
-     *
-     **/
-    public static long getLongValue(String name) {
-        CdmPreference pref = getDBPreferenceValue(name);
-        String prefValue = null;
-        if (pref != null){
-            prefValue = pref.getValue();
-        }
-        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);
-            }
+    public static CdmPreference setPreferredNomenclaturalCode(
+            String preferenceValue, boolean local) {
+        if (local){
+            setStringValue(PreferencePredicate.NomenclaturalCode.getKey(),
+                    preferenceValue);
         }
-        return result;
-    }
-
-
-       /**
-        * <p>
-        * setPreferredNomenclaturalCode
-        * </p>
-        *
-        * @param preferredCode
-        *            a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
-        *            object.
-        */
-       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){
+        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;
+            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(PreferencePredicate.NomenclaturalCode.getKey(),
+                            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) {
 
@@ -470,86 +451,57 @@ public class PreferencesUtil implements IPreferenceKeys {
         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);
 
+        if (preference == null){
+            PrefKey key = null;
+              try{
+                  key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
+              }catch (Exception e){
+                  System.out.println(e.getStackTrace());
+              }
+            controller.getPreferenceService().remove(key);
+        }else{
+            controller.getPreferenceService().set(preference);
+        }
     }
 
+    public static NomenclaturalCode getPreferredNomenclaturalCode() {
 
+        String nomString = getStringValue(PreferencePredicate.NomenclaturalCode.getKey());
+        return getPreferredNomenclaturalCode(nomString);
+    }
 
-
-       /**
-        * <p>
-        * getPreferredNomenclaturalCode
-        * </p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
-        */
-       public static NomenclaturalCode getPreferredNomenclaturalCode() {
-
-               CdmPreference pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
-
-
-           String preferredCode;
-           if(pref == null || (pref.isAllowOverride() && getBooleanValue(prefOverrideKey(PreferencePredicate.NomenclaturalCode.getKey())))){
-               preferredCode = getStringValue(
-                       PreferencePredicate.NomenclaturalCode.getKey(), true);
-
-           }else{
-               preferredCode = pref.getValue();
-           }
-           if (StringUtils.isBlank(preferredCode)){
-               preferredCode = getPreferenceKey((NomenclaturalCode)PreferencePredicate.NomenclaturalCode.getDefaultValue());
-           }
-
-           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)) {
+            if (getPreferenceKey(code).equals(preferenceKeyNomenclaturalCode) || code.getKey().equals(preferenceKeyNomenclaturalCode)) {
                 return code;
             }
         }
         return null;
     }
 
-       public static boolean isShowTaxonAssociations(){
+    public static boolean isShowTaxonAssociations(){
         boolean result = getBooleanValue(PreferencePredicate.ShowTaxonAssociations.getKey());
         return result;
     }
 
-       public static boolean isShowLifeForm(){
-           boolean result =  getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
-           return result;
+    public static boolean isShowLifeForm(){
+        boolean result =  getBooleanValue(PreferencePredicate.ShowLifeForm.getKey());
+        return result;
     }
 
-       public static boolean isDeterminationOnlyForFieldUnits(){
-           boolean result =  getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
+    public static boolean isDeterminationOnlyForFieldUnits(){
+        boolean result =  getBooleanValue(PreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
         return result;
     }
 
-       public static boolean isCollectingAreaInGeneralSection(){
-           boolean result =  getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey());
+    public static boolean isCollectingAreaInGeneralSection(){
+        boolean result =  getBooleanValue(PreferencePredicate.ShowCollectingAreasInGeneralSection.getKey());
         return result;
-       }
+    }
 
-       public static CdmPreference getPreferenceFromDB(IPreferencePredicate predicate){
+    public static CdmPreference getPreferenceFromDB(IPreferencePredicate<?> predicate){
         ICdmRepository controller;
         CdmPreference pref = null;
 
@@ -564,10 +516,9 @@ public class PreferencesUtil implements IPreferenceKeys {
         }
 
         return pref;
-
     }
 
-       public static List<CdmPreference> getPreferencesFromDB(IPreferencePredicate predicate){
+    public static List<CdmPreference> getPreferencesFromDB(IPreferencePredicate<?> predicate){
         ICdmRepository controller;
         List<CdmPreference> prefs = null;
 
@@ -585,7 +536,24 @@ public class PreferencesUtil implements IPreferenceKeys {
 
     }
 
-       public static CdmPreference getPreferenceFromDB(PrefKey key){
+    public static void setPreferencesToDB(CdmPreference preference, boolean setDefault){
+        ICdmRepository controller;
+        try{
+            if(CdmStore.isActive()){
+                controller = CdmStore.getCurrentApplicationConfiguration();
+
+                if (setDefault){
+                    controller.getPreferenceService().remove(preference.getKey());
+                }else{
+                    controller.getPreferenceService().set(preference);
+                }
+            }
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    public static CdmPreference getPreferenceFromDB(PrefKey key){
         ICdmRepository controller;
         CdmPreference pref = null;
 
@@ -602,363 +570,337 @@ public class PreferencesUtil implements IPreferenceKeys {
 
     }
 
-
-
     public static void setPreferenceToDB(CdmPreference preference){
         ICdmRepository controller;
         try{
             if(CdmStore.isActive()){
                 controller = CdmStore.getCurrentApplicationConfiguration();
-                controller.getPreferenceService().set(preference);
+                if (preference.getValue() == null && preference.isAllowOverride()){
+                    controller.getPreferenceService().remove(preference.getKey());
+                }else{
+                    controller.getPreferenceService().set(preference);
+                }
                 CdmPreferenceCache.instance().put(preference);
             }
         }catch(Exception e){
             e.printStackTrace();
         }
-
     }
 
+    public static String getPreferredDefaultLangugae(){
+        String preferredLanguage = getStringValue(DEFAULT_LANGUAGE_EDITOR, true);
+        if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
+            return preferredLanguage;
+        }
+        return null;
+    }
 
-
-       public static String getPreferredDefaultLangugae(){
-           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);
+    public static boolean isShowMediaPreview(){
+        boolean isShowMediaPreview = getBooleanValue(SHOW_MEDIA_PREVIEW, true);
         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
-        *
-        * @param clazz
-        *            a {@link java.lang.Class} object.
-        * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
-        */
-       public static IMatchStrategy getMatchStrategy(Class<?> clazz) {
-               String className = clazz.getName();
-               if (getBooleanValue(MATCH_STRATEGY_PREFIX + className)) {
-                       IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
-
-                       //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 {
-                                       matchStrategy.setMatchMode(fieldName, matchMode);
-                               } catch (MatchException e) {
-                                       MessagingUtils.error(PreferencesUtil.class, e);
-                                       throw new RuntimeException(e);
-                               }
-                       }
-
-                       return matchStrategy;
-               }
-               return getDefaultMatchStrategy(clazz);
-       }
+    /**
+     * Get the match strategy for the given class that was stored in preferences
+     * or the default strategy if it was not stored in preferences
+     *
+     * @param clazz
+     *            a {@link java.lang.Class} object.
+     * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
+     */
+    public static IMatchStrategy getMatchStrategy(Class<?> clazz) {
+        String className = clazz.getName();
+        if (getBooleanValue(MATCH_STRATEGY_PREFIX + className, true)) {
+            IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
+
+            //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), true);
+                MatchMode matchMode = MatchMode.valueOf(matchModeName);
+                try {
+                    matchStrategy.setMatchMode(fieldName, matchMode);
+                } catch (MatchException e) {
+                    MessagingUtils.error(PreferencesUtil.class, e);
+                    throw new RuntimeException(e);
+                }
+            }
 
-       /**
-        * Stores a matchStrategy into the preference store.
-        *
-        * @param matchStrategy
-        *            a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
-        *            object.
-        */
-       public static void setMatchStrategy(IMatchStrategy matchStrategy) {
-               String className = "ANY class"; //FIXME was: matchStrategy.getMatchClass().getName(); seems currently not in use
-               setBooleanValue(MATCH_STRATEGY_PREFIX + className, true);
-
-               List<FieldMatcher> fieldMatchers = matchStrategy.getMatching().getFieldMatchers(false);
-
-               for (FieldMatcher fieldMatcher : fieldMatchers) {
-                       String fieldName = fieldMatcher.getPropertyName();
-                       setStringValue(
-                                       getMatchStrategyFieldName(className, fieldName),
-                                       fieldMatcher.getMatchMode().name());
-               }
-       }
+            return matchStrategy;
+        }
+        return getDefaultMatchStrategy(clazz);
+    }
 
-       /**
-        * Helper method to create the preference property for a match field.
-        *
-        * @param className
-        * @param fieldName
-        * @return
-        */
-       private static String getMatchStrategyFieldName(String className,
-                       String fieldName) {
-               return MATCH_STRATEGY_PREFIX + className + "." + fieldName;
-       }
+    /**
+     * Stores a matchStrategy into the preference store.
+     *
+     * @param matchStrategy
+     *            a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
+     *            object.
+     */
+    public static void setMatchStrategy(IMatchStrategy matchStrategy) {
+        String className = "ANY class"; //FIXME was: matchStrategy.getMatchClass().getName(); seems currently not in use
+        setBooleanValue(MATCH_STRATEGY_PREFIX + className, true);
 
-       /**
-        * Returns the default match strategy for a given class.
-        *
-        * @param clazz
-        *            a {@link java.lang.Class} object.
-        * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
-        */
-       public static IMatchStrategy getDefaultMatchStrategy(Class clazz) {
-               return DefaultMatchStrategy.NewInstance(clazz);
-       }
+        List<FieldMatcher> fieldMatchers = matchStrategy.getMatching().getFieldMatchers(false);
 
-       /**
-        * <p>
-        * getDateFormatPattern
-        * </p>
-        *
-        * @return a {@link java.lang.String} object.
-        */
-       public static String getDateFormatPattern() {
-               // TODO make this configurable in properties
-               String pattern = "Y-M-d H:m";
-               return pattern;
-       }
+        for (FieldMatcher fieldMatcher : fieldMatchers) {
+            String fieldName = fieldMatcher.getPropertyName();
+            setStringValue(
+                    getMatchStrategyFieldName(className, fieldName),
+                    fieldMatcher.getMatchMode().name());
+        }
+    }
 
-       /**
-        * <p>
-        * addTermToPreferredTerms
-        * </p>
-        *
-        * @param term
-        *            a T object.
-        * @param <T>
-        *            a T object.
-        */
-       public static <T extends TermBase> void addTermToPreferredTerms(T term) {
-
-               // VocabularyEnum vocabulary =
-               // VocabularyEnum.getVocabularyEnum(term.getClass());
-               //
-               // getPreferenceStore().setValue(getPreferenceKey(term),
-               // VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
-               //
-               // firePreferencesChanged(term.getClass());
-       }
+    /**
+     * Helper method to create the preference property for a match field.
+     *
+     * @param className
+     * @param fieldName
+     * @return
+     */
+    private static String getMatchStrategyFieldName(String className,
+            String fieldName) {
+        return MATCH_STRATEGY_PREFIX + className + "." + fieldName;
+    }
 
-       /**
-        * Construct a unique key using the CdmBase object's uuid
-        *
-        * @param cdmBase
-        * @return
-        */
-       private static String getPreferenceKey(ICdmBase cdmBase) {
-               cdmBase = HibernateProxyHelper.deproxy(cdmBase);
-
-               String key = cdmBase.getClass().getName().concat(".")
-                               .concat(cdmBase.getUuid().toString());
-               if (key.contains("javassist")) {
-                       MessagingUtils.info("proxy");
-               }
-               return key;
-       }
+    /**
+     * Returns the default match strategy for a given class.
+     *
+     * @param clazz
+     *            a {@link java.lang.Class} object.
+     * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
+     */
+    public static IMatchStrategy getDefaultMatchStrategy(Class clazz) {
+        return DefaultMatchStrategy.NewInstance(clazz);
+    }
 
-       /**
-        * Construct a unique key using the CdmBase object's uuid
-        *
-        * @param cdmBase
-        * @return
-        */
-       public static String getPreferenceKey(ISimpleTerm simpleTerm) {
-               simpleTerm = HibernateProxyHelper.deproxy(simpleTerm);
-               String key = simpleTerm.getClass().getName().concat(".")
-                               .concat(simpleTerm.getUuid().toString());
-               if (key.contains("javassist")) {
-                       MessagingUtils.warn(PreferencesUtil.class,
-                                       "Trying to persist a preference based on a proxy class.");
-               }
-               return key;
-       }
+    public static String getDateFormatPattern() {
+        // TODO make this configurable in properties
+        String pattern = "Y-M-d H:m";
+        return pattern;
+    }
 
+    public static <T extends TermBase> void addTermToPreferredTerms(T term) {
 
+        // VocabularyEnum vocabulary =
+        // VocabularyEnum.getVocabularyEnum(term.getClass());
+        //
+        // getPreferenceStore().setValue(getPreferenceKey(term),
+        // VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
+        //
+        // firePreferencesChanged(term.getClass());
+    }
 
-       /**
-        * Construct a unique key using the CdmBase object's uuid
-        *
-        * @param cdmBase
-        * @return
-        */
-       public static String getPreferenceKey(IDefinedTerm definedTerm) {
-               definedTerm = HibernateProxyHelper.deproxy(definedTerm);
-               String key = definedTerm.getClass().getName().concat(".")
-                               .concat(definedTerm.getUuid().toString());
-               if (key.contains("javassist")) {
-                       MessagingUtils.warn(PreferencesUtil.class,
-                                       "Trying to persist a preference based on a proxy class.");
-               }
-               return key;
-       }
+    /**
+     * Construct a unique key using the CdmBase object's uuid
+     *
+     * @param cdmBase
+     * @return
+     */
+    private static String getPreferenceKey(ICdmBase cdmBase) {
+        cdmBase = HibernateProxyHelper.deproxy(cdmBase);
 
-       /**
-        * Retrieves search preferences from the preference store
-        *
-        * @return an {@link ITaxonServiceConfigurator} to pass to search methods
-        */
-       public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
-               IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
-
-               configurator.setDoTaxa(getBooleanValue(
-                               TAXON_SERVICE_CONFIGURATOR_TAXA));
-               configurator.setDoSynonyms(getBooleanValue(
-                               TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
-               configurator.setDoNamesWithoutTaxa(getBooleanValue(
-                               TAXON_SERVICE_CONFIGURATOR_NAMES));
-               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;
-       }
+        String key = cdmBase.getClass().getName().concat(".")
+                .concat(cdmBase.getUuid().toString());
+        if (key.contains("javassist")) {
+            MessagingUtils.info("proxy");
+        }
+        return key;
+    }
 
-       /**
-        * create new preferences, setting all search options to true
-        *
-        * @return a
-        *         {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
-        *         object.
-        */
-       public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
-               IFindTaxaAndNamesConfigurator configurator = FindTaxaAndNamesConfiguratorImpl.NewInstance();
-
-               configurator.setDoTaxa(true);
-               configurator.setDoSynonyms(true);
-               configurator.setDoNamesWithoutTaxa(true);
-               configurator.setDoTaxaByCommonNames(true);
-
-               configurator.setTaxonPropertyPath(Arrays.asList("$", "titleCache",
-                               "name", "name.$", "relationsFromThisTaxon.$"));
-
-               configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
-                               "name", "name.$", "synonyms.relatedTo.*"));
-
-               // DEFAULT VALUES
-               // match mode is a simple like, actually all other match modes are kind
-               // of bogus
-               configurator
-                               .setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.ANYWHERE);
-               // we set page number and size here as this should always be unlimited
-               configurator.setPageNumber(0);
-               // TODO currently limit results to 10000
-               configurator.setPageSize(10000);
-               //setSearchConfigurator(configurator) ;
-               return configurator;
-       }
+    /**
+     * Construct a unique key using the CdmBase object's uuid
+     *
+     * @param cdmBase
+     * @return
+     */
+    public static String getPreferenceKey(ISimpleTerm<?> simpleTerm) {
+        simpleTerm = HibernateProxyHelper.deproxy(simpleTerm);
+        String key = simpleTerm.getClass().getName().concat(".")
+                .concat(simpleTerm.getUuid().toString());
+        if (key.contains("javassist")) {
+            MessagingUtils.warn(PreferencesUtil.class,
+                    "Trying to persist a preference based on a proxy class.");
+        }
+        return key;
+    }
 
-       /**
-        * Store search preferences
-        *
-        * @param configurator
-        *            a
-        *            {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
-        *            object.
-        */
-       public static void setSearchConfigurator(
-                       IFindTaxaAndNamesConfigurator configurator) {
-               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA,
-                               configurator.isDoTaxa());
-               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
-                               configurator.isDoSynonyms());
-               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES,
-                               configurator.isDoNamesWithoutTaxa());
-               getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES,
-                               configurator.isDoTaxaByCommonNames());
-       }
+    /**
+     * Construct a unique key using the CdmBase object's uuid
+     */
+    public static String getPreferenceKey(IDefinedTerm definedTerm) {
+        definedTerm = HibernateProxyHelper.deproxy(definedTerm);
+        String key = definedTerm.getClass().getName().concat(".")
+                .concat(definedTerm.getUuid().toString());
+        if (key.contains("javassist")) {
+            MessagingUtils.warn(PreferencesUtil.class,
+                    "Trying to persist a preference based on a proxy class.");
+        }
+        return key;
+    }
 
-       /**
-        * <p>
-        * firePreferencesChanged
-        * </p>
-        *
-        * @param clazz
-        *            a {@link java.lang.Class} object.
-        */
-       public static void firePreferencesChanged(Class clazz) {
-               getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE,
-                               null, clazz);
-       }
+    /**
+     * Retrieves search preferences from the preference store
+     *
+     * @return an {@link ITaxonServiceConfigurator} to pass to search methods
+     */
+    public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
+        IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
+
+        configurator.setDoTaxa(PreferencesUtil.getPreferenceStore().contains(IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_TAXA)? PreferencesUtil.getPreferenceStore().getBoolean(
+                IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_TAXA): true);
+        configurator.setDoSynonyms(PreferencesUtil.getPreferenceStore().contains(IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_SYNONYMS)? PreferencesUtil.getPreferenceStore().getBoolean(
+                IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_SYNONYMS): true);
+        configurator.setDoNamesWithoutTaxa(PreferencesUtil.getPreferenceStore().contains(IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_NAMES)? PreferencesUtil.getPreferenceStore().getBoolean(
+                IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_NAMES): true);
+        configurator.setDoTaxaByCommonNames(PreferencesUtil.getPreferenceStore().contains(IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES)? PreferencesUtil.getPreferenceStore().getBoolean(
+                IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES): true);
+        configurator.setDoIncludeAuthors(PreferencesUtil.getPreferenceStore().contains(IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_WITH_AUTHORS)? PreferencesUtil.getPreferenceStore().getBoolean(
+                IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_WITH_AUTHORS): false);
+        configurator.setIncludeUnpublished(PreferencesUtil.getPreferenceStore().contains(IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_UNPUBLISHED)? PreferencesUtil.getPreferenceStore().getBoolean(
+                IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_UNPUBLISHED): true);
+        //configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getStringValue(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
+
+        return configurator;
+    }
 
-       public static String createPreferenceString(String property){
-          return prefKey(property);
+    /**
+     * create new preferences, setting all search options to true
+     *
+     * @return a
+     *         {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
+     *         object.
+     */
+    public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
+        IFindTaxaAndNamesConfigurator configurator = FindTaxaAndNamesConfiguratorImpl.NewInstance();
+
+        configurator.setDoTaxa(true);
+        configurator.setDoSynonyms(true);
+        configurator.setDoNamesWithoutTaxa(true);
+        configurator.setDoTaxaByCommonNames(true);
+        configurator.setIncludeUnpublished(true);
+        configurator.setDoIncludeAuthors(false);
+        configurator.setTaxonPropertyPath(Arrays.asList("$", "titleCache",
+                "name", "name.$", "relationsFromThisTaxon.$"));
+
+        configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
+                "name", "name.$", "synonyms.relatedTo.*"));
+
+        // DEFAULT VALUES
+        // match mode is a simple like, actually all other match modes are kind
+        // of bogus
+        configurator
+                .setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.ANYWHERE);
+        // we set page number and size here as this should always be unlimited
+        configurator.setPageNumber(0);
+        // TODO currently limit results to 10000
+        configurator.setPageSize(10000);
+        //setSearchConfigurator(configurator) ;
+        return configurator;
+    }
 
-       }
-       public static String createOverridePreferenceString(String property){
-              return prefOverrideKey(property);
-
-           }
-
-       /**
-        * Set default values for preferences
-        */
-       public static void setDefaults() {
-               getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
-               getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
-                               true);
-               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(createPreferenceString(SHOULD_CONNECT_AT_STARTUP), false);
-               getPreferenceStore().setDefault(createPreferenceString(OPENURL_ACCESS_POINT),
-                               "http://www.biodiversitylibrary.org/openurl");
-               getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_WIDTH), "1000");
-               getPreferenceStore().setDefault(createPreferenceString(OPENURL_IMAGE_MAX_HEIGHT), "1000");
-               //Distribution Editor:
-               getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DistributionEditorActivated.getKey()), Boolean.valueOf(PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString()));
-//             getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()), PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString());
-//             getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisplayOfStatus.getKey()), PreferencePredicate.DisplayOfStatus.getDefaultValue().toString());
-
-
-               //Name Details
-               getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.NameDetailsView.getKey()), new NameDetailsConfigurator(false).toString());
-
-               //Navigator preferences
-               getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.TaxonNodeOrder.getKey()), NavigatorOrderEnum.RankAndNameOrder.getKey());
-
-               //getPreferenceStore().setDefault(createPreferenceString(Prefe), true);
-
-               getPreferenceStore().setDefault(createPreferenceString(SHOW_ADVANCED_MEDIA_SECTION), false);
+    /**
+     * Store search preferences
+     *
+     * @param configurator
+     *            a
+     *            {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
+     *            object.
+     */
+    public static void setSearchConfigurator(
+            IFindTaxaAndNamesConfigurator configurator) {
+        getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA,
+                configurator.isDoTaxa());
+        getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
+                configurator.isDoSynonyms());
+        getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES,
+                configurator.isDoNamesWithoutTaxa());
+        getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES,
+                configurator.isDoTaxaByCommonNames());
+        getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_WITH_AUTHORS,
+                configurator.isDoIncludeAuthors());
+        getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_UNPUBLISHED,
+                configurator.isIncludeUnpublished());
+    }
 
-        getPreferenceStore().setDefault(createPreferenceString(SHOW_MEDIA_PREVIEW), false);
-               //override db preferences
-               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AbcdImportConfig.getKey())), false);
-               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.ShowSpecimen.getKey())), true);
-               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.NameDetailsView.getKey())), false);
-               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey())), true);
-               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AvailableDistributionStatus.getKey())), true);
-               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaTerms.getKey())), true);
-               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey())), true);
-               getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.CommonNameAreaVocabularies.getKey())), false);
-               getPreferenceStore().setDefault(createPreferenceString(FILTER_COMMON_NAME_REFERENCES), false);
-               getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowTaxonNodeWizard.getKey()), Boolean.valueOf(PreferencePredicate.ShowTaxonNodeWizard.getDefaultValue().toString()));
-               getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowNamespaceInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowNamespaceInSource.getDefaultValue().toString()));
-               getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowIdInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowIdInSource.getDefaultValue().toString()));
-               getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisableMultiClassification.getKey()), Boolean.valueOf(PreferencePredicate.DisableMultiClassification.getDefaultValue().toString()));
-               getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowImportExportMenu.getKey()), Boolean.valueOf(PreferencePredicate.ShowImportExportMenu.getDefaultValue().toString()));
+    public static void firePreferencesChanged(Class clazz) {
+        getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE,
+                null, clazz);
+    }
 
-       }
 
-       /**
-        * <p>
-        * checkNomenclaturalCode
-        * </p>
-        */
-       public static void checkNomenclaturalCode() {
-               // First time Editor is opened, no nomenclatural code has been set
-               if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
-                       PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
-               }
+    public static String createPreferenceString(String property){
+       return prefKey(property);
+    }
+    public static String createOverridePreferenceString(String property){
+           return prefOverrideKey(property);
+    }
 
+    public static boolean getOverrideForPreference(String preferenceString){
+        return PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(preferenceString), true);
+    }
 
+    /**
+     * Set default values for preferences
+     */
+    public static void setDefaults() {
 
-       }
-       public static void setNomenclaturalCodePreferences(){
-           ICdmRepository controller;
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.EditMapServiceAccessPoint.getKey()),
+                "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(createPreferenceString(SHOULD_CONNECT_AT_STARTUP), false);
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.MobotOpenUrlServiceAccessPoint.getKey()),
+                "http://www.biodiversitylibrary.org/openurl");
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.MobotOpenUrlServiceMaxWidth.getKey()), "1000");
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.MobotOpenUrlServiceMaxHeight.getKey()), "1000");
+        getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
+        getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS, true);
+        getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_NAMES, true);
+        getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES, true);
+        getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_WITH_AUTHORS, false);
+
+        //Name Details
+       // getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.NameDetailsView.getKey()), new NameDetailsConfigurator(false).toString());
+
+        //Navigator preferences
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.TaxonNodeOrder.getKey()), NavigatorOrderEnum.RankAndNameOrder.getKey());
+
+        //getPreferenceStore().setDefault(createPreferenceString(Prefe), true);
+
+        getPreferenceStore().setDefault(createPreferenceString(SHOW_ADVANCED_MEDIA_SECTION), false);
+
+        getPreferenceStore().setDefault(createPreferenceString(SHOW_MEDIA_PREVIEW), false);
+        //override db preferences
+        getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.AbcdImportConfig.getKey())), false);
+        getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.NameDetailsView.getKey())), false);
+        getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.CommonNameAreaVocabularies.getKey())), false);
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.CommonNameReferencesWithMarker.getKey()), false);
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowTaxonNodeWizard.getKey()), Boolean.valueOf(PreferencePredicate.ShowTaxonNodeWizard.getDefaultValue().toString()));
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowNamespaceInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowNamespaceInSource.getDefaultValue().toString()));
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowIdInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowIdInSource.getDefaultValue().toString()));
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisableMultiClassification.getKey()), Boolean.valueOf(PreferencePredicate.DisableMultiClassification.getDefaultValue().toString()));
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowImportExportMenu.getKey()), Boolean.valueOf(PreferencePredicate.ShowImportExportMenu.getDefaultValue().toString()));
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowSpecimen.getKey()), Boolean.valueOf(PreferencePredicate.ShowSpecimen.getDefaultValue().toString()));
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey()), Boolean.valueOf(PreferencePredicate.SearchForIdentifierAndTitleCache.getDefaultValue().toString()));
+        getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey())), false);
+        getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.SearchForIdentifierAsDefault.getKey()), Boolean.valueOf(PreferencePredicate.SearchForIdentifierAsDefault.getDefaultValue().toString()));
+        getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.SearchForIdentifierAsDefault.getKey())), false);
+        getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.ShowModifierFreeText.getKey())), false);
+        getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.ShowModifier.getKey())), false);
+        getPreferenceStore().setDefault(createPreferenceString(prefOverrideKey(PreferencePredicate.DistributionEditorActivated.getKey())), false);
+    }
+
+    public static void checkNomenclaturalCode() {
+        // First time Editor is opened, no nomenclatural code has been set
+        if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
+            PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
+        }
+    }
+
+    public static void setNomenclaturalCodePreferences(){
+        ICdmRepository controller;
         controller = CdmStore.getCurrentApplicationConfiguration();
         PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
         CdmPreference preference = null;
@@ -975,213 +917,145 @@ public class PreferencesUtil implements IPreferenceKeys {
         UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
         NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
 
-        setStringValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
+        setStringValue(PreferencePredicate.NomenclaturalCode.getKey(),
                 getPreferenceKey(preferredCode));
+    }
 
-       }
-
-       public static void checkDefaultLanguage(){
-           if(PreferencesUtil.getPreferredDefaultLangugae() == null){
-              Shell shell = AbstractUtility.getShell();
-              int open = new DefaultLanguageDialog(shell).open();
-              if(open == Window.OK){
-                  PlatformUI.getWorkbench().restart();
-              }
-           }else{
-               //TODO:In case of a reinstall, the config.ini will be overwritten
-               //     here you create config.ini with the stored key from preferences
-           }
-       }
+    public static void checkDefaultLanguage(){
+        if(PreferencesUtil.getPreferredDefaultLangugae() == null){
+           Shell shell = AbstractUtility.getShell();
+           int open = new DefaultLanguageDialog(shell).open();
+           if(open == Window.OK){
+               PlatformUI.getWorkbench().restart();
+           }
+        }else{
+            //TODO:In case of a reinstall, the config.ini will be overwritten
+            //     here you create config.ini with the stored key from preferences
+        }
+    }
 
-       /**
-        * <p>
-        * getMapServiceAccessPoint
-        * </p>
-        *
-        * @return a {@link java.lang.String} object.
-        */
-       public static String getMapServiceAccessPoint() {
-               return getStringValue(EDIT_MAP_SERVICE_ACCES_POINT);
-       }
+    public static String getMapServiceAccessPoint() {
+        return getStringValue(PreferencePredicate.EditMapServiceAccessPoint.getKey());
+    }
 
-       /**
-        * <p>
-        * shouldConnectAtStartUp
-        * </p>
-        *
-        * @return a boolean.
-        */
-       public static boolean shouldConnectAtStartUp() {
-               //FIXME :  force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
-               //return getBooleanValue(SHOULD_CONNECT_AT_STARTUP);
-               return false;
-       }
+    public static boolean shouldConnectAtStartUp() {
+        //FIXME :  force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
+        //return getBooleanValue(SHOULD_CONNECT_AT_STARTUP);
+        return false;
+    }
 
-       /**
-        * <p>
-        * getDefaultFeatureTreeForTextualDescription
-        * </p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.model.term.FeatureTree} object.
-        */
-       public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
-               String uuidString = getStringValue(
-                               FEATURE_TREE_DEFAULT_TEXT);
-               if (StringUtils.isBlank(uuidString)) {
+    public static TermTree<?> getDefaultFeatureTreeForTextualDescription() {
+        String uuidString = getStringValue(
+                FEATURE_TREE_DEFAULT_TEXT, true);
+        if (StringUtils.isBlank(uuidString)) {
             return null;
         }
-               FeatureTree tree = CdmStore.getService(
-                       IFeatureTreeService.class).load(UUID.fromString(uuidString));
-               if (tree.getId() == 0) {
+        TermTree<?> tree = CdmStore.getService(
+                ITermTreeService.class).load(UUID.fromString(uuidString));
+
+        if (tree == null || tree.getId() == 0) {
             return null;
         }
-               return tree;
-       }
-
-       /**
-        * <p>
-        * getDefaultFeatureTreeForStructuredDescription
-        * </p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.model.term.FeatureTree} object.
-        */
-       public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
-               String uuidString = getStringValue(
-                               FEATURE_TREE_DEFAULT_STRUCTURE);
-               return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
-                               IFeatureTreeService.class).load(UUID.fromString(uuidString));
-       }
+        return tree;
+    }
 
-       /**
-        * <p>
-        * setSortRanksHierarchichally
-        * </p>
-        *
-        * @param selection
-        *            a boolean.
-        */
-       public static void setSortRanksHierarchichally(boolean selection) {
-               setBooleanValue(SORT_RANKS_HIERARCHICHALLY, selection);
-       }
+    public static TermTree<?> getDefaultFeatureTreeForStructuredDescription() {
+        String uuidString = getStringValue(
+                FEATURE_TREE_DEFAULT_STRUCTURE, true);
+        return StringUtils.isBlank(uuidString) ? null : CdmStore.getService(
+                ITermTreeService.class).load(UUID.fromString(uuidString));
+    }
 
-       /**
-        * <p>
-        * getSortRanksHierarchichally
-        * </p>
-        *
-        * @return a boolean.
-        */
-       public static boolean getSortRanksHierarchichally() {
-               return getBooleanValue(SORT_RANKS_HIERARCHICHALLY);
-       }
+    public static void setSortRanksHierarchichally(boolean selection) {
+        setBooleanValue(PreferencePredicate.SortRanksHierarchichally.getKey(), selection);
+    }
 
-       public static boolean isMultilanguageTextEditingCapability() {
-               return getBooleanValue(
-                               MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
-       }
+    public static boolean getSortRanksHierarchichally() {
+        return getBooleanValue(PreferencePredicate.SortRanksHierarchichally.getKey());
+    }
 
-       public static Language getGlobalLanguage() {
+    public static boolean isMultilanguageTextEditingCapability() {
+        return getBooleanValue(
+                PreferencePredicate.MultiLanguageTextEditing.getKey());
+    }
 
+    public static Language getGlobalLanguage() {
 
-               String languageUuidString = getStringValue(
-                               GLOBAL_LANGUAGE_UUID);
+        String languageUuidString = getStringValue(
+                GLOBAL_LANGUAGE_UUID, true);
 
-               if(!CdmStore.isActive()) {
+        if(!CdmStore.isActive()) {
             MessagingUtils.noDataSourceWarningDialog(languageUuidString);
             return null;
         }
 
-               if (CdmUtils.isBlank(languageUuidString)) {
-                       return Language.getDefaultLanguage();
-               }
-
-               UUID languageUuid = UUID.fromString(languageUuidString);
-               return (Language) CdmStore.getService(ITermService.class).load(
-                               languageUuid);
-       }
-
-       public static void setGlobalLanguage(Language language) {
-           if(language != null) {
-               setStringValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
-               CdmStore.setDefaultLanguage(language);
-           }
-
-       }
+        if (CdmUtils.isBlank(languageUuidString)) {
+            return Language.getDefaultLanguage();
+        }
 
-       /**
-        * @return
-        */
-       public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
-               List<MarkerType> markerTypes = CdmStore.getTermManager()
-                               .getPreferredTerms(MarkerType.class);
+        UUID languageUuid = UUID.fromString(languageUuidString);
+        return (Language) CdmStore.getService(ITermService.class).load(
+                languageUuid);
+    }
 
-               Map<MarkerType, Boolean> result = new HashMap<MarkerType, Boolean>();
+    public static void setGlobalLanguage(Language language) {
+        if(language != null) {
+            setStringValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
+            CdmStore.setDefaultLanguage(language);
+        }
+    }
 
-               for (MarkerType markerType : markerTypes) {
-                       String name = getMarkerTypeEditingPreferenceKey(markerType);
-                       Boolean value = getBooleanValue(name);
+    public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
+        List<MarkerType> markerTypes = CdmStore.getTermManager()
+                .getPreferredTerms(MarkerType.class);
 
-                       result.put(markerType, value);
-               }
+        Map<MarkerType, Boolean> result = new HashMap<>();
 
-               return result;
-       }
+        for (MarkerType markerType : markerTypes) {
+            String name = getMarkerTypeEditingPreferenceKey(markerType);
+            Boolean value = getBooleanValue(name);
+            result.put(markerType, value);
+        }
 
-       /**
-        * @param markerTypeEditingMap
-        */
-       public static void setEditMarkerTypePreferences(
-                       Map<MarkerType, Boolean> markerTypeEditingMap) {
-               for (MarkerType markerType : markerTypeEditingMap.keySet()) {
-                       String name = getMarkerTypeEditingPreferenceKey(markerType);
-                       setBooleanValue(name,
-                                       markerTypeEditingMap.get(markerType));
-               }
+        return result;
+    }
 
-       }
+    public static void setEditMarkerTypePreferences(
+            Map<MarkerType, Boolean> markerTypeEditingMap) {
+        for (MarkerType markerType : markerTypeEditingMap.keySet()) {
+            String name = getMarkerTypeEditingPreferenceKey(markerType);
+            setBooleanValue(name,
+                    markerTypeEditingMap.get(markerType));
+        }
+    }
 
-       private static String getMarkerTypeEditingPreferenceKey(
-                       MarkerType markerType) {
-               markerType = HibernateProxyHelper.deproxy(markerType);
-               return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
-       }
+    private static String getMarkerTypeEditingPreferenceKey(
+            MarkerType markerType) {
+        markerType = HibernateProxyHelper.deproxy(markerType);
+        return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
+    }
 
-       /**
-        * <p>
-        * setEditMarkerTypePreference
-        * </p>
-        *
-        * @param input
-        *            a {@link org.eclipse.ui.IEditorInput} object.
-        * @param markerType
-        *            a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
-        * @param edit
-        *            a boolean.
-        */
-       public static void setEditMarkerTypePreference(MarkerType markerType,
-                       boolean edit) {
-               setBooleanValue(
-                               getMarkerTypeEditingPreferenceKey(markerType), edit);
-       }
+    public static void setEditMarkerTypePreference(MarkerType markerType,
+            boolean edit) {
+        setBooleanValue(
+                getMarkerTypeEditingPreferenceKey(markerType), edit);
+    }
 
-       /**
-        * @return
-        */
-       public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
-               DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator
-                               .NewInstance();
-               configurator.setMoveDerivedUnitMediaToGallery(true);
-               configurator.setMoveFieldObjectMediaToGallery(true);
-               return configurator;
-       }
+    public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
+        DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator
+                .NewInstance();
+        configurator.setMoveDerivedUnitMediaToGallery(true);
+        configurator.setMoveFieldObjectMediaToGallery(true);
+        return configurator;
+    }
 
-       /**
-        * This method will write language properties to the config.ini located in the configuration folder
-        * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
-        *
-        * @param setLanguage 0 is for german and 1 for english.
-        * @throws IOException
-        */
+    /**
+     * This method will write language properties to the config.ini located in the configuration folder
+     * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
+     *
+     * @param setLanguage 0 is for german and 1 for english.
+     * @throws IOException
+     */
     public void writePropertyToConfigFile(int setLanguage) throws IOException {
         File file = org.eclipse.core.runtime.preferences.ConfigurationScope.INSTANCE.getLocation().toFile();
         //give warning to user if the directory has no write access
@@ -1257,12 +1131,10 @@ public class PreferencesUtil implements IPreferenceKeys {
 
     /**
      * Retrieves a list of previously saved P2 repositories
-     *
-     * @return
      */
     public static List<MetadataRepositoryElement> getP2Repositories() {
         List<MetadataRepositoryElement> p2Repos = new ArrayList<MetadataRepositoryElement>();
-        String p2ReposPref =  getStringValue(P2_REPOSITORY_LIST);
+        String p2ReposPref =  getStringValue(P2_REPOSITORY_LIST, true);
         if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
             StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
 
@@ -1278,7 +1150,7 @@ public class PreferencesUtil implements IPreferenceKeys {
                         continue;
                     }
                     boolean enabled = Boolean.parseBoolean(p2ReposStrST.nextToken());
-                    MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri, true);
+                    MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri.getJavaUri(), true);
                     mre.setNickname(nickname);
                     mre.setEnabled(enabled);
                     p2Repos.add(mre);
@@ -1306,90 +1178,68 @@ public class PreferencesUtil implements IPreferenceKeys {
         }
     }
 
-
-
-
-    /**
-     * @param orderActivated
-     */
     public static void setSortNodes(NavigatorOrderEnum nodesOrder) {
-        setStringValue(PreferencePredicate.TaxonNodeOrder.getKey(), nodesOrder.key);
-
+        if (nodesOrder == null){
+            setStringValue(PreferencePredicate.TaxonNodeOrder.getKey(), null);
+        }else{
+            setStringValue(PreferencePredicate.TaxonNodeOrder.getKey(), nodesOrder.key);
+        }
     }
 
-    /**
-     * @param orderActivated
-     */
     public static NavigatorOrderEnum getSortNodes() {
         return NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
-
     }
-
-    /**
-     * @param orderActivated
-     */
+    
     public static boolean isNodesSortedNaturally() {
         NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
         return value.equals(NavigatorOrderEnum.NaturalOrder);
-
     }
 
-    /**
-     * @param orderActivated
-     */
     public static boolean isNodesSortedByName() {
         NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
         return value.equals(NavigatorOrderEnum.AlphabeticalOrder);
-
     }
 
-    /**
-     * @param orderActivated
-     */
     public static boolean isNodesSortedByNameAndRank() {
         NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
         return value.equals(NavigatorOrderEnum.RankAndNameOrder);
-
     }
-       /**
-        * <p>
-        * setStoreNavigatorState
-        * </p>
-        *
-        * @param selection
-        *            a boolean.
-        */
-       public static boolean isStoreNavigatorState() {
-               return getBooleanValue(RESTORE_NAVIGATOR_STATE);
+    
+    public static Comparator<TaxonNodeDto> getNodeComparator() {
+               Comparator<TaxonNodeDto> comparator;
+        NavigatorOrderEnum orderValue = NavigatorOrderEnum.RankAndNameOrder;
+               try{
+                   orderValue = PreferencesUtil.getSortNodes();
+               }catch(IllegalArgumentException e){
+
+               }
 
+               if (orderValue.equals(NavigatorOrderEnum.NaturalOrder)){
+                       comparator = new TaxonNodeDtoNaturalComparator();
+               } else if (orderValue.equals(NavigatorOrderEnum.AlphabeticalOrder)){
+                       comparator = new TaxonNodeDtoByNameComparator();
+               }else {
+                       comparator = new TaxonNodeDtoByRankAndNameComparator();
+               }
+               return comparator;
        }
 
-       /**
-        * <p>
-        * setStoreNavigatorState
-        * </p>
-        *
-        * @param selection
-        *            a boolean.
-        */
-       public static void setStoreNavigatorState(boolean selection) {
-               setBooleanValue(RESTORE_NAVIGATOR_STATE, selection);
+    public static boolean isStoreNavigatorState() {
+        return getBooleanValue(RESTORE_NAVIGATOR_STATE);
+    }
 
-       }
+    public static void setStoreNavigatorState(boolean selection) {
+        setBooleanValue(RESTORE_NAVIGATOR_STATE, selection);
+    }
 
-    /**
-     * @return
-     */
     public static boolean isShowUpWidgetIsDisposedMessages() {
        return getBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED);
     }
+
     public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
         setBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
     }
 
-    /**
-     * @return
-     */
     public static boolean isShowIdInVocabularyInChecklistEditor() {
         String area_display = getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
         if (area_display.equals(TermDisplayEnum.IdInVocabulary.getKey())) {
@@ -1405,7 +1255,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         }else{
             return false;
         }
-     }
+    }
     public static boolean isShowSymbol2InChecklistEditor() {
         String area_display = getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
         if (area_display.equals(TermDisplayEnum.Symbol2.getKey())) {
@@ -1413,7 +1263,8 @@ public class PreferencesUtil implements IPreferenceKeys {
         }else{
             return false;
         }
-     }
+    }
+
     public static void setAreaDisplayInChecklistEditor(String selection) {
         setStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey(), selection);
     }
@@ -1426,55 +1277,46 @@ public class PreferencesUtil implements IPreferenceKeys {
         return getBooleanValue(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey());
     }
 
-    /**
-     * @return
-     */
-    public static String displayAreaInChecklistEditor() {
-        String result = getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
-        if (StringUtils.isBlank(result)){
-            return ((TermDisplayEnum) PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue()).getKey();
+    public static TermDisplayEnum displayAreaInChecklistEditor() {
+        TermDisplayEnum result;
+        try{
+            result = TermDisplayEnum.byKey(getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey()));
+        }catch (IllegalArgumentException e){
+           result = ((TermDisplayEnum) PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue());
         }
        return result;
     }
 
-    /**
-     * @return
-     */
-    public static String displayStatusInChecklistEditor() {
-        String result = getStringValue(PreferencePredicate.DisplayOfStatus.getKey());
-        if (StringUtils.isBlank(result)){
-            return((TermDisplayEnum) PreferencePredicate.DisplayOfStatus.getDefaultValue()).getKey();
+    public static TermDisplayEnum displayStatusInChecklistEditor() {
+        TermDisplayEnum result;
+        try{
+            result = TermDisplayEnum.byKey(getStringValue(PreferencePredicate.DisplayOfStatus.getKey()));
+        }catch (IllegalArgumentException e){
+           result = ((TermDisplayEnum) PreferencePredicate.DisplayOfStatus.getDefaultValue());
         }
        return result;
     }
+
     public static void setDisplayStatusInChecklistEditor(String selection) {
         setStringValue(PreferencePredicate.DisplayOfStatus.getKey(), selection);
-
     }
 
-    /**
-     * @return
-     */
     public static boolean isShowRankInChecklistEditor() {
         return getBooleanValue(PreferencePredicate.ShowRankInDistributionEditor.getKey());
     }
+
     public static void setShowRankInChecklistEditor(boolean selection) {
        setBooleanValue(PreferencePredicate.ShowRankInDistributionEditor.getKey(), selection);
     }
 
-    /**
-     * @param object
-     * @param b
-     * @return
-     */
     public static NameDetailsConfigurator getPreferredNameDetailsConfiguration( boolean local) {
-        NameDetailsConfigurator config = new NameDetailsConfigurator(true);
+        NameDetailsConfigurator config = new NameDetailsConfigurator();
         CdmPreferenceCache cache = CdmPreferenceCache.instance();
         CdmPreference preference = null;
         String value;
         if (!local) {
             PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.NameDetailsView);
-            preference = cache.findBestMatching(key);
+            preference =  getPreferenceFromDB(PreferencePredicate.NameDetailsView);
             if (preference == null){
                 return null;
             }
@@ -1487,103 +1329,50 @@ public class PreferencesUtil implements IPreferenceKeys {
         }else{
             value = getStringValue(PreferencePredicate.NameDetailsView.getKey(), local);
         }
+        if (value!= null){
+            fillNameDetailsConfigurator(config, value);
+
+
+        }else {
+            return null;
+        }
+        return config;
+    }
+
+    public static void fillNameDetailsConfigurator(NameDetailsConfigurator config, String value) {
         String [] sections = value.split(";");
-        Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
+        Map<String, Boolean> sectionMap = new HashMap<>();
         String[] sectionValues;
         for (String sectionValue: sections){
-            sectionValues = sectionValue.split(":");
-            sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
+            if (sectionValue.contains(":")){
+                sectionValues = sectionValue.split(":");
+                sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
+            }
+        }
+        for (Field field: config.getClass().getDeclaredFields()){
+            try {
+                config.getClass().getDeclaredField(field.getName()).set(config, getValue(sectionMap, field.getName()));
+            } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
+                    | SecurityException e) {
+               logger.debug(e.getMessage());
+            }
         }
-
-        config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
-
-        config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
-
-        config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
-        config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
-
-        config.setLSIDActivated(getValue(sectionMap, "lsid"));
-
-        config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
-
-        config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
-
-        config.setRankActivated(getValue(sectionMap, "rank"));
-
-        config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
-
-        config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
-
-        config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
-
-        config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
-
-        config.setProtologueActivated(getValue(sectionMap,"protologue"));
-
-        config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
-
-        config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
-
-            config.setHybridActivated(getValue(sectionMap,"hybrid"));
-
-        return config;
     }
 
     public static NameDetailsConfigurator getPreferredNameDetailsConfiguration() {
-        NameDetailsConfigurator config = new NameDetailsConfigurator(true);
+        NameDetailsConfigurator config = new NameDetailsConfigurator();
 
         String value;
 
         value = getStringValue(PreferencePredicate.NameDetailsView.getKey(), false);
         if (value != null){
-            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.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
-
-            config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
-
-            config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
-            config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
-
-            config.setLSIDActivated(getValue(sectionMap, "lsid"));
-
-            config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
-
-            config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
-
-            config.setRankActivated(getValue(sectionMap, "rank"));
-
-            config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
-
-            config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
-
-            config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
-
-            config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
-
-            config.setProtologueActivated(getValue(sectionMap,"protologue"));
-
-            config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
-
-            config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
-
-                config.setHybridActivated(getValue(sectionMap,"hybrid"));
+            fillNameDetailsConfigurator(config, value);
+        }else {
+            return null;
         }
         return config;
     }
 
-
-    /**
-     * @param object
-     * @param b
-     * @return
-     */
     public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config, boolean local) {
         CdmPreference preference = null;
 
@@ -1595,30 +1384,55 @@ public class PreferencesUtil implements IPreferenceKeys {
         else{
             setStringValue(PreferencePredicate.NameDetailsView.getKey(), config.toString());
         }
-
-
     }
 
     private static Boolean getValue(Map<String, Boolean> sectionMap, String string) {
-               if (sectionMap.containsKey(string)){
-                       return sectionMap.get(string);
-               }else{
-                       return true;
-               }
+        if (sectionMap.containsKey(string)){
+            return sectionMap.get(string);
+        }else{
+            return true;
+        }
+    }
 
-       }
+    public static void extractSecundumForSubtreeConfiguratorFromPreferenceString(SecundumForSubtreeConfigurator config,
+            String configString) {
+        if(configString != null){
+             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 (keyValue.length>2){
 
+                         for (int index = 2; index< keyValue.length; index++){
+                             valueString += ":"+ keyValue[index];
+                         }
+                     }
+                 }
+                 if (keyString.equals("includeAcceptedTaxa")){
+                     config.setIncludeAcceptedTaxa(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("includeSynonyms")){
+                     config.setIncludeSynonyms(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("includeSharedTaxa")){
+                     config.setIncludeSharedTaxa(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("includeProParteSynonyms")){
+                     config.setIncludeProParteSynonyms(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("includeMisapplications")){
+                     config.setIncludeMisapplications(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("overwriteExisting")){
+                     config.setOverwriteExisting(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("emptySecundumDetail")){
+                     config.setEmptySecundumDetail(Boolean.valueOf(valueString));
+                 }else{
+                     logger.debug("This key of the set secundum configurator needs to be added to the transformer: " + keyString);
+                 }
+             }
+         }
+    }
 
-    /**
-     * <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);
@@ -1634,6 +1448,14 @@ public class PreferencesUtil implements IPreferenceKeys {
             return config;
          } else{
              String configString = preference.getValue();
+             extractAbcdConfiguratorFromPreferenceString(config, configString);
+         }
+        return config;
+    }
+
+    public static void extractAbcdConfiguratorFromPreferenceString(Abcd206ImportConfigurator config,
+            String configString) {
+        if(configString != null){
              String[] configArray = configString.split(";");
 
              for (String configItem: configArray){
@@ -1641,7 +1463,13 @@ public class PreferencesUtil implements IPreferenceKeys {
                  String keyString = keyValue[0];
                  String valueString = null;
                  if (keyValue.length>1){
-                      valueString = keyValue[1];
+                     valueString = keyValue[1];
+                     if (keyValue.length>2){
+
+                         for (int index = 2; index< keyValue.length; index++){
+                             valueString += ":"+ keyValue[index];
+                         }
+                     }
                  }
                  if (keyString.equals("ignoreImportOfExistingSpecimen")){
                      config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
@@ -1674,45 +1502,78 @@ public class PreferencesUtil implements IPreferenceKeys {
                  }else if (keyString.equals("overwriteExistingSpecimens")){
                      config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
                  }else if (keyString.equals("nomenclaturalCode")){
-                         config.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
+                     config.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
+                 }else if (keyString.equals("removeCountryFromLocalityText")){
+                     config.setRemoveCountryFromLocalityText(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("getSiblings")){
+                     config.setGetSiblings(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("classificationUUID")){
+                     if (valueString != null){
+                         config.setClassificationUuid(UUID.fromString(valueString));
+                     }
+                 }else if (keyString.equals("classificationName")){
+                     config.setClassificationName(valueString);
+                 }else if (keyString.equals("dnaSource")){
+                     try{
+                         if (StringUtils.isNotBlank(valueString)){
+                             config.setDnaSoure(URI.create(valueString));
+                         }
+                     }catch(Exception e){
+                         config.setDnaSoure(null);
+                     }
                  }else{
                      logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
                  }
-
              }
-        }
-        return config;
+         }
     }
 
     public static Abcd206ImportConfigurator getLocalAbcdImportConfigurator(){
+        return getLocalAbcdImportConfigurator(true);
+    }
+
+    public static Abcd206ImportConfigurator getLocalAbcdImportConfigurator(boolean skipCheckOverride){
        Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+       CdmPreference pref = CdmPreferenceCache.instance().get(PreferencePredicate.AbcdImportConfig.getKey());
+       if (pref  == null || pref.isAllowOverride()){
+       String configString = PreferencesUtil.getStringValue(PreferencePredicate.AbcdImportConfig.getKey());
+           if (StringUtils.isBlank(configString)){
+               configString = getStringValue(PreferencePredicate.AbcdImportConfig.getKey(), skipCheckOverride);
+               extractAbcdConfiguratorFromPreferenceString(config, configString);
+               if (config.getNomenclaturalCode() == null){
+                   config.setNomenclaturalCode(getPreferredNomenclaturalCode());
+               }
+           }else{
+               config = Abcd206ImportConfigurator.NewInstance(null, null);
+               PreferencesUtil.extractAbcdConfiguratorFromPreferenceString(config, configString);
+           }
+       }else{
+           extractAbcdConfiguratorFromPreferenceString(config, pref.getValue());
+       }
+
+       return config;
 
-        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)));
+    }
+
+    public static Abcd206ImportConfigurator getLastUsedAbcdImportConfigurator(){
+        Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
+
+       String configString = PreferencesUtil.getStringValue(IPreferenceKeys.LAST_USED_ABCD_CONFIG, true);
+       if (configString != null){
+           extractAbcdConfiguratorFromPreferenceString(config, configString);
+           if (config != null){
+               if (config.getNomenclaturalCode() == null){
+                   config.setNomenclaturalCode(getPreferredNomenclaturalCode());
+               }
+           }
+       }else{
+           config = PreferencesUtil.getLocalAbcdImportConfigurator(false);
+       }
 
         return config;
 
     }
 
-
     public static void updateAbcdImportConfigurationPreference() {
         CdmPreferenceCache cache = CdmPreferenceCache.instance();
 
@@ -1726,82 +1587,37 @@ public class PreferencesUtil implements IPreferenceKeys {
 
     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());
+        setStringValue(PreferencePredicate.AbcdImportConfig.getKey(), config.toString());
+    }
 
-        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());
+    public static boolean isSortTaxaByRankAndName() {
+        return getBooleanValue(PreferencePredicate.SortTaxaByRankAndName.getKey());
+    }
 
-        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 static TermOrder getSortNamedAreasInDistributionEditor() {
+        TermOrder result;
+        try{
+            result = TermOrder.valueOf(getStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey()));
+        }catch (IllegalArgumentException e){
+            result = (TermOrder)PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue();
         }
+        return result;
     }
 
+    public static void setSortNamedAreasInDistributionEditor(String isSortByVocabularyOrder) {
+        setStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey(), isSortByVocabularyOrder);
+    }
 
+    public static void setLastSelectedReference(
+            List<String> lastSelectedReferences) {
 
-
-
-
-
-/**
- * @return
- */
-public static boolean isSortTaxaByRankAndName() {
-
-    return getBooleanValue(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
-}
-
-/**
- * @return
- */
-public static String getSortNamedAreasInDistributionEditor() {
-
-    return getStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey());
-}
-
-public static void setSortNamedAreasInDistributionEditor(String isSortByVocabularyOrder) {
-    setStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey(), isSortByVocabularyOrder);
-
-}
-
-/**
- * <p>
- * setPreferredNamedAreasForDistributionEditor
- * </p>
- *
- * @param saveCheckedElements
- * @param saveGrayedElements
- */
-public static void setLastSelectedReference(
-        List<String> lastSelectedReferences) {
-
-        setStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
+        setStringValue(IPreferenceKeys.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
     }
 
-/**
- * <p>
- * setPreferredNamedAreasForDistributionEditor
- * </p>
- *
- * @param saveCheckedElements
- * @param saveGrayedElements
- */
-public static List<String> getLastSelectedReferences() {
+    public static List<String> getLastSelectedReferences() {
 
         //IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
-        String lastSelected = getStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES);
+        String lastSelected = getStringValue(IPreferenceKeys.LAST_SELECTED_REFERENCES, true);
         List<String> result = new ArrayList<>();
         if (!StringUtils.isBlank(lastSelected)){
             Collections.addAll(result, lastSelected.substring(1,lastSelected.length()-1).split(", "));
@@ -1809,190 +1625,308 @@ public static List<String> getLastSelectedReferences() {
         return result;
     }
 
+    public static void setPreferredNamedAreasForDistributionEditor(
+            String saveCheckedElements, String saveGrayedElements, boolean local) {
+        if (local){
+            setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(), saveCheckedElements);
+        }
+        else{
+            CdmPreference preference = null;
 
-/**
- * <p>
- * setPreferredNamedAreasForDistributionEditor
- * </p>
- *
- * @param saveCheckedElements
- * @param saveGrayedElements
- */
-public static void setPreferredNamedAreasForDistributionEditor(
-        String saveCheckedElements, String saveGrayedElements, boolean local) {
-    if (local){
-        setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(), saveCheckedElements);
-
-    }
-    else{
-        CdmPreference preference = null;
+            if (saveCheckedElements == null){
+                preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
 
-        if (saveCheckedElements == null){
-            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
+                if (preference == null){
+                    return ;
+                } else{
+                    setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
+                            saveCheckedElements);
+                    preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
+                    setPreferenceToDB(preference);
 
-            if (preference == null){
-                return ;
+                }
             } else{
-                setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
-                        saveCheckedElements);
                 preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
                 setPreferenceToDB(preference);
+                setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
+                        saveCheckedElements);
 
             }
-        } else{
-           preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
-           setPreferenceToDB(preference);
-           setStringValue(PreferencePredicate.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 ;
+    public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
+            boolean local, boolean isOverride) {
+        if (local){
+            setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), saveCheckedElements);
+            setBooleanValue(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()), isOverride);
+        }
+        else{
+            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{
-                setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
-                        saveCheckedElements);
                 preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
                 preference.setAllowOverride(isOverride);
                 setPreferenceToDB(preference);
+                setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
+                        saveCheckedElements);
             }
-        } else{
-            preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
-            preference.setAllowOverride(isOverride);
-            setPreferenceToDB(preference);
-            setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
-                    saveCheckedElements);
-
         }
     }
-}
 
+    public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
+        if (local){
 
-/**
- * @param saveCheckedElements
- * @param saveCheckedElements2
- * @param b
- */
-public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
-    if (local){
-
-        String pref = getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), local);
-        return pref;
+            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();
+            }
+        }
     }
-    else{
-        CdmPreference preference = null;
-        preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
-        if (preference == null){
+
+    public static List<UUID> createUUIDListFromStringPref(String prefKey, boolean local) {
+        if (prefKey == null){
             return null;
-        } else{
-            return preference.getValue();
         }
-
+        String prefValue = PreferencesUtil.getStringValue(prefKey, local);
+        if (prefValue == null){
+            return null;
+        }
+        List<UUID> uuidList = createUuidList(prefValue);
+        return uuidList;
     }
-}
 
-public static List<UUID> createUUIDListFromStringPref(String prefKey) {
-    String prefValue = PreferencesUtil.getStringValue(prefKey);
-    String[] stringArray = prefValue.split(";");
-    List<UUID> uuidList = new ArrayList();
-    for (String uuid: stringArray){
-        if (!StringUtils.isBlank(uuid)){
-            uuidList.add(UUID.fromString(uuid));
+    public static List<UUID> createUuidList(String prefValue) {
+        String[] stringArray = prefValue.split(";");
+        List<UUID> uuidList = new ArrayList<>();
+        for (String uuid: stringArray){
+            if (!StringUtils.isBlank(uuid)){
+                uuidList.add(UUID.fromString(uuid));
+            }
         }
+        return uuidList;
     }
-    return uuidList;
-}
 
-public static boolean getFilterCommonNameReferences(){
-    return getBooleanValue(PreferencesUtil.FILTER_COMMON_NAME_REFERENCES);
-}
+    public static boolean getFilterCommonNameReferences(){
+        return getBooleanValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey());
+    }
 
-/**
- *
- */
-public static void updateDBPreferences() {
-    CdmPreference preference = null;
-    CdmPreferenceCache cache = CdmPreferenceCache.instance();
-    cache.getAllTaxEditorDBPreferences();
+    public static void updateDBPreferences() {
 
-    //ABCD Configurator
+        CdmPreferenceCache cache = CdmPreferenceCache.instance();
+        cache.getAllTaxEditorDBPreferences();
 
-    updateAbcdImportConfigurationPreference();
+        //Name Details
+        NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
 
-    //Name Details
-    NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
-//    if (config != null ){
-//        if (!getBooleanValue(OVERRIDE_NAME_DETAILS) ||  !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS)){
-//            setPreferredNameDetailsConfiguration(config, false);
-//        }
-//    }
+    }
 
+    public static void setPreferencesToDB(List<CdmPreference> preferences) {
 
+        ICdmRepository controller;
+        if(CdmStore.isActive()){
+            controller = CdmStore.getCurrentApplicationConfiguration();
+            for (CdmPreference preference: preferences){
+                if (preference.getValue() == null && preference.isAllowOverride()){
+                    controller.getPreferenceService().remove(preference.getKey());
 
+                }else{
+                    controller.getPreferenceService().set(preference);
 
+                }
 
+            }
+            CdmPreferenceCache.instance().getAllTaxEditorDBPreferences();
+        }
+    }
 
+    /**
+     * Returns whether the named preference is known.
+     * @param prefKey the key of the preference
+     * @return <code>true</code> if the preference is known, <code>false</code> otherwise
+     */
+    public static boolean contains(String prefKey){
+        return getPreferenceStore().contains(prefKey(prefKey));
+    }
 
+    /**
+     *
+     */
+    public static TermTree<?> getPreferredFeatureTreeForNameDescription(boolean createNew) {
+        if(preferredNameFeatureTree != null && !createNew){
+            return preferredNameFeatureTree;
+        }
+        createPreferredFeatureTreeForNameDescription();
+        return preferredNameFeatureTree;
+    }
 
-}
+    public static void createPreferredFeatureTreeForNameDescription() {
 
-/**
- * @param string
- * @param saveCheckedElements
- */
-public static void setPreferencesToDB(List<CdmPreference> preferences) {
+        CdmPreferenceCache cache = CdmPreferenceCache.instance();
+        CdmPreference pref = cache.get(PreferencePredicate.NameFeatures.getKey());
+        List<Feature> terms = new ArrayList<>();
+        boolean override = PreferencesUtil.getOverrideForPreference(PreferencePredicate.NameFeatures.getKey());
 
-    ICdmRepository controller;
-    try{
-        if(CdmStore.isActive()){
-            controller = CdmStore.getCurrentApplicationConfiguration();
-            for (CdmPreference preference: preferences){
+        List<UUID> uuids = PreferencesUtil.createUUIDListFromStringPref(PreferencePredicate.NameFeatures.getKey(), false);
+        if (uuids != null && !uuids.isEmpty()){
+            terms = CdmStore.getTermManager().getTerms(uuids, Feature.class);
+        }
 
-                controller.getPreferenceService().set(preference);
+       if (terms.isEmpty()){
+           terms.addAll(TermStore.getTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid()), null));
+        }
+        terms.remove(Feature.PROTOLOGUE());
+        if (terms.isEmpty()){
+            preferredNameFeatureTree = TermEditorInput.getDefaultNameFeatureTree();
+        }else{
+            preferredNameFeatureTree = TermTree.NewInstance(terms);
+        }
+    }
 
-                CdmPreferenceCache.instance().put(preference);
+    public static void removeFromDB(List<CdmPreference> prefsToDelete) {
+        ICdmRepository controller;
+        //try{
+            if(CdmStore.isActive()){
+                controller = CdmStore.getCurrentApplicationConfiguration();
+                for (CdmPreference preference: prefsToDelete){
+                    controller.getPreferenceService().remove(preference.getKey());
+                }
+                CdmPreferenceCache.instance().getAllTaxEditorDBPreferences();
             }
+    }
+
+    public static void removeFromDB(CdmPreference prefToDelete) {
+        ICdmRepository controller;
+
+        if(CdmStore.isActive()){
+            controller = CdmStore.getCurrentApplicationConfiguration();
+            controller.getPreferenceService().remove(prefToDelete.getKey());
+
+            CdmPreferenceCache.instance().getAllTaxEditorDBPreferences();
         }
-    }catch(Exception e){
-        e.printStackTrace();
     }
-}
 
+    public static TermTree<?> getPreferredFeatureTreeForTaxonDescription(boolean createNew) {
+        if(preferredTaxonFeatureTree != null && !createNew){
+            return preferredTaxonFeatureTree;
+        }
+        createPreferredFeatureTreeForTaxonDescription();
+        return preferredTaxonFeatureTree;
+    }
 
+    public static void createPreferredFeatureTreeForTaxonDescription() {
 
+        CdmPreferenceCache cache = CdmPreferenceCache.instance();
+        CdmPreference pref = cache.get(PreferencePredicate.TaxonFeatures.getKey());
+        List<Feature> terms = null;
+        boolean override = PreferencesUtil.getOverrideForPreference(PreferencePredicate.TaxonFeatures.getKey());
+        List<UUID> uuids = PreferencesUtil.createUUIDListFromStringPref(PreferencePredicate.TaxonFeatures.getKey(), false);
+        if (uuids != null && !uuids.isEmpty()){
+            terms = CdmStore.getTermManager().getTerms(uuids, Feature.class);
+        }
+        if (terms == null || terms.isEmpty()){
+            terms= CdmStore.getTermManager().getPreferredTerms(TermType.Feature);
+            TermVocabulary nameVocabulary = CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid());
+            Set<Feature> nameFeature = nameVocabulary.getTerms();
+            terms.removeAll(nameFeature);
 
+        }
 
+        if (terms.isEmpty()){
+            preferredTaxonFeatureTree = TermEditorInput.getDefaultFeatureTree();
+        }else{
+            preferredTaxonFeatureTree = TermTree.NewInstance(terms);
+        }
+    }
 
+    public static void setLastSelectedBiocaseProvider(String lastAccessPoint) {
+        setStringValue(LAST_USED_BIOCASE_PROVIDER, lastAccessPoint);
+    }
 
+    /**
+     * @return
+     */
+    public static boolean getLocalActive() {
+        // TODO: this needs to be adapted!!!
+        return true;
+    }
 
     /**
-     * Returns whether the named preference is known.
-     * @param prefKey the key of the preference
-     * @return <code>true</code> if the preference is known, <code>false</code> otherwise
+     * @return
      */
-    public static boolean contains(String prefKey){
-        return getPreferenceStore().contains(prefKey(prefKey));
+    public static boolean showGfbioMetaData() {
+        //TODO: needs to be adapted!!!
+        return false;
+    }
+
+    public static SecReferenceHandlingEnum getSecReferenceHandlingPreference(){
+
+        String defaultBehaviour = getStringValue(PreferencePredicate.DefaultBehaviourForSecundum.getKey());
+        SecReferenceHandlingEnum handling = null;
+        try{
+            handling = SecReferenceHandlingEnum.valueOf(defaultBehaviour);
+        }catch(IllegalArgumentException e){
+            handling = (SecReferenceHandlingEnum)PreferencePredicate.DefaultBehaviourForSecundum.getDefaultValue();
+        }
+        return handling;
+
+    }
+
+    public static SecReferenceHandlingSwapEnum getSecReferenceHandlingSwapPreference(){
+        String defaultBehaviour = getStringValue(PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getKey());
+        SecReferenceHandlingSwapEnum handling = null;
+        try{
+            handling = SecReferenceHandlingSwapEnum.valueOf(defaultBehaviour);
+        }catch (IllegalArgumentException e){
+            handling = (SecReferenceHandlingSwapEnum)PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getDefaultValue();
+        }
+        return handling;
+
+    }
+
+    public static EnabledComputedDescription getComputedDesciptionHandlingPreference(){
+        String defaultBehaviour= getStringValue(PreferencePredicate.EnableComputedDescription.getKey());
+        EnabledComputedDescription computedDescriptionsEnabled = (EnabledComputedDescription)PreferencePredicate.EnableComputedDescription.getDefaultValue();
+        if (StringUtils.isNotBlank(defaultBehaviour)){
+            try{
+                computedDescriptionsEnabled = EnabledComputedDescription.byKey(defaultBehaviour);
+            }catch(IllegalArgumentException e){
+                //do nothing, keep default value;
+            }
+        }
+        return computedDescriptionsEnabled;
+
+    }
+
+    public static boolean isComputedDesciptionHandlingDisabled(){
+        String defaultBehaviour= getStringValue(PreferencePredicate.EnableComputedDescription.getKey());
+        EnabledComputedDescription computedDescriptionsEnabled = null;
+        try{
+            computedDescriptionsEnabled = EnabledComputedDescription.byKey(defaultBehaviour);
+        }catch (IllegalArgumentException e){
+            computedDescriptionsEnabled = (EnabledComputedDescription)PreferencePredicate.EnableComputedDescription.getDefaultValue();
+        }
+        return computedDescriptionsEnabled.equals(EnabledComputedDescription.Disabled);
+
     }
 
 }