From 13f6932f697e33bd85acb852ec9544d60569cd14 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Tue, 1 Oct 2024 14:56:52 -0700 Subject: [PATCH] Use WritablePropertyMap --- LDK/src/org/labkey/ldk/LDKController.java | 3 ++- .../ldk/notification/NotificationServiceImpl.java | 11 ++++++----- .../ldk/notification/SiteSummaryNotification.java | 11 ++++++----- .../laboratory/query/ContainerIncrementingTable.java | 3 ++- .../org/labkey/laboratory/LaboratoryController.java | 9 +++++---- .../org/labkey/laboratory/LaboratoryServiceImpl.java | 9 +++++---- .../notification/LabSummaryNotification.java | 5 +++-- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/LDK/src/org/labkey/ldk/LDKController.java b/LDK/src/org/labkey/ldk/LDKController.java index fac82bb6..3f40d163 100644 --- a/LDK/src/org/labkey/ldk/LDKController.java +++ b/LDK/src/org/labkey/ldk/LDKController.java @@ -39,6 +39,7 @@ import org.labkey.api.data.CoreSchema; import org.labkey.api.data.DbSequenceManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SqlExecutor; import org.labkey.api.data.SqlScriptRunner; import org.labkey.api.data.TableInfo; @@ -1079,7 +1080,7 @@ public ApiResponse execute(SetRedirectUrlForm form, BindException errors) throws return null; } - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(getContainer(), REDIRECT_URL_DOMAIN, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(getContainer(), REDIRECT_URL_DOMAIN, true); props.put(REDIRECT_URL_PROP, StringUtils.trimToNull(form.getUrl())); props.save(); diff --git a/LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java b/LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java index 028378f0..6fede1fd 100644 --- a/LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java +++ b/LDK/src/org/labkey/ldk/notification/NotificationServiceImpl.java @@ -30,6 +30,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.Table; import org.labkey.api.data.TableInfo; @@ -169,7 +170,7 @@ public boolean isServiceEnabled() public void setServiceEnabled(Boolean status) { - PropertyManager.PropertyMap pm = PropertyManager.getWritableProperties(ContainerManager.getRoot(), NotificationServiceImpl.CONFIG_PROPERTY_DOMAIN, true); + WritablePropertyMap pm = PropertyManager.getWritableProperties(ContainerManager.getRoot(), NotificationServiceImpl.CONFIG_PROPERTY_DOMAIN, true); pm.put(ENABLED_PROP, status.toString()); pm.save(); } @@ -226,7 +227,7 @@ public void setReturnEmail(Container c, String returnEmail) { ValidEmail email = new ValidEmail(returnEmail); - PropertyManager.PropertyMap pm = PropertyManager.getWritableProperties(c, NotificationServiceImpl.CONFIG_PROPERTY_DOMAIN, true); + WritablePropertyMap pm = PropertyManager.getWritableProperties(c, NotificationServiceImpl.CONFIG_PROPERTY_DOMAIN, true); pm.put(RETURN_EMAIL, email.getEmailAddress()); pm.save(); } @@ -250,7 +251,7 @@ public void setUser(Container c, Integer userId) { if(userId != null) { - PropertyManager.PropertyMap pm = PropertyManager.getWritableProperties(c, NotificationServiceImpl.CONFIG_PROPERTY_DOMAIN, true); + WritablePropertyMap pm = PropertyManager.getWritableProperties(c, NotificationServiceImpl.CONFIG_PROPERTY_DOMAIN, true); pm.put(USER_PROP, String.valueOf(userId)); pm.save(); } @@ -344,7 +345,7 @@ public Date getLastRunDate(Notification n) public void setLastRun(Notification n, Long lastRun) { - PropertyManager.PropertyMap pm = PropertyManager.getWritableProperties(NotificationServiceImpl.TIMESTAMP_PROPERTY_DOMAIN, true); + WritablePropertyMap pm = PropertyManager.getWritableProperties(NotificationServiceImpl.TIMESTAMP_PROPERTY_DOMAIN, true); pm.put(getKey(n), lastRun.toString()); pm.save(); } @@ -363,7 +364,7 @@ public boolean isActive(Notification n, Container c) public void setActive(Notification n, Container c, boolean active) { - PropertyManager.PropertyMap pm = PropertyManager.getWritableProperties(c, NotificationServiceImpl.STATUS_PROPERTY_DOMAIN, true); + WritablePropertyMap pm = PropertyManager.getWritableProperties(c, NotificationServiceImpl.STATUS_PROPERTY_DOMAIN, true); pm.put(getKey(n), active ? String.valueOf(active) : null); pm.save(); } diff --git a/LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java b/LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java index 37b51b84..64bc49e5 100644 --- a/LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java +++ b/LDK/src/org/labkey/ldk/notification/SiteSummaryNotification.java @@ -19,11 +19,14 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DurationFormatUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.json.JSONArray; import org.json.JSONObject; import org.labkey.api.action.SpringActionController; +import org.labkey.api.assay.AssayProtocolSchema; +import org.labkey.api.assay.AssayProvider; +import org.labkey.api.assay.AssayService; import org.labkey.api.audit.AuditLogService; import org.labkey.api.audit.AuditTypeProvider; import org.labkey.api.data.CompareType; @@ -33,6 +36,7 @@ import org.labkey.api.data.DbSchema; import org.labkey.api.data.DbScope; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SQLFragment; import org.labkey.api.data.Selector; import org.labkey.api.data.SimpleFilter; @@ -55,9 +59,6 @@ import org.labkey.api.settings.LookAndFeelProperties; import org.labkey.api.study.Study; import org.labkey.api.study.StudyService; -import org.labkey.api.assay.AssayProtocolSchema; -import org.labkey.api.assay.AssayProvider; -import org.labkey.api.assay.AssayService; import org.labkey.api.util.JsonUtil; import org.labkey.ldk.LDKServiceImpl; @@ -155,7 +156,7 @@ private String getLastSaveString(Container c, Map map) private void saveValues(Container c, Map saved, Map newValues) { - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(c, PROP_CATEGORY, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(c, PROP_CATEGORY, true); Long lastSaveMills = map.containsKey(lastSave) ? Long.parseLong(map.get(lastSave)) : null; diff --git a/laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java b/laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java index 15daaa64..bc3e7843 100644 --- a/laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java +++ b/laboratory/api-src/org/labkey/api/laboratory/query/ContainerIncrementingTable.java @@ -10,6 +10,7 @@ import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.data.TableSelector; @@ -184,7 +185,7 @@ public Integer getCurrentId(Container c) public void saveId(Container c, Integer value) { Container target = c.isWorkbook() ? c.getParent() : c; - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(target, PROPERT_CATEGORY_BASE, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(target, PROPERT_CATEGORY_BASE, true); map.put(getPropertyKey(), value.toString()); map.save(); } diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryController.java b/laboratory/src/org/labkey/laboratory/LaboratoryController.java index c3335d39..31dedddc 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryController.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryController.java @@ -42,6 +42,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.TableInfo; import org.labkey.api.exp.ChangePropertyDescriptorException; import org.labkey.api.exp.ExperimentException; @@ -1557,7 +1558,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) } Map results = new HashMap<>(); - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(getContainer(), NavItem.PROPERTY_CATEGORY, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(getContainer(), NavItem.PROPERTY_CATEGORY, true); map.clear(); JSONObject json = new JSONObject(form.getJsonData()); @@ -1613,7 +1614,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) } Map results = new HashMap<>(); - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(getContainer(), NavItem.VIEW_PROPERTY_CATEGORY, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(getContainer(), NavItem.VIEW_PROPERTY_CATEGORY, true); JSONObject json = new JSONObject(form.getJsonData()); for (String key : json.keySet()) @@ -1648,7 +1649,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) Map results = new HashMap<>(); - PropertyManager.PropertyMap propMap = PropertyManager.getWritableProperties(getContainer(), TabbedReportItem.OVERRIDES_PROP_KEY, true); + WritablePropertyMap propMap = PropertyManager.getWritableProperties(getContainer(), TabbedReportItem.OVERRIDES_PROP_KEY, true); List tabbedReports = LaboratoryService.get().getTabbedReportItems(getContainer(), getUser()); Map reportMap = new HashMap(); @@ -1707,7 +1708,7 @@ public ApiResponse execute(JsonDataForm form, BindException errors) } Map results = new HashMap<>(); - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(getContainer(), AbstractAssayDataProvider.PROPERTY_CATEGORY, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(getContainer(), AbstractAssayDataProvider.PROPERTY_CATEGORY, true); JSONObject json = new JSONObject(form.getJsonData()); for (String key : json.keySet()) diff --git a/laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java b/laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java index 64c3358b..731216b4 100644 --- a/laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java +++ b/laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java @@ -15,8 +15,8 @@ */ package org.labkey.laboratory; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; import org.json.JSONObject; import org.labkey.api.assay.AssayFileWriter; @@ -27,6 +27,7 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.TableCustomizer; import org.labkey.api.data.TableInfo; import org.labkey.api.exp.ChangePropertyDescriptorException; @@ -402,7 +403,7 @@ public Set getDemographicsSources(Container c, User u) throw public void setDemographicsSources(Container c, User u, Set sources) throws IllegalArgumentException { Container target = c.isWorkbookOrTab() ? c.getParent() : c; - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(target, DEMOGRAPHICS_PROPERTY_CATEGORY, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(target, DEMOGRAPHICS_PROPERTY_CATEGORY, true); props.clear(); Set labels = new HashSet<>(); @@ -541,7 +542,7 @@ public Set getAdditionalDataSources(Container c, User u) t public void setURLDataSources(Container c, User u, Set sources) { Container cc = c.isWorkbookOrTab() ? c.getParent() : c; - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(cc, URL_DATASOURCE_PROPERTY_CATEGORY, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(cc, URL_DATASOURCE_PROPERTY_CATEGORY, true); props.clear(); for (URLDataSource qd : sources) @@ -554,7 +555,7 @@ public void setURLDataSources(Container c, User u, Set sources) public void setAdditionalDataSources(Container c, User u, Set sources) { Container cc = c.isWorkbookOrTab() ? c.getParent() : c; - PropertyManager.PropertyMap props = PropertyManager.getWritableProperties(cc, DATASOURCE_PROPERTY_CATEGORY, true); + WritablePropertyMap props = PropertyManager.getWritableProperties(cc, DATASOURCE_PROPERTY_CATEGORY, true); props.clear(); for (AdditionalDataSource qd : sources) diff --git a/laboratory/src/org/labkey/laboratory/notification/LabSummaryNotification.java b/laboratory/src/org/labkey/laboratory/notification/LabSummaryNotification.java index 8f1fb838..eaa80ccc 100644 --- a/laboratory/src/org/labkey/laboratory/notification/LabSummaryNotification.java +++ b/laboratory/src/org/labkey/laboratory/notification/LabSummaryNotification.java @@ -2,14 +2,15 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.time.DateUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.json.JSONArray; import org.json.JSONObject; import org.labkey.api.action.SpringActionController; import org.labkey.api.data.Container; import org.labkey.api.data.CoreSchema; import org.labkey.api.data.PropertyManager; +import org.labkey.api.data.PropertyManager.WritablePropertyMap; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.data.TableSelector; @@ -102,7 +103,7 @@ private Map getSavedValues(Container c) private void saveValues(Container c, Map saved, Map newValues) { - PropertyManager.PropertyMap map = PropertyManager.getWritableProperties(c, PROP_CATEGORY, true); + WritablePropertyMap map = PropertyManager.getWritableProperties(c, PROP_CATEGORY, true); Long lastSaveMills = map.containsKey(lastSave) ? Long.parseLong(map.get(lastSave)) : null;