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
.api
.application
.ICdmRepository
;
12 import eu
.etaxonomy
.cdm
.api
.service
.IPreferenceService
;
13 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
14 import eu
.etaxonomy
.cdm
.model
.metadata
.NamedAreaSearchField
;
15 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
16 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
17 import eu
.etaxonomy
.taxeditor
.preference
.SearchDialogPreferences
;
18 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
24 public class SearchDialogAdminPreferences
extends SearchDialogPreferences
implements IE4AdminPreferencePage
{
30 public void getValues(){
32 isAdminPreference
= true;
33 if(showIdInSelectionDialogPref
!= null){
34 showIdInSelectionDialog
= showIdInSelectionDialogPref
.getValue() != null? Boolean
.parseBoolean(showIdInSelectionDialogPref
.getValue()): null;
36 showIdInSelectionDialog
= null;
37 showIdInSelectionDialogPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowIdInSelectionDialog
, null);
39 if (searchForIdentifierAsDefaultPref
!= null){
40 searchForIdentifierAsDefault
= searchForIdentifierAsDefaultPref
.getValue() != null? Boolean
.parseBoolean(searchForIdentifierAsDefaultPref
.getValue()): null;
42 searchForIdentifierAsDefault
= null;
43 searchForIdentifierAsDefaultPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAsDefault
, null);
45 if (searchForIdentifierAndTitleCachePref
!= null){
46 searchForIdentifierAndTitleCache
= searchForIdentifierAndTitleCachePref
.getValue() != null? Boolean
.parseBoolean(searchForIdentifierAndTitleCachePref
.getValue()): null;
48 searchForIdentifierAndTitleCache
= null;
49 searchForIdentifierAndTitleCachePref
=CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAndTitleCache
, null);
51 if (sortTaxaByRankAndNamePref
!= null){
52 sortTaxaByRankAndName
= sortTaxaByRankAndNamePref
.getValue() != null? Boolean
.parseBoolean(sortTaxaByRankAndNamePref
.getValue()): null;
54 sortTaxaByRankAndName
= null;
55 sortTaxaByRankAndNamePref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SortTaxaByRankAndName
, null);
57 if (filterCommonNameReferencesPref
!= null){
58 filterCommonNameReferences
= filterCommonNameReferencesPref
.getValue() != null? Boolean
.parseBoolean(filterCommonNameReferencesPref
.getValue()): null;
60 filterCommonNameReferences
= null;
61 filterCommonNameReferencesPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.CommonNameReferencesWithMarker
, null);
63 if (this.searchNamedAreasByAbbrevPref
!= null){
64 searchNamedAreasByAbbrev
= searchNamedAreasByAbbrevPref
.getValue() != null? NamedAreaSearchField
.byKey(searchNamedAreasByAbbrevPref
.getValue()): null;
66 searchNamedAreasByAbbrev
= null;
67 searchNamedAreasByAbbrevPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.NamedAreaSearchForAbbrev
, null);
73 public boolean performOk(){
77 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
78 if (controller
!= null){
79 IPreferenceService service
= controller
.getPreferenceService();
81 if (showIdInSelectionDialog
!= null || !showIdInSelectionDialogPref
.isAllowOverride()) {
82 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowIdInSelectionDialog
, showIdInSelectionDialog
!= null? showIdInSelectionDialog
.toString():null);
83 pref
.setAllowOverride(showIdInSelectionDialogPref
.isAllowOverride());
86 service
.remove(showIdInSelectionDialogPref
.getKey());
90 if(searchForIdentifierAsDefault
!= null || !searchForIdentifierAsDefaultPref
.isAllowOverride()){
91 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAsDefault
, searchForIdentifierAsDefault
!= null? searchForIdentifierAsDefault
.toString():null);
92 pref
.setAllowOverride(searchForIdentifierAsDefaultPref
.isAllowOverride());
95 service
.remove(searchForIdentifierAsDefaultPref
.getKey());
99 if(searchForIdentifierAndTitleCache
!= null || !searchForIdentifierAndTitleCachePref
.isAllowOverride()){
100 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAndTitleCache
, searchForIdentifierAndTitleCache
!= null? searchForIdentifierAndTitleCache
.toString():null);
101 pref
.setAllowOverride(searchForIdentifierAndTitleCachePref
.isAllowOverride());
104 service
.remove(searchForIdentifierAndTitleCachePref
.getKey());
107 if(sortTaxaByRankAndName
!= null || !sortTaxaByRankAndNamePref
.isAllowOverride()){
109 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SortTaxaByRankAndName
, sortTaxaByRankAndName
!= null? sortTaxaByRankAndName
.toString():null);
110 pref
.setAllowOverride(sortTaxaByRankAndNamePref
.isAllowOverride());
113 service
.remove(sortTaxaByRankAndNamePref
.getKey());
116 if(filterCommonNameReferences
!= null || !filterCommonNameReferencesPref
.isAllowOverride()){
117 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.CommonNameReferencesWithMarker
, filterCommonNameReferences
!= null? filterCommonNameReferences
.toString():null);
118 pref
.setAllowOverride(filterCommonNameReferencesPref
.isAllowOverride());
121 service
.remove(filterCommonNameReferencesPref
.getKey());
124 if(searchNamedAreasByAbbrev
!= null || !searchNamedAreasByAbbrevPref
.isAllowOverride()){
125 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.NamedAreaSearchForAbbrev
, searchNamedAreasByAbbrev
!= null? searchNamedAreasByAbbrev
.getKey():null);
126 pref
.setAllowOverride(searchNamedAreasByAbbrevPref
.isAllowOverride());
129 service
.remove(searchNamedAreasByAbbrevPref
.getKey());
132 PreferencesUtil
.updateDBPreferences();