--- /dev/null
+/**
+* Copyright (C) 2019 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* 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.databaseAdmin.preferencePage;
+
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.preference.SupplementalDataSourcePreferences;
+
+/**
+ * @author k.luther
+ * @since 28.06.2019
+ *
+ */
+public class SupplementalDataSourceAdminPreference extends SupplementalDataSourcePreferences implements IE4AdminPreferencePage{
+
+ private CdmPreference prefShowIdNamespace;
+ private CdmPreference prefShowNamespace;
+
+ @Override
+ public boolean performOk() {
+ if (!isApply()){
+ return true;
+ }
+ boolean setToDefault = false;
+ if (isShowIDNamspace == null){
+ setToDefault = true;
+ isShowIDNamspace = true;
+ }
+ CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSource, Boolean.toString(this.isShowIDNamspace));
+ pref.setAllowOverride(isAllowOverrideShowIDNamspace);
+ PreferencesUtil.setPreferencesToDB(pref, setToDefault);
+
+ if (isShowIDSource == null){
+ setToDefault = true;
+ isShowIDSource = true;
+ }
+ pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowNamespaceInSource, Boolean.toString(this.isShowIDSource));
+ pref.setAllowOverride(isAllowOverrideShowIDSource);
+ PreferencesUtil.setPreferencesToDB(pref, setToDefault);
+
+ PreferencesUtil.updateDBPreferences();
+ return true;
+ }
+
+ @Override
+ protected void getValues(){
+ isAdminPreference = true;
+
+ prefShowIdNamespace = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInSource);
+ if (prefShowIdNamespace == null){
+ prefShowIdNamespace = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSource, null);
+ prefShowIdNamespace.setAllowOverride(true);
+ }
+ isShowIDNamspace = prefShowIdNamespace.getValue()!= null? Boolean.parseBoolean(prefShowIdNamespace.getValue()): null;
+ isAllowOverrideShowIDNamspace = prefShowIdNamespace.isAllowOverride();
+
+
+ prefShowNamespace = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowNamespaceInSource);
+ if (prefShowNamespace == null){
+ prefShowNamespace = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowNamespaceInSource, null);
+ prefShowNamespace.setAllowOverride(true);
+ }
+ isShowIDSource = prefShowNamespace.getValue()!= null? Boolean.parseBoolean(prefShowNamespace.getValue()): null;
+ isAllowOverrideShowIDSource = prefShowNamespace.isAllowOverride();
+ }
+}