search preference cache for prefKey
authorKatja Luther <k.luther@bgbm.org>
Tue, 30 Apr 2019 06:40:10 +0000 (08:40 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 30 Apr 2019 06:40:10 +0000 (08:40 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/CdmPreferenceCache.java

index 6482221..25da114 100755 (executable)
@@ -60,47 +60,13 @@ public class CdmPreferenceCache {
     public void getAllTaxEditorDBPreferences(){
         ICdmRepository controller;
         controller = CdmStore.getCurrentApplicationConfiguration();
-        //ABCD
-        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AbcdImportConfig);
-        loadAndPutPreference(controller, key);
-
-        //ShowIOMenu
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowImportExportMenu);
-        loadAndPutPreference(controller, key);
-
-//        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowMediaView);
-//        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowChecklistPerspective);
-        loadAndPutPreference(controller, key);
-
-
-        //Specimen Details
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
-        loadAndPutPreference(controller, key);
-
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
-        loadAndPutPreference(controller, key);
-
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits);
-        loadAndPutPreference(controller, key);
-
-
-        //Name Details
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.NameDetailsView);
-        loadAndPutPreference(controller, key);
+        List<CdmPreference> allPreferences = controller.getPreferenceService().list();
 
+        for (CdmPreference pref: allPreferences){
+            put(pref);
+        }
 
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionStatus);
-        loadAndPutPreference(controller, key);
+        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionStatus);
 
         if (preferenceCache.get(key) != null){
             if (!PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.AvailableDistributionStatus.getKey())) || !preferenceCache.get(key).isAllowOverride()){
@@ -120,70 +86,11 @@ public class CdmPreferenceCache {
                 CdmStore.getTermManager().setPreferredTerms(definedTermBases, TermStore.getTerms(TermType.PresenceAbsenceTerm, null));
             }
         }
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies);
-        loadAndPutPreference(controller, key);
-
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DistributionEditorActivated);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfAreasInDistributionEditor);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfStatus);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowRankInDistributionEditor);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AreasSortedInDistributionEditor);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.OwnDescriptionForDistributionEditor);
-        loadAndPutPreference(controller, key);
-
-        //common names
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.CommonNameAreaVocabularies);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.CommonNameReferencesWithMarker);
-        loadAndPutPreference(controller, key);
-
-        //sources
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowIdInSource);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowNamespaceInSource);
-        loadAndPutPreference(controller, key);
-
-        //multiple classifications / taxon navigator
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisableMultiClassification);
-        loadAndPutPreference(controller, key);
-
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonNodeWizard);
-        loadAndPutPreference(controller, key);
-
-        key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DefaultBehaviourForPublishFlag);
-        loadAndPutPreference(controller, key);
-
-
     }
 
-    private void loadAndPutPreference(ICdmRepository controller, PrefKey key) {
-        if (controller == null){
-            return ;
-        }
-        CdmPreference preference = controller.getPreferenceService().find(key);
-        if (preference != null){
-            put(preference);
-        }
-    }
 
-    private CdmPreference findBestMatching(PrefKey key) {
+
+    public CdmPreference findBestMatching(PrefKey key) {
 
         return PreferenceResolver.resolve(new ArrayList(this.preferenceCache.values()), key);