From a0253849f29ad6b002fbf3c86c78c6705d324658 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Tue, 1 Oct 2024 14:57:07 -0700 Subject: [PATCH] Use WritablePropertyMap --- .../targetedms/TargetedMSController.java | 31 ++++++++++--------- .../chromlib/ChromatogramLibraryUtils.java | 3 +- .../folderImport/PanoramaQCSettings.java | 4 +-- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/org/labkey/targetedms/TargetedMSController.java b/src/org/labkey/targetedms/TargetedMSController.java index 61c975106..965dea45a 100644 --- a/src/org/labkey/targetedms/TargetedMSController.java +++ b/src/org/labkey/targetedms/TargetedMSController.java @@ -77,6 +77,8 @@ import org.labkey.api.data.DataRegion; import org.labkey.api.data.DbScope; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.PropertyMap; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.RenderContext; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SimpleFilter; @@ -751,12 +753,12 @@ public Object execute(LeveyJenningsPlotOptions form, BindException errors) { ApiSimpleResponse response = new ApiSimpleResponse(); - PropertyManager.PropertyMap properties = null; + PropertyMap properties = null; - // only stash and retrieve plot option properties for logged in users + // only stash and retrieve plot option properties for logged-in users if (!getUser().isGuest()) { - properties = PropertyManager.getWritableProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY, true); + WritablePropertyMap writable = PropertyManager.getWritableProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY, true); Map valuesToPersist = form.getAsMapOfStrings(); if (!valuesToPersist.isEmpty()) @@ -766,20 +768,21 @@ public Object execute(LeveyJenningsPlotOptions form, BindException errors) valuesToPersist.put("endDate", form.getEndDate()); valuesToPersist.put("selectedAnnotations", form.getSelectedAnnotationsString()); - properties.putAll(valuesToPersist); - properties.save(); + writable.putAll(valuesToPersist); + writable.save(); } else { - if (properties.containsKey("selectedAnnotations") && (ReplicateManager.getReplicateAnnotationNameValues(getContainer()).size() == 0)) + if (writable.containsKey("selectedAnnotations") && (ReplicateManager.getReplicateAnnotationNameValues(getContainer()).isEmpty())) { // If there are no replicate annotations in this folder anymore, remove any saved annotation filters // Issue 35726: No way to clear previously saved replicate annotation values in QC plots if folder no longer contains annotations - properties.remove("selectedAnnotations"); - properties.save(); + writable.remove("selectedAnnotations"); + writable.save(); } } + properties = writable; } if (properties == null || properties.isEmpty()) @@ -802,8 +805,8 @@ public static class SaveQCPlotSettingsAsDefaultAction extends MutatingApiAction< @Override public Object execute(LeveyJenningsPlotOptions form, BindException errors) { - PropertyManager.PropertyMap current = PropertyManager.getProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY); - PropertyManager.PropertyMap defaults = PropertyManager.getWritableProperties(getContainer(), QCFolderConstants.CATEGORY, true); + PropertyMap current = PropertyManager.getProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY); + WritablePropertyMap defaults = PropertyManager.getWritableProperties(getContainer(), QCFolderConstants.CATEGORY, true); defaults.clear(); // Clear the map. There may be properties that are no longer applicable (e.g. selectedAnnotations, startDate, endDate). defaults.putAll(current); defaults.save(); @@ -825,7 +828,7 @@ public static class RevertToDefaultQCPlotSettingsAction extends MutatingApiActio @Override public Object execute(LeveyJenningsPlotOptions form, BindException errors) { - PropertyManager.PropertyMap current = PropertyManager.getWritableProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY, false); + WritablePropertyMap current = PropertyManager.getWritableProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY, false); if (current != null) { current.delete(); @@ -837,7 +840,7 @@ public Object execute(LeveyJenningsPlotOptions form, BindException errors) } } - private static class LeveyJenningsPlotOptions + public static class LeveyJenningsPlotOptions { private String _metric; private String _yAxisScale; @@ -1306,7 +1309,7 @@ public Object execute(QCMetricOutliersForm form, BindException errors) response.put("offlineAnnotationTypeId", ts2.getObject(Integer.class)); } - PropertyManager.PropertyMap properties = PropertyManager.getWritableProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY, false); + WritablePropertyMap properties = PropertyManager.getWritableProperties(getUser(), getContainer(), QCFolderConstants.CATEGORY, false); if (properties != null) { Map toSend = new HashMap<>(properties); @@ -4158,7 +4161,7 @@ public static class PharmacokineticsOptionsAction extends MutatingApiAction entry : props.entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String)