Skip to content

Commit 5a9cc7b

Browse files
committed
support for domains in java client api
SVN r64433 |2019-09-04 19:10:47 +0000
1 parent 1745af9 commit 5a9cc7b

File tree

9 files changed

+621
-0
lines changed

9 files changed

+621
-0
lines changed

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ java/src/org/labkey/remoteapi/di/RunTransformCommand.java -text
4646
java/src/org/labkey/remoteapi/di/RunTransformResponse.java -text
4747
java/src/org/labkey/remoteapi/di/UpdateTransformConfigurationCommand.java -text
4848
java/src/org/labkey/remoteapi/di/UpdateTransformConfigurationResponse.java -text
49+
java/src/org/labkey/remoteapi/domain/AbstractDomainUpdateCommand.java -text
50+
java/src/org/labkey/remoteapi/domain/CreateDomainCommand.java -text
51+
java/src/org/labkey/remoteapi/domain/Domain.java -text
52+
java/src/org/labkey/remoteapi/domain/DomainResponse.java -text
53+
java/src/org/labkey/remoteapi/domain/DropDomainCommand.java -text
54+
java/src/org/labkey/remoteapi/domain/GetDomainCommand.java -text
55+
java/src/org/labkey/remoteapi/domain/PropertyDescriptor.java -text
56+
java/src/org/labkey/remoteapi/domain/SaveDomainCommand.java -text
4957
java/src/org/labkey/remoteapi/experiment/LineageCommand.java -text
5058
java/src/org/labkey/remoteapi/experiment/LineageNode.java -text
5159
java/src/org/labkey/remoteapi/experiment/LineageResponse.java -text
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.labkey.remoteapi.domain;
2+
3+
import org.json.simple.JSONObject;
4+
import org.labkey.remoteapi.PostCommand;
5+
6+
abstract class AbstractDomainUpdateCommand extends PostCommand<DomainResponse>
7+
{
8+
private Domain _design = new Domain();
9+
10+
public AbstractDomainUpdateCommand(String controllerName, String actionName)
11+
{
12+
super(controllerName, actionName);
13+
}
14+
15+
@Override
16+
protected DomainResponse createResponse(String text, int status, String contentType, JSONObject json)
17+
{
18+
return new DomainResponse(text, status, contentType, json, this);
19+
}
20+
21+
@Override
22+
public JSONObject getJsonObject()
23+
{
24+
JSONObject result = new JSONObject();
25+
26+
result.put("domainDesign", _design.toJSONObject());
27+
28+
return result;
29+
}
30+
31+
public Domain getDomainDesign()
32+
{
33+
return _design;
34+
}
35+
36+
public void setDomainDesign(Domain design)
37+
{
38+
_design = design;
39+
}
40+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.labkey.remoteapi.domain;
2+
3+
import org.json.simple.JSONObject;
4+
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
8+
public class CreateDomainCommand extends AbstractDomainUpdateCommand
9+
{
10+
private String _kind;
11+
private Map<String, Object> _options = new HashMap<>();
12+
13+
public CreateDomainCommand(String kind, String domainName)
14+
{
15+
super("property", "createDomain");
16+
_kind = kind;
17+
18+
getDomainDesign().setName(domainName);
19+
}
20+
21+
@Override
22+
public JSONObject getJsonObject()
23+
{
24+
JSONObject result = super.getJsonObject();
25+
26+
result.put("kind", _kind);
27+
result.put("options", _options);
28+
29+
return result;
30+
}
31+
32+
public String getKind()
33+
{
34+
return _kind;
35+
}
36+
37+
public void setKind(String kind)
38+
{
39+
_kind = kind;
40+
}
41+
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+
}
51+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package org.labkey.remoteapi.domain;
2+
3+
import org.json.simple.JSONArray;
4+
import org.json.simple.JSONObject;
5+
import org.labkey.remoteapi.ResponseObject;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
public class Domain extends ResponseObject
11+
{
12+
private String _name;
13+
private String _description;
14+
private Long _domainId;
15+
private String _domainURI;
16+
private List<PropertyDescriptor> _fields = new ArrayList<>();
17+
18+
public Domain()
19+
{
20+
super(null);
21+
}
22+
23+
public Domain(String name)
24+
{
25+
super(null);
26+
_name = name;
27+
}
28+
29+
public Domain(JSONObject json)
30+
{
31+
super(json);
32+
33+
_name = (String)json.get("name");
34+
_description = (String)json.get("description");
35+
_domainId = (Long)json.get("domainId");
36+
_domainURI = (String)json.get("domainURI");
37+
38+
if (json.get("fields") instanceof JSONArray)
39+
{
40+
for (Object field : ((JSONArray)json.get("fields")))
41+
{
42+
_fields.add(new PropertyDescriptor((JSONObject)field));
43+
}
44+
}
45+
46+
_allProperties.remove("success");
47+
_allProperties.remove("failure");
48+
}
49+
50+
public JSONObject toJSONObject()
51+
{
52+
JSONObject result = new JSONObject();
53+
54+
if (getAllProperties() != null)
55+
result.putAll(getAllProperties());
56+
57+
result.put("name", _name);
58+
result.put("description", _description);
59+
result.put("domainId", _domainId);
60+
result.put("domainURI", _domainURI);
61+
62+
JSONArray fields = new JSONArray();
63+
result.put("fields", fields);
64+
for (PropertyDescriptor field : _fields)
65+
{
66+
fields.add(field.toJSONObject());
67+
}
68+
return result;
69+
}
70+
71+
public String getName()
72+
{
73+
return _name;
74+
}
75+
76+
public void setName(String name)
77+
{
78+
_name = name;
79+
}
80+
81+
public String getDescription()
82+
{
83+
return _description;
84+
}
85+
86+
public void setDescription(String description)
87+
{
88+
_description = description;
89+
}
90+
91+
public Long getDomainId()
92+
{
93+
return _domainId;
94+
}
95+
96+
public void setDomainId(Long domainId)
97+
{
98+
_domainId = domainId;
99+
}
100+
101+
public String getDomainURI()
102+
{
103+
return _domainURI;
104+
}
105+
106+
public void setDomainURI(String domainURI)
107+
{
108+
_domainURI = domainURI;
109+
}
110+
111+
public List<PropertyDescriptor> getFields()
112+
{
113+
return _fields;
114+
}
115+
116+
public void setFields(List<PropertyDescriptor> fields)
117+
{
118+
_fields = fields;
119+
}
120+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.labkey.remoteapi.domain;
2+
3+
import org.json.simple.JSONObject;
4+
import org.labkey.remoteapi.Command;
5+
import org.labkey.remoteapi.CommandResponse;
6+
7+
public class DomainResponse extends CommandResponse
8+
{
9+
private Domain _domain;
10+
11+
public DomainResponse(String text, int statusCode, String contentType, JSONObject json, Command sourceCommand)
12+
{
13+
super(text, statusCode, contentType, json, sourceCommand);
14+
_domain = new Domain(json);
15+
}
16+
17+
public Domain getDomain()
18+
{
19+
return _domain;
20+
}
21+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.labkey.remoteapi.domain;
2+
3+
import org.json.simple.JSONObject;
4+
import org.labkey.remoteapi.PostCommand;
5+
6+
public class DropDomainCommand extends PostCommand
7+
{
8+
private String _schemaName;
9+
private String _queryName;
10+
11+
public DropDomainCommand(String schemaName, String queryName)
12+
{
13+
super("property", "deleteDomain");
14+
_schemaName = schemaName;
15+
_queryName = queryName;
16+
}
17+
18+
public String getQueryName()
19+
{
20+
return _queryName;
21+
}
22+
23+
public void setQueryName(String queryName)
24+
{
25+
_queryName = queryName;
26+
}
27+
28+
public String getSchemaName()
29+
{
30+
return _schemaName;
31+
}
32+
33+
public void setSchemaName(String schemaName)
34+
{
35+
_schemaName = schemaName;
36+
}
37+
38+
@Override
39+
public JSONObject getJsonObject()
40+
{
41+
JSONObject json = new JSONObject();
42+
json.put("schemaName", getSchemaName());
43+
json.put("queryName", getQueryName());
44+
45+
return json;
46+
}
47+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package org.labkey.remoteapi.domain;
2+
3+
import org.json.simple.JSONObject;
4+
import org.labkey.remoteapi.Command;
5+
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
9+
public class GetDomainCommand extends Command<DomainResponse>
10+
{
11+
private String _schemaName;
12+
private String _queryName;
13+
private Long _domainId;
14+
15+
public GetDomainCommand(String schemaName, String queryName)
16+
{
17+
super("property", "getDomain");
18+
_schemaName = schemaName;
19+
_queryName = queryName;
20+
}
21+
22+
public GetDomainCommand(Long domainId)
23+
{
24+
super("property", "getDomain");
25+
_domainId = domainId;
26+
}
27+
28+
public GetDomainCommand(Command<DomainResponse> source)
29+
{
30+
super(source);
31+
}
32+
33+
@Override
34+
public Map<String, Object> getParameters()
35+
{
36+
Map<String,Object> params = new HashMap<String,Object>();
37+
38+
if (_schemaName != null && _queryName != null)
39+
{
40+
params.put("schemaName", _schemaName);
41+
params.put("queryName", _queryName);
42+
}
43+
else if (_domainId != null)
44+
{
45+
params.put("domainId", _domainId);
46+
}
47+
return params;
48+
}
49+
50+
@Override
51+
protected DomainResponse createResponse(String text, int status, String contentType, JSONObject json)
52+
{
53+
return new DomainResponse(text, status, contentType, json, this);
54+
}
55+
56+
public String getSchemaName()
57+
{
58+
return _schemaName;
59+
}
60+
61+
public void setSchemaName(String schemaName)
62+
{
63+
_schemaName = schemaName;
64+
}
65+
66+
public String getQueryName()
67+
{
68+
return _queryName;
69+
}
70+
71+
public void setQueryName(String queryName)
72+
{
73+
_queryName = queryName;
74+
}
75+
76+
public Long getDomainId()
77+
{
78+
return _domainId;
79+
}
80+
81+
public void setDomainId(Long domainId)
82+
{
83+
_domainId = domainId;
84+
}
85+
}

0 commit comments

Comments
 (0)