Skip to content

Commit c36e99a

Browse files
43246: Lineage query NPE while processing an UploadedFile (#20)
- handle nodes without an row id in the case of orphaned exp.objects - support multiple seeds and additional properties of the lineage node
1 parent 1de8768 commit c36e99a

File tree

4 files changed

+278
-55
lines changed

4 files changed

+278
-55
lines changed

labkey-client-api/CHANGELOG.md

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

3+
## version 1.4.0-SNAPSHOT
4+
*Released*: TBD
5+
* Issue 43246: Lineage query NPE while processing an UploadedFile
6+
* Additional lineage options and support additional properties in response
7+
38
## version 1.3.2
49
*Released* : 05 November 2020
510
* Fix `selectedMetadataInputFormat` serialization

labkey-client-api/src/org/labkey/remoteapi/experiment/LineageCommand.java

Lines changed: 65 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,71 +19,70 @@
1919
import org.labkey.remoteapi.Command;
2020
import org.labkey.remoteapi.Connection;
2121

22+
import java.util.Arrays;
2223
import java.util.HashMap;
24+
import java.util.List;
2325
import java.util.Map;
2426

2527

2628
public class LineageCommand extends Command<LineageResponse>
2729
{
28-
// One of rowId or LSID required
29-
private final Integer _rowId;
30-
private final String _lsid;
30+
// One or more LSIDs are required
31+
private final List<String> _lsids;
3132

33+
// Optional parameters below
3234
private final Boolean _parents;
3335
private final Boolean _children;
3436
private final Integer _depth;
3537
private final String _expType;
3638
private final String _cpasType;
39+
private final Boolean _includeProperties;
40+
private final Boolean _includeInputsAndOutputs;
41+
private final Boolean _includeRunSteps;
3742

38-
private LineageCommand(/*@Nullable*/ Integer rowId, /*@Nullable*/ String lsid, Boolean parents, Boolean children, Integer depth, String cpasType, String expType)
43+
private LineageCommand(
44+
List<String> lsids, Boolean parents, Boolean children, Integer depth, String cpasType, String expType,
45+
Boolean includeProperites, Boolean includeInputsAndOutputs, Boolean includeRunSteps)
3946
{
4047
super("experiment", "lineage");
41-
if (rowId == null && lsid == null)
42-
throw new IllegalArgumentException("One of rowId or lsid required");
48+
if (lsids == null || lsids.isEmpty())
49+
throw new IllegalArgumentException("One or more starting LSIDs required");
4350

44-
if (lsid != null && rowId != null)
45-
throw new IllegalArgumentException("Only one of rowId or lsid allowed");
46-
47-
_rowId = rowId;
48-
_lsid = lsid;
51+
_lsids = lsids;
4952
_depth = depth;
5053
_parents = parents;
5154
_children = children;
5255
_expType = expType;
5356
_cpasType = cpasType;
57+
_includeProperties = includeProperites;
58+
_includeInputsAndOutputs = includeInputsAndOutputs;
59+
_includeRunSteps = includeRunSteps;
5460
}
5561

5662
public static final class Builder
5763
{
58-
private final Integer _rowId;
59-
private final String _lsid;
64+
private final List<String> _lsids;
6065

6166
private Integer _depth;
6267
private Boolean _parents;
6368
private Boolean _children;
6469
private String _expType;
6570
private String _cpasType;
71+
private Boolean _includeProperties;
72+
private Boolean _includeInputsAndOutputs;
73+
private Boolean _includeRunSteps;
6674

6775
public Builder(String lsid)
6876
{
69-
this(lsid, null);
77+
this(Arrays.asList(lsid));
7078
}
7179

72-
public Builder(Integer rowId)
80+
public Builder(List<String> lsids)
7381
{
74-
this(null, rowId);
75-
}
76-
77-
public Builder(String lsid, Integer rowId)
78-
{
79-
if (lsid == null && rowId == null)
80-
throw new IllegalArgumentException("One of rowId or lsid required");
81-
82-
if (lsid != null && rowId != null)
83-
throw new IllegalArgumentException("Only one of rowId or lsid allowed");
82+
if (lsids == null || lsids.isEmpty())
83+
throw new IllegalArgumentException("One or more starting LSIDs required");
8484

85-
_rowId = rowId;
86-
_lsid = lsid;
85+
_lsids = lsids;
8786
}
8887

8988
public Builder setDepth(Integer depth)
@@ -116,9 +115,29 @@ public Builder setCpasType(String cpasType)
116115
return this;
117116
}
118117

118+
public Builder setIncludeProperties(Boolean includeProperties)
119+
{
120+
_includeProperties = includeProperties;
121+
return this;
122+
}
123+
124+
public Builder setIncludeInputsAndOutputs(Boolean includeInputsAndOutputs)
125+
{
126+
_includeInputsAndOutputs = includeInputsAndOutputs;
127+
return this;
128+
}
129+
130+
public Builder setIncludeRunSteps(Boolean includeRunSteps)
131+
{
132+
_includeRunSteps = includeRunSteps;
133+
return this;
134+
}
135+
119136
public LineageCommand build()
120137
{
121-
return new LineageCommand(_rowId, _lsid, _parents, _children, _depth, _cpasType, _expType);
138+
return new LineageCommand(
139+
_lsids, _parents, _children, _depth, _cpasType, _expType,
140+
_includeProperties, _includeInputsAndOutputs, _includeRunSteps);
122141
}
123142
}
124143

@@ -130,10 +149,7 @@ protected LineageResponse createResponse(String text, int statusCode, String con
130149
public Map<String, Object> getParameters()
131150
{
132151
Map<String,Object> params = new HashMap<>();
133-
if (null != _rowId)
134-
params.put("rowId", _rowId);
135-
if (null != _lsid)
136-
params.put("lsid", _lsid);
152+
params.put("lsids", _lsids);
137153
if (null != _parents)
138154
params.put("parents", _parents);
139155
if (null != _children)
@@ -144,6 +160,12 @@ public Map<String, Object> getParameters()
144160
params.put("expType", _expType);
145161
if (null != _cpasType)
146162
params.put("cpasType", _cpasType);
163+
if (null != _includeProperties)
164+
params.put("includeProperties", _includeProperties);
165+
if (null != _includeInputsAndOutputs)
166+
params.put("includeInputsAndOutputs", _includeInputsAndOutputs);
167+
if (null != _includeRunSteps)
168+
params.put("includeRunSteps", _includeRunSteps);
147169

148170
return params;
149171
}
@@ -152,28 +174,27 @@ public Map<String, Object> getParameters()
152174
@Override
153175
public LineageCommand copy()
154176
{
155-
return new LineageCommand(_rowId, _lsid, _parents, _children, _depth, _cpasType, _expType);
177+
return new LineageCommand(_lsids, _parents, _children, _depth, _cpasType, _expType,
178+
_includeProperties, _includeInputsAndOutputs, _includeRunSteps);
156179
}
157180

158181
public static void main(String[] args) throws Exception
159182
{
160183
String url = "http://localhost:8080/labkey";
161-
String folderPath = "/bl";
184+
String folderPath = "/AssayImportProvenance Test";
162185
String user = "kevink@labkey.com";
163186
String password = "xxxxxx";
164187

165-
String lsid = null;
166-
Integer rowId = 7523;
167-
Boolean parents = false;
168-
Boolean children = null;
188+
String lsid = "urn:lsid:labkey.com:GeneralAssayRun.Folder-4780:40166791-3d3f-1039-a854-9b7575483a25";
169189

170-
Builder builder = new Builder(lsid, rowId);
171-
if (parents != null)
172-
builder.setParents(parents);
173-
if (children != null)
174-
builder.setChildren(children);
190+
LineageCommand cmd = new Builder(lsid)
191+
.setParents(false)
192+
.setChildren(true)
193+
.setIncludeProperties(true)
194+
.setIncludeInputsAndOutputs(true)
195+
.setIncludeRunSteps(true)
196+
.build();
175197

176-
LineageCommand cmd = builder.build();
177198
Connection conn = new Connection(url, user, password);
178199
LineageResponse resp = cmd.execute(conn, folderPath);
179200
System.out.println(resp.dump());

0 commit comments

Comments
 (0)