Skip to content

Commit 71fbacd

Browse files
committed
Item 6174: New LoadAssayRunCommand to get the runs without a batch
SVN r64467 |2019-09-09 23:48:11 +0000
1 parent 59d5683 commit 71fbacd

File tree

6 files changed

+169
-2
lines changed

6 files changed

+169
-2
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ java/src/org/labkey/remoteapi/assay/ImportRunCommand.java -text
2626
java/src/org/labkey/remoteapi/assay/ImportRunResponse.java -text
2727
java/src/org/labkey/remoteapi/assay/LoadAssayBatchCommand.java -text
2828
java/src/org/labkey/remoteapi/assay/LoadAssayBatchResponse.java -text
29+
java/src/org/labkey/remoteapi/assay/LoadAssayRunCommand.java -text
30+
java/src/org/labkey/remoteapi/assay/LoadAssayRunResponse.java -text
2931
java/src/org/labkey/remoteapi/assay/Material.java -text
3032
java/src/org/labkey/remoteapi/assay/Run.java -text
3133
java/src/org/labkey/remoteapi/assay/SaveAssayBatchCommand.java -text
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.labkey.remoteapi.assay;
2+
3+
4+
import org.json.simple.JSONObject;
5+
import org.labkey.remoteapi.PostCommand;
6+
7+
/**
8+
* Command for obtaining information about a run in a particular folder.
9+
*/
10+
public class LoadAssayRunCommand extends PostCommand<LoadAssayRunResponse>
11+
{
12+
private String _lsid;
13+
14+
public LoadAssayRunCommand(LoadAssayRunCommand source)
15+
{
16+
super(source);
17+
_lsid = source.getLsid();
18+
}
19+
20+
public LoadAssayRunCommand(String lsid)
21+
{
22+
super("experiment", "loadAssayRun");
23+
_lsid = lsid;
24+
}
25+
26+
public String getLsid()
27+
{
28+
return _lsid;
29+
}
30+
31+
public void setLsid(String lsid)
32+
{
33+
_lsid = lsid;
34+
}
35+
36+
@Override
37+
public LoadAssayRunCommand copy()
38+
{
39+
return new LoadAssayRunCommand(this);
40+
}
41+
42+
@Override
43+
public JSONObject getJsonObject()
44+
{
45+
JSONObject result = new JSONObject();
46+
47+
result.put("lsid", _lsid);
48+
return result;
49+
}
50+
51+
@Override
52+
protected LoadAssayRunResponse createResponse(String text, int status, String contentType, JSONObject json)
53+
{
54+
return new LoadAssayRunResponse(text, status, contentType, json, this);
55+
}
56+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.labkey.remoteapi.assay;
2+
3+
import org.json.simple.JSONObject;
4+
import org.labkey.remoteapi.Command;
5+
import org.labkey.remoteapi.CommandResponse;
6+
7+
public class LoadAssayRunResponse extends CommandResponse
8+
{
9+
private Run _run;
10+
11+
public Run getRun()
12+
{
13+
return _run;
14+
}
15+
16+
public void setRun(Run run)
17+
{
18+
_run = run;
19+
}
20+
21+
/**
22+
* Constructs a new CommandResponse, initialized with the provided
23+
* response text and status code.
24+
*
25+
* @param text The response text
26+
* @param statusCode The HTTP status code
27+
* @param contentType The response content type
28+
* @param json The parsed JSONObject (or null if JSON was not returned).
29+
* @param sourceCommand A copy of the command that created this response
30+
*/
31+
public LoadAssayRunResponse(String text, int statusCode, String contentType, JSONObject json, Command sourceCommand)
32+
{
33+
super(text, statusCode, contentType, json, sourceCommand);
34+
JSONObject runJson = (JSONObject) json.get("run");
35+
_run = new Run();
36+
37+
_run.setName((String) runJson.get("name"));
38+
_run.setLsid((String) runJson.get("lsid"));
39+
}
40+
}

java/src/org/labkey/remoteapi/assay/Run.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Run extends ExpObject
3434
private List<Data> _dataOutputs = new ArrayList<Data>();
3535
private List<Material> _materialInputs = new ArrayList<>();
3636
private List<Material> _materialOutputs = new ArrayList<>();
37+
private String _lsid;
3738

3839
// Used when inserting new data via SaveAssayBatchAction
3940
private List<Map<String, Object>> _resultData;
@@ -83,6 +84,12 @@ public Run(JSONObject json)
8384
}
8485
}
8586
_comment = (String)json.get("comment");
87+
88+
if (json.containsKey("lsid"))
89+
{
90+
_lsid = (String) json.get("lsid");
91+
}
92+
8693
}
8794

8895
@Override
@@ -103,6 +110,7 @@ public JSONObject toJSONObject()
103110
}
104111
result.put("dataOutputs", dataOutputs);
105112
result.put("comment", _comment);
113+
result.put("lsid", _lsid);
106114

107115
JSONArray materialInputs = new JSONArray();
108116
JSONArray materialOutputs = new JSONArray();
@@ -198,4 +206,14 @@ public void setResultData(List<Map<String, Object>> resultData)
198206
{
199207
_resultData = resultData;
200208
}
209+
210+
public String getLsid()
211+
{
212+
return _lsid;
213+
}
214+
215+
public void setLsid(String lsid)
216+
{
217+
_lsid = lsid;
218+
}
201219
}

java/src/org/labkey/remoteapi/assay/SaveAssayRunCommand.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
*/
1414
public class SaveAssayRunCommand extends PostCommand<SaveAssayRunResponse>
1515
{
16-
private List<Run> _runs = new ArrayList<Run>();
16+
private List<Run> _runs;
17+
private String _protocolName;
1718

1819
/**
1920
* @param runs the runs to be saved
2021
*/
21-
public SaveAssayRunCommand(List<Run> runs)
22+
public SaveAssayRunCommand(String protocolName, List<Run> runs)
2223
{
2324
super("assay", "saveAssayRun");
2425
_runs = runs;
26+
_protocolName = protocolName;
2527
}
2628

2729
public SaveAssayRunCommand(SaveAssayRunCommand source)
@@ -46,6 +48,33 @@ public JSONObject getJsonObject()
4648
runs.add(run.toJSONObject());
4749
}
4850
result.put("runs", runs);
51+
result.put("protocolName", getProtocolName());
4952
return result;
5053
}
54+
55+
@Override
56+
protected SaveAssayRunResponse createResponse(String text, int status, String contentType, JSONObject json)
57+
{
58+
return new SaveAssayRunResponse(text, status, contentType, json, this);
59+
}
60+
61+
public List<Run> getRuns()
62+
{
63+
return _runs;
64+
}
65+
66+
public void setRuns(List<Run> runs)
67+
{
68+
_runs = runs;
69+
}
70+
71+
public String getProtocolName()
72+
{
73+
return _protocolName;
74+
}
75+
76+
public void setProtocolName(String protocolName)
77+
{
78+
_protocolName = protocolName;
79+
}
5180
}

java/src/org/labkey/remoteapi/assay/SaveAssayRunResponse.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package org.labkey.remoteapi.assay;
22

3+
import org.json.simple.JSONArray;
34
import org.json.simple.JSONObject;
45
import org.labkey.remoteapi.Command;
56
import org.labkey.remoteapi.CommandResponse;
67

8+
import java.util.ArrayList;
9+
import java.util.List;
10+
711
public class SaveAssayRunResponse extends CommandResponse
812
{
13+
private List<Run> _runs = new ArrayList<>();
14+
915
/**
1016
* Constructs a new CommandResponse, initialized with the provided
1117
* response text and status code.
@@ -19,5 +25,21 @@ public class SaveAssayRunResponse extends CommandResponse
1925
public SaveAssayRunResponse(String text, int statusCode, String contentType, JSONObject json, Command sourceCommand)
2026
{
2127
super(text, statusCode, contentType, json, sourceCommand);
28+
JSONArray array = (JSONArray)json.get("runs");
29+
for (Object o : array)
30+
{
31+
JSONObject run = (JSONObject) o;
32+
_runs.add(new Run(run));
33+
}
34+
}
35+
36+
public List<Run> getRuns()
37+
{
38+
return _runs;
39+
}
40+
41+
public void setRuns(List<Run> runs)
42+
{
43+
_runs = runs;
2244
}
2345
}

0 commit comments

Comments
 (0)