2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.databaseAdmin
.preferencePage
;
11 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
12 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
13 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
14 import eu
.etaxonomy
.taxeditor
.preference
.SupplementalDataSourcePreferences
;
21 public class SupplementalDataSourceAdminPreference
extends SupplementalDataSourcePreferences
implements IE4AdminPreferencePage
{
23 private CdmPreference prefShowIdNamespace
;
24 private CdmPreference prefShowIdInSource
;
27 public boolean performOk() {
31 boolean setToDefault
= false;
32 if (isShowIDSource
== null && isAllowOverrideShowIDSource
){
36 CdmPreference pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowIdInSource
, isShowIDSource
!= null? Boolean
.toString(this.isShowIDSource
): null);
37 pref
.setAllowOverride(isAllowOverrideShowIDSource
);
38 PreferencesUtil
.setPreferencesToDB(pref
, setToDefault
);
40 if (isShowIDNamespace
== null && isAllowOverrideShowIDNamespace
){
44 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowNamespaceInSource
, isShowIDNamespace
!= null? Boolean
.toString(this.isShowIDNamespace
): null);
45 pref
.setAllowOverride(isAllowOverrideShowIDNamespace
);
46 PreferencesUtil
.setPreferencesToDB(pref
, setToDefault
);
48 PreferencesUtil
.updateDBPreferences();
53 protected void getValues(){
54 isAdminPreference
= true;
56 prefShowIdNamespace
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowNamespaceInSource
);
57 if (prefShowIdNamespace
== null){
58 prefShowIdNamespace
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowNamespaceInSource
, null);
59 prefShowIdNamespace
.setAllowOverride(true);
61 isShowIDNamespace
= prefShowIdNamespace
.getValue()!= null? Boolean
.parseBoolean(prefShowIdNamespace
.getValue()): null;
62 isAllowOverrideShowIDNamespace
= prefShowIdNamespace
.isAllowOverride();
64 prefShowIdInSource
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.ShowIdInSource
);
65 if (prefShowIdInSource
== null){
66 prefShowIdInSource
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowIdInSource
, null);
67 prefShowIdInSource
.setAllowOverride(true);
69 isShowIDSource
= prefShowIdInSource
.getValue()!= null? Boolean
.parseBoolean(prefShowIdInSource
.getValue()): null;
70 isAllowOverrideShowIDSource
= prefShowIdInSource
.isAllowOverride();