Skip to content

Commit 9f9ae20

Browse files
committed
Item 6174: New SaveAssayRunCommand, LoadAssayBatchCommand and refactor CreateDomainCommand from legacy code to common place
SVN r64446 |2019-09-06 17:29:14 +0000
1 parent ba7dfe1 commit 9f9ae20

File tree

8 files changed

+323
-12
lines changed

8 files changed

+323
-12
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ java/src/org/labkey/remoteapi/assay/Data.java -text
2424
java/src/org/labkey/remoteapi/assay/ExpObject.java -text
2525
java/src/org/labkey/remoteapi/assay/ImportRunCommand.java -text
2626
java/src/org/labkey/remoteapi/assay/ImportRunResponse.java -text
27+
java/src/org/labkey/remoteapi/assay/LoadAssayBatchCommand.java -text
28+
java/src/org/labkey/remoteapi/assay/LoadAssayBatchResponse.java -text
2729
java/src/org/labkey/remoteapi/assay/Material.java -text
2830
java/src/org/labkey/remoteapi/assay/Run.java -text
2931
java/src/org/labkey/remoteapi/assay/SaveAssayBatchCommand.java -text
3032
java/src/org/labkey/remoteapi/assay/SaveAssayBatchResponse.java -text
33+
java/src/org/labkey/remoteapi/assay/SaveAssayRunCommand.java -text
34+
java/src/org/labkey/remoteapi/assay/SaveAssayRunResponse.java -text
3135
java/src/org/labkey/remoteapi/assay/nab/NAbRunsCommand.java -text
3236
java/src/org/labkey/remoteapi/assay/nab/NAbRunsResponse.java -text
3337
java/src/org/labkey/remoteapi/assay/nab/model/NAbCurveParameters.java -text
@@ -49,6 +53,7 @@ java/src/org/labkey/remoteapi/di/UpdateTransformConfigurationResponse.java -text
4953
java/src/org/labkey/remoteapi/domain/AbstractDomainUpdateCommand.java -text
5054
java/src/org/labkey/remoteapi/domain/CreateDomainCommand.java -text
5155
java/src/org/labkey/remoteapi/domain/Domain.java -text
56+
java/src/org/labkey/remoteapi/domain/DomainCommand.java -text
5257
java/src/org/labkey/remoteapi/domain/DomainResponse.java -text
5358
java/src/org/labkey/remoteapi/domain/DropDomainCommand.java -text
5459
java/src/org/labkey/remoteapi/domain/GetDomainCommand.java -text
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.labkey.remoteapi.assay;
2+
3+
import org.json.simple.JSONObject;
4+
import org.labkey.remoteapi.PostCommand;
5+
6+
7+
/**
8+
* Command for obtaining information about the current batch in a particular folder.
9+
*/
10+
public class LoadAssayBatchCommand extends PostCommand<LoadAssayBatchResponse>
11+
{
12+
13+
private String _protocolName;
14+
private int _batchId;
15+
private Batch _batch;
16+
17+
public Batch getBatch()
18+
{
19+
return _batch;
20+
}
21+
22+
public void setBatch(Batch batch)
23+
{
24+
_batch = batch;
25+
}
26+
27+
public LoadAssayBatchCommand(String protocolName, int batchId)
28+
{
29+
super("assay", "getAssayBatch");
30+
_protocolName = protocolName;
31+
_batchId = batchId;
32+
}
33+
34+
public LoadAssayBatchCommand(LoadAssayBatchCommand source)
35+
{
36+
super(source);
37+
_protocolName = source.getProtocolName();
38+
_batchId = source.getBatchId();
39+
}
40+
41+
public String getProtocolName()
42+
{
43+
return _protocolName;
44+
}
45+
46+
public void setProtocolName(String protocolName)
47+
{
48+
_protocolName = protocolName;
49+
}
50+
51+
public int getBatchId()
52+
{
53+
return _batchId;
54+
}
55+
56+
public void setBatchId(int batchId)
57+
{
58+
_batchId = batchId;
59+
}
60+
61+
@Override
62+
public JSONObject getJsonObject()
63+
{
64+
JSONObject result = new JSONObject();
65+
result.put("protocolName", getProtocolName());
66+
result.put("batchId", getBatchId());
67+
result.put("batch", getBatch());
68+
return result;
69+
}
70+
71+
@Override
72+
public LoadAssayBatchCommand copy()
73+
{
74+
return new LoadAssayBatchCommand(this);
75+
}
76+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 LoadAssayBatchResponse extends CommandResponse
8+
{
9+
/**
10+
* Constructs a new CommandResponse, initialized with the provided
11+
* response text and status code.
12+
*
13+
* @param text The response text
14+
* @param statusCode The HTTP status code
15+
* @param contentType The response content type
16+
* @param json The parsed JSONObject (or null if JSON was not returned).
17+
* @param sourceCommand A copy of the command that created this response
18+
*/
19+
public LoadAssayBatchResponse(String text, int statusCode, String contentType, JSONObject json, Command sourceCommand)
20+
{
21+
super(text, statusCode, contentType, json, sourceCommand);
22+
}
23+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.labkey.remoteapi.assay;
2+
3+
4+
import org.json.simple.JSONArray;
5+
import org.json.simple.JSONObject;
6+
import org.labkey.remoteapi.PostCommand;
7+
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
11+
/**
12+
* Saves runs on the server.
13+
*/
14+
public class SaveAssayRunCommand extends PostCommand<SaveAssayRunResponse>
15+
{
16+
private List<Run> _runs = new ArrayList<Run>();
17+
18+
/**
19+
* @param runs the runs to be saved
20+
*/
21+
public SaveAssayRunCommand(List<Run> runs)
22+
{
23+
super("assay", "saveAssayRun");
24+
_runs = runs;
25+
}
26+
27+
public SaveAssayRunCommand(SaveAssayRunCommand source)
28+
{
29+
super(source);
30+
_runs = source._runs;
31+
}
32+
33+
@Override
34+
public PostCommand copy()
35+
{
36+
return new SaveAssayRunCommand(this);
37+
}
38+
39+
@Override
40+
public JSONObject getJsonObject()
41+
{
42+
JSONObject result = new JSONObject();
43+
JSONArray runs = new JSONArray();
44+
for (Run run : _runs)
45+
{
46+
runs.add(run.toJSONObject());
47+
}
48+
result.put("runs", runs);
49+
return result;
50+
}
51+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 SaveAssayRunResponse extends CommandResponse
8+
{
9+
/**
10+
* Constructs a new CommandResponse, initialized with the provided
11+
* response text and status code.
12+
*
13+
* @param text The response text
14+
* @param statusCode The HTTP status code
15+
* @param contentType The response content type
16+
* @param json The parsed JSONObject (or null if JSON was not returned).
17+
* @param sourceCommand A copy of the command that created this response
18+
*/
19+
public SaveAssayRunResponse(String text, int statusCode, String contentType, JSONObject json, Command sourceCommand)
20+
{
21+
super(text, statusCode, contentType, json, sourceCommand);
22+
}
23+
}
Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package org.labkey.remoteapi.domain;
22

3+
import org.json.simple.JSONArray;
34
import org.json.simple.JSONObject;
45

56
import java.util.HashMap;
67
import java.util.Map;
78

8-
public class CreateDomainCommand extends AbstractDomainUpdateCommand
9+
public class CreateDomainCommand extends DomainCommand
910
{
1011
private String _kind;
1112
private Map<String, Object> _options = new HashMap<>();
@@ -15,17 +16,33 @@ public CreateDomainCommand(String kind, String domainName)
1516
super("property", "createDomain");
1617
_kind = kind;
1718

18-
getDomainDesign().setName(domainName);
19+
setDomainName(domainName);
1920
}
2021

2122
@Override
2223
public JSONObject getJsonObject()
2324
{
2425
JSONObject result = super.getJsonObject();
2526

26-
result.put("kind", _kind);
27+
result.put("kind", getKind());
2728
result.put("options", _options);
2829

30+
JSONArray fields = new JSONArray();
31+
fields.addAll(getColumns());
32+
33+
JSONObject domainDesign = new JSONObject();
34+
domainDesign.put("name", getDomainName());
35+
domainDesign.put("fields", fields);
36+
37+
result.put("domainDesign", domainDesign);
38+
39+
if (!getOptions().isEmpty())
40+
{
41+
JSONObject domainOptions = new JSONObject();
42+
domainOptions.putAll(getOptions());
43+
result.put("options", domainOptions);
44+
}
45+
2946
return result;
3047
}
3148

@@ -39,13 +56,4 @@ public void setKind(String kind)
3956
_kind = kind;
4057
}
4158

42-
public Map<String, Object> getOptions()
43-
{
44-
return _options;
45-
}
46-
47-
public void setOptions(Map<String, Object> options)
48-
{
49-
_options = options;
50-
}
5159
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package org.labkey.remoteapi.domain;
2+
3+
import org.json.simple.JSONObject;
4+
5+
import java.util.ArrayList;
6+
import java.util.HashMap;
7+
import java.util.List;
8+
import java.util.Map;
9+
10+
public class DomainCommand extends AbstractDomainUpdateCommand
11+
{
12+
protected String _schemaName;
13+
protected String _domainName;
14+
private String _domainKind;
15+
private Map<String, String> _options = new HashMap<>();
16+
private List<Map<String, Object>> _columns = new ArrayList<>();
17+
18+
public DomainCommand(String controllerName, String actionName)
19+
{
20+
super(controllerName, actionName);
21+
}
22+
23+
@Override
24+
protected DomainResponse createResponse(String text, int status, String contentType, JSONObject json)
25+
{
26+
return new DomainResponse(text, status, contentType, json, this);
27+
}
28+
29+
public void setColumns(List<Map<String, Object>> columns)
30+
{
31+
_columns = columns;
32+
}
33+
34+
public List<Map<String, Object>> getColumns()
35+
{
36+
return _columns;
37+
}
38+
39+
/**
40+
* Returns the domain name.
41+
* @return The domain name.
42+
*/
43+
public String getDomainName()
44+
{
45+
return _domainName;
46+
}
47+
48+
/**
49+
* Sets the schema name
50+
* @param domainName The domain name.
51+
*/
52+
public void setDomainName(String domainName)
53+
{
54+
_domainName = domainName;
55+
}
56+
57+
/**
58+
* Returns the domain kind.
59+
* @return The domain kind.
60+
*/
61+
public String getDomainKind()
62+
{
63+
return _domainKind;
64+
}
65+
66+
/**
67+
* Sets the domain kind
68+
* @param domainKind The domain kind.
69+
*/
70+
public void setDomainKind(String domainKind)
71+
{
72+
_domainKind = domainKind;
73+
}
74+
75+
/**
76+
* Returns the schema name.
77+
* @return The schema name.
78+
*/
79+
public String getSchemaName()
80+
{
81+
return _schemaName;
82+
}
83+
84+
/**
85+
* Sets the schema name
86+
* @param schemaName The schema name.
87+
*/
88+
public void setSchemaName(String schemaName)
89+
{
90+
_schemaName = schemaName;
91+
}
92+
93+
/**
94+
* sets the domain options, such as keyName
95+
* @param options
96+
*/
97+
public void setOptions(Map options)
98+
{
99+
_options = options;
100+
}
101+
102+
public Map<String, String> getOptions()
103+
{
104+
return _options;
105+
}
106+
107+
}

0 commit comments

Comments
 (0)