Merge branch 'release/5.8.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / databaseAdmin / preferencePage / SpecimenAdminPreferences.java
index 4310b5c0b2a1648fa3e6c1e448cb54beac733c68..0415f7656baf67f47bde47ef49863889a50536b3 100755 (executable)
@@ -53,8 +53,8 @@ public class SpecimenAdminPreferences extends SpecimenOrObservationPreferences i
                 this.isShowSpecimenRelatedIssues = Boolean.valueOf(showSpecimenPref.getValue());
                 this.allowOverrideShowSpecimenRelatedIssues = showSpecimenPref.isAllowOverride();
             }else{
-                showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(true));
-                this.isShowSpecimenRelatedIssues = true;
+                //showSpecimenPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(true));
+//                this.isShowSpecimenRelatedIssues = true;
                 this.allowOverrideShowSpecimenRelatedIssues = true;
             }
 
@@ -64,7 +64,7 @@ public class SpecimenAdminPreferences extends SpecimenOrObservationPreferences i
                 this.isShowCollectingAreaInGeneralSection = Boolean.valueOf(isShowCollectingAreaInGeneralSectionPref.getValue());
                 this.allowOverrideShowCollectingAreaInGeneralSection = isShowCollectingAreaInGeneralSectionPref.isAllowOverride();
             }else{
-                this.isShowCollectingAreaInGeneralSection = (Boolean) PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue();
+//                this.isShowCollectingAreaInGeneralSection = (Boolean) PreferencePredicate.ShowCollectingAreasInGeneralSection.getDefaultValue();
                 this.allowOverrideShowCollectingAreaInGeneralSection = true;
             }
 
@@ -74,7 +74,7 @@ public class SpecimenAdminPreferences extends SpecimenOrObservationPreferences i
                 this.isDeterminationOnlyForFieldUnits = Boolean.valueOf(isDeterminationOnlyForFieldUnitsPref.getValue());
                 this.allowOverrideDeterminationOnlyForFieldUnits = isDeterminationOnlyForFieldUnitsPref.isAllowOverride();
             }else{
-                this.isDeterminationOnlyForFieldUnits =(Boolean)PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue();
+//                this.isDeterminationOnlyForFieldUnits =(Boolean)PreferencePredicate.DeterminationOnlyForFieldUnits.getDefaultValue();
                 this.allowOverrideDeterminationOnlyForFieldUnits = true;
             }
             key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations);
@@ -83,7 +83,7 @@ public class SpecimenAdminPreferences extends SpecimenOrObservationPreferences i
                 this.isShowTaxonAssociation = Boolean.valueOf(isShowTaxonAssociationPref.getValue());
                 this.allowOverrideShowTaxonAssociation = isShowTaxonAssociationPref.isAllowOverride();
             }else{
-                this.isShowTaxonAssociation = (Boolean)PreferencePredicate.ShowTaxonAssociations.getDefaultValue();
+//                this.isShowTaxonAssociation = (Boolean)PreferencePredicate.ShowTaxonAssociations.getDefaultValue();
                 this.allowOverrideShowTaxonAssociation = true;
             }
 
@@ -93,7 +93,7 @@ public class SpecimenAdminPreferences extends SpecimenOrObservationPreferences i
                 this.isShowLifeForm = Boolean.valueOf(isShowLifeFormPref.getValue());
                 this.allowOverrideShowLifeForm = isShowLifeFormPref.isAllowOverride();
             } else{
-                this.isShowLifeForm = (Boolean)PreferencePredicate.ShowLifeForm.getDefaultValue();
+//                this.isShowLifeForm = (Boolean)PreferencePredicate.ShowLifeForm.getDefaultValue();
                 this.allowOverrideShowLifeForm = true;
             }
 
@@ -102,31 +102,49 @@ public class SpecimenAdminPreferences extends SpecimenOrObservationPreferences i
 
     @Override
      public boolean performOk() {
-        if (showSpecimenPref == null){
+        if (!isApply()){
             return true;
         }
         ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
         if (controller != null){
             IPreferenceService service = controller.getPreferenceService();
+            CdmPreference pref;
+            if (isShowCollectingAreaInGeneralSection == null){
+                service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection));
+            }else{
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, Boolean.toString(this.isShowCollectingAreaInGeneralSection));
+                pref.setAllowOverride(allowOverrideShowCollectingAreaInGeneralSection);
+                service.set(pref);
+            }
+            if (isShowSpecimenRelatedIssues == null){
+                service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowSpecimen));
+            }else{
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(this.isShowSpecimenRelatedIssues));
+                pref.setAllowOverride(allowOverrideShowSpecimenRelatedIssues);
+                service.set(pref);
+            }
 
-            CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowCollectingAreasInGeneralSection, Boolean.toString(this.isShowCollectingAreaInGeneralSection));
-            pref.setAllowOverride(allowOverrideShowCollectingAreaInGeneralSection);
-            service.set(pref);
-            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowSpecimen, Boolean.toString(this.isShowSpecimenRelatedIssues));
-            pref.setAllowOverride(allowOverrideShowSpecimenRelatedIssues);
-            service.set(pref);
-
-            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, Boolean.toString(this.isDeterminationOnlyForFieldUnits));
-            pref.setAllowOverride(allowOverrideDeterminationOnlyForFieldUnits);
-            service.set(pref);
-
-            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, Boolean.toString(this.isShowTaxonAssociation));
-            pref.setAllowOverride(allowOverrideShowTaxonAssociation);
-            service.set(pref);
-
-            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, Boolean.toString(this.isShowLifeForm));
-            pref.setAllowOverride(allowOverrideShowLifeForm);
-            service.set(pref);
+            if (isDeterminationOnlyForFieldUnits == null){
+                service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DeterminationOnlyForFieldUnits));
+            }else{
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DeterminationOnlyForFieldUnits, Boolean.toString(this.isDeterminationOnlyForFieldUnits));
+                pref.setAllowOverride(allowOverrideDeterminationOnlyForFieldUnits);
+                service.set(pref);
+            }
+            if (isShowTaxonAssociation == null){
+                service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowTaxonAssociations));
+            }else{
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowTaxonAssociations, Boolean.toString(this.isShowTaxonAssociation));
+                pref.setAllowOverride(allowOverrideShowTaxonAssociation);
+                service.set(pref);
+            }
+            if (isShowLifeForm == null){
+                service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowLifeForm));
+            }else{
+                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowLifeForm, Boolean.toString(this.isShowLifeForm));
+                pref.setAllowOverride(allowOverrideShowLifeForm);
+                service.set(pref);
+            }
             PreferencesUtil.updateDBPreferences();