Skip to content

Commit ce3d889

Browse files
authored
Fix NPE when saving assay protocol with transform scripts (#27)
1 parent c30ac78 commit ce3d889

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

labkey-client-api/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# The LabKey Remote API Library for Java - Change Log
22

3+
## version 1.5.1
4+
*Released*: TBD
5+
* Fix NPE when saving assay protocol with transform scripts
6+
37
## version 1.5.0
48
*Released*: 20 April 2022
59
* Update gradle and various dependencies

labkey-client-api/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ repositories {
5757

5858
group "org.labkey.api"
5959

60-
version "1.6.0-SNAPSHOT"
60+
version "1.5.1-SNAPSHOT"
6161

6262
dependencies {
6363
implementation "org.apache.httpcomponents:httpmime:${httpmimeVersion}"

labkey-client-api/src/org/labkey/remoteapi/assay/Protocol.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Protocol extends ResponseObject
4040
private Map<String, String> _availableMetadataInputFormats;
4141
private String _selectedMetadataInputFormat;
4242

43-
private List<String> _availablePlateTemplates = new ArrayList<>();
43+
private List<String> _availablePlateTemplates;
4444
private String _selectedPlateTemplate;
4545

4646
private Map<String, String> _protocolParameters;
@@ -90,31 +90,22 @@ public Protocol(JSONObject json)
9090
_autoCopyTargetContainerId = (String)json.get("autoCopyTargetContainerId");
9191

9292
if (json.get("availableDetectionMethods") instanceof JSONArray)
93-
{
94-
for (Object detectionMethod : (JSONArray)json.get("availableDetectionMethods"))
95-
_availableDetectionMethods.add((String)detectionMethod);
96-
}
93+
_availableDetectionMethods = new ArrayList<>((JSONArray)json.get("availableDetectionMethods"));
9794
if (json.containsKey("selectedDetectionMethod"))
9895
_selectedDetectionMethod = (String)json.get("selectedDetectionMethod");
99-
if (json.containsKey("availableMetadataInputFormats"))
100-
_availableMetadataInputFormats = (HashMap<String,String>)json.get("availableMetadataInputFormats");
96+
if (json.get("availableMetadataInputFormats") instanceof JSONObject)
97+
_availableMetadataInputFormats = new HashMap<>((JSONObject)json.get("availableMetadataInputFormats"));
10198
if (json.containsKey("selectedMetadataInputFormat"))
10299
_selectedMetadataInputFormat = (String)json.get("selectedMetadataInputFormat");
103100
if (json.get("availablePlateTemplates") instanceof JSONArray)
104-
{
105-
for (Object plateTemplate : (JSONArray)json.get("availablePlateTemplates"))
106-
_availablePlateTemplates.add((String)plateTemplate);
107-
}
101+
_availablePlateTemplates = new ArrayList<>((JSONArray)json.get("availablePlateTemplates"));
108102
if (json.containsKey("selectedPlateTemplate"))
109103
_selectedPlateTemplate = (String)json.get("selectedPlateTemplate");
110104

111-
if (json.get("protocolTransformScripts") instanceof JSONArray)
112-
{
113-
for (Object transformScript : (JSONArray)json.get("protocolTransformScripts"))
114-
_protocolTransformScripts.add((String)transformScript);
115-
}
105+
if (json.containsKey("protocolTransformScripts"))
106+
_protocolTransformScripts = new ArrayList<>((JSONArray)json.get("protocolTransformScripts"));
116107
if (json.containsKey("protocolParameters"))
117-
_protocolParameters = (HashMap<String,String>)json.get("protocolParameters");
108+
_protocolParameters = new HashMap<>((JSONObject) json.get("protocolParameters"));
118109
}
119110

120111
public JSONObject toJSONObject()
@@ -318,6 +309,11 @@ public String getSelectedDetectionMethod()
318309
return _selectedDetectionMethod;
319310
}
320311

312+
public Map<String, String> getAvailableMetadataInputFormats()
313+
{
314+
return _availableMetadataInputFormats;
315+
}
316+
321317
public Protocol setSelectedMetadataInputFormat(String inputFormat)
322318
{
323319
_selectedMetadataInputFormat = inputFormat;

0 commit comments

Comments
 (0)