ref #10398: make it configurable how the specimen/taxon rel should be
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / PreferencesUtil.java
index 862e2068cde2a681f23890310e02c8b51ac694ab..194a5edc4ee897af88681a4f4a1a7e4c4265ba37 100644 (file)
@@ -6,7 +6,6 @@
  * The contents of this file are subject to the Mozilla Public License Version 1.1
  * See LICENSE.TXT at the top of this package for the full license terms.
  */
-
 package eu.etaxonomy.taxeditor.preference;
 
 import java.io.File;
@@ -14,11 +13,11 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.lang.reflect.Field;
-import java.net.URI;
 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;
@@ -27,78 +26,81 @@ import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.UUID;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.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;
 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.CdmApplicationState;
 import eu.etaxonomy.cdm.api.application.ICdmRepository;
-import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
-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.facade.DerivedUnitFacadeConfigurator;
 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.DistributionDescription;
+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.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.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;
 
 /**
- * <p>
- * PreferencesUtil class.
- * </p>
- *
  * @author p.ciardelli
  * @author n.hoffmann
  * @created 05.12.2008
  */
 public class PreferencesUtil implements IPreferenceKeys {
+
+    private final static Logger logger = LogManager.getLogger(PreferencesUtil.class);
+
     private final static String EDITOR_PREFERENCES_NODE = "eu.etaxonomy.taxeditor";
 
     public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
-
+    public static final String UPDATE_NAVIGATOR = "update_navigator";
     public static final String P2_REPOSITORIES_DELIM = ",";
     public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
     public static final String SUBJECT_DELIM = "/";
@@ -107,7 +109,6 @@ public class PreferencesUtil implements IPreferenceKeys {
 
     private static TermTree<Feature> preferredTaxonFeatureTree;
 
-    private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
 
     public static IPreferenceStore getPreferenceStore() {
        return TaxeditorStorePlugin.getDefault().getPreferenceStore();
@@ -124,9 +125,11 @@ public class PreferencesUtil implements IPreferenceKeys {
 
     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){
@@ -237,7 +240,7 @@ public class PreferencesUtil implements IPreferenceKeys {
                  if (result instanceof String){
                      return (String)result;
                  }else{
-                     return result.toString();
+                     return result != null?result.toString(): null;
                  }
              }
             return pref.getValue();
@@ -582,6 +585,27 @@ public class PreferencesUtil implements IPreferenceKeys {
         return null;
     }
 
+    public static Language getPreferredDefaultLanguage(){
+        
+        String prop = System.getProperty("osgi.nl");
+        if (prop.startsWith("de")) {
+            return Language.GERMAN();
+        }else {
+            return Language.ENGLISH();
+        }
+//        String preferredLanguage = getStringValue(DEFAULT_LANGUAGE_EDITOR, true);
+//        if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
+//            if (preferredLanguage.equals(Language.uuidEnglish.toString())) {
+//             return Language.ENGLISH();
+//            }else if (preferredLanguage.equals(Language.uuidGerman.toString())) {
+//             return Language.GERMAN();
+//            }else {
+//             return Language.ENGLISH();
+//            }
+//        }
+//        return Language.getDefaultLanguage();
+    }
+
     public static boolean isShowMediaPreview(){
         boolean isShowMediaPreview = getBooleanValue(SHOW_MEDIA_PREVIEW, true);
         return isShowMediaPreview;
@@ -669,45 +693,14 @@ public class PreferencesUtil implements IPreferenceKeys {
         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
-     */
-    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;
-    }
-
-    /**
-     * 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")) {
+        if (key.contains("javassist")) { //Note by AM (2022-06): javassist is not used anymore, instead hibernate uses bytebuddy which is not contained in class names so this logging will not work anymore
             MessagingUtils.warn(PreferencesUtil.class,
                     "Trying to persist a preference based on a proxy class.");
         }
@@ -721,7 +714,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         definedTerm = HibernateProxyHelper.deproxy(definedTerm);
         String key = definedTerm.getClass().getName().concat(".")
                 .concat(definedTerm.getUuid().toString());
-        if (key.contains("javassist")) {
+        if (key.contains("javassist")) { //Note by AM (2022-06): javassist is not used anymore, instead hibernate uses bytebuddy which is not contained in class names so this logging will not work anymore
             MessagingUtils.warn(PreferencesUtil.class,
                     "Trying to persist a preference based on a proxy class.");
         }
@@ -744,6 +737,10 @@ public class PreferencesUtil implements IPreferenceKeys {
                 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;
@@ -763,7 +760,8 @@ public class PreferencesUtil implements IPreferenceKeys {
         configurator.setDoSynonyms(true);
         configurator.setDoNamesWithoutTaxa(true);
         configurator.setDoTaxaByCommonNames(true);
-
+        configurator.setIncludeUnpublished(true);
+        configurator.setDoIncludeAuthors(false);
         configurator.setTaxonPropertyPath(Arrays.asList("$", "titleCache",
                 "name", "name.$", "relationsFromThisTaxon.$"));
 
@@ -801,6 +799,10 @@ public class PreferencesUtil implements IPreferenceKeys {
                 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());
     }
 
     public static void firePreferencesChanged(Class clazz) {
@@ -808,6 +810,11 @@ public class PreferencesUtil implements IPreferenceKeys {
                 null, clazz);
     }
 
+    public static void firePreferencesChangedForNavigator() {
+        getPreferenceStore().firePropertyChangeEvent(UPDATE_NAVIGATOR,
+                null, null);
+    }
+
 
     public static String createPreferenceString(String property){
        return prefKey(property);
@@ -837,6 +844,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         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());
@@ -898,18 +906,18 @@ public class PreferencesUtil implements IPreferenceKeys {
                 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
+//        }
+//    }
 
     public static String getMapServiceAccessPoint() {
         return getStringValue(PreferencePredicate.EditMapServiceAccessPoint.getKey());
@@ -959,26 +967,35 @@ public class PreferencesUtil implements IPreferenceKeys {
     public static Language getGlobalLanguage() {
 
         String languageUuidString = getStringValue(
-                GLOBAL_LANGUAGE_UUID, true);
+                PreferencePredicate.TermLanguage.getKey(), true);
 
-        if(!CdmStore.isActive()) {
-            MessagingUtils.noDataSourceWarningDialog(languageUuidString);
-            return null;
-        }
+        CdmPreference dbPref = getDBPreferenceValue(PreferencePredicate.TermLanguage.getKey());
 
-        if (CdmUtils.isBlank(languageUuidString)) {
-            return Language.getDefaultLanguage();
+        if (dbPref == null || (dbPref != null && dbPref.isAllowOverride() && getOverrideForPreference(PreferencePredicate.TermLanguage.getKey()))) {
+            if (CdmUtils.isBlank(languageUuidString)) {
+                return Language.getDefaultLanguage();
+            }else {
+                return Language.getLanguageFromUuid(UUID.fromString(languageUuidString));
+            }
+        }else {
+            languageUuidString = dbPref.getValue();
         }
-
         UUID languageUuid = UUID.fromString(languageUuidString);
-        return (Language) CdmStore.getService(ITermService.class).load(
-                languageUuid);
+        Language language = (Language)CdmApplicationState.getTermProxy().load(languageUuid);
+        if (language != null){
+            return language;
+        }else{
+            MessagingUtils.noDataSourceWarningDialog(languageUuidString);
+            return null;
+        }
     }
 
     public static void setGlobalLanguage(Language language) {
         if(language != null) {
-            setStringValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
+            setStringValue(PreferencePredicate.TermLanguage.getKey(),language.getUuid().toString());
             CdmStore.setDefaultLanguage(language);
+        }else {
+            CdmStore.setDefaultLanguage(Language.getDefaultLanguage());
         }
     }
 
@@ -1033,26 +1050,29 @@ public class PreferencesUtil implements IPreferenceKeys {
      * @param setLanguage 0 is for german and 1 for english.
      * @throws IOException
      */
-    public void writePropertyToConfigFile(int setLanguage) throws IOException {
+    public static 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
         if(file == null){
             throw new IOException();
         }
-        Properties properties = load(file.getAbsolutePath()+"/config.ini");
+        Properties properties;
+        properties = load(file.getAbsolutePath()+"/config.ini");
         switch(setLanguage){
         case 0:
             properties.setProperty("osgi.nl", "de");
-            setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
+            setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, Language.uuidGerman.toString());
             break;
         case 1:
             properties.setProperty("osgi.nl", "en");
-            setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
+            setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, Language.uuidEnglish.toString());
             break;
         default:
             break;
         }
         save(file+"/config.ini", properties);
+        
+        
     }
 
     /**
@@ -1062,7 +1082,7 @@ public class PreferencesUtil implements IPreferenceKeys {
      * @return
      * @throws IOException
      */
-    private Properties load(String filename) throws IOException {
+    private static Properties load(String filename) throws IOException {
         FileInputStream in = new FileInputStream(filename);
         Properties prop = new Properties();
         prop.load(in);
@@ -1077,7 +1097,7 @@ public class PreferencesUtil implements IPreferenceKeys {
      * @param properties
      * @throws IOException
      */
-    private void save(String filename, Properties properties) throws IOException{
+    private static void save(String filename, Properties properties) throws IOException{
         FileOutputStream fos =  new FileOutputStream(filename);
         properties.store(fos, "");
         fos.close();
@@ -1127,7 +1147,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);
@@ -1182,6 +1202,25 @@ public class PreferencesUtil implements IPreferenceKeys {
         return value.equals(NavigatorOrderEnum.RankAndNameOrder);
     }
 
+    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;
+       }
+
     public static boolean isStoreNavigatorState() {
         return getBooleanValue(RESTORE_NAVIGATOR_STATE);
     }
@@ -1227,12 +1266,19 @@ public class PreferencesUtil implements IPreferenceKeys {
         setStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey(), selection);
     }
 
-    public static void setOwnDescriptionForChecklistEditor(boolean selection) {
-        setBooleanValue(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey(), selection);
+    public static void setDescriptionForChecklistEditor(DistributionDescription selection) {
+        setStringValue(PreferencePredicate.DescriptionForDistributionEditor.getKey(), selection.getKey());
     }
 
-    public static boolean isOwnDescriptionForChecklistEditor() {
-        return getBooleanValue(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey());
+    public static DistributionDescription getDescriptionForChecklistEditor() {
+        String str =  getStringValue(PreferencePredicate.DescriptionForDistributionEditor.getKey());
+        DistributionDescription result = null;
+        try {
+            result = DistributionDescription.byKey(str);
+        }catch(IllegalArgumentException e) {
+            result = (DistributionDescription)PreferencePredicate.DescriptionForDistributionEditor.getDefaultValue();
+        }
+        return result;
     }
 
     public static TermDisplayEnum displayAreaInChecklistEditor() {
@@ -1352,6 +1398,45 @@ public class PreferencesUtil implements IPreferenceKeys {
         }
     }
 
+    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);
+                 }
+             }
+         }
+    }
+
     public static Abcd206ImportConfigurator getDBAbcdImportConfigurationPreference() {
 
         Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
@@ -1392,8 +1477,10 @@ public class PreferencesUtil implements IPreferenceKeys {
                  }
                  if (keyString.equals("ignoreImportOfExistingSpecimen")){
                      config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
-                 }else if (keyString.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
-                     config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("addIndividualsAssociations")){
+                     config.setAddIndividualsAssociations(Boolean.valueOf(valueString));
+                 }else if (keyString.equals("addDeterminations")){
+                     config.setAddDeterminations(Boolean.valueOf(valueString));
                  }else if (keyString.equals("reuseExistingTaxaWhenPossible")){
                      config.setReuseExistingTaxaWhenPossible(Boolean.valueOf(valueString));
                  }else if (keyString.equals("ignoreAuthorship")){
@@ -1426,17 +1513,23 @@ public class PreferencesUtil implements IPreferenceKeys {
                      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{
-                         config.setDnaSoure(URI.create(valueString));
+                         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);
                  }
-
-
              }
          }
     }
@@ -1471,20 +1564,19 @@ public class PreferencesUtil implements IPreferenceKeys {
     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);
-       }
+        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() {
@@ -1494,7 +1586,6 @@ public class PreferencesUtil implements IPreferenceKeys {
 
         if (!getBooleanValue(prefOverrideKey(PreferencePredicate.AbcdImportConfig.getKey())) || !pref.isAllowOverride()){
             resetToDBPreferenceAbcdCOnfigurator();
-
         }
     }
 
@@ -1556,14 +1647,12 @@ public class PreferencesUtil implements IPreferenceKeys {
                             saveCheckedElements);
                     preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
                     setPreferenceToDB(preference);
-
                 }
             } else{
                 preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
                 setPreferenceToDB(preference);
                 setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
                         saveCheckedElements);
-
             }
         }
     }
@@ -1640,11 +1729,7 @@ public class PreferencesUtil implements IPreferenceKeys {
     }
 
     public static boolean getFilterCommonNameReferences(){
-        Boolean result = getBooleanValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey());
-        if (result == null){
-            return false;
-        }
-        return result;
+        return getBooleanValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey());
     }
 
     public static void updateDBPreferences() {
@@ -1652,18 +1737,8 @@ public class PreferencesUtil implements IPreferenceKeys {
         CdmPreferenceCache cache = CdmPreferenceCache.instance();
         cache.getAllTaxEditorDBPreferences();
 
-        //ABCD Configurator
-
-        //updateAbcdImportConfigurationPreference();
-
         //Name Details
         NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
-        //    if (config != null ){
-        //        if (!getBooleanValue(OVERRIDE_NAME_DETAILS) ||  !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS)){
-        //            setPreferredNameDetailsConfiguration(config, false);
-        //        }
-        //    }
-
     }
 
     public static void setPreferencesToDB(List<CdmPreference> preferences) {
@@ -1674,12 +1749,9 @@ public class PreferencesUtil implements IPreferenceKeys {
             for (CdmPreference preference: preferences){
                 if (preference.getValue() == null && preference.isAllowOverride()){
                     controller.getPreferenceService().remove(preference.getKey());
-
                 }else{
                     controller.getPreferenceService().set(preference);
-
                 }
-
             }
             CdmPreferenceCache.instance().getAllTaxEditorDBPreferences();
         }
@@ -1694,10 +1766,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         return getPreferenceStore().contains(prefKey(prefKey));
     }
 
-    /**
-     *
-     */
-    public static TermTree<?> getPreferredFeatureTreeForNameDescription(boolean createNew) {
+    public static TermTree<Feature> getPreferredFeatureTreeForNameDescription(boolean createNew) {
         if(preferredNameFeatureTree != null && !createNew){
             return preferredNameFeatureTree;
         }
@@ -1724,7 +1793,7 @@ public class PreferencesUtil implements IPreferenceKeys {
         if (terms.isEmpty()){
             preferredNameFeatureTree = TermEditorInput.getDefaultNameFeatureTree();
         }else{
-            preferredNameFeatureTree = TermTree.NewInstance(terms);
+            preferredNameFeatureTree = TermTree.NewFeatureInstance(terms);
         }
     }
 
@@ -1780,11 +1849,79 @@ public class PreferencesUtil implements IPreferenceKeys {
         if (terms.isEmpty()){
             preferredTaxonFeatureTree = TermEditorInput.getDefaultFeatureTree();
         }else{
-            preferredTaxonFeatureTree = TermTree.NewInstance(terms);
+            preferredTaxonFeatureTree = TermTree.NewFeatureInstance(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;
+    }
+
+    /**
+     * @return
+     */
+    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);
+
+    }
+
 }