19
19
import org .labkey .remoteapi .Command ;
20
20
import org .labkey .remoteapi .Connection ;
21
21
22
+ import java .util .Arrays ;
22
23
import java .util .HashMap ;
24
+ import java .util .List ;
23
25
import java .util .Map ;
24
26
25
27
26
28
public class LineageCommand extends Command <LineageResponse >
27
29
{
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 ;
31
32
33
+ // Optional parameters below
32
34
private final Boolean _parents ;
33
35
private final Boolean _children ;
34
36
private final Integer _depth ;
35
37
private final String _expType ;
36
38
private final String _cpasType ;
39
+ private final Boolean _includeProperties ;
40
+ private final Boolean _includeInputsAndOutputs ;
41
+ private final Boolean _includeRunSteps ;
37
42
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 )
39
46
{
40
47
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" );
43
50
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 ;
49
52
_depth = depth ;
50
53
_parents = parents ;
51
54
_children = children ;
52
55
_expType = expType ;
53
56
_cpasType = cpasType ;
57
+ _includeProperties = includeProperites ;
58
+ _includeInputsAndOutputs = includeInputsAndOutputs ;
59
+ _includeRunSteps = includeRunSteps ;
54
60
}
55
61
56
62
public static final class Builder
57
63
{
58
- private final Integer _rowId ;
59
- private final String _lsid ;
64
+ private final List <String > _lsids ;
60
65
61
66
private Integer _depth ;
62
67
private Boolean _parents ;
63
68
private Boolean _children ;
64
69
private String _expType ;
65
70
private String _cpasType ;
71
+ private Boolean _includeProperties ;
72
+ private Boolean _includeInputsAndOutputs ;
73
+ private Boolean _includeRunSteps ;
66
74
67
75
public Builder (String lsid )
68
76
{
69
- this (lsid , null );
77
+ this (Arrays . asList ( lsid ) );
70
78
}
71
79
72
- public Builder (Integer rowId )
80
+ public Builder (List < String > lsids )
73
81
{
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" );
84
84
85
- _rowId = rowId ;
86
- _lsid = lsid ;
85
+ _lsids = lsids ;
87
86
}
88
87
89
88
public Builder setDepth (Integer depth )
@@ -116,9 +115,29 @@ public Builder setCpasType(String cpasType)
116
115
return this ;
117
116
}
118
117
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
+
119
136
public LineageCommand build ()
120
137
{
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 );
122
141
}
123
142
}
124
143
@@ -130,10 +149,7 @@ protected LineageResponse createResponse(String text, int statusCode, String con
130
149
public Map <String , Object > getParameters ()
131
150
{
132
151
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 );
137
153
if (null != _parents )
138
154
params .put ("parents" , _parents );
139
155
if (null != _children )
@@ -144,6 +160,12 @@ public Map<String, Object> getParameters()
144
160
params .put ("expType" , _expType );
145
161
if (null != _cpasType )
146
162
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 );
147
169
148
170
return params ;
149
171
}
@@ -152,28 +174,27 @@ public Map<String, Object> getParameters()
152
174
@ Override
153
175
public LineageCommand copy ()
154
176
{
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 );
156
179
}
157
180
158
181
public static void main (String [] args ) throws Exception
159
182
{
160
183
String url = "http://localhost:8080/labkey" ;
161
- String folderPath = "/bl " ;
184
+ String folderPath = "/AssayImportProvenance Test " ;
162
185
String user = "kevink@labkey.com" ;
163
186
String password = "xxxxxx" ;
164
187
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" ;
169
189
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 ();
175
197
176
- LineageCommand cmd = builder .build ();
177
198
Connection conn = new Connection (url , user , password );
178
199
LineageResponse resp = cmd .execute (conn , folderPath );
179
200
System .out .println (resp .dump ());
0 commit comments