001package org.galaxyproject.gxformat2.v19_09;
002
003import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances;
004import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions;
005import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder;
006import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl;
007import org.galaxyproject.gxformat2.v19_09.utils.ValidationException;
008
009/**
010 * Auto-generated class implementation for
011 * <I>https://galaxyproject.org/gxformat2/v19_09#WorkflowStep</I><br>
012 *
013 * <BLOCKQUOTE>
014 *
015 * This represents a non-input step a Galaxy Workflow.
016 *
017 * <p># A note about `state` and `tool_state` fields.
018 *
019 * <p>Only one or the other should be specified. These are two ways to represent the "state" of a
020 * tool at this workflow step. Both are essentially maps from parameter names to parameter values.
021 *
022 * <p>`tool_state` is much more low-level and expects a flat dictionary with each value a JSON dump.
023 * Nested tool structures such as conditionals and repeats should have all their values in the JSON
024 * dumped string. In general `tool_state` may be present in workflows exported from Galaxy but
025 * shouldn't be written by humans.
026 *
027 * <p>`state` can contained a typed map. Repeat values can be represented as YAML arrays. An
028 * alternative to representing `state` this way is defining inputs with default values.
029 *
030 * </BLOCKQUOTE>
031 */
032public class WorkflowStepImpl extends SavableImpl implements WorkflowStep {
033  private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build();
034  private java.util.Map<String, Object> extensionFields_ = new java.util.HashMap<String, Object>();
035
036  private java.util.Optional<String> id;
037
038  /**
039   * Getter for property <I>https://w3id.org/cwl/cwl#Identified/id</I><br>
040   *
041   * <BLOCKQUOTE>
042   *
043   * The unique identifier for this object. *
044   *
045   * </BLOCKQUOTE>
046   */
047  public java.util.Optional<String> getId() {
048    return this.id;
049  }
050
051  private java.util.Optional<String> label;
052
053  /**
054   * Getter for property <I>https://w3id.org/cwl/cwl#Labeled/label</I><br>
055   *
056   * <BLOCKQUOTE>
057   *
058   * A short, human-readable label of this object. *
059   *
060   * </BLOCKQUOTE>
061   */
062  public java.util.Optional<String> getLabel() {
063    return this.label;
064  }
065
066  private Object doc;
067
068  /**
069   * Getter for property <I>https://w3id.org/cwl/salad#Documented/doc</I><br>
070   *
071   * <BLOCKQUOTE>
072   *
073   * A documentation string for this object, or an array of strings which should be concatenated. *
074   *
075   * </BLOCKQUOTE>
076   */
077  public Object getDoc() {
078    return this.doc;
079  }
080
081  private java.util.Optional<StepPosition> position;
082
083  /**
084   * Getter for property
085   * <I>https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition/position</I><br>
086   */
087  public java.util.Optional<StepPosition> getPosition() {
088    return this.position;
089  }
090
091  private java.util.Optional<String> tool_id;
092
093  /**
094   * Getter for property
095   * <I>https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_id</I><br>
096   *
097   * <BLOCKQUOTE>
098   *
099   * The tool ID used to run this step of the workflow (e.g. 'cat1' or
100   * 'toolshed.g2.bx.psu.edu/repos/nml/collapse_collections/collapse_dataset/4.0'). *
101   *
102   * </BLOCKQUOTE>
103   */
104  public java.util.Optional<String> getTool_id() {
105    return this.tool_id;
106  }
107
108  private java.util.Optional<ToolShedRepository> tool_shed_repository;
109
110  /**
111   * Getter for property
112   * <I>https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_shed_repository</I>
113   * <br>
114   *
115   * <BLOCKQUOTE>
116   *
117   * The Galaxy Tool Shed repository that should be installed in order to use this tool. *
118   *
119   * </BLOCKQUOTE>
120   */
121  public java.util.Optional<ToolShedRepository> getTool_shed_repository() {
122    return this.tool_shed_repository;
123  }
124
125  private java.util.Optional<String> tool_version;
126
127  /**
128   * Getter for property
129   * <I>https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_version</I><br>
130   *
131   * <BLOCKQUOTE>
132   *
133   * The tool version corresponding used to run this step of the workflow. For tool shed installed
134   * tools, the ID generally uniquely specifies a version and this field is optional. *
135   *
136   * </BLOCKQUOTE>
137   */
138  public java.util.Optional<String> getTool_version() {
139    return this.tool_version;
140  }
141
142  private java.util.Optional<String> errors;
143
144  /**
145   * Getter for property
146   * <I>https://galaxyproject.org/gxformat2/gxformat2common#HasStepErrors/errors</I><br>
147   *
148   * <BLOCKQUOTE>
149   *
150   * During Galaxy export there may be some problem validating the tool state, tool used, etc.. that
151   * will be indicated by this field. The Galaxy user should be warned of these problems before the
152   * workflow can be used in Galaxy.
153   *
154   * <p>This field should not be used in human written Galaxy workflow files.
155   *
156   * <p>A typical problem is the referenced tool is not installed, this can be fixed by installed
157   * the tool and re-saving the workflow and then re-exporting it. *
158   *
159   * </BLOCKQUOTE>
160   */
161  public java.util.Optional<String> getErrors() {
162    return this.errors;
163  }
164
165  private java.util.Optional<String> uuid;
166
167  /**
168   * Getter for property <I>https://galaxyproject.org/gxformat2/gxformat2common#HasUUID/uuid</I><br>
169   *
170   * <BLOCKQUOTE>
171   *
172   * UUID uniquely representing this element. *
173   *
174   * </BLOCKQUOTE>
175   */
176  public java.util.Optional<String> getUuid() {
177    return this.uuid;
178  }
179
180  private java.util.Optional<java.util.List<Object>> in;
181
182  /**
183   * Getter for property <I>https://galaxyproject.org/gxformat2/v19_09#in</I><br>
184   *
185   * <BLOCKQUOTE>
186   *
187   * Defines the input parameters of the workflow step. The process is ready to run when all
188   * required input parameters are associated with concrete values. Input parameters include a
189   * schema for each parameter which is used to validate the input object. It may also be used build
190   * a user interface for constructing the input object. *
191   *
192   * </BLOCKQUOTE>
193   */
194  public java.util.Optional<java.util.List<Object>> getIn() {
195    return this.in;
196  }
197
198  private java.util.Optional<java.util.List<Object>> out;
199
200  /**
201   * Getter for property <I>https://galaxyproject.org/gxformat2/v19_09#out</I><br>
202   *
203   * <BLOCKQUOTE>
204   *
205   * Defines the parameters representing the output of the process. May be used to generate and/or
206   * validate the output object.
207   *
208   * <p>This can also be called 'outputs' for legacy reasons - but the resulting workflow document
209   * is not a valid instance of this schema. *
210   *
211   * </BLOCKQUOTE>
212   */
213  public java.util.Optional<java.util.List<Object>> getOut() {
214    return this.out;
215  }
216
217  private java.util.Optional<Object> state;
218
219  /**
220   * Getter for property <I>https://galaxyproject.org/gxformat2/v19_09#state</I><br>
221   *
222   * <BLOCKQUOTE>
223   *
224   * Structured tool state. *
225   *
226   * </BLOCKQUOTE>
227   */
228  public java.util.Optional<Object> getState() {
229    return this.state;
230  }
231
232  private java.util.Optional<Object> tool_state;
233
234  /**
235   * Getter for property <I>https://galaxyproject.org/gxformat2/v19_09#tool_state</I><br>
236   *
237   * <BLOCKQUOTE>
238   *
239   * Unstructured tool state. *
240   *
241   * </BLOCKQUOTE>
242   */
243  public java.util.Optional<Object> getTool_state() {
244    return this.tool_state;
245  }
246
247  private java.util.Optional<WorkflowStepType> type;
248
249  /**
250   * Getter for property <I>https://w3id.org/cwl/salad#type</I><br>
251   *
252   * <BLOCKQUOTE>
253   *
254   * Workflow step module's type (defaults to 'tool'). *
255   *
256   * </BLOCKQUOTE>
257   */
258  public java.util.Optional<WorkflowStepType> getType() {
259    return this.type;
260  }
261
262  private java.util.Optional<GalaxyWorkflow> run;
263
264  /**
265   * Getter for property <I>https://w3id.org/cwl/cwl#run</I><br>
266   *
267   * <BLOCKQUOTE>
268   *
269   * Specifies a subworkflow to run. *
270   *
271   * </BLOCKQUOTE>
272   */
273  public java.util.Optional<GalaxyWorkflow> getRun() {
274    return this.run;
275  }
276
277  private java.util.Optional<java.util.List<Object>> runtime_inputs;
278
279  /**
280   * Getter for property
281   * <I>https://galaxyproject.org/gxformat2/v19_09#WorkflowStep/runtime_inputs</I><br>
282   */
283  public java.util.Optional<java.util.List<Object>> getRuntime_inputs() {
284    return this.runtime_inputs;
285  }
286
287  /**
288   * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of
289   * WorkflowStepImpl.
290   *
291   * @param __doc_ Document fragment to load this record object from (presumably a {@link
292   *     java.util.Map}).
293   * @param __baseUri_ Base URI to generate child document IDs against.
294   * @param __loadingOptions Context for loading URIs and populating objects.
295   * @param __docRoot_ ID at this position in the document (if available) (maybe?)
296   * @throws ValidationException If the document fragment is not a {@link java.util.Map} or
297   *     validation of fields fails.
298   */
299  public WorkflowStepImpl(
300      final Object __doc_,
301      final String __baseUri_,
302      LoadingOptions __loadingOptions,
303      final String __docRoot_) {
304    super(__doc_, __baseUri_, __loadingOptions, __docRoot_);
305    // Prefix plumbing variables with '__' to reduce likelihood of collision with
306    // generated names.
307    String __baseUri = __baseUri_;
308    String __docRoot = __docRoot_;
309    if (!(__doc_ instanceof java.util.Map)) {
310      throw new ValidationException("WorkflowStepImpl called on non-map");
311    }
312    final java.util.Map<String, Object> __doc = (java.util.Map<String, Object>) __doc_;
313    final java.util.List<ValidationException> __errors =
314        new java.util.ArrayList<ValidationException>();
315    if (__loadingOptions != null) {
316      this.loadingOptions_ = __loadingOptions;
317    }
318    java.util.Optional<String> id;
319
320    if (__doc.containsKey("id")) {
321      try {
322        id =
323            LoaderInstances.uri_optional_StringInstance_True_False_None.loadField(
324                __doc.get("id"), __baseUri, __loadingOptions);
325      } catch (ValidationException e) {
326        id = null; // won't be used but prevents compiler from complaining.
327        final String __message = "the `id` field is not valid because:";
328        __errors.add(new ValidationException(__message, e));
329      }
330
331    } else {
332      id = null;
333    }
334
335    if (id == null) {
336      if (__docRoot != null) {
337        id = java.util.Optional.of(__docRoot);
338      } else {
339        id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString());
340      }
341    }
342    __baseUri = (String) id.orElse(null);
343    java.util.Optional<String> label;
344
345    if (__doc.containsKey("label")) {
346      try {
347        label =
348            LoaderInstances.optional_StringInstance.loadField(
349                __doc.get("label"), __baseUri, __loadingOptions);
350      } catch (ValidationException e) {
351        label = null; // won't be used but prevents compiler from complaining.
352        final String __message = "the `label` field is not valid because:";
353        __errors.add(new ValidationException(__message, e));
354      }
355
356    } else {
357      label = null;
358    }
359    Object doc;
360
361    if (__doc.containsKey("doc")) {
362      try {
363        doc =
364            LoaderInstances.union_of_NullInstance_or_StringInstance_or_array_of_StringInstance
365                .loadField(__doc.get("doc"), __baseUri, __loadingOptions);
366      } catch (ValidationException e) {
367        doc = null; // won't be used but prevents compiler from complaining.
368        final String __message = "the `doc` field is not valid because:";
369        __errors.add(new ValidationException(__message, e));
370      }
371
372    } else {
373      doc = null;
374    }
375    java.util.Optional<StepPosition> position;
376
377    if (__doc.containsKey("position")) {
378      try {
379        position =
380            LoaderInstances.optional_StepPosition.loadField(
381                __doc.get("position"), __baseUri, __loadingOptions);
382      } catch (ValidationException e) {
383        position = null; // won't be used but prevents compiler from complaining.
384        final String __message = "the `position` field is not valid because:";
385        __errors.add(new ValidationException(__message, e));
386      }
387
388    } else {
389      position = null;
390    }
391    java.util.Optional<String> tool_id;
392
393    if (__doc.containsKey("tool_id")) {
394      try {
395        tool_id =
396            LoaderInstances.optional_StringInstance.loadField(
397                __doc.get("tool_id"), __baseUri, __loadingOptions);
398      } catch (ValidationException e) {
399        tool_id = null; // won't be used but prevents compiler from complaining.
400        final String __message = "the `tool_id` field is not valid because:";
401        __errors.add(new ValidationException(__message, e));
402      }
403
404    } else {
405      tool_id = null;
406    }
407    java.util.Optional<ToolShedRepository> tool_shed_repository;
408
409    if (__doc.containsKey("tool_shed_repository")) {
410      try {
411        tool_shed_repository =
412            LoaderInstances.optional_ToolShedRepository.loadField(
413                __doc.get("tool_shed_repository"), __baseUri, __loadingOptions);
414      } catch (ValidationException e) {
415        tool_shed_repository = null; // won't be used but prevents compiler from complaining.
416        final String __message = "the `tool_shed_repository` field is not valid because:";
417        __errors.add(new ValidationException(__message, e));
418      }
419
420    } else {
421      tool_shed_repository = null;
422    }
423    java.util.Optional<String> tool_version;
424
425    if (__doc.containsKey("tool_version")) {
426      try {
427        tool_version =
428            LoaderInstances.optional_StringInstance.loadField(
429                __doc.get("tool_version"), __baseUri, __loadingOptions);
430      } catch (ValidationException e) {
431        tool_version = null; // won't be used but prevents compiler from complaining.
432        final String __message = "the `tool_version` field is not valid because:";
433        __errors.add(new ValidationException(__message, e));
434      }
435
436    } else {
437      tool_version = null;
438    }
439    java.util.Optional<String> errors;
440
441    if (__doc.containsKey("errors")) {
442      try {
443        errors =
444            LoaderInstances.optional_StringInstance.loadField(
445                __doc.get("errors"), __baseUri, __loadingOptions);
446      } catch (ValidationException e) {
447        errors = null; // won't be used but prevents compiler from complaining.
448        final String __message = "the `errors` field is not valid because:";
449        __errors.add(new ValidationException(__message, e));
450      }
451
452    } else {
453      errors = null;
454    }
455    java.util.Optional<String> uuid;
456
457    if (__doc.containsKey("uuid")) {
458      try {
459        uuid =
460            LoaderInstances.optional_StringInstance.loadField(
461                __doc.get("uuid"), __baseUri, __loadingOptions);
462      } catch (ValidationException e) {
463        uuid = null; // won't be used but prevents compiler from complaining.
464        final String __message = "the `uuid` field is not valid because:";
465        __errors.add(new ValidationException(__message, e));
466      }
467
468    } else {
469      uuid = null;
470    }
471    java.util.Optional<java.util.List<Object>> in;
472
473    if (__doc.containsKey("in")) {
474      try {
475        in =
476            LoaderInstances.idmap_in_optional_array_of_WorkflowStepInput.loadField(
477                __doc.get("in"), __baseUri, __loadingOptions);
478      } catch (ValidationException e) {
479        in = null; // won't be used but prevents compiler from complaining.
480        final String __message = "the `in` field is not valid because:";
481        __errors.add(new ValidationException(__message, e));
482      }
483
484    } else {
485      in = null;
486    }
487    java.util.Optional<java.util.List<Object>> out;
488
489    if (__doc.containsKey("out")) {
490      try {
491        out =
492            LoaderInstances
493                .idmap_out_optional_array_of_union_of_StringInstance_or_WorkflowStepOutput
494                .loadField(__doc.get("out"), __baseUri, __loadingOptions);
495      } catch (ValidationException e) {
496        out = null; // won't be used but prevents compiler from complaining.
497        final String __message = "the `out` field is not valid because:";
498        __errors.add(new ValidationException(__message, e));
499      }
500
501    } else {
502      out = null;
503    }
504    java.util.Optional<Object> state;
505
506    if (__doc.containsKey("state")) {
507      try {
508        state =
509            LoaderInstances.optional_AnyInstance.loadField(
510                __doc.get("state"), __baseUri, __loadingOptions);
511      } catch (ValidationException e) {
512        state = null; // won't be used but prevents compiler from complaining.
513        final String __message = "the `state` field is not valid because:";
514        __errors.add(new ValidationException(__message, e));
515      }
516
517    } else {
518      state = null;
519    }
520    java.util.Optional<Object> tool_state;
521
522    if (__doc.containsKey("tool_state")) {
523      try {
524        tool_state =
525            LoaderInstances.optional_AnyInstance.loadField(
526                __doc.get("tool_state"), __baseUri, __loadingOptions);
527      } catch (ValidationException e) {
528        tool_state = null; // won't be used but prevents compiler from complaining.
529        final String __message = "the `tool_state` field is not valid because:";
530        __errors.add(new ValidationException(__message, e));
531      }
532
533    } else {
534      tool_state = null;
535    }
536    java.util.Optional<WorkflowStepType> type;
537
538    if (__doc.containsKey("type")) {
539      try {
540        type =
541            LoaderInstances.typedsl_optional_WorkflowStepType_2.loadField(
542                __doc.get("type"), __baseUri, __loadingOptions);
543      } catch (ValidationException e) {
544        type = null; // won't be used but prevents compiler from complaining.
545        final String __message = "the `type` field is not valid because:";
546        __errors.add(new ValidationException(__message, e));
547      }
548
549    } else {
550      type = null;
551    }
552    java.util.Optional<GalaxyWorkflow> run;
553
554    if (__doc.containsKey("run")) {
555      try {
556        run =
557            LoaderInstances.uri_optional_GalaxyWorkflow_False_False_None.loadField(
558                __doc.get("run"), __baseUri, __loadingOptions);
559      } catch (ValidationException e) {
560        run = null; // won't be used but prevents compiler from complaining.
561        final String __message = "the `run` field is not valid because:";
562        __errors.add(new ValidationException(__message, e));
563      }
564
565    } else {
566      run = null;
567    }
568    java.util.Optional<java.util.List<Object>> runtime_inputs;
569
570    if (__doc.containsKey("runtime_inputs")) {
571      try {
572        runtime_inputs =
573            LoaderInstances.optional_array_of_StringInstance.loadField(
574                __doc.get("runtime_inputs"), __baseUri, __loadingOptions);
575      } catch (ValidationException e) {
576        runtime_inputs = null; // won't be used but prevents compiler from complaining.
577        final String __message = "the `runtime_inputs` field is not valid because:";
578        __errors.add(new ValidationException(__message, e));
579      }
580
581    } else {
582      runtime_inputs = null;
583    }
584    if (!__errors.isEmpty()) {
585      throw new ValidationException("Trying 'RecordField'", __errors);
586    }
587    this.id = (java.util.Optional<String>) id;
588    this.label = (java.util.Optional<String>) label;
589    this.doc = (Object) doc;
590    this.position = (java.util.Optional<StepPosition>) position;
591    this.tool_id = (java.util.Optional<String>) tool_id;
592    this.tool_shed_repository = (java.util.Optional<ToolShedRepository>) tool_shed_repository;
593    this.tool_version = (java.util.Optional<String>) tool_version;
594    this.errors = (java.util.Optional<String>) errors;
595    this.uuid = (java.util.Optional<String>) uuid;
596    this.in = (java.util.Optional<java.util.List<Object>>) in;
597    this.out = (java.util.Optional<java.util.List<Object>>) out;
598    this.state = (java.util.Optional<Object>) state;
599    this.tool_state = (java.util.Optional<Object>) tool_state;
600    this.type = (java.util.Optional<WorkflowStepType>) type;
601    this.run = (java.util.Optional<GalaxyWorkflow>) run;
602    this.runtime_inputs = (java.util.Optional<java.util.List<Object>>) runtime_inputs;
603  }
604}