• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

common-workflow-language / cwljava / #394

31 Oct 2025 04:10PM UTC coverage: 57.972% (-1.6%) from 59.538%
#394

push

github

mr-c
rename package to a namespace that we control

7575 of 12994 new or added lines in 261 files covered. (58.3%)

7752 of 13372 relevant lines covered (57.97%)

0.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.63
/src/main/java/org/commonwl/cwlsdk/cwl1_2/WorkflowStepImpl.java
1
// Copyright Common Workflow Language project contributors
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
package org.commonwl.cwlsdk.cwl1_2;
16

17
import org.commonwl.cwlsdk.cwl1_2.utils.LoaderInstances;
18
import org.commonwl.cwlsdk.cwl1_2.utils.LoadingOptions;
19
import org.commonwl.cwlsdk.cwl1_2.utils.LoadingOptionsBuilder;
20
import org.commonwl.cwlsdk.cwl1_2.utils.SaveableImpl;
21
import org.commonwl.cwlsdk.cwl1_2.utils.ValidationException;
22

23
/**
24
* Auto-generated class implementation for <I>https://w3id.org/cwl/cwl#WorkflowStep</I><BR> <BLOCKQUOTE>
25
 A workflow step is an executable element of a workflow.  It specifies the
26
 underlying process implementation (such as `CommandLineTool` or another
27
 `Workflow`) in the `run` field and connects the input and output parameters
28
 of the underlying process to workflow parameters.
29
 
30
 # Scatter/gather
31
 
32
 To use scatter/gather,
33
 [ScatterFeatureRequirement](#ScatterFeatureRequirement) must be specified
34
 in the workflow or workflow step requirements.
35
 
36
 A "scatter" operation specifies that the associated workflow step or
37
 subworkflow should execute separately over a list of input elements.  Each
38
 job making up a scatter operation is independent and may be executed
39
 concurrently.
40
 
41
 The `scatter` field specifies one or more input parameters which will be
42
 scattered.  An input parameter may be listed more than once.  The declared
43
 type of each input parameter implicitly becomes an array of items of the
44
 input parameter type.  If a parameter is listed more than once, it becomes
45
 a nested array.  As a result, upstream parameters which are connected to
46
 scattered parameters must be arrays.
47
 
48
 All output parameter types are also implicitly wrapped in arrays.  Each job
49
 in the scatter results in an entry in the output array.
50
 
51
 If any scattered parameter runtime value is an empty array, all outputs are
52
 set to empty arrays and no work is done for the step, according to
53
 applicable scattering rules.
54
 
55
 If `scatter` declares more than one input parameter, `scatterMethod`
56
 describes how to decompose the input into a discrete set of jobs.
57
 
58
   * **dotproduct** specifies that each of the input arrays are aligned and one
59
       element taken from each array to construct each job.  It is an error
60
       if all input arrays are not the same length.
61
 
62
   * **nested_crossproduct** specifies the Cartesian product of the inputs,
63
       producing a job for every combination of the scattered inputs.  The
64
       output must be nested arrays for each level of scattering, in the
65
       order that the input arrays are listed in the `scatter` field.
66
 
67
   * **flat_crossproduct** specifies the Cartesian product of the inputs,
68
       producing a job for every combination of the scattered inputs.  The
69
       output arrays must be flattened to a single level, but otherwise listed in the
70
       order that the input arrays are listed in the `scatter` field.
71
 
72
 # Conditional execution (Optional)
73
 
74
 Conditional execution makes execution of a step conditional on an
75
 expression.  A step that is not executed is "skipped".  A skipped
76
 step produces `null` for all output parameters.
77
 
78
 The condition is evaluated after `scatter`, using the input object
79
 of each individual scatter job.  This means over a set of scatter
80
 jobs, some may be executed and some may be skipped.  When the
81
 results are gathered, skipped steps must be `null` in the output
82
 arrays.
83
 
84
 The `when` field controls conditional execution.  This is an
85
 expression that must be evaluated with `inputs` bound to the step
86
 input object (or individual scatter job), and returns a boolean
87
 value.  It is an error if this expression returns a value other
88
 than `true` or `false`.
89
 
90
 Conditionals in CWL are an optional feature and are not required
91
 to be implemented by all consumers of CWL documents.  An
92
 implementation that does not support conditionals must return a
93
 fatal error when attempting to execute a workflow that uses
94
 conditional constructs the implementation does not support.
95
 
96
 # Subworkflows
97
 
98
 To specify a nested workflow as part of a workflow step,
99
 [SubworkflowFeatureRequirement](#SubworkflowFeatureRequirement) must be
100
 specified in the workflow or workflow step requirements.
101
 
102
 It is a fatal error if a workflow directly or indirectly invokes itself as
103
 a subworkflow (recursive workflows are not allowed).
104
  </BLOCKQUOTE>
105
 */
106
public class WorkflowStepImpl extends SaveableImpl implements WorkflowStep {
107
  private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build();
1✔
108
  private java.util.Map<String, Object> extensionFields_ =
1✔
109
      new java.util.HashMap<String, Object>();
110
  public LoadingOptions getLoadingOptions() {
NEW
111
    return this.loadingOptions_;
×
112
  }
113
  public java.util.Map<String, Object> getExtensionFields() {
NEW
114
    return this.extensionFields_;
×
115
  }
116

117
  private java.util.Optional<String> id;
118

119
  /**
120
   * Getter for property <I>https://w3id.org/cwl/cwl#Identified/id</I><BR>
121
   * <BLOCKQUOTE>
122
   * The unique identifier for this object.   * </BLOCKQUOTE>
123
   */
124

125
  public java.util.Optional<String> getId() {
NEW
126
    return this.id;
×
127
  }
128

129
  private java.util.Optional<String> label;
130

131
  /**
132
   * Getter for property <I>https://w3id.org/cwl/cwl#Labeled/label</I><BR>
133
   * <BLOCKQUOTE>
134
   * A short, human-readable label of this object.   * </BLOCKQUOTE>
135
   */
136

137
  public java.util.Optional<String> getLabel() {
NEW
138
    return this.label;
×
139
  }
140

141
  private Object doc;
142

143
  /**
144
   * Getter for property <I>https://w3id.org/cwl/salad#Documented/doc</I><BR>
145
   * <BLOCKQUOTE>
146
   * A documentation string for this object, or an array of strings which should be concatenated.   * </BLOCKQUOTE>
147
   */
148

149
  public Object getDoc() {
NEW
150
    return this.doc;
×
151
  }
152

153
  private java.util.List<Object> in;
154

155
  /**
156
   * Getter for property <I>https://w3id.org/cwl/cwl#in</I><BR>
157
   * <BLOCKQUOTE>
158
   * Defines the input parameters of the workflow step.  The process is ready to
159
   * run when all required input parameters are associated with concrete
160
   * values.  Input parameters include a schema for each parameter which is
161
   * used to validate the input object.  It may also be used build a user
162
   * interface for constructing the input object.
163
   *    * </BLOCKQUOTE>
164
   */
165

166
  public java.util.List<Object> getIn() {
167
    return this.in;
1✔
168
  }
169

170
  private java.util.List<Object> out;
171

172
  /**
173
   * Getter for property <I>https://w3id.org/cwl/cwl#out</I><BR>
174
   * <BLOCKQUOTE>
175
   * Defines the parameters representing the output of the process.  May be
176
   * used to generate and/or validate the output object.
177
   *    * </BLOCKQUOTE>
178
   */
179

180
  public java.util.List<Object> getOut() {
NEW
181
    return this.out;
×
182
  }
183

184
  private java.util.Optional<java.util.List<Object>> requirements;
185

186
  /**
187
   * Getter for property <I>https://w3id.org/cwl/cwl#requirements</I><BR>
188
   * <BLOCKQUOTE>
189
   * Declares requirements that apply to either the runtime environment or the
190
   * workflow engine that must be met in order to execute this workflow step.  If
191
   * an implementation cannot satisfy all requirements, or a requirement is
192
   * listed which is not recognized by the implementation, it is a fatal
193
   * error and the implementation must not attempt to run the process,
194
   * unless overridden at user option.
195
   *    * </BLOCKQUOTE>
196
   */
197

198
  public java.util.Optional<java.util.List<Object>> getRequirements() {
NEW
199
    return this.requirements;
×
200
  }
201

202
  private java.util.Optional<java.util.List<Object>> hints;
203

204
  /**
205
   * Getter for property <I>https://w3id.org/cwl/cwl#hints</I><BR>
206
   * <BLOCKQUOTE>
207
   * Declares hints applying to either the runtime environment or the
208
   * workflow engine that may be helpful in executing this workflow step.  It is
209
   * not an error if an implementation cannot satisfy all hints, however
210
   * the implementation may report a warning.
211
   *    * </BLOCKQUOTE>
212
   */
213

214
  public java.util.Optional<java.util.List<Object>> getHints() {
NEW
215
    return this.hints;
×
216
  }
217

218
  private Object run;
219

220
  /**
221
   * Getter for property <I>https://w3id.org/cwl/cwl#run</I><BR>
222
   * <BLOCKQUOTE>
223
   * Specifies the process to run.  If `run` is a string, it must be an absolute IRI
224
   * or a relative path from the primary document.
225
   *    * </BLOCKQUOTE>
226
   */
227

228
  public Object getRun() {
NEW
229
    return this.run;
×
230
  }
231

232
  private java.util.Optional<String> when;
233

234
  /**
235
   * Getter for property <I>https://w3id.org/cwl/cwl#WorkflowStep/when</I><BR>
236
   * <BLOCKQUOTE>
237
   * If defined, only run the step when the expression evaluates to
238
   * `true`.  If `false` the step is skipped.  A skipped step
239
   * produces a `null` on each output.
240
   *    * </BLOCKQUOTE>
241
   */
242

243
  public java.util.Optional<String> getWhen() {
NEW
244
    return this.when;
×
245
  }
246

247
  private Object scatter;
248

249
  /**
250
   * Getter for property <I>https://w3id.org/cwl/cwl#scatter</I><BR>
251

252
   */
253

254
  public Object getScatter() {
NEW
255
    return this.scatter;
×
256
  }
257

258
  private java.util.Optional<ScatterMethod> scatterMethod;
259

260
  /**
261
   * Getter for property <I>https://w3id.org/cwl/cwl#scatterMethod</I><BR>
262
   * <BLOCKQUOTE>
263
   * Required if `scatter` is an array of more than one element.
264
   *    * </BLOCKQUOTE>
265
   */
266

267
  public java.util.Optional<ScatterMethod> getScatterMethod() {
NEW
268
    return this.scatterMethod;
×
269
  }
270

271
  /**
272
   * Used by {@link org.commonwl.cwlsdk.cwl1_2.utils.RootLoader} to construct instances of WorkflowStepImpl.
273
   *
274
   * @param __doc_            Document fragment to load this record object from (presumably a
275
                              {@link java.util.Map}).
276
   * @param __baseUri_        Base URI to generate child document IDs against.
277
   * @param __loadingOptions  Context for loading URIs and populating objects.
278
   * @param __docRoot_        ID at this position in the document (if available) (maybe?)
279
   * @throws ValidationException If the document fragment is not a {@link java.util.Map}
280
   *                             or validation of fields fails.
281
   */
282
  public WorkflowStepImpl(
283
      final Object __doc_,
284
      final String __baseUri_,
285
      LoadingOptions __loadingOptions,
286
      final String __docRoot_) {
287
    super(__doc_, __baseUri_, __loadingOptions, __docRoot_);
1✔
288
    // Prefix plumbing variables with '__' to reduce likelihood of collision with
289
    // generated names.
290
    String __baseUri = __baseUri_;
1✔
291
    String __docRoot = __docRoot_;
1✔
292
    if (!(__doc_ instanceof java.util.Map)) {
1✔
NEW
293
      throw new ValidationException("WorkflowStepImpl called on non-map");
×
294
    }
295
    final java.util.Map<String, Object> __doc = (java.util.Map<String, Object>) __doc_;
1✔
296
    final java.util.List<ValidationException> __errors =
1✔
297
        new java.util.ArrayList<ValidationException>();
298
    if (__loadingOptions != null) {
1✔
299
      this.loadingOptions_ = __loadingOptions;
1✔
300
    }
301
    java.util.Optional<String> id;
302

303
    if (__doc.containsKey("id")) {
1✔
304
      try {
305
        id =
1✔
306
            LoaderInstances
307
                .uri_optional_StringInstance_True_False_None_None
308
                .loadField(__doc.get("id"), __baseUri, __loadingOptions);
1✔
NEW
309
      } catch (ValidationException e) {
×
NEW
310
        id = null; // won't be used but prevents compiler from complaining.
×
NEW
311
        final String __message = "the `id` field is not valid because:";
×
NEW
312
        __errors.add(new ValidationException(__message, e));
×
313
      }
1✔
314

315
    } else {
NEW
316
      id = null;
×
317
    }
318

319
    Boolean __original_is_null = id == null;
1✔
320
    if (id == null) {
1✔
NEW
321
      if (__docRoot != null) {
×
NEW
322
        id = java.util.Optional.of(__docRoot);
×
323
      } else {
NEW
324
        id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString());
×
325
      }
326
    }
327
    if (__original_is_null) {
1✔
NEW
328
        __baseUri = __baseUri_;
×
329
    } else {
330
        __baseUri = (String) id.orElse(null);
1✔
331
    }
332
    java.util.Optional<String> label;
333

334
    if (__doc.containsKey("label")) {
1✔
335
      try {
NEW
336
        label =
×
337
            LoaderInstances
338
                .optional_StringInstance
NEW
339
                .loadField(__doc.get("label"), __baseUri, __loadingOptions);
×
NEW
340
      } catch (ValidationException e) {
×
NEW
341
        label = null; // won't be used but prevents compiler from complaining.
×
NEW
342
        final String __message = "the `label` field is not valid because:";
×
NEW
343
        __errors.add(new ValidationException(__message, e));
×
NEW
344
      }
×
345

346
    } else {
347
      label = null;
1✔
348
    }
349
    Object doc;
350

351
    if (__doc.containsKey("doc")) {
1✔
352
      try {
NEW
353
        doc =
×
354
            LoaderInstances
355
                .union_of_NullInstance_or_StringInstance_or_array_of_StringInstance
NEW
356
                .loadField(__doc.get("doc"), __baseUri, __loadingOptions);
×
NEW
357
      } catch (ValidationException e) {
×
NEW
358
        doc = null; // won't be used but prevents compiler from complaining.
×
NEW
359
        final String __message = "the `doc` field is not valid because:";
×
NEW
360
        __errors.add(new ValidationException(__message, e));
×
NEW
361
      }
×
362

363
    } else {
364
      doc = null;
1✔
365
    }
366
    java.util.List<Object> in;
367
    try {
368
      in =
1✔
369
          LoaderInstances
370
              .idmap_in_array_of_WorkflowStepInput
371
              .loadField(__doc.get("in"), __baseUri, __loadingOptions);
1✔
NEW
372
    } catch (ValidationException e) {
×
NEW
373
      in = null; // won't be used but prevents compiler from complaining.
×
NEW
374
      final String __message = "the `in` field is not valid because:";
×
NEW
375
      __errors.add(new ValidationException(__message, e));
×
376
    }
1✔
377
    java.util.List<Object> out;
378
    try {
379
      out =
1✔
380
          LoaderInstances
381
              .uri_array_of_union_of_StringInstance_or_WorkflowStepOutput_True_False_None_None
382
              .loadField(__doc.get("out"), __baseUri, __loadingOptions);
1✔
NEW
383
    } catch (ValidationException e) {
×
NEW
384
      out = null; // won't be used but prevents compiler from complaining.
×
NEW
385
      final String __message = "the `out` field is not valid because:";
×
NEW
386
      __errors.add(new ValidationException(__message, e));
×
387
    }
1✔
388
    java.util.Optional<java.util.List<Object>> requirements;
389

390
    if (__doc.containsKey("requirements")) {
1✔
391
      try {
392
        requirements =
1✔
393
            LoaderInstances
394
                .idmap_requirements_optional_array_of_union_of_InlineJavascriptRequirement_or_SchemaDefRequirement_or_LoadListingRequirement_or_DockerRequirement_or_SoftwareRequirement_or_InitialWorkDirRequirement_or_EnvVarRequirement_or_ShellCommandRequirement_or_ResourceRequirement_or_WorkReuse_or_NetworkAccess_or_InplaceUpdateRequirement_or_ToolTimeLimit_or_SubworkflowFeatureRequirement_or_ScatterFeatureRequirement_or_MultipleInputFeatureRequirement_or_StepInputExpressionRequirement
395
                .loadField(__doc.get("requirements"), __baseUri, __loadingOptions);
1✔
NEW
396
      } catch (ValidationException e) {
×
NEW
397
        requirements = null; // won't be used but prevents compiler from complaining.
×
NEW
398
        final String __message = "the `requirements` field is not valid because:";
×
NEW
399
        __errors.add(new ValidationException(__message, e));
×
400
      }
1✔
401

402
    } else {
403
      requirements = null;
1✔
404
    }
405
    java.util.Optional<java.util.List<Object>> hints;
406

407
    if (__doc.containsKey("hints")) {
1✔
408
      try {
NEW
409
        hints =
×
410
            LoaderInstances
411
                .idmap_hints_optional_array_of_AnyInstance
NEW
412
                .loadField(__doc.get("hints"), __baseUri, __loadingOptions);
×
NEW
413
      } catch (ValidationException e) {
×
NEW
414
        hints = null; // won't be used but prevents compiler from complaining.
×
NEW
415
        final String __message = "the `hints` field is not valid because:";
×
NEW
416
        __errors.add(new ValidationException(__message, e));
×
NEW
417
      }
×
418

419
    } else {
420
      hints = null;
1✔
421
    }
422
    Object run;
423
    try {
424
      run =
1✔
425
          LoaderInstances
426
              .uri_union_of_StringInstance_or_CommandLineTool_or_ExpressionTool_or_Workflow_or_Operation_False_False_None_None
427
              .loadField(__doc.get("run"), __baseUri, __loadingOptions);
1✔
NEW
428
    } catch (ValidationException e) {
×
NEW
429
      run = null; // won't be used but prevents compiler from complaining.
×
NEW
430
      final String __message = "the `run` field is not valid because:";
×
NEW
431
      __errors.add(new ValidationException(__message, e));
×
432
    }
1✔
433
    java.util.Optional<String> when;
434

435
    if (__doc.containsKey("when")) {
1✔
436
      try {
437
        when =
1✔
438
            LoaderInstances
439
                .optional_ExpressionLoader
440
                .loadField(__doc.get("when"), __baseUri, __loadingOptions);
1✔
NEW
441
      } catch (ValidationException e) {
×
NEW
442
        when = null; // won't be used but prevents compiler from complaining.
×
NEW
443
        final String __message = "the `when` field is not valid because:";
×
NEW
444
        __errors.add(new ValidationException(__message, e));
×
445
      }
1✔
446

447
    } else {
448
      when = null;
1✔
449
    }
450
    Object scatter;
451

452
    if (__doc.containsKey("scatter")) {
1✔
453
      try {
454
        scatter =
1✔
455
            LoaderInstances
456
                .uri_union_of_NullInstance_or_StringInstance_or_array_of_StringInstance_False_False_0_None
457
                .loadField(__doc.get("scatter"), __baseUri, __loadingOptions);
1✔
NEW
458
      } catch (ValidationException e) {
×
NEW
459
        scatter = null; // won't be used but prevents compiler from complaining.
×
NEW
460
        final String __message = "the `scatter` field is not valid because:";
×
NEW
461
        __errors.add(new ValidationException(__message, e));
×
462
      }
1✔
463

464
    } else {
465
      scatter = null;
1✔
466
    }
467
    java.util.Optional<ScatterMethod> scatterMethod;
468

469
    if (__doc.containsKey("scatterMethod")) {
1✔
470
      try {
471
        scatterMethod =
1✔
472
            LoaderInstances
473
                .uri_optional_ScatterMethod_False_True_None_None
474
                .loadField(__doc.get("scatterMethod"), __baseUri, __loadingOptions);
1✔
NEW
475
      } catch (ValidationException e) {
×
NEW
476
        scatterMethod = null; // won't be used but prevents compiler from complaining.
×
NEW
477
        final String __message = "the `scatterMethod` field is not valid because:";
×
NEW
478
        __errors.add(new ValidationException(__message, e));
×
479
      }
1✔
480

481
    } else {
482
      scatterMethod = null;
1✔
483
    }
484
    if (!__errors.isEmpty()) {
1✔
NEW
485
      throw new ValidationException("Trying 'RecordField'", __errors);
×
486
    }
487
    this.id = (java.util.Optional<String>) id;
1✔
488
    this.label = (java.util.Optional<String>) label;
1✔
489
    this.doc = (Object) doc;
1✔
490
    this.in = (java.util.List<Object>) in;
1✔
491
    this.out = (java.util.List<Object>) out;
1✔
492
    this.requirements = (java.util.Optional<java.util.List<Object>>) requirements;
1✔
493
    this.hints = (java.util.Optional<java.util.List<Object>>) hints;
1✔
494
    this.run = (Object) run;
1✔
495
    this.when = (java.util.Optional<String>) when;
1✔
496
    this.scatter = (Object) scatter;
1✔
497
    this.scatterMethod = (java.util.Optional<ScatterMethod>) scatterMethod;
1✔
498
    for (String field:__doc.keySet()) {
1✔
499
      if (!attrs.contains(field)) {
1✔
NEW
500
        if (field.contains(":")) {
×
NEW
501
          String expanded_field = __loadingOptions.expandUrl(field, "", false, false, null);
×
NEW
502
          extensionFields_.put(expanded_field, __doc.get(field));
×
503
        }
504
      }
505
    }
1✔
506
  }
1✔
507
  private java.util.List<String> attrs = java.util.Arrays.asList("id", "label", "doc", "in", "out", "requirements", "hints", "run", "when", "scatter", "scatterMethod");
1✔
508
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc