From cf3706512a71af5696bfacea79fda8da995e19bd Mon Sep 17 00:00:00 2001 From: Terry J Hawkins Date: Mon, 6 May 2024 16:31:45 -0500 Subject: [PATCH 1/2] Added displayable property to the lookupValues in the SNDControler.java GetPackagesAction API response --- src/org/labkey/snd/SNDServiceImpl.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/org/labkey/snd/SNDServiceImpl.java b/src/org/labkey/snd/SNDServiceImpl.java index 43f5794f..6c0f610d 100644 --- a/src/org/labkey/snd/SNDServiceImpl.java +++ b/src/org/labkey/snd/SNDServiceImpl.java @@ -56,6 +56,8 @@ import org.labkey.api.snd.SNDService; import org.labkey.api.snd.SuperPackage; import org.labkey.api.util.JsonUtil; +import org.labkey.snd.query.AttributeDataTable; +import org.labkey.snd.query.LookupsTable; import org.labkey.snd.security.SNDSecurityManager; import org.labkey.snd.trigger.SNDTriggerManager; @@ -421,7 +423,6 @@ public JSONObject convertPropertyDescriptorToJson(Container c, User u, GWTProper private JSONArray lookupValuesToJson(Container c, User u, String schema, String query) { JSONArray array = new JSONArray(); - JSONObject jsonObject; UserSchema userSchema = QueryService.get().getUserSchema(u, c, schema); TableInfo table = userSchema.getTable(query); @@ -431,6 +432,7 @@ private JSONArray lookupValuesToJson(Container c, User u, String schema, String // Use the title column for the actual lookup value String title = table.getTitleColumn(); String pk = null; + if (!table.getPkColumnNames().isEmpty()) { pk = table.getPkColumnNames().get(0); @@ -448,19 +450,23 @@ private JSONArray lookupValuesToJson(Container c, User u, String schema, String { TableSelector ts = new TableSelector(table); - Object label; - Object value; try (ResultSet rs = ts.getResultSet()) { while (rs.next()) { - value = rs.getObject(pk); - label = rs.getObject(title); + Object value = rs.getObject(pk); + Object label = rs.getObject(title); - jsonObject = new JSONObject(); + JSONObject jsonObject = new JSONObject(); jsonObject.put("value", value); jsonObject.put("label", label); + Set colNames = table.getColumnNameSet(); + if (colNames.contains("displayable")) { + Object displayable = rs.getObject("displayable"); + jsonObject.put("displayable",displayable); + } + array.put(jsonObject); } } From 9efa394b6e6b5786e5a7f29b2c0135d288a8fd02 Mon Sep 17 00:00:00 2001 From: Terry J Hawkins Date: Mon, 6 May 2024 16:47:00 -0500 Subject: [PATCH 2/2] Removed unused imports --- src/org/labkey/snd/SNDServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/org/labkey/snd/SNDServiceImpl.java b/src/org/labkey/snd/SNDServiceImpl.java index 6c0f610d..0761acbf 100644 --- a/src/org/labkey/snd/SNDServiceImpl.java +++ b/src/org/labkey/snd/SNDServiceImpl.java @@ -56,8 +56,6 @@ import org.labkey.api.snd.SNDService; import org.labkey.api.snd.SuperPackage; import org.labkey.api.util.JsonUtil; -import org.labkey.snd.query.AttributeDataTable; -import org.labkey.snd.query.LookupsTable; import org.labkey.snd.security.SNDSecurityManager; import org.labkey.snd.trigger.SNDTriggerManager;