From a5e3e22a15713bf98e8ef2f346e32918d67ed229 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 3 Dec 2019 14:19:34 -0500 Subject: [PATCH] Copy in schema generated workflow parser (and linter) from gxformat2. xref https://github.com/galaxyproject/gxformat2/pull/13 --- .../gxformat2/Format2Linter.java | 15 + .../gxformat2/GalaxyWorkflowLinter.java | 7 + .../org/galaxyproject/gxformat2/Lint.java | 45 ++ .../galaxyproject/gxformat2/LintContext.java | 52 ++ .../galaxyproject/gxformat2/LintUtils.java | 51 ++ .../galaxyproject/gxformat2/NativeLinter.java | 64 +++ .../galaxyproject/gxformat2/v19_09/Any.java | 23 + .../gxformat2/v19_09/ArraySchema.java | 30 ++ .../gxformat2/v19_09/ArraySchemaImpl.java | 102 ++++ .../gxformat2/v19_09/Documented.java | 17 + .../gxformat2/v19_09/EnumSchema.java | 36 ++ .../gxformat2/v19_09/EnumSchemaImpl.java | 109 +++++ .../gxformat2/v19_09/GalaxyType.java | 25 + .../gxformat2/v19_09/GalaxyWorkflow.java | 90 ++++ .../gxformat2/v19_09/GalaxyWorkflowImpl.java | 271 +++++++++++ .../gxformat2/v19_09/HasStepPosition.java | 15 + .../gxformat2/v19_09/Identified.java | 6 + .../gxformat2/v19_09/InputParameter.java | 29 ++ .../gxformat2/v19_09/Labeled.java | 17 + .../gxformat2/v19_09/OutputParameter.java | 17 + .../gxformat2/v19_09/Parameter.java | 25 + .../gxformat2/v19_09/PrimitiveType.java | 31 ++ .../gxformat2/v19_09/Process.java | 65 +++ .../gxformat2/v19_09/RecordField.java | 46 ++ .../gxformat2/v19_09/RecordFieldImpl.java | 157 ++++++ .../gxformat2/v19_09/RecordSchema.java | 30 ++ .../gxformat2/v19_09/RecordSchemaImpl.java | 107 ++++ .../gxformat2/v19_09/ReferencesTool.java | 46 ++ .../galaxyproject/gxformat2/v19_09/Sink.java | 18 + .../gxformat2/v19_09/StepPosition.java | 39 ++ .../gxformat2/v19_09/StepPositionImpl.java | 109 +++++ .../gxformat2/v19_09/ToolShedRepository.java | 57 +++ .../v19_09/ToolShedRepositoryImpl.java | 176 +++++++ .../v19_09/WorkflowInputParameter.java | 53 ++ .../v19_09/WorkflowInputParameterImpl.java | 191 ++++++++ .../v19_09/WorkflowOutputParameter.java | 60 +++ .../v19_09/WorkflowOutputParameterImpl.java | 198 ++++++++ .../gxformat2/v19_09/WorkflowStep.java | 142 ++++++ .../gxformat2/v19_09/WorkflowStepImpl.java | 457 ++++++++++++++++++ .../gxformat2/v19_09/WorkflowStepInput.java | 60 +++ .../v19_09/WorkflowStepInputImpl.java | 199 ++++++++ .../gxformat2/v19_09/WorkflowStepOutput.java | 32 ++ .../v19_09/WorkflowStepOutputImpl.java | 104 ++++ .../gxformat2/v19_09/WorkflowStepType.java | 26 + ...2602be0b4b8fd33e69e29a841317b6ab665bc.java | 26 + ...1d79c225752b9fadb617367615ab176b47d77.java | 26 + ...ba076fca539106791a4f46d198c7fcfbdb779.java | 26 + .../gxformat2/v19_09/package.html | 4 + .../gxformat2/v19_09/utils/AnyLoader.java | 15 + .../gxformat2/v19_09/utils/ArrayLoader.java | 42 ++ .../gxformat2/v19_09/utils/ConstantMaps.java | 117 +++++ .../v19_09/utils/DefaultFetcher.java | 32 ++ .../gxformat2/v19_09/utils/EnumLoader.java | 26 + .../gxformat2/v19_09/utils/Fetcher.java | 8 + .../gxformat2/v19_09/utils/IdMapLoader.java | 53 ++ .../gxformat2/v19_09/utils/Loader.java | 111 +++++ .../v19_09/utils/LoaderInstances.java | 218 +++++++++ .../v19_09/utils/LoadingOptions.java | 124 +++++ .../v19_09/utils/LoadingOptionsBuilder.java | 62 +++ .../gxformat2/v19_09/utils/NullLoader.java | 15 + .../gxformat2/v19_09/utils/OneOrListOf.java | 47 ++ .../v19_09/utils/OneOrListOfLoader.java | 33 ++ .../v19_09/utils/OptionalLoader.java | 22 + .../v19_09/utils/PrimitiveLoader.java | 17 + .../gxformat2/v19_09/utils/RecordLoader.java | 35 ++ .../gxformat2/v19_09/utils/RootLoader.java | 132 +++++ .../gxformat2/v19_09/utils/Savable.java | 6 + .../gxformat2/v19_09/utils/SavableImpl.java | 5 + .../gxformat2/v19_09/utils/TypeDslLoader.java | 81 ++++ .../gxformat2/v19_09/utils/UnionLoader.java | 33 ++ .../gxformat2/v19_09/utils/UriLoader.java | 52 ++ .../gxformat2/v19_09/utils/Uris.java | 117 +++++ .../v19_09/utils/ValidationException.java | 80 +++ .../gxformat2/v19_09/utils/Validator.java | 14 + .../gxformat2/v19_09/utils/YamlUtils.java | 13 + .../gxformat2/v19_09/utils/package.html | 3 + .../v19_09/utils/DefaultFetcherTest.java | 37 ++ .../gxformat2/v19_09/utils/ExamplesTest.java | 31 ++ .../gxformat2/v19_09/utils/YamlUtilsTest.java | 15 + .../gxformat2/v19_09/utils/valid1.yml | 16 + 80 files changed, 5143 insertions(+) create mode 100644 src/main/java/org/galaxyproject/gxformat2/Format2Linter.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/GalaxyWorkflowLinter.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/Lint.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/LintContext.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/LintUtils.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/NativeLinter.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/Any.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/ArraySchema.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/ArraySchemaImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/Documented.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/EnumSchema.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/EnumSchemaImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyType.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyWorkflow.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyWorkflowImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/HasStepPosition.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/Identified.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/InputParameter.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/Labeled.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/OutputParameter.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/Parameter.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/PrimitiveType.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/Process.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/RecordField.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/RecordFieldImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/RecordSchema.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/RecordSchemaImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/ReferencesTool.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/Sink.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/StepPosition.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/StepPositionImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/ToolShedRepository.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/ToolShedRepositoryImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowInputParameter.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowInputParameterImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowOutputParameter.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowOutputParameterImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStep.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepInput.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepInputImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepOutput.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepOutputImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepType.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d062602be0b4b8fd33e69e29a841317b6ab665bc.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d961d79c225752b9fadb617367615ab176b47d77.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d9cba076fca539106791a4f46d198c7fcfbdb779.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/package.html create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/AnyLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ArrayLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ConstantMaps.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/DefaultFetcher.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/EnumLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Fetcher.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/IdMapLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Loader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoaderInstances.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoadingOptions.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoadingOptionsBuilder.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/NullLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OneOrListOf.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OneOrListOfLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OptionalLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/PrimitiveLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/RecordLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/RootLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Savable.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/SavableImpl.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/TypeDslLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/UnionLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/UriLoader.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Uris.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ValidationException.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Validator.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/YamlUtils.java create mode 100644 src/main/java/org/galaxyproject/gxformat2/v19_09/utils/package.html create mode 100644 src/test/java/org/galaxyproject/gxformat2/v19_09/utils/DefaultFetcherTest.java create mode 100644 src/test/java/org/galaxyproject/gxformat2/v19_09/utils/ExamplesTest.java create mode 100644 src/test/java/org/galaxyproject/gxformat2/v19_09/utils/YamlUtilsTest.java create mode 100644 src/test/resources/org/galaxyproject/gxformat2/v19_09/utils/valid1.yml diff --git a/src/main/java/org/galaxyproject/gxformat2/Format2Linter.java b/src/main/java/org/galaxyproject/gxformat2/Format2Linter.java new file mode 100644 index 00000000..12207628 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/Format2Linter.java @@ -0,0 +1,15 @@ +package org.galaxyproject.gxformat2; + +import java.util.Map; +import org.galaxyproject.gxformat2.v19_09.utils.RootLoader; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +public class Format2Linter implements GalaxyWorkflowLinter { + public void lint(final LintContext lintContext, final Map workflow) { + try { + RootLoader.loadDocument(workflow); + } catch (ValidationException e) { + lintContext.error("Validation failed " + e.toString()); + } + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/GalaxyWorkflowLinter.java b/src/main/java/org/galaxyproject/gxformat2/GalaxyWorkflowLinter.java new file mode 100644 index 00000000..eccedda4 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/GalaxyWorkflowLinter.java @@ -0,0 +1,7 @@ +package org.galaxyproject.gxformat2; + +import java.util.Map; + +public interface GalaxyWorkflowLinter { + public void lint(final LintContext lintContext, final Map workflow); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/Lint.java b/src/main/java/org/galaxyproject/gxformat2/Lint.java new file mode 100644 index 00000000..8d0c7953 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/Lint.java @@ -0,0 +1,45 @@ +package org.galaxyproject.gxformat2; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Map; +import org.yaml.snakeyaml.Yaml; + +public class Lint { + public static int EXIT_CODE_SUCCESS = 0; + public static int EXIT_CODE_LINT_FAILED = 1; + public static int EXIT_CODE_FORMAT_ERROR = 2; + public static int EXIT_CODE_FILE_PARSE_FAILED = 3; + + public static void main(String[] args) throws Exception { + final int exitCode = lint(args); + System.exit(exitCode); + } + + public static int lint(final String[] args) throws Exception { + final Path path = Paths.get(args[0]); + final String workflowContents = new String(Files.readAllBytes(path), "UTF8"); + final Yaml yaml = new Yaml(); + final Map object = (Map) yaml.load(workflowContents); + final String wfClass = (String) object.get("class"); + GalaxyWorkflowLinter linter; + if (wfClass != null && wfClass.equals("GalaxyWorkflow")) { + linter = new Format2Linter(); + } else { + linter = new NativeLinter(); + } + final LintContext lintContext = new LintContext(); + linter.lint(lintContext, object); + lintContext.printMessages(); + int exitCode; + if (lintContext.getFoundErrors()) { + exitCode = EXIT_CODE_FORMAT_ERROR; + } else if (lintContext.getFoundWarns()) { + exitCode = EXIT_CODE_LINT_FAILED; + } else { + exitCode = EXIT_CODE_SUCCESS; + } + return exitCode; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/LintContext.java b/src/main/java/org/galaxyproject/gxformat2/LintContext.java new file mode 100644 index 00000000..41b0c844 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/LintContext.java @@ -0,0 +1,52 @@ +package org.galaxyproject.gxformat2; + +import java.util.ArrayList; +import java.util.List; + +public class LintContext { + private boolean foundErrors = false; + private boolean foundWarns = false; + + private List validMessages = new ArrayList(); + private List infoMessages = new ArrayList(); + private List warnMessages = new ArrayList(); + private List errorMessages = new ArrayList(); + + LintContext() {} + + boolean getFoundErrors() { + return this.foundErrors; + } + + boolean getFoundWarns() { + return this.foundWarns; + } + + void valid(String message, Object... args) { + this.validMessages.add(String.format(message, args)); + } + + void info(String message, Object... args) { + this.infoMessages.add(String.format(message, args)); + } + + void error(String message, Object... args) { + this.errorMessages.add(String.format(message, args)); + } + + void warn(String message, Object... args) { + this.warnMessages.add(String.format(message, args)); + } + + void printMessages() { + for (final String message : this.errorMessages) { + this.foundErrors = true; + System.out.print(".. ERROR " + message); + } + + for (final String message : this.warnMessages) { + this.foundWarns = true; + System.out.print(".. WARNING " + message); + } + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/LintUtils.java b/src/main/java/org/galaxyproject/gxformat2/LintUtils.java new file mode 100644 index 00000000..e8bf2760 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/LintUtils.java @@ -0,0 +1,51 @@ +package org.galaxyproject.gxformat2; + +import java.util.Map; + +class LintUtils { + static T ensureKey( + LintContext lintContext, Object hasKeys, String key, Class hasClass, Object hasValue) { + if (!(hasKeys instanceof Map)) { + lintContext.error("expected [%s] to be a dictionary type", hasKeys); + return null; + } + final Map map = (Map) hasKeys; + if (!map.containsKey(key)) { + lintContext.error("expected to have key [%s] but absent", key); + } + final Object value = map.get(key); + return ensureKeyHasValue(lintContext, map, key, value, hasClass, hasValue); + } + + static T ensureKeyIfPresent( + LintContext lintContext, Object hasKeys, String key, T defaultValue, Class hasClass) { + if (!(hasKeys instanceof Map)) { + lintContext.error("expected [%s] to be a dictionary type", hasKeys); + return null; + } + final Map map = (Map) hasKeys; + if (!map.containsKey(key)) { + return defaultValue; + } + final Object value = map.get(key); + return ensureKeyHasValue(lintContext, map, key, value, hasClass, null); + } + + static T ensureKeyHasValue( + LintContext lintContext, + Map hasKeys, + String key, + Object value, + Class hasClass, + Object hasValue) { + if (!hasClass.isInstance(value)) { + lintContext.error( + "expected value [%s] with key [%s] to be of class %s", key, value, hasClass); + return null; + } + if (hasValue != null && !hasValue.equals(value)) { + lintContext.error("expected value [%s] with key [%s] to be %s", key, value, hasValue); + } + return (T) value; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/NativeLinter.java b/src/main/java/org/galaxyproject/gxformat2/NativeLinter.java new file mode 100644 index 00000000..9bd3c314 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/NativeLinter.java @@ -0,0 +1,64 @@ +package org.galaxyproject.gxformat2; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class NativeLinter implements GalaxyWorkflowLinter { + public static String LINT_FAILED_NO_OUTPUTS = "Workflow contained no outputs"; + public static String LINT_FAILED_OUTPUT_NO_LABEL = "Workflow contained output without a label"; + + public void lint(final LintContext lintContext, final Map workflow) { + LintUtils.ensureKey(lintContext, workflow, "format-version", String.class, "0.1"); + LintUtils.ensureKey(lintContext, workflow, "a_galaxy_workflow", String.class, "true"); + + final Map steps = + (Map) LintUtils.ensureKey(lintContext, workflow, "steps", Map.class, null); + boolean foundOutputs = false; + boolean foundOutputsWithoutLabel = false; + if (steps != null) { + for (Map.Entry stepEntry : steps.entrySet()) { + final String orderIndexStr = stepEntry.getKey(); + try { + final int orderIndex = Integer.parseInt(orderIndexStr); + } catch (NumberFormatException e) { + lintContext.error("expected step_key to be integer not [%s]", orderIndexStr); + } + if (!(stepEntry.getValue() instanceof Map)) { + lintContext.error("expected step value to be Map not [%s]", stepEntry.getValue()); + } + Map step = (Map) stepEntry.getValue(); + List workflowOutputs = + LintUtils.ensureKeyIfPresent( + lintContext, step, "workflow_outputs", new ArrayList(), List.class); + for (Object workflowOutputObject : workflowOutputs) { + foundOutputs = true; + if (!(workflowOutputObject instanceof Map)) { + lintContext.error("Not a map"); + } + final Map workflowOutput = (Map) workflowOutputObject; + final String label = workflowOutput.get("label"); + if (label == null || label.length() == 0) { + foundOutputsWithoutLabel = true; + } + } + final String stepType = + LintUtils.ensureKeyIfPresent(lintContext, step, "type", "tool", String.class); + assert stepType != null; + if (stepType != null && stepType.equals("subworkflow")) { + final Map subworkflow = + (Map) + LintUtils.ensureKey(lintContext, step, "subworkflow", Map.class, null); + assert subworkflow != null; + lint(lintContext, subworkflow); + } + } + } + if (!foundOutputs) { + lintContext.warn(LINT_FAILED_NO_OUTPUTS); + } + if (foundOutputsWithoutLabel) { + lintContext.warn(LINT_FAILED_OUTPUT_NO_LABEL); + } + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/Any.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/Any.java new file mode 100644 index 00000000..5c82828b --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/Any.java @@ -0,0 +1,23 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +public enum Any { + ANY("Any"); + + private static String[] symbols = new String[] {"Any"}; + private String docVal; + + private Any(final String docVal) { + this.docVal = docVal; + } + + public static Any fromDocumentVal(final String docVal) { + for (final Any val : Any.values()) { + if (val.docVal.equals(docVal)) { + return val; + } + } + throw new ValidationException(String.format("Expected one of %s", Any.symbols, docVal)); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/ArraySchema.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/ArraySchema.java new file mode 100644 index 00000000..bc5cb57b --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/ArraySchema.java @@ -0,0 +1,30 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://w3id.org/cwl/salad#ArraySchema
+ * This interface is implemented by {@link ArraySchemaImpl}
+ */ +public interface ArraySchema extends Savable { + /** + * Getter for property https://w3id.org/cwl/salad#items
+ * + *
+ * + * Defines the type of the array elements. * + * + *
+ */ + Object getItems(); + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Must be `array` * + * + *
+ */ + enum_d062602be0b4b8fd33e69e29a841317b6ab665bc getType(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/ArraySchemaImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/ArraySchemaImpl.java new file mode 100644 index 00000000..31b6708d --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/ArraySchemaImpl.java @@ -0,0 +1,102 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** Auto-generated class implementation for https://w3id.org/cwl/salad#ArraySchema
*/ +public class ArraySchemaImpl extends SavableImpl implements ArraySchema { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private Object items; + + /** + * Getter for property https://w3id.org/cwl/salad#items
+ * + *
+ * + * Defines the type of the array elements. * + * + *
+ */ + public Object getItems() { + return this.items; + } + + private enum_d062602be0b4b8fd33e69e29a841317b6ab665bc type; + + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Must be `array` * + * + *
+ */ + public enum_d062602be0b4b8fd33e69e29a841317b6ab665bc getType() { + return this.type; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * ArraySchemaImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public ArraySchemaImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("ArraySchemaImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + Object items; + try { + items = + LoaderInstances + .uri_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_or_array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_False_True_2 + .loadField(__doc.get("items"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + items = null; // won't be used but prevents compiler from complaining. + final String __message = "the `items` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + enum_d062602be0b4b8fd33e69e29a841317b6ab665bc type; + try { + type = + LoaderInstances.typedsl_enum_d062602be0b4b8fd33e69e29a841317b6ab665bc_2.loadField( + __doc.get("type"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + type = null; // won't be used but prevents compiler from complaining. + final String __message = "the `type` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.items = (Object) items; + this.type = (enum_d062602be0b4b8fd33e69e29a841317b6ab665bc) type; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/Documented.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/Documented.java new file mode 100644 index 00000000..361ab249 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/Documented.java @@ -0,0 +1,17 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** Auto-generated interface for https://w3id.org/cwl/salad#Documented
*/ +public interface Documented extends Savable { + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/EnumSchema.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/EnumSchema.java new file mode 100644 index 00000000..cba82887 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/EnumSchema.java @@ -0,0 +1,36 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://w3id.org/cwl/salad#EnumSchema
+ * This interface is implemented by {@link EnumSchemaImpl}
+ * + *
+ * + * Define an enumerated type. + * + *
+ */ +public interface EnumSchema extends Savable { + /** + * Getter for property https://w3id.org/cwl/salad#symbols
+ * + *
+ * + * Defines the set of valid symbols. * + * + *
+ */ + java.util.List getSymbols(); + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Must be `enum` * + * + *
+ */ + enum_d961d79c225752b9fadb617367615ab176b47d77 getType(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/EnumSchemaImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/EnumSchemaImpl.java new file mode 100644 index 00000000..73e4c21d --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/EnumSchemaImpl.java @@ -0,0 +1,109 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for https://w3id.org/cwl/salad#EnumSchema
+ * + *
+ * + * Define an enumerated type. + * + *
+ */ +public class EnumSchemaImpl extends SavableImpl implements EnumSchema { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private java.util.List symbols; + + /** + * Getter for property https://w3id.org/cwl/salad#symbols
+ * + *
+ * + * Defines the set of valid symbols. * + * + *
+ */ + public java.util.List getSymbols() { + return this.symbols; + } + + private enum_d961d79c225752b9fadb617367615ab176b47d77 type; + + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Must be `enum` * + * + *
+ */ + public enum_d961d79c225752b9fadb617367615ab176b47d77 getType() { + return this.type; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * EnumSchemaImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public EnumSchemaImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("EnumSchemaImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + java.util.List symbols; + try { + symbols = + LoaderInstances.uri_array_of_StringInstance_True_False_None.loadField( + __doc.get("symbols"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + symbols = null; // won't be used but prevents compiler from complaining. + final String __message = "the `symbols` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + enum_d961d79c225752b9fadb617367615ab176b47d77 type; + try { + type = + LoaderInstances.typedsl_enum_d961d79c225752b9fadb617367615ab176b47d77_2.loadField( + __doc.get("type"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + type = null; // won't be used but prevents compiler from complaining. + final String __message = "the `type` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.symbols = (java.util.List) symbols; + this.type = (enum_d961d79c225752b9fadb617367615ab176b47d77) type; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyType.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyType.java new file mode 100644 index 00000000..4a5b09fd --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyType.java @@ -0,0 +1,25 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +public enum GalaxyType { + FILE("File"), + DATA("data"), + COLLECTION("collection"); + + private static String[] symbols = new String[] {"File", "data", "collection"}; + private String docVal; + + private GalaxyType(final String docVal) { + this.docVal = docVal; + } + + public static GalaxyType fromDocumentVal(final String docVal) { + for (final GalaxyType val : GalaxyType.values()) { + if (val.docVal.equals(docVal)) { + return val; + } + } + throw new ValidationException(String.format("Expected one of %s", GalaxyType.symbols, docVal)); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyWorkflow.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyWorkflow.java new file mode 100644 index 00000000..9a2621f6 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyWorkflow.java @@ -0,0 +1,90 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://galaxyproject.org/gxformat2/v19_09#GalaxyWorkflow
+ * This interface is implemented by {@link GalaxyWorkflowImpl}
+ * + *
+ * + * This is documentation for a workflow! + * + *
+ */ +public interface GalaxyWorkflow extends Process, Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + java.util.Optional getId(); + /** + * Getter for property https://w3id.org/cwl/cwl#Labeled/label
+ * + *
+ * + * A short, human-readable label of this object. * + * + *
+ */ + java.util.Optional getLabel(); + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); + /** + * Getter for property https://w3id.org/cwl/cwl#inputs
+ * + *
+ * + * Defines the input parameters of the process. The process is ready to run when all required + * input parameters are associated with concrete values. Input parameters include a schema for + * each parameter which is used to validate the input object. It may also be used to build a user + * interface for constructing the input object. + * + *

When accepting an input object, all input parameters must have a value. If an input + * parameter is missing from the input object, it must be assigned a value of `null` (or the value + * of `default` for that parameter, if provided) for the purposes of validation and evaluation of + * expressions. * + * + *

+ */ + java.util.List getInputs(); + /** + * Getter for property https://w3id.org/cwl/cwl#outputs
+ * + *
+ * + * Defines the parameters representing the output of the process. May be used to generate and/or + * validate the output object. * + * + *
+ */ + java.util.List getOutputs(); + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#GalaxyWorkflow/class
+ */ + String getClass_(); + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#GalaxyWorkflow/steps
+ * + *
+ * + * The individual steps that make up the workflow. Each step is executed when all of its input + * data links are fulfilled. * + * + *
+ */ + java.util.List getSteps(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyWorkflowImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyWorkflowImpl.java new file mode 100644 index 00000000..b6a2192a --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/GalaxyWorkflowImpl.java @@ -0,0 +1,271 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for + * https://galaxyproject.org/gxformat2/v19_09#GalaxyWorkflow
+ * + *
+ * + * This is documentation for a workflow! + * + *
+ */ +public class GalaxyWorkflowImpl extends SavableImpl implements GalaxyWorkflow { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private java.util.Optional id; + + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + public java.util.Optional getId() { + return this.id; + } + + private java.util.Optional label; + + /** + * Getter for property https://w3id.org/cwl/cwl#Labeled/label
+ * + *
+ * + * A short, human-readable label of this object. * + * + *
+ */ + public java.util.Optional getLabel() { + return this.label; + } + + private Object doc; + + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + public Object getDoc() { + return this.doc; + } + + private java.util.List inputs; + + /** + * Getter for property https://w3id.org/cwl/cwl#inputs
+ * + *
+ * + * Defines the input parameters of the process. The process is ready to run when all required + * input parameters are associated with concrete values. Input parameters include a schema for + * each parameter which is used to validate the input object. It may also be used to build a user + * interface for constructing the input object. + * + *

When accepting an input object, all input parameters must have a value. If an input + * parameter is missing from the input object, it must be assigned a value of `null` (or the value + * of `default` for that parameter, if provided) for the purposes of validation and evaluation of + * expressions. * + * + *

+ */ + public java.util.List getInputs() { + return this.inputs; + } + + private java.util.List outputs; + + /** + * Getter for property https://w3id.org/cwl/cwl#outputs
+ * + *
+ * + * Defines the parameters representing the output of the process. May be used to generate and/or + * validate the output object. * + * + *
+ */ + public java.util.List getOutputs() { + return this.outputs; + } + + private String class_; + + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#GalaxyWorkflow/class
+ */ + public String getClass_() { + return this.class_; + } + + private java.util.List steps; + + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#GalaxyWorkflow/steps
+ * + *
+ * + * The individual steps that make up the workflow. Each step is executed when all of its input + * data links are fulfilled. * + * + *
+ */ + public java.util.List getSteps() { + return this.steps; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * GalaxyWorkflowImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public GalaxyWorkflowImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("GalaxyWorkflowImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + java.util.Optional id; + + if (__doc.containsKey("id")) { + try { + id = + LoaderInstances.uri_optional_StringInstance_True_False_None.loadField( + __doc.get("id"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + id = null; // won't be used but prevents compiler from complaining. + final String __message = "the `id` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + id = null; + } + + if (id == null) { + if (__docRoot != null) { + id = java.util.Optional.of(__docRoot); + } else { + id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString()); + } + } + __baseUri = (String) id.orElse(null); + java.util.Optional label; + + if (__doc.containsKey("label")) { + try { + label = + LoaderInstances.optional_StringInstance.loadField( + __doc.get("label"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + label = null; // won't be used but prevents compiler from complaining. + final String __message = "the `label` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + label = null; + } + Object doc; + + if (__doc.containsKey("doc")) { + try { + doc = + LoaderInstances.union_of_NullInstance_or_StringInstance_or_array_of_StringInstance + .loadField(__doc.get("doc"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + doc = null; // won't be used but prevents compiler from complaining. + final String __message = "the `doc` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + doc = null; + } + java.util.List inputs; + try { + inputs = + LoaderInstances.idmap_inputs_array_of_WorkflowInputParameter.loadField( + __doc.get("inputs"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + inputs = null; // won't be used but prevents compiler from complaining. + final String __message = "the `inputs` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + java.util.List outputs; + try { + outputs = + LoaderInstances.idmap_outputs_array_of_WorkflowOutputParameter.loadField( + __doc.get("outputs"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + outputs = null; // won't be used but prevents compiler from complaining. + final String __message = "the `outputs` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + String class_; + try { + class_ = + LoaderInstances.uri_StringInstance_False_True_None.loadField( + __doc.get("class"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + class_ = null; // won't be used but prevents compiler from complaining. + final String __message = "the `class` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + java.util.List steps; + try { + steps = + LoaderInstances.idmap_steps_array_of_WorkflowStep.loadField( + __doc.get("steps"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + steps = null; // won't be used but prevents compiler from complaining. + final String __message = "the `steps` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.id = (java.util.Optional) id; + this.label = (java.util.Optional) label; + this.doc = (Object) doc; + this.inputs = (java.util.List) inputs; + this.outputs = (java.util.List) outputs; + this.class_ = (String) class_; + this.steps = (java.util.List) steps; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/HasStepPosition.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/HasStepPosition.java new file mode 100644 index 00000000..893e10d0 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/HasStepPosition.java @@ -0,0 +1,15 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for + * https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition
+ */ +public interface HasStepPosition extends Savable { + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition/position
+ */ + java.util.Optional getPosition(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/Identified.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/Identified.java new file mode 100644 index 00000000..32399f2d --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/Identified.java @@ -0,0 +1,6 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** Auto-generated interface for https://w3id.org/cwl/cwl#Identified
*/ +public interface Identified extends Savable {} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/InputParameter.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/InputParameter.java new file mode 100644 index 00000000..fc2b6305 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/InputParameter.java @@ -0,0 +1,29 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** Auto-generated interface for https://w3id.org/cwl/cwl#InputParameter
*/ +public interface InputParameter extends Parameter, Savable { + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); + /** + * Getter for property https://w3id.org/cwl/salad#default
+ * + *
+ * + * The default value to use for this parameter if the parameter is missing from the input object, + * or if the value of the parameter in the input object is `null`. Default values are applied + * before evaluating expressions (e.g. dependent `valueFrom` fields). * + * + *
+ */ + java.util.Optional getDefault(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/Labeled.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/Labeled.java new file mode 100644 index 00000000..bd1665b5 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/Labeled.java @@ -0,0 +1,17 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** Auto-generated interface for https://w3id.org/cwl/cwl#Labeled
*/ +public interface Labeled extends Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#Labeled/label
+ * + *
+ * + * A short, human-readable label of this object. * + * + *
+ */ + java.util.Optional getLabel(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/OutputParameter.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/OutputParameter.java new file mode 100644 index 00000000..f7099fba --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/OutputParameter.java @@ -0,0 +1,17 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** Auto-generated interface for https://w3id.org/cwl/cwl#OutputParameter
*/ +public interface OutputParameter extends Parameter, Savable { + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/Parameter.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/Parameter.java new file mode 100644 index 00000000..b512ccb3 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/Parameter.java @@ -0,0 +1,25 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://w3id.org/cwl/cwl#Parameter
+ * + *
+ * + * Define an input or output parameter to a process. + * + *
+ */ +public interface Parameter extends Documented, Identified, Savable { + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/PrimitiveType.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/PrimitiveType.java new file mode 100644 index 00000000..8538e201 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/PrimitiveType.java @@ -0,0 +1,31 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +public enum PrimitiveType { + NULL("null"), + BOOLEAN("boolean"), + INT("int"), + LONG("long"), + FLOAT("float"), + DOUBLE("double"), + STRING("string"); + + private static String[] symbols = + new String[] {"null", "boolean", "int", "long", "float", "double", "string"}; + private String docVal; + + private PrimitiveType(final String docVal) { + this.docVal = docVal; + } + + public static PrimitiveType fromDocumentVal(final String docVal) { + for (final PrimitiveType val : PrimitiveType.values()) { + if (val.docVal.equals(docVal)) { + return val; + } + } + throw new ValidationException( + String.format("Expected one of %s", PrimitiveType.symbols, docVal)); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/Process.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/Process.java new file mode 100644 index 00000000..ce97934c --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/Process.java @@ -0,0 +1,65 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://w3id.org/cwl/cwl#Process
+ * + *
+ * + * The base executable type in CWL is the `Process` object defined by the document. Note that the + * `Process` object is abstract and cannot be directly executed. + * + *
+ */ +public interface Process extends Identified, Labeled, Documented, Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#Labeled/label
+ * + *
+ * + * A short, human-readable label of this object. * + * + *
+ */ + java.util.Optional getLabel(); + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); + /** + * Getter for property https://w3id.org/cwl/cwl#inputs
+ * + *
+ * + * Defines the input parameters of the process. The process is ready to run when all required + * input parameters are associated with concrete values. Input parameters include a schema for + * each parameter which is used to validate the input object. It may also be used to build a user + * interface for constructing the input object. + * + *

When accepting an input object, all input parameters must have a value. If an input + * parameter is missing from the input object, it must be assigned a value of `null` (or the value + * of `default` for that parameter, if provided) for the purposes of validation and evaluation of + * expressions. * + * + *

+ */ + java.util.List getInputs(); + /** + * Getter for property https://w3id.org/cwl/cwl#outputs
+ * + *
+ * + * Defines the parameters representing the output of the process. May be used to generate and/or + * validate the output object. * + * + *
+ */ + java.util.List getOutputs(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordField.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordField.java new file mode 100644 index 00000000..30f351ed --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordField.java @@ -0,0 +1,46 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://w3id.org/cwl/salad#RecordField
+ * This interface is implemented by {@link RecordFieldImpl}
+ * + *
+ * + * A field of a record. + * + *
+ */ +public interface RecordField extends Documented, Savable { + /** + * Getter for property https://w3id.org/cwl/salad#RecordField/name
+ * + *
+ * + * The name of the field * + * + *
+ */ + String getName(); + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * The field type * + * + *
+ */ + Object getType(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordFieldImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordFieldImpl.java new file mode 100644 index 00000000..7904e97d --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordFieldImpl.java @@ -0,0 +1,157 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for https://w3id.org/cwl/salad#RecordField
+ * + *
+ * + * A field of a record. + * + *
+ */ +public class RecordFieldImpl extends SavableImpl implements RecordField { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private String name; + + /** + * Getter for property https://w3id.org/cwl/salad#RecordField/name
+ * + *
+ * + * The name of the field * + * + *
+ */ + public String getName() { + return this.name; + } + + private Object doc; + + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + public Object getDoc() { + return this.doc; + } + + private Object type; + + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * The field type * + * + *
+ */ + public Object getType() { + return this.type; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * RecordFieldImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public RecordFieldImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("RecordFieldImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + String name; + + if (__doc.containsKey("name")) { + try { + name = + LoaderInstances.uri_StringInstance_True_False_None.loadField( + __doc.get("name"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + name = null; // won't be used but prevents compiler from complaining. + final String __message = "the `name` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + name = null; + } + + if (name == null) { + if (__docRoot != null) { + name = __docRoot; + } else { + throw new ValidationException("Missing name"); + } + } + __baseUri = (String) name; + Object doc; + + if (__doc.containsKey("doc")) { + try { + doc = + LoaderInstances.union_of_NullInstance_or_StringInstance_or_array_of_StringInstance + .loadField(__doc.get("doc"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + doc = null; // won't be used but prevents compiler from complaining. + final String __message = "the `doc` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + doc = null; + } + Object type; + try { + type = + LoaderInstances + .typedsl_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_or_array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_2 + .loadField(__doc.get("type"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + type = null; // won't be used but prevents compiler from complaining. + final String __message = "the `type` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.doc = (Object) doc; + this.name = (String) name; + this.type = (Object) type; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordSchema.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordSchema.java new file mode 100644 index 00000000..f03cd25d --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordSchema.java @@ -0,0 +1,30 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://w3id.org/cwl/salad#RecordSchema
+ * This interface is implemented by {@link RecordSchemaImpl}
+ */ +public interface RecordSchema extends Savable { + /** + * Getter for property https://w3id.org/cwl/salad#fields
+ * + *
+ * + * Defines the fields of the record. * + * + *
+ */ + java.util.Optional> getFields(); + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Must be `record` * + * + *
+ */ + enum_d9cba076fca539106791a4f46d198c7fcfbdb779 getType(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordSchemaImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordSchemaImpl.java new file mode 100644 index 00000000..0f590d37 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/RecordSchemaImpl.java @@ -0,0 +1,107 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** Auto-generated class implementation for https://w3id.org/cwl/salad#RecordSchema
*/ +public class RecordSchemaImpl extends SavableImpl implements RecordSchema { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private java.util.Optional> fields; + + /** + * Getter for property https://w3id.org/cwl/salad#fields
+ * + *
+ * + * Defines the fields of the record. * + * + *
+ */ + public java.util.Optional> getFields() { + return this.fields; + } + + private enum_d9cba076fca539106791a4f46d198c7fcfbdb779 type; + + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Must be `record` * + * + *
+ */ + public enum_d9cba076fca539106791a4f46d198c7fcfbdb779 getType() { + return this.type; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * RecordSchemaImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public RecordSchemaImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("RecordSchemaImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + java.util.Optional> fields; + + if (__doc.containsKey("fields")) { + try { + fields = + LoaderInstances.idmap_fields_optional_array_of_RecordField.loadField( + __doc.get("fields"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + fields = null; // won't be used but prevents compiler from complaining. + final String __message = "the `fields` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + fields = null; + } + enum_d9cba076fca539106791a4f46d198c7fcfbdb779 type; + try { + type = + LoaderInstances.typedsl_enum_d9cba076fca539106791a4f46d198c7fcfbdb779_2.loadField( + __doc.get("type"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + type = null; // won't be used but prevents compiler from complaining. + final String __message = "the `type` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.fields = (java.util.Optional>) fields; + this.type = (enum_d9cba076fca539106791a4f46d198c7fcfbdb779) type; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/ReferencesTool.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/ReferencesTool.java new file mode 100644 index 00000000..600be3e0 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/ReferencesTool.java @@ -0,0 +1,46 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool
+ */ +public interface ReferencesTool extends Savable { + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_id
+ * + *
+ * + * The tool ID used to run this step of the workflow (e.g. 'cat1' or + * 'toolshed.g2.bx.psu.edu/repos/nml/collapse_collections/collapse_dataset/4.0'). * + * + *
+ */ + java.util.Optional getTool_id(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_shed_repository + *
+ * + *
+ * + * The Galaxy Tool Shed repository that should be installed in order to use this tool. * + * + *
+ */ + java.util.Optional getTool_shed_repository(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_version
+ * + *
+ * + * The tool version corresponding used to run this step of the workflow. For tool shed installed + * tools, the ID generally uniquely specifies a version and this field is optional. * + * + *
+ */ + java.util.Optional getTool_version(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/Sink.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/Sink.java new file mode 100644 index 00000000..223be750 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/Sink.java @@ -0,0 +1,18 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** Auto-generated interface for https://galaxyproject.org/gxformat2/v19_09#Sink
*/ +public interface Sink extends Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#source
+ * + *
+ * + * Specifies one or more workflow parameters that will provide input to the underlying step + * parameter. * + * + *
+ */ + Object getSource(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/StepPosition.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/StepPosition.java new file mode 100644 index 00000000..291280d3 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/StepPosition.java @@ -0,0 +1,39 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for + * https://galaxyproject.org/gxformat2/gxformat2common#StepPosition
+ * This interface is implemented by {@link StepPositionImpl}
+ * + *
+ * + * This field specifies the location of the step's node when rendered in the workflow editor. + * + *
+ */ +public interface StepPosition extends Savable { + /** + * Getter for property https://galaxyproject.org/gxformat2/gxformat2common#StepPosition/top + *
+ * + *
+ * + * Relative vertical position of the step's node when rendered in the workflow editor. * + * + *
+ */ + Float getTop(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#StepPosition/left
+ * + *
+ * + * Relative horizontal position of the step's node when rendered in the workflow editor. * + * + *
+ */ + Float getLeft(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/StepPositionImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/StepPositionImpl.java new file mode 100644 index 00000000..c219af5d --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/StepPositionImpl.java @@ -0,0 +1,109 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for + * https://galaxyproject.org/gxformat2/gxformat2common#StepPosition
+ * + *
+ * + * This field specifies the location of the step's node when rendered in the workflow editor. + * + *
+ */ +public class StepPositionImpl extends SavableImpl implements StepPosition { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private Float top; + + /** + * Getter for property https://galaxyproject.org/gxformat2/gxformat2common#StepPosition/top + *
+ * + *
+ * + * Relative vertical position of the step's node when rendered in the workflow editor. * + * + *
+ */ + public Float getTop() { + return this.top; + } + + private Float left; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#StepPosition/left
+ * + *
+ * + * Relative horizontal position of the step's node when rendered in the workflow editor. * + * + *
+ */ + public Float getLeft() { + return this.left; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * StepPositionImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public StepPositionImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("StepPositionImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + Float top; + try { + top = LoaderInstances.FloatInstance.loadField(__doc.get("top"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + top = null; // won't be used but prevents compiler from complaining. + final String __message = "the `top` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + Float left; + try { + left = + LoaderInstances.FloatInstance.loadField(__doc.get("left"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + left = null; // won't be used but prevents compiler from complaining. + final String __message = "the `left` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.top = (Float) top; + this.left = (Float) left; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/ToolShedRepository.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/ToolShedRepository.java new file mode 100644 index 00000000..d21f112a --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/ToolShedRepository.java @@ -0,0 +1,57 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository
+ * This interface is implemented by {@link ToolShedRepositoryImpl}
+ */ +public interface ToolShedRepository extends Savable { + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository/name
+ * + *
+ * + * The name of the tool shed repository this tool can be found in. * + * + *
+ */ + String getName(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository/changeset_revision + *
+ * + *
+ * + * The revision of the tool shed repository this tool can be found in. * + * + *
+ */ + String getChangeset_revision(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository/owner
+ * + *
+ * + * The owner of the tool shed repository this tool can be found in. * + * + *
+ */ + String getOwner(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository/tool_shed
+ * + *
+ * + * The URI of the tool shed containing the repository this tool can be found in - typically this + * should be toolshed.g2.bx.psu.edu. * + * + *
+ */ + String getTool_shed(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/ToolShedRepositoryImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/ToolShedRepositoryImpl.java new file mode 100644 index 00000000..f55bb781 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/ToolShedRepositoryImpl.java @@ -0,0 +1,176 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository
+ */ +public class ToolShedRepositoryImpl extends SavableImpl implements ToolShedRepository { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private String name; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository/name
+ * + *
+ * + * The name of the tool shed repository this tool can be found in. * + * + *
+ */ + public String getName() { + return this.name; + } + + private String changeset_revision; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository/changeset_revision + *
+ * + *
+ * + * The revision of the tool shed repository this tool can be found in. * + * + *
+ */ + public String getChangeset_revision() { + return this.changeset_revision; + } + + private String owner; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository/owner
+ * + *
+ * + * The owner of the tool shed repository this tool can be found in. * + * + *
+ */ + public String getOwner() { + return this.owner; + } + + private String tool_shed; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository/tool_shed
+ * + *
+ * + * The URI of the tool shed containing the repository this tool can be found in - typically this + * should be toolshed.g2.bx.psu.edu. * + * + *
+ */ + public String getTool_shed() { + return this.tool_shed; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * ToolShedRepositoryImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public ToolShedRepositoryImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("ToolShedRepositoryImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + String name; + + if (__doc.containsKey("name")) { + try { + name = + LoaderInstances.uri_StringInstance_True_False_None.loadField( + __doc.get("name"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + name = null; // won't be used but prevents compiler from complaining. + final String __message = "the `name` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + name = null; + } + + if (name == null) { + if (__docRoot != null) { + name = __docRoot; + } else { + throw new ValidationException("Missing name"); + } + } + __baseUri = (String) name; + String changeset_revision; + try { + changeset_revision = + LoaderInstances.StringInstance.loadField( + __doc.get("changeset_revision"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + changeset_revision = null; // won't be used but prevents compiler from complaining. + final String __message = "the `changeset_revision` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + String owner; + try { + owner = + LoaderInstances.StringInstance.loadField(__doc.get("owner"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + owner = null; // won't be used but prevents compiler from complaining. + final String __message = "the `owner` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + String tool_shed; + try { + tool_shed = + LoaderInstances.StringInstance.loadField( + __doc.get("tool_shed"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + tool_shed = null; // won't be used but prevents compiler from complaining. + final String __message = "the `tool_shed` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.changeset_revision = (String) changeset_revision; + this.name = (String) name; + this.owner = (String) owner; + this.tool_shed = (String) tool_shed; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowInputParameter.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowInputParameter.java new file mode 100644 index 00000000..a30bca0b --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowInputParameter.java @@ -0,0 +1,53 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for + * https://galaxyproject.org/gxformat2/v19_09#WorkflowInputParameter
+ * This interface is implemented by {@link WorkflowInputParameterImpl}
+ */ +public interface WorkflowInputParameter extends InputParameter, Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + java.util.Optional getId(); + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); + /** + * Getter for property https://w3id.org/cwl/salad#default
+ * + *
+ * + * The default value to use for this parameter if the parameter is missing from the input object, + * or if the value of the parameter in the input object is `null`. Default values are applied + * before evaluating expressions (e.g. dependent `valueFrom` fields). * + * + *
+ */ + java.util.Optional getDefault(); + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Specify valid types of data that may be assigned to this parameter. * + * + *
+ */ + java.util.Optional getType(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowInputParameterImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowInputParameterImpl.java new file mode 100644 index 00000000..d19baf53 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowInputParameterImpl.java @@ -0,0 +1,191 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for + * https://galaxyproject.org/gxformat2/v19_09#WorkflowInputParameter
+ */ +public class WorkflowInputParameterImpl extends SavableImpl implements WorkflowInputParameter { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private java.util.Optional id; + + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + public java.util.Optional getId() { + return this.id; + } + + private Object doc; + + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + public Object getDoc() { + return this.doc; + } + + private java.util.Optional default_; + + /** + * Getter for property https://w3id.org/cwl/salad#default
+ * + *
+ * + * The default value to use for this parameter if the parameter is missing from the input object, + * or if the value of the parameter in the input object is `null`. Default values are applied + * before evaluating expressions (e.g. dependent `valueFrom` fields). * + * + *
+ */ + public java.util.Optional getDefault() { + return this.default_; + } + + private java.util.Optional type; + + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Specify valid types of data that may be assigned to this parameter. * + * + *
+ */ + public java.util.Optional getType() { + return this.type; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * WorkflowInputParameterImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public WorkflowInputParameterImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("WorkflowInputParameterImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + java.util.Optional id; + + if (__doc.containsKey("id")) { + try { + id = + LoaderInstances.uri_optional_StringInstance_True_False_None.loadField( + __doc.get("id"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + id = null; // won't be used but prevents compiler from complaining. + final String __message = "the `id` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + id = null; + } + + if (id == null) { + if (__docRoot != null) { + id = java.util.Optional.of(__docRoot); + } else { + id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString()); + } + } + __baseUri = (String) id.orElse(null); + Object doc; + + if (__doc.containsKey("doc")) { + try { + doc = + LoaderInstances.union_of_NullInstance_or_StringInstance_or_array_of_StringInstance + .loadField(__doc.get("doc"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + doc = null; // won't be used but prevents compiler from complaining. + final String __message = "the `doc` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + doc = null; + } + java.util.Optional default_; + + if (__doc.containsKey("default")) { + try { + default_ = + LoaderInstances.optional_AnyInstance.loadField( + __doc.get("default"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + default_ = null; // won't be used but prevents compiler from complaining. + final String __message = "the `default` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + default_ = null; + } + java.util.Optional type; + + if (__doc.containsKey("type")) { + try { + type = + LoaderInstances.typedsl_optional_GalaxyType_2.loadField( + __doc.get("type"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + type = null; // won't be used but prevents compiler from complaining. + final String __message = "the `type` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + type = null; + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.doc = (Object) doc; + this.id = (java.util.Optional) id; + this.default_ = (java.util.Optional) default_; + this.type = (java.util.Optional) type; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowOutputParameter.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowOutputParameter.java new file mode 100644 index 00000000..9a4ff9e8 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowOutputParameter.java @@ -0,0 +1,60 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for + * https://galaxyproject.org/gxformat2/v19_09#WorkflowOutputParameter
+ * This interface is implemented by {@link WorkflowOutputParameterImpl}
+ * + *
+ * + * Describe an output parameter of a workflow. The parameter must be connected to one parameter + * defined in the workflow that will provide the value of the output parameter. It is legal to + * connect a WorkflowInputParameter to a WorkflowOutputParameter. + * + *
+ */ +public interface WorkflowOutputParameter extends OutputParameter, Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + java.util.Optional getId(); + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/v19_09#WorkflowOutputParameter/outputSource
+ * + *
+ * + * Specifies workflow parameter that supply the value of to the output parameter. * + * + *
+ */ + java.util.Optional getOutputSource(); + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Specify valid types of data that may be assigned to this parameter. * + * + *
+ */ + java.util.Optional getType(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowOutputParameterImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowOutputParameterImpl.java new file mode 100644 index 00000000..e318cea2 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowOutputParameterImpl.java @@ -0,0 +1,198 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for + * https://galaxyproject.org/gxformat2/v19_09#WorkflowOutputParameter
+ * + *
+ * + * Describe an output parameter of a workflow. The parameter must be connected to one parameter + * defined in the workflow that will provide the value of the output parameter. It is legal to + * connect a WorkflowInputParameter to a WorkflowOutputParameter. + * + *
+ */ +public class WorkflowOutputParameterImpl extends SavableImpl implements WorkflowOutputParameter { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private java.util.Optional id; + + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + public java.util.Optional getId() { + return this.id; + } + + private Object doc; + + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + public Object getDoc() { + return this.doc; + } + + private java.util.Optional outputSource; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/v19_09#WorkflowOutputParameter/outputSource
+ * + *
+ * + * Specifies workflow parameter that supply the value of to the output parameter. * + * + *
+ */ + public java.util.Optional getOutputSource() { + return this.outputSource; + } + + private java.util.Optional type; + + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Specify valid types of data that may be assigned to this parameter. * + * + *
+ */ + public java.util.Optional getType() { + return this.type; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * WorkflowOutputParameterImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public WorkflowOutputParameterImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("WorkflowOutputParameterImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + java.util.Optional id; + + if (__doc.containsKey("id")) { + try { + id = + LoaderInstances.uri_optional_StringInstance_True_False_None.loadField( + __doc.get("id"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + id = null; // won't be used but prevents compiler from complaining. + final String __message = "the `id` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + id = null; + } + + if (id == null) { + if (__docRoot != null) { + id = java.util.Optional.of(__docRoot); + } else { + id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString()); + } + } + __baseUri = (String) id.orElse(null); + Object doc; + + if (__doc.containsKey("doc")) { + try { + doc = + LoaderInstances.union_of_NullInstance_or_StringInstance_or_array_of_StringInstance + .loadField(__doc.get("doc"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + doc = null; // won't be used but prevents compiler from complaining. + final String __message = "the `doc` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + doc = null; + } + java.util.Optional outputSource; + + if (__doc.containsKey("outputSource")) { + try { + outputSource = + LoaderInstances.optional_StringInstance.loadField( + __doc.get("outputSource"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + outputSource = null; // won't be used but prevents compiler from complaining. + final String __message = "the `outputSource` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + outputSource = null; + } + java.util.Optional type; + + if (__doc.containsKey("type")) { + try { + type = + LoaderInstances.typedsl_optional_GalaxyType_2.loadField( + __doc.get("type"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + type = null; // won't be used but prevents compiler from complaining. + final String __message = "the `type` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + type = null; + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.doc = (Object) doc; + this.id = (java.util.Optional) id; + this.outputSource = (java.util.Optional) outputSource; + this.type = (java.util.Optional) type; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStep.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStep.java new file mode 100644 index 00000000..892c06a8 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStep.java @@ -0,0 +1,142 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://galaxyproject.org/gxformat2/v19_09#WorkflowStep
+ * This interface is implemented by {@link WorkflowStepImpl}
+ * + *
+ * + * Workflow step. + * + *
+ */ +public interface WorkflowStep + extends Identified, Labeled, Documented, HasStepPosition, ReferencesTool, Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + java.util.Optional getId(); + /** + * Getter for property https://w3id.org/cwl/cwl#Labeled/label
+ * + *
+ * + * A short, human-readable label of this object. * + * + *
+ */ + java.util.Optional getLabel(); + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + Object getDoc(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition/position
+ */ + java.util.Optional getPosition(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_id
+ * + *
+ * + * The tool ID used to run this step of the workflow (e.g. 'cat1' or + * 'toolshed.g2.bx.psu.edu/repos/nml/collapse_collections/collapse_dataset/4.0'). * + * + *
+ */ + java.util.Optional getTool_id(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_shed_repository + *
+ * + *
+ * + * The Galaxy Tool Shed repository that should be installed in order to use this tool. * + * + *
+ */ + java.util.Optional getTool_shed_repository(); + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_version
+ * + *
+ * + * The tool version corresponding used to run this step of the workflow. For tool shed installed + * tools, the ID generally uniquely specifies a version and this field is optional. * + * + *
+ */ + java.util.Optional getTool_version(); + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#in
+ * + *
+ * + * Defines the input parameters of the workflow step. The process is ready to run when all + * required input parameters are associated with concrete values. Input parameters include a + * schema for each parameter which is used to validate the input object. It may also be used build + * a user interface for constructing the input object. * + * + *
+ */ + java.util.Optional> getIn(); + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#out
+ * + *
+ * + * Defines the parameters representing the output of the process. May be used to generate and/or + * validate the output object. * + * + *
+ */ + java.util.Optional> getOut(); + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#WorkflowStep/state
+ * + *
+ * + * Structured tool state. * + * + *
+ */ + java.util.Optional getState(); + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Workflow step module's type (defaults to 'tool'). * + * + *
+ */ + java.util.Optional getType(); + /** + * Getter for property https://w3id.org/cwl/cwl#run
+ * + *
+ * + * Specifies a subworkflow to run. * + * + *
+ */ + java.util.Optional getRun(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepImpl.java new file mode 100644 index 00000000..11bd3af5 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepImpl.java @@ -0,0 +1,457 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for + * https://galaxyproject.org/gxformat2/v19_09#WorkflowStep
+ * + *
+ * + * Workflow step. + * + *
+ */ +public class WorkflowStepImpl extends SavableImpl implements WorkflowStep { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private java.util.Optional id; + + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + public java.util.Optional getId() { + return this.id; + } + + private java.util.Optional label; + + /** + * Getter for property https://w3id.org/cwl/cwl#Labeled/label
+ * + *
+ * + * A short, human-readable label of this object. * + * + *
+ */ + public java.util.Optional getLabel() { + return this.label; + } + + private Object doc; + + /** + * Getter for property https://w3id.org/cwl/salad#Documented/doc
+ * + *
+ * + * A documentation string for this object, or an array of strings which should be concatenated. * + * + *
+ */ + public Object getDoc() { + return this.doc; + } + + private java.util.Optional position; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition/position
+ */ + public java.util.Optional getPosition() { + return this.position; + } + + private java.util.Optional tool_id; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_id
+ * + *
+ * + * The tool ID used to run this step of the workflow (e.g. 'cat1' or + * 'toolshed.g2.bx.psu.edu/repos/nml/collapse_collections/collapse_dataset/4.0'). * + * + *
+ */ + public java.util.Optional getTool_id() { + return this.tool_id; + } + + private java.util.Optional tool_shed_repository; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_shed_repository + *
+ * + *
+ * + * The Galaxy Tool Shed repository that should be installed in order to use this tool. * + * + *
+ */ + public java.util.Optional getTool_shed_repository() { + return this.tool_shed_repository; + } + + private java.util.Optional tool_version; + + /** + * Getter for property + * https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool/tool_version
+ * + *
+ * + * The tool version corresponding used to run this step of the workflow. For tool shed installed + * tools, the ID generally uniquely specifies a version and this field is optional. * + * + *
+ */ + public java.util.Optional getTool_version() { + return this.tool_version; + } + + private java.util.Optional> in; + + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#in
+ * + *
+ * + * Defines the input parameters of the workflow step. The process is ready to run when all + * required input parameters are associated with concrete values. Input parameters include a + * schema for each parameter which is used to validate the input object. It may also be used build + * a user interface for constructing the input object. * + * + *
+ */ + public java.util.Optional> getIn() { + return this.in; + } + + private java.util.Optional> out; + + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#out
+ * + *
+ * + * Defines the parameters representing the output of the process. May be used to generate and/or + * validate the output object. * + * + *
+ */ + public java.util.Optional> getOut() { + return this.out; + } + + private java.util.Optional state; + + /** + * Getter for property https://galaxyproject.org/gxformat2/v19_09#WorkflowStep/state
+ * + *
+ * + * Structured tool state. * + * + *
+ */ + public java.util.Optional getState() { + return this.state; + } + + private java.util.Optional type; + + /** + * Getter for property https://w3id.org/cwl/salad#type
+ * + *
+ * + * Workflow step module's type (defaults to 'tool'). * + * + *
+ */ + public java.util.Optional getType() { + return this.type; + } + + private java.util.Optional run; + + /** + * Getter for property https://w3id.org/cwl/cwl#run
+ * + *
+ * + * Specifies a subworkflow to run. * + * + *
+ */ + public java.util.Optional getRun() { + return this.run; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * WorkflowStepImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public WorkflowStepImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("WorkflowStepImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + java.util.Optional id; + + if (__doc.containsKey("id")) { + try { + id = + LoaderInstances.uri_optional_StringInstance_True_False_None.loadField( + __doc.get("id"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + id = null; // won't be used but prevents compiler from complaining. + final String __message = "the `id` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + id = null; + } + + if (id == null) { + if (__docRoot != null) { + id = java.util.Optional.of(__docRoot); + } else { + id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString()); + } + } + __baseUri = (String) id.orElse(null); + java.util.Optional label; + + if (__doc.containsKey("label")) { + try { + label = + LoaderInstances.optional_StringInstance.loadField( + __doc.get("label"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + label = null; // won't be used but prevents compiler from complaining. + final String __message = "the `label` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + label = null; + } + Object doc; + + if (__doc.containsKey("doc")) { + try { + doc = + LoaderInstances.union_of_NullInstance_or_StringInstance_or_array_of_StringInstance + .loadField(__doc.get("doc"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + doc = null; // won't be used but prevents compiler from complaining. + final String __message = "the `doc` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + doc = null; + } + java.util.Optional position; + + if (__doc.containsKey("position")) { + try { + position = + LoaderInstances.optional_StepPosition.loadField( + __doc.get("position"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + position = null; // won't be used but prevents compiler from complaining. + final String __message = "the `position` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + position = null; + } + java.util.Optional tool_id; + + if (__doc.containsKey("tool_id")) { + try { + tool_id = + LoaderInstances.optional_StringInstance.loadField( + __doc.get("tool_id"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + tool_id = null; // won't be used but prevents compiler from complaining. + final String __message = "the `tool_id` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + tool_id = null; + } + java.util.Optional tool_shed_repository; + + if (__doc.containsKey("tool_shed_repository")) { + try { + tool_shed_repository = + LoaderInstances.optional_ToolShedRepository.loadField( + __doc.get("tool_shed_repository"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + tool_shed_repository = null; // won't be used but prevents compiler from complaining. + final String __message = "the `tool_shed_repository` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + tool_shed_repository = null; + } + java.util.Optional tool_version; + + if (__doc.containsKey("tool_version")) { + try { + tool_version = + LoaderInstances.optional_StringInstance.loadField( + __doc.get("tool_version"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + tool_version = null; // won't be used but prevents compiler from complaining. + final String __message = "the `tool_version` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + tool_version = null; + } + java.util.Optional> in; + + if (__doc.containsKey("in")) { + try { + in = + LoaderInstances.idmap_in_optional_array_of_WorkflowStepInput.loadField( + __doc.get("in"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + in = null; // won't be used but prevents compiler from complaining. + final String __message = "the `in` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + in = null; + } + java.util.Optional> out; + + if (__doc.containsKey("out")) { + try { + out = + LoaderInstances + .uri_optional_array_of_union_of_StringInstance_or_WorkflowStepOutput_True_False_None + .loadField(__doc.get("out"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + out = null; // won't be used but prevents compiler from complaining. + final String __message = "the `out` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + out = null; + } + java.util.Optional state; + + if (__doc.containsKey("state")) { + try { + state = + LoaderInstances.optional_AnyInstance.loadField( + __doc.get("state"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + state = null; // won't be used but prevents compiler from complaining. + final String __message = "the `state` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + state = null; + } + java.util.Optional type; + + if (__doc.containsKey("type")) { + try { + type = + LoaderInstances.typedsl_optional_WorkflowStepType_2.loadField( + __doc.get("type"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + type = null; // won't be used but prevents compiler from complaining. + final String __message = "the `type` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + type = null; + } + java.util.Optional run; + + if (__doc.containsKey("run")) { + try { + run = + LoaderInstances.uri_optional_GalaxyWorkflow_False_False_None.loadField( + __doc.get("run"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + run = null; // won't be used but prevents compiler from complaining. + final String __message = "the `run` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + run = null; + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.id = (java.util.Optional) id; + this.label = (java.util.Optional) label; + this.doc = (Object) doc; + this.position = (java.util.Optional) position; + this.tool_id = (java.util.Optional) tool_id; + this.tool_shed_repository = (java.util.Optional) tool_shed_repository; + this.tool_version = (java.util.Optional) tool_version; + this.in = (java.util.Optional>) in; + this.out = (java.util.Optional>) out; + this.state = (java.util.Optional) state; + this.type = (java.util.Optional) type; + this.run = (java.util.Optional) run; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepInput.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepInput.java new file mode 100644 index 00000000..7bb75b10 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepInput.java @@ -0,0 +1,60 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://galaxyproject.org/gxformat2/v19_09#WorkflowStepInput + *
+ * This interface is implemented by {@link WorkflowStepInputImpl}
+ * + *
+ * + * TODO: + * + *
+ */ +public interface WorkflowStepInput extends Identified, Sink, Labeled, Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + java.util.Optional getId(); + /** + * Getter for property https://w3id.org/cwl/cwl#source
+ * + *
+ * + * Specifies one or more workflow parameters that will provide input to the underlying step + * parameter. * + * + *
+ */ + Object getSource(); + /** + * Getter for property https://w3id.org/cwl/cwl#Labeled/label
+ * + *
+ * + * A short, human-readable label of this object. * + * + *
+ */ + java.util.Optional getLabel(); + /** + * Getter for property https://w3id.org/cwl/salad#default
+ * + *
+ * + * The default value for this parameter to use if either there is no `source` field, or the value + * produced by the `source` is `null`. The default must be applied prior to scattering or + * evaluating `valueFrom`. * + * + *
+ */ + java.util.Optional getDefault(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepInputImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepInputImpl.java new file mode 100644 index 00000000..47cda948 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepInputImpl.java @@ -0,0 +1,199 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for + * https://galaxyproject.org/gxformat2/v19_09#WorkflowStepInput
+ * + *
+ * + * TODO: + * + *
+ */ +public class WorkflowStepInputImpl extends SavableImpl implements WorkflowStepInput { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private java.util.Optional id; + + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + public java.util.Optional getId() { + return this.id; + } + + private Object source; + + /** + * Getter for property https://w3id.org/cwl/cwl#source
+ * + *
+ * + * Specifies one or more workflow parameters that will provide input to the underlying step + * parameter. * + * + *
+ */ + public Object getSource() { + return this.source; + } + + private java.util.Optional label; + + /** + * Getter for property https://w3id.org/cwl/cwl#Labeled/label
+ * + *
+ * + * A short, human-readable label of this object. * + * + *
+ */ + public java.util.Optional getLabel() { + return this.label; + } + + private java.util.Optional default_; + + /** + * Getter for property https://w3id.org/cwl/salad#default
+ * + *
+ * + * The default value for this parameter to use if either there is no `source` field, or the value + * produced by the `source` is `null`. The default must be applied prior to scattering or + * evaluating `valueFrom`. * + * + *
+ */ + public java.util.Optional getDefault() { + return this.default_; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * WorkflowStepInputImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public WorkflowStepInputImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("WorkflowStepInputImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + java.util.Optional id; + + if (__doc.containsKey("id")) { + try { + id = + LoaderInstances.uri_optional_StringInstance_True_False_None.loadField( + __doc.get("id"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + id = null; // won't be used but prevents compiler from complaining. + final String __message = "the `id` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + id = null; + } + + if (id == null) { + if (__docRoot != null) { + id = java.util.Optional.of(__docRoot); + } else { + id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString()); + } + } + __baseUri = (String) id.orElse(null); + Object source; + + if (__doc.containsKey("source")) { + try { + source = + LoaderInstances + .uri_union_of_NullInstance_or_StringInstance_or_array_of_StringInstance_False_False_2 + .loadField(__doc.get("source"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + source = null; // won't be used but prevents compiler from complaining. + final String __message = "the `source` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + source = null; + } + java.util.Optional label; + + if (__doc.containsKey("label")) { + try { + label = + LoaderInstances.optional_StringInstance.loadField( + __doc.get("label"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + label = null; // won't be used but prevents compiler from complaining. + final String __message = "the `label` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + label = null; + } + java.util.Optional default_; + + if (__doc.containsKey("default")) { + try { + default_ = + LoaderInstances.optional_AnyInstance.loadField( + __doc.get("default"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + default_ = null; // won't be used but prevents compiler from complaining. + final String __message = "the `default` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + default_ = null; + } + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.id = (java.util.Optional) id; + this.source = (Object) source; + this.label = (java.util.Optional) label; + this.default_ = (java.util.Optional) default_; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepOutput.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepOutput.java new file mode 100644 index 00000000..05c466c5 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepOutput.java @@ -0,0 +1,32 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.Savable; + +/** + * Auto-generated interface for https://galaxyproject.org/gxformat2/v19_09#WorkflowStepOutput + *
+ * This interface is implemented by {@link WorkflowStepOutputImpl}
+ * + *
+ * + * Associate an output parameter of the underlying process with a workflow parameter. The workflow + * parameter (given in the `id` field) be may be used as a `source` to connect with input parameters + * of other workflow steps, or with an output parameter of the process. + * + *

A unique identifier for this workflow output parameter. This is the identifier to use in the + * `source` field of `WorkflowStepInput` to connect the output value to downstream parameters. + * + *

+ */ +public interface WorkflowStepOutput extends Identified, Savable { + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + java.util.Optional getId(); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepOutputImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepOutputImpl.java new file mode 100644 index 00000000..2e2b5bf9 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepOutputImpl.java @@ -0,0 +1,104 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.LoaderInstances; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptions; +import org.galaxyproject.gxformat2.v19_09.utils.LoadingOptionsBuilder; +import org.galaxyproject.gxformat2.v19_09.utils.SavableImpl; +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +/** + * Auto-generated class implementation for + * https://galaxyproject.org/gxformat2/v19_09#WorkflowStepOutput
+ * + *
+ * + * Associate an output parameter of the underlying process with a workflow parameter. The workflow + * parameter (given in the `id` field) be may be used as a `source` to connect with input parameters + * of other workflow steps, or with an output parameter of the process. + * + *

A unique identifier for this workflow output parameter. This is the identifier to use in the + * `source` field of `WorkflowStepInput` to connect the output value to downstream parameters. + * + *

+ */ +public class WorkflowStepOutputImpl extends SavableImpl implements WorkflowStepOutput { + private LoadingOptions loadingOptions_ = new LoadingOptionsBuilder().build(); + private java.util.Map extensionFields_ = new java.util.HashMap(); + + private java.util.Optional id; + + /** + * Getter for property https://w3id.org/cwl/cwl#Identified/id
+ * + *
+ * + * The unique identifier for this object. * + * + *
+ */ + public java.util.Optional getId() { + return this.id; + } + + /** + * Used by {@link org.galaxyproject.gxformat2.v19_09.utils.RootLoader} to construct instances of + * WorkflowStepOutputImpl. + * + * @param __doc_ Document fragment to load this record object from (presumably a {@link + * java.util.Map}). + * @param __baseUri_ Base URI to generate child document IDs against. + * @param __loadingOptions Context for loading URIs and populating objects. + * @param __docRoot_ ID at this position in the document (if available) (maybe?) + * @throws ValidationException If the document fragment is not a {@link java.util.Map} or + * validation of fields fails. + */ + public WorkflowStepOutputImpl( + final Object __doc_, + final String __baseUri_, + LoadingOptions __loadingOptions, + final String __docRoot_) { + super(__doc_, __baseUri_, __loadingOptions, __docRoot_); + // Prefix plumbing variables with '__' to reduce likelihood of collision with + // generated names. + String __baseUri = __baseUri_; + String __docRoot = __docRoot_; + if (!(__doc_ instanceof java.util.Map)) { + throw new ValidationException("WorkflowStepOutputImpl called on non-map"); + } + final java.util.Map __doc = (java.util.Map) __doc_; + final java.util.List __errors = + new java.util.ArrayList(); + if (__loadingOptions != null) { + this.loadingOptions_ = __loadingOptions; + } + java.util.Optional id; + + if (__doc.containsKey("id")) { + try { + id = + LoaderInstances.uri_optional_StringInstance_True_False_None.loadField( + __doc.get("id"), __baseUri, __loadingOptions); + } catch (ValidationException e) { + id = null; // won't be used but prevents compiler from complaining. + final String __message = "the `id` field is not valid because:"; + __errors.add(new ValidationException(__message, e)); + } + + } else { + id = null; + } + + if (id == null) { + if (__docRoot != null) { + id = java.util.Optional.of(__docRoot); + } else { + id = java.util.Optional.of("_:" + java.util.UUID.randomUUID().toString()); + } + } + __baseUri = (String) id.orElse(null); + if (!__errors.isEmpty()) { + throw new ValidationException("Trying 'RecordField'", __errors); + } + this.id = (java.util.Optional) id; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepType.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepType.java new file mode 100644 index 00000000..08ba51c6 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/WorkflowStepType.java @@ -0,0 +1,26 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +public enum WorkflowStepType { + TOOL("tool"), + SUBWORKFLOW("subworkflow"), + PAUSE("pause"); + + private static String[] symbols = new String[] {"tool", "subworkflow", "pause"}; + private String docVal; + + private WorkflowStepType(final String docVal) { + this.docVal = docVal; + } + + public static WorkflowStepType fromDocumentVal(final String docVal) { + for (final WorkflowStepType val : WorkflowStepType.values()) { + if (val.docVal.equals(docVal)) { + return val; + } + } + throw new ValidationException( + String.format("Expected one of %s", WorkflowStepType.symbols, docVal)); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d062602be0b4b8fd33e69e29a841317b6ab665bc.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d062602be0b4b8fd33e69e29a841317b6ab665bc.java new file mode 100644 index 00000000..b9027305 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d062602be0b4b8fd33e69e29a841317b6ab665bc.java @@ -0,0 +1,26 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +public enum enum_d062602be0b4b8fd33e69e29a841317b6ab665bc { + ARRAY("array"); + + private static String[] symbols = new String[] {"array"}; + private String docVal; + + private enum_d062602be0b4b8fd33e69e29a841317b6ab665bc(final String docVal) { + this.docVal = docVal; + } + + public static enum_d062602be0b4b8fd33e69e29a841317b6ab665bc fromDocumentVal(final String docVal) { + for (final enum_d062602be0b4b8fd33e69e29a841317b6ab665bc val : + enum_d062602be0b4b8fd33e69e29a841317b6ab665bc.values()) { + if (val.docVal.equals(docVal)) { + return val; + } + } + throw new ValidationException( + String.format( + "Expected one of %s", enum_d062602be0b4b8fd33e69e29a841317b6ab665bc.symbols, docVal)); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d961d79c225752b9fadb617367615ab176b47d77.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d961d79c225752b9fadb617367615ab176b47d77.java new file mode 100644 index 00000000..8eddf33b --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d961d79c225752b9fadb617367615ab176b47d77.java @@ -0,0 +1,26 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +public enum enum_d961d79c225752b9fadb617367615ab176b47d77 { + ENUM("enum"); + + private static String[] symbols = new String[] {"enum"}; + private String docVal; + + private enum_d961d79c225752b9fadb617367615ab176b47d77(final String docVal) { + this.docVal = docVal; + } + + public static enum_d961d79c225752b9fadb617367615ab176b47d77 fromDocumentVal(final String docVal) { + for (final enum_d961d79c225752b9fadb617367615ab176b47d77 val : + enum_d961d79c225752b9fadb617367615ab176b47d77.values()) { + if (val.docVal.equals(docVal)) { + return val; + } + } + throw new ValidationException( + String.format( + "Expected one of %s", enum_d961d79c225752b9fadb617367615ab176b47d77.symbols, docVal)); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d9cba076fca539106791a4f46d198c7fcfbdb779.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d9cba076fca539106791a4f46d198c7fcfbdb779.java new file mode 100644 index 00000000..498eec1f --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/enum_d9cba076fca539106791a4f46d198c7fcfbdb779.java @@ -0,0 +1,26 @@ +package org.galaxyproject.gxformat2.v19_09; + +import org.galaxyproject.gxformat2.v19_09.utils.ValidationException; + +public enum enum_d9cba076fca539106791a4f46d198c7fcfbdb779 { + RECORD("record"); + + private static String[] symbols = new String[] {"record"}; + private String docVal; + + private enum_d9cba076fca539106791a4f46d198c7fcfbdb779(final String docVal) { + this.docVal = docVal; + } + + public static enum_d9cba076fca539106791a4f46d198c7fcfbdb779 fromDocumentVal(final String docVal) { + for (final enum_d9cba076fca539106791a4f46d198c7fcfbdb779 val : + enum_d9cba076fca539106791a4f46d198c7fcfbdb779.values()) { + if (val.docVal.equals(docVal)) { + return val; + } + } + throw new ValidationException( + String.format( + "Expected one of %s", enum_d9cba076fca539106791a4f46d198c7fcfbdb779.symbols, docVal)); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/package.html b/src/main/java/org/galaxyproject/gxformat2/v19_09/package.html new file mode 100644 index 00000000..3f7b0472 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/package.html @@ -0,0 +1,4 @@ + +Package for the auto-generated Java objects corresponding generated by Schema Salad +for https://galaxyproject.org/gxformat2/v19_09#. + diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/AnyLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/AnyLoader.java new file mode 100644 index 00000000..ab50022a --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/AnyLoader.java @@ -0,0 +1,15 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +public class AnyLoader implements Loader { + + public Object load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + if (doc == null) { + throw new ValidationException("Expected non-null"); + } + return doc; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ArrayLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ArrayLoader.java new file mode 100644 index 00000000..04b52814 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ArrayLoader.java @@ -0,0 +1,42 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.ArrayList; +import java.util.List; + +public class ArrayLoader implements Loader> { + private final Loader itemLoader; + + public ArrayLoader(Loader itemLoader) { + this.itemLoader = itemLoader; + } + + public List load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + final List docList = (List) Loader.validateOfJavaType(List.class, doc); + final List r = new ArrayList(); + final List loaders = new ArrayList(); + loaders.add(this); + loaders.add(this.itemLoader); + final UnionLoader unionLoader = new UnionLoader(loaders); + final List errors = new ArrayList(); + for (final Object el : docList) { + try { + final Object loadedField = unionLoader.loadField(el, baseUri, loadingOptions); + if (loadedField instanceof List) { + r.addAll((List) loadedField); + } else { + r.add((T) loadedField); + } + } catch (final ValidationException e) { + errors.add(e); + } + } + if (!errors.isEmpty()) { + throw new ValidationException("", errors); + } + return r; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ConstantMaps.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ConstantMaps.java new file mode 100644 index 00000000..dfb66dfd --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ConstantMaps.java @@ -0,0 +1,117 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.HashMap; + +public class ConstantMaps { + // declare as HashMap for clone(). + public static final HashMap vocab = new HashMap(); + public static final HashMap rvocab = new HashMap(); + + static { + vocab.put("Any", "https://w3id.org/cwl/salad#Any"); + vocab.put("ArraySchema", "https://w3id.org/cwl/salad#ArraySchema"); + vocab.put("Documented", "https://w3id.org/cwl/salad#Documented"); + vocab.put("EnumSchema", "https://w3id.org/cwl/salad#EnumSchema"); + vocab.put("File", "https://galaxyproject.org/gxformat2/v19_09#GalaxyType/File"); + vocab.put("GalaxyType", "https://galaxyproject.org/gxformat2/v19_09#GalaxyType"); + vocab.put("GalaxyWorkflow", "https://galaxyproject.org/gxformat2/v19_09#GalaxyWorkflow"); + vocab.put( + "HasStepPosition", "https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition"); + vocab.put("Identified", "https://w3id.org/cwl/cwl#Identified"); + vocab.put("InputParameter", "https://w3id.org/cwl/cwl#InputParameter"); + vocab.put("Labeled", "https://w3id.org/cwl/cwl#Labeled"); + vocab.put("OutputParameter", "https://w3id.org/cwl/cwl#OutputParameter"); + vocab.put("Parameter", "https://w3id.org/cwl/cwl#Parameter"); + vocab.put("PrimitiveType", "https://w3id.org/cwl/salad#PrimitiveType"); + vocab.put("Process", "https://w3id.org/cwl/cwl#Process"); + vocab.put("RecordField", "https://w3id.org/cwl/salad#RecordField"); + vocab.put("RecordSchema", "https://w3id.org/cwl/salad#RecordSchema"); + vocab.put( + "ReferencesTool", "https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool"); + vocab.put("Sink", "https://galaxyproject.org/gxformat2/v19_09#Sink"); + vocab.put("StepPosition", "https://galaxyproject.org/gxformat2/gxformat2common#StepPosition"); + vocab.put( + "ToolShedRepository", + "https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository"); + vocab.put( + "WorkflowInputParameter", + "https://galaxyproject.org/gxformat2/v19_09#WorkflowInputParameter"); + vocab.put( + "WorkflowOutputParameter", + "https://galaxyproject.org/gxformat2/v19_09#WorkflowOutputParameter"); + vocab.put("WorkflowStep", "https://galaxyproject.org/gxformat2/v19_09#WorkflowStep"); + vocab.put("WorkflowStepInput", "https://galaxyproject.org/gxformat2/v19_09#WorkflowStepInput"); + vocab.put( + "WorkflowStepOutput", "https://galaxyproject.org/gxformat2/v19_09#WorkflowStepOutput"); + vocab.put("WorkflowStepType", "https://galaxyproject.org/gxformat2/v19_09#WorkflowStepType"); + vocab.put("array", "array"); + vocab.put("boolean", "http://www.w3.org/2001/XMLSchema#boolean"); + vocab.put("collection", "https://galaxyproject.org/gxformat2/v19_09#GalaxyType/collection"); + vocab.put("data", "https://galaxyproject.org/gxformat2/v19_09#GalaxyType/data"); + vocab.put("double", "http://www.w3.org/2001/XMLSchema#double"); + vocab.put("enum", "enum"); + vocab.put("float", "http://www.w3.org/2001/XMLSchema#float"); + vocab.put("int", "http://www.w3.org/2001/XMLSchema#int"); + vocab.put("long", "http://www.w3.org/2001/XMLSchema#long"); + vocab.put("null", "https://w3id.org/cwl/salad#null"); + vocab.put("pause", "https://galaxyproject.org/gxformat2/v19_09#WorkflowStepType/pause"); + vocab.put("record", "record"); + vocab.put("string", "http://www.w3.org/2001/XMLSchema#string"); + vocab.put( + "subworkflow", "https://galaxyproject.org/gxformat2/v19_09#WorkflowStepType/subworkflow"); + vocab.put("tool", "https://galaxyproject.org/gxformat2/v19_09#WorkflowStepType/tool"); + + rvocab.put("https://w3id.org/cwl/salad#Any", "Any"); + rvocab.put("https://w3id.org/cwl/salad#ArraySchema", "ArraySchema"); + rvocab.put("https://w3id.org/cwl/salad#Documented", "Documented"); + rvocab.put("https://w3id.org/cwl/salad#EnumSchema", "EnumSchema"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#GalaxyType/File", "File"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#GalaxyType", "GalaxyType"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#GalaxyWorkflow", "GalaxyWorkflow"); + rvocab.put( + "https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition", "HasStepPosition"); + rvocab.put("https://w3id.org/cwl/cwl#Identified", "Identified"); + rvocab.put("https://w3id.org/cwl/cwl#InputParameter", "InputParameter"); + rvocab.put("https://w3id.org/cwl/cwl#Labeled", "Labeled"); + rvocab.put("https://w3id.org/cwl/cwl#OutputParameter", "OutputParameter"); + rvocab.put("https://w3id.org/cwl/cwl#Parameter", "Parameter"); + rvocab.put("https://w3id.org/cwl/salad#PrimitiveType", "PrimitiveType"); + rvocab.put("https://w3id.org/cwl/cwl#Process", "Process"); + rvocab.put("https://w3id.org/cwl/salad#RecordField", "RecordField"); + rvocab.put("https://w3id.org/cwl/salad#RecordSchema", "RecordSchema"); + rvocab.put( + "https://galaxyproject.org/gxformat2/gxformat2common#ReferencesTool", "ReferencesTool"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#Sink", "Sink"); + rvocab.put("https://galaxyproject.org/gxformat2/gxformat2common#StepPosition", "StepPosition"); + rvocab.put( + "https://galaxyproject.org/gxformat2/gxformat2common#ToolShedRepository", + "ToolShedRepository"); + rvocab.put( + "https://galaxyproject.org/gxformat2/v19_09#WorkflowInputParameter", + "WorkflowInputParameter"); + rvocab.put( + "https://galaxyproject.org/gxformat2/v19_09#WorkflowOutputParameter", + "WorkflowOutputParameter"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#WorkflowStep", "WorkflowStep"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#WorkflowStepInput", "WorkflowStepInput"); + rvocab.put( + "https://galaxyproject.org/gxformat2/v19_09#WorkflowStepOutput", "WorkflowStepOutput"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#WorkflowStepType", "WorkflowStepType"); + rvocab.put("array", "array"); + rvocab.put("http://www.w3.org/2001/XMLSchema#boolean", "boolean"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#GalaxyType/collection", "collection"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#GalaxyType/data", "data"); + rvocab.put("http://www.w3.org/2001/XMLSchema#double", "double"); + rvocab.put("enum", "enum"); + rvocab.put("http://www.w3.org/2001/XMLSchema#float", "float"); + rvocab.put("http://www.w3.org/2001/XMLSchema#int", "int"); + rvocab.put("http://www.w3.org/2001/XMLSchema#long", "long"); + rvocab.put("https://w3id.org/cwl/salad#null", "null"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#WorkflowStepType/pause", "pause"); + rvocab.put("record", "record"); + rvocab.put("http://www.w3.org/2001/XMLSchema#string", "string"); + rvocab.put( + "https://galaxyproject.org/gxformat2/v19_09#WorkflowStepType/subworkflow", "subworkflow"); + rvocab.put("https://galaxyproject.org/gxformat2/v19_09#WorkflowStepType/tool", "tool"); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/DefaultFetcher.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/DefaultFetcher.java new file mode 100644 index 00000000..679282e6 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/DefaultFetcher.java @@ -0,0 +1,32 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.net.URI; + +public class DefaultFetcher implements Fetcher { + + public String urlJoin(final String baseUrl, final String url) { + if (url.startsWith("_:")) { + return url; + } + + final URI baseUri = Uris.toUri(baseUrl); + final URI uri = Uris.toUri(url); + if (baseUri.getScheme() != null + && !baseUri.getScheme().equals("file") + && "file".equals(uri.getScheme())) { + throw new ValidationException( + String.format( + "Not resolving potential remote exploit %s from base %s".format(url, baseUrl))); + } + String result = baseUri.resolve(uri).toString(); + if (result.startsWith("file:")) { + // Well this is gross - needed for http as well? + result = "file://" + result.substring("file:".length()); + } + return result; + } + + public String fetchText(final String url) { + return "fetched"; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/EnumLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/EnumLoader.java new file mode 100644 index 00000000..0a4885a2 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/EnumLoader.java @@ -0,0 +1,26 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.lang.reflect.Method; + +public class EnumLoader implements Loader { + private final Class symbolEnumClass; + + public EnumLoader(final Class symbolEnumClass) { + this.symbolEnumClass = symbolEnumClass; + } + + public T load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + final String docString = Loader.validateOfJavaType(String.class, doc); + try { + final Method m = symbolEnumClass.getMethod("fromDocumentVal", String.class); + final T val = (T) m.invoke(null, docString); + return val; + } catch (final ReflectiveOperationException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Fetcher.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Fetcher.java new file mode 100644 index 00000000..ef1840db --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Fetcher.java @@ -0,0 +1,8 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +public interface Fetcher { + + public abstract String urlJoin(final String baseUrl, final String url); + + public abstract String fetchText(final String url); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/IdMapLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/IdMapLoader.java new file mode 100644 index 00000000..03a1c25a --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/IdMapLoader.java @@ -0,0 +1,53 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeSet; + +public class IdMapLoader implements Loader { + private final Loader innerLoader; + private final String mapSubject; + private final String mapPredicate; + + public IdMapLoader( + final Loader innerLoader, final String mapSubject, final String mapPredicate) { + this.innerLoader = innerLoader; + this.mapSubject = mapSubject; + this.mapPredicate = mapPredicate; + } + + public T load( + final Object doc_, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + Object doc = doc_; + if (doc instanceof Map) { + final Map docMap = (Map) doc; + final List asList = new ArrayList(); + final TreeSet sortedKeys = new TreeSet(); + sortedKeys.addAll(docMap.keySet()); + for (final String key : sortedKeys) { + final Object el = docMap.get(key); + if (el instanceof Map) { + final Map v2 = new HashMap((Map) el); + v2.put(this.mapSubject, key); + asList.add(v2); + } else { + if (this.mapPredicate != null) { + final Map v3 = new HashMap(); + v3.put(this.mapPredicate, el); + v3.put(this.mapSubject, key); + asList.add(v3); + } else { + throw new ValidationException("No mapPredicate"); + } + } + } + doc = asList; + } + return this.innerLoader.load(doc, baseUri, loadingOptions); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Loader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Loader.java new file mode 100644 index 00000000..8e0d6491 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Loader.java @@ -0,0 +1,111 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface Loader { + + abstract T load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot); + + default T load(final Object doc, final String baseUri, final LoadingOptions loadingOptions) { + return load(doc, baseUri, loadingOptions, null); + } + + default T documentLoad( + final String doc, final String baseUri, final LoadingOptions loadingOptions) { + return load(doc, baseUri, loadingOptions); + } + + default T documentLoad( + final Map doc_, final String baseUri_, final LoadingOptions loadingOptions_) { + Map doc = doc_; + LoadingOptions loadingOptions = loadingOptions_; + if (doc.containsKey("$namespaces")) { + final Map namespaces = (Map) doc.get("$namespaces"); + loadingOptions = + new LoadingOptionsBuilder().copiedFrom(loadingOptions).setNamespaces(namespaces).build(); + doc = copyWithoutKey(doc, "$namespaces"); + } + String baseUri = baseUri_; + if (doc.containsKey("$base")) { + baseUri = (String) doc.get("$base"); + } + if (doc.containsKey("$graph")) { + return load(doc.get("$graph"), baseUri, loadingOptions); + } else { + return load(doc, baseUri, loadingOptions, baseUri); + } + } + + default T documentLoad( + final List doc, final String baseUri, final LoadingOptions loadingOptions) { + return load(doc, baseUri, loadingOptions); + } + + default T documentLoadByUrl(final String url, final LoadingOptions loadingOptions) { + if (loadingOptions.idx.containsKey(url)) { + return documentLoad(loadingOptions.idx.get(url), url, loadingOptions); + } + + final String text = loadingOptions.fetcher.fetchText(url); + final Map result = YamlUtils.mapFromString(text); + loadingOptions.idx.put(url, result); + final LoadingOptionsBuilder urlLoadingOptions = + new LoadingOptionsBuilder().copiedFrom(loadingOptions).setFileUri(url); + return documentLoad(result, url, urlLoadingOptions.build()); + } + + default T loadField( + final Object val_, final String baseUri, final LoadingOptions loadingOptions) { + Object val = val_; + if (val instanceof Map) { + Map valMap = (Map) val; + if (valMap.containsKey("$import")) { + if (loadingOptions.fileUri == null) { + throw new ValidationException("Cannot load $import without fileuri"); + } + return documentLoadByUrl( + loadingOptions.fetcher.urlJoin(loadingOptions.fileUri, (String) valMap.get("$import")), + loadingOptions); + } else if (valMap.containsKey("$include")) { + if (loadingOptions.fileUri == null) { + throw new ValidationException("Cannot load $import without fileuri"); + } + val = + loadingOptions.fetcher.fetchText( + loadingOptions.fetcher.urlJoin( + loadingOptions.fileUri, (String) valMap.get("$include"))); + } + } + return load(val, baseUri, loadingOptions); + } + + private Map copyWithoutKey(final Map doc, final String key) { + final Map result = new HashMap(); + for (final Map.Entry entry : doc.entrySet()) { + if (!entry.getKey().equals(key)) { + result.put(entry.getKey(), entry.getValue()); + } + } + return result; + } + + public static T validateOfJavaType(final Class clazz, final Object doc) { + if (!clazz.isInstance(doc)) { + String className = "null"; + if (doc != null) { + className = doc.getClass().getName(); + } + final String message = + String.format( + "Expected object with Java type of %s but got %s", clazz.getName(), className); + throw new ValidationException(message); + } + return (T) doc; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoaderInstances.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoaderInstances.java new file mode 100644 index 00000000..d6e29070 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoaderInstances.java @@ -0,0 +1,218 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import org.galaxyproject.gxformat2.v19_09.*; + +public class LoaderInstances { + public static Loader IntegerInstance = new PrimitiveLoader(Integer.class); + public static Loader BooleanInstance = new PrimitiveLoader(Boolean.class); + public static Loader StringInstance = new PrimitiveLoader(String.class); + public static Loader AnyInstance = new AnyLoader(); + public static Loader LongInstance = new PrimitiveLoader(Long.class); + public static Loader FloatInstance = new PrimitiveLoader(Float.class); + public static Loader NullInstance = new NullLoader(); + public static Loader DoubleInstance = new PrimitiveLoader(Double.class); + public static Loader Documented = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.Documented.class); + public static Loader PrimitiveType = new EnumLoader(PrimitiveType.class); + public static Loader Any = new EnumLoader(Any.class); + public static Loader RecordField = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.RecordFieldImpl.class); + public static Loader RecordSchema = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.RecordSchemaImpl.class); + public static Loader EnumSchema = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.EnumSchemaImpl.class); + public static Loader ArraySchema = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.ArraySchemaImpl.class); + public static Loader Labeled = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.Labeled.class); + public static Loader Identified = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.Identified.class); + public static Loader Parameter = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.Parameter.class); + public static Loader InputParameter = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.InputParameter.class); + public static Loader OutputParameter = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.OutputParameter.class); + public static Loader Process = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.Process.class); + public static Loader HasStepPosition = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.HasStepPosition.class); + public static Loader StepPosition = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.StepPositionImpl.class); + public static Loader ReferencesTool = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.ReferencesTool.class); + public static Loader ToolShedRepository = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.ToolShedRepositoryImpl.class); + public static Loader GalaxyType = new EnumLoader(GalaxyType.class); + public static Loader WorkflowStepType = new EnumLoader(WorkflowStepType.class); + public static Loader + WorkflowInputParameter = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.WorkflowInputParameterImpl.class); + public static Loader + WorkflowOutputParameter = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.WorkflowOutputParameterImpl.class); + public static Loader WorkflowStep = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.WorkflowStepImpl.class); + public static Loader Sink = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.Sink.class); + public static Loader WorkflowStepInput = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.WorkflowStepInputImpl.class); + public static Loader WorkflowStepOutput = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.WorkflowStepOutputImpl.class); + public static Loader GalaxyWorkflow = + new RecordLoader( + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflowImpl.class); + public static Loader> array_of_StringInstance = + new ArrayLoader(StringInstance); + public static Loader union_of_NullInstance_or_StringInstance_or_array_of_StringInstance = + new UnionLoader(new Loader[] {NullInstance, StringInstance, array_of_StringInstance}); + public static Loader uri_StringInstance_True_False_None = + new UriLoader(StringInstance, true, false, null); + public static Loader + union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance = + new UnionLoader( + new Loader[] {PrimitiveType, RecordSchema, EnumSchema, ArraySchema, StringInstance}); + public static Loader> + array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance = + new ArrayLoader( + union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance); + public static Loader + union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_or_array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance = + new UnionLoader( + new Loader[] { + PrimitiveType, + RecordSchema, + EnumSchema, + ArraySchema, + StringInstance, + array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance + }); + public static Loader + typedsl_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_or_array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_2 = + new TypeDslLoader( + union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_or_array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance, + 2); + public static Loader> array_of_RecordField = + new ArrayLoader(RecordField); + public static Loader>> optional_array_of_RecordField = + new OptionalLoader(array_of_RecordField); + public static Loader>> + idmap_fields_optional_array_of_RecordField = + new IdMapLoader(optional_array_of_RecordField, "name", "type"); + public static Loader + enum_d9cba076fca539106791a4f46d198c7fcfbdb779 = + new EnumLoader(enum_d9cba076fca539106791a4f46d198c7fcfbdb779.class); + public static Loader + typedsl_enum_d9cba076fca539106791a4f46d198c7fcfbdb779_2 = + new TypeDslLoader(enum_d9cba076fca539106791a4f46d198c7fcfbdb779, 2); + public static Loader> uri_array_of_StringInstance_True_False_None = + new UriLoader(array_of_StringInstance, true, false, null); + public static Loader + enum_d961d79c225752b9fadb617367615ab176b47d77 = + new EnumLoader(enum_d961d79c225752b9fadb617367615ab176b47d77.class); + public static Loader + typedsl_enum_d961d79c225752b9fadb617367615ab176b47d77_2 = + new TypeDslLoader(enum_d961d79c225752b9fadb617367615ab176b47d77, 2); + public static Loader + uri_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_or_array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_False_True_2 = + new UriLoader( + union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance_or_array_of_union_of_PrimitiveType_or_RecordSchema_or_EnumSchema_or_ArraySchema_or_StringInstance, + false, + true, + 2); + public static Loader + enum_d062602be0b4b8fd33e69e29a841317b6ab665bc = + new EnumLoader(enum_d062602be0b4b8fd33e69e29a841317b6ab665bc.class); + public static Loader + typedsl_enum_d062602be0b4b8fd33e69e29a841317b6ab665bc_2 = + new TypeDslLoader(enum_d062602be0b4b8fd33e69e29a841317b6ab665bc, 2); + public static Loader> optional_StringInstance = + new OptionalLoader(StringInstance); + public static Loader> uri_optional_StringInstance_True_False_None = + new UriLoader(optional_StringInstance, true, false, null); + public static Loader> optional_AnyInstance = + new OptionalLoader(AnyInstance); + public static Loader> array_of_WorkflowInputParameter = + new ArrayLoader(WorkflowInputParameter); + public static Loader> idmap_inputs_array_of_WorkflowInputParameter = + new IdMapLoader(array_of_WorkflowInputParameter, "id", "type"); + public static Loader> array_of_WorkflowOutputParameter = + new ArrayLoader(WorkflowOutputParameter); + public static Loader> idmap_outputs_array_of_WorkflowOutputParameter = + new IdMapLoader(array_of_WorkflowOutputParameter, "id", "type"); + public static Loader> optional_StepPosition = + new OptionalLoader(StepPosition); + public static Loader> optional_ToolShedRepository = + new OptionalLoader(ToolShedRepository); + public static Loader> optional_GalaxyType = + new OptionalLoader(GalaxyType); + public static Loader> typedsl_optional_GalaxyType_2 = + new TypeDslLoader(optional_GalaxyType, 2); + public static Loader> array_of_WorkflowStepInput = + new ArrayLoader(WorkflowStepInput); + public static Loader>> + optional_array_of_WorkflowStepInput = new OptionalLoader(array_of_WorkflowStepInput); + public static Loader>> + idmap_in_optional_array_of_WorkflowStepInput = + new IdMapLoader(optional_array_of_WorkflowStepInput, "id", "source"); + public static Loader union_of_StringInstance_or_WorkflowStepOutput = + new UnionLoader(new Loader[] {StringInstance, WorkflowStepOutput}); + public static Loader> + array_of_union_of_StringInstance_or_WorkflowStepOutput = + new ArrayLoader(union_of_StringInstance_or_WorkflowStepOutput); + public static Loader>> + optional_array_of_union_of_StringInstance_or_WorkflowStepOutput = + new OptionalLoader(array_of_union_of_StringInstance_or_WorkflowStepOutput); + public static Loader>> + uri_optional_array_of_union_of_StringInstance_or_WorkflowStepOutput_True_False_None = + new UriLoader( + optional_array_of_union_of_StringInstance_or_WorkflowStepOutput, true, false, null); + public static Loader> optional_WorkflowStepType = + new OptionalLoader(WorkflowStepType); + public static Loader> typedsl_optional_WorkflowStepType_2 = + new TypeDslLoader(optional_WorkflowStepType, 2); + public static Loader> optional_GalaxyWorkflow = + new OptionalLoader(GalaxyWorkflow); + public static Loader> + uri_optional_GalaxyWorkflow_False_False_None = + new UriLoader(optional_GalaxyWorkflow, false, false, null); + public static Loader + uri_union_of_NullInstance_or_StringInstance_or_array_of_StringInstance_False_False_2 = + new UriLoader( + union_of_NullInstance_or_StringInstance_or_array_of_StringInstance, false, false, 2); + public static Loader uri_StringInstance_False_True_None = + new UriLoader(StringInstance, false, true, null); + public static Loader> array_of_WorkflowStep = + new ArrayLoader(WorkflowStep); + public static Loader> idmap_steps_array_of_WorkflowStep = + new IdMapLoader(array_of_WorkflowStep, "id", "None"); + public static Loader> array_of_GalaxyWorkflow = + new ArrayLoader(GalaxyWorkflow); + public static Loader< + org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow>> + one_or_array_of_GalaxyWorkflow = + new OneOrListOfLoader( + GalaxyWorkflow, array_of_GalaxyWorkflow); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoadingOptions.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoadingOptions.java new file mode 100644 index 00000000..21a2bb78 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoadingOptions.java @@ -0,0 +1,124 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +public class LoadingOptions { + Fetcher fetcher; + String fileUri; + Map namespaces; + List schemas; + Map> idx; + Map vocab; + Map rvocab; + + LoadingOptions( + final Fetcher fetcher, + final String fileUri, + final Map namespaces, + final List schemas, + final Map> idx) { + this.fetcher = fetcher; + this.fileUri = fileUri; + this.namespaces = namespaces; + this.schemas = schemas; + this.idx = idx; + + if (namespaces != null) { + this.vocab = (Map) ConstantMaps.vocab.clone(); + this.rvocab = (Map) ConstantMaps.rvocab.clone(); + for (Map.Entry namespaceEntry : namespaces.entrySet()) { + this.vocab.put(namespaceEntry.getKey(), namespaceEntry.getValue()); + this.rvocab.put(namespaceEntry.getValue(), namespaceEntry.getKey()); + } + } else { + this.vocab = (Map) ConstantMaps.vocab; + this.rvocab = (Map) ConstantMaps.rvocab; + } + } + + public String expandUrl( + String url_, + final String baseUrl, + final boolean scopedId, + final boolean vocabTerm, + final Integer scopedRef) { + // NOT CONVERTING this - doesn't match type declaration + // if not isinstance(url, string_types): + // return url + String url = url_; + if (url.equals("@id") || url.equals("@type")) { + return url; + } + + if (vocabTerm && this.vocab.containsKey(url)) { + return url; + } + + if (!this.vocab.isEmpty() && url.contains(":")) { + String prefix = url.split(":", 1)[0]; + if (this.vocab.containsKey(prefix)) { + url = this.vocab.get(prefix) + url.substring(prefix.length() + 1); + } + } + + Uris.UriSplit split = Uris.split(url); + final String scheme = split.scheme; + final boolean hasFragment = stringHasContent(split.fragment); + if (scheme != null + && ((scheme.length() > 0 + && (scheme.equals("http") || scheme.equals("https") || scheme.equals("file"))) + || url.startsWith("$(") + || url.startsWith("${"))) { + // pass + } else if (scopedId && !hasFragment) { + final Uris.UriSplit splitbase = Uris.split(baseUrl); + final String frg; + if (stringHasContent(splitbase.fragment)) { + frg = splitbase.fragment + "/" + split.path; + } else { + frg = split.path; + } + String pt; + if (!splitbase.path.equals("")) { + pt = splitbase.path; + } else { + pt = "/"; + } + url = Uris.unsplit(splitbase.scheme, splitbase.netloc, pt, splitbase.query, frg); + } else if (scopedRef != null && !hasFragment) { + final Uris.UriSplit splitbase = Uris.split(baseUrl); + final ArrayList sp = new ArrayList(Arrays.asList(splitbase.fragment.split("/"))); + int n = scopedRef; + while (n > 0 && sp.size() > 0) { + sp.remove(0); + n -= 1; + } + sp.add(url); + final String fragment = String.join("/", sp); + url = + Uris.unsplit( + splitbase.scheme, splitbase.netloc, splitbase.path, splitbase.query, fragment); + } else { + url = this.fetcher.urlJoin(baseUrl, url); + } + + if (vocabTerm) { + split = Uris.split(url); + if (stringHasContent(split.scheme)) { + if (this.rvocab.containsKey(url)) { + return this.rvocab.get(url); + } + } else { + throw new ValidationException("Term '{}' not in vocabulary".format(url)); + } + } + return url; + } + + static boolean stringHasContent(final String s) { + return s != null && s.length() > 0; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoadingOptionsBuilder.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoadingOptionsBuilder.java new file mode 100644 index 00000000..20117460 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/LoadingOptionsBuilder.java @@ -0,0 +1,62 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class LoadingOptionsBuilder { + private Optional fetcher = Optional.empty(); + private Optional fileUri = Optional.empty(); + private Optional> namespaces = Optional.empty(); + private Optional> schemas = Optional.empty(); + private Optional copyFrom = Optional.empty(); + + public LoadingOptionsBuilder() {} + + public LoadingOptionsBuilder setFetcher(final Fetcher fetcher) { + this.fetcher = Optional.of(fetcher); + return this; + } + + public LoadingOptionsBuilder copiedFrom(final LoadingOptions copyFrom) { + this.copyFrom = Optional.of(copyFrom); + return this; + } + + public LoadingOptionsBuilder setFileUri(final String fileUri) { + this.fileUri = Optional.of(fileUri); + return this; + } + + public LoadingOptionsBuilder setNamespaces(final Map namespaces) { + this.namespaces = Optional.of(namespaces); + return this; + } + + public LoadingOptions build() { + Fetcher fetcher = this.fetcher.orElse(null); + String fileUri = this.fileUri.orElse(null); + List schemas = this.schemas.orElse(null); + Map namespaces = this.namespaces.orElse(null); + Map> idx = new HashMap>(); + if (this.copyFrom.isPresent()) { + final LoadingOptions copyFrom = this.copyFrom.get(); + idx = copyFrom.idx; + if (fetcher == null) { + fetcher = copyFrom.fetcher; + } + if (fileUri == null) { + fileUri = copyFrom.fileUri; + } + if (namespaces == null) { + namespaces = copyFrom.namespaces; + schemas = copyFrom.schemas; // Bug in Python codegen? + } + } + if (fetcher == null) { + fetcher = new DefaultFetcher(); + } + return new LoadingOptions(fetcher, fileUri, namespaces, schemas, idx); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/NullLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/NullLoader.java new file mode 100644 index 00000000..6d2ee010 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/NullLoader.java @@ -0,0 +1,15 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +public class NullLoader implements Loader { + + public Object load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + if (doc != null) { + throw new ValidationException("Expected null"); + } + return doc; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OneOrListOf.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OneOrListOf.java new file mode 100644 index 00000000..90e17b26 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OneOrListOf.java @@ -0,0 +1,47 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.List; +import java.util.Optional; + +public class OneOrListOf { + private Optional object; + private Optional> objects; + + private OneOrListOf(final T object, final List objects) { + this.object = Optional.ofNullable(object); + this.objects = Optional.ofNullable(objects); + } + + public static OneOrListOf oneOf(T object) { + return new OneOrListOf(object, null); + } + + public static OneOrListOf listOf(List objects) { + assert objects != null; + return new OneOrListOf(null, objects); + } + + public boolean isOne() { + return this.getOneOptional().isPresent(); + } + + public boolean isList() { + return this.getListOptional().isPresent(); + } + + public Optional getOneOptional() { + return this.object; + } + + public Optional> getListOptional() { + return this.objects; + } + + public T getOne() { + return this.getOneOptional().get(); + } + + public List getList() { + return this.getListOptional().get(); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OneOrListOfLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OneOrListOfLoader.java new file mode 100644 index 00000000..9a91a1eb --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OneOrListOfLoader.java @@ -0,0 +1,33 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.ArrayList; +import java.util.List; + +public class OneOrListOfLoader implements Loader> { + private final Loader oneLoader; + private final Loader> listLoader; + + public OneOrListOfLoader(Loader oneLoader, Loader> listLoader) { + this.oneLoader = oneLoader; + this.listLoader = listLoader; + } + + public OneOrListOf load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + final List errors = new ArrayList(); + try { + return OneOrListOf.oneOf(this.oneLoader.load(doc, baseUri, loadingOptions, docRoot)); + } catch (ValidationException e) { + errors.add(e); + } + try { + return OneOrListOf.listOf(this.listLoader.load(doc, baseUri, loadingOptions, docRoot)); + } catch (ValidationException e) { + errors.add(e); + } + throw new ValidationException("Failed to one or list of of type", errors); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OptionalLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OptionalLoader.java new file mode 100644 index 00000000..39647c18 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/OptionalLoader.java @@ -0,0 +1,22 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.Optional; + +public class OptionalLoader implements Loader> { + private final Loader itemLoader; + + public OptionalLoader(Loader itemLoader) { + this.itemLoader = itemLoader; + } + + public Optional load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + if (doc == null) { + return Optional.empty(); + } + return Optional.of(itemLoader.load(doc, baseUri, loadingOptions, docRoot)); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/PrimitiveLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/PrimitiveLoader.java new file mode 100644 index 00000000..56f5e67d --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/PrimitiveLoader.java @@ -0,0 +1,17 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +public class PrimitiveLoader implements Loader { + private Class clazz; + + public PrimitiveLoader(Class clazz) { + this.clazz = clazz; + } + + public T load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + return Loader.validateOfJavaType(this.clazz, doc); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/RecordLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/RecordLoader.java new file mode 100644 index 00000000..c6ab3195 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/RecordLoader.java @@ -0,0 +1,35 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +public class RecordLoader implements Loader { + private final Class savableClass; + + public RecordLoader(final Class savableClass) { + this.savableClass = savableClass; + } + + public T load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + Loader.validateOfJavaType(java.util.Map.class, doc); + try { + final Constructor constructor = + this.savableClass.getConstructor( + new Class[] {Object.class, String.class, LoadingOptions.class, String.class}); + final T ret = constructor.newInstance(doc, baseUri, loadingOptions, docRoot); + return ret; + } catch (InvocationTargetException e) { + final Throwable cause = e.getCause(); + if (cause instanceof RuntimeException) { + throw (RuntimeException) cause; + } + throw new RuntimeException(e.getCause()); + } catch (ReflectiveOperationException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/RootLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/RootLoader.java new file mode 100644 index 00000000..0c3cd772 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/RootLoader.java @@ -0,0 +1,132 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Map; + +public class RootLoader { + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument( + final Map doc, + final String baseUri_, + final LoadingOptions loadingOptions_) { + final String baseUri = ensureBaseUri(baseUri_); + LoadingOptions loadingOptions = loadingOptions_; + if (loadingOptions == null) { + loadingOptions = new LoadingOptionsBuilder().build(); + } + return LoaderInstances.one_or_array_of_GalaxyWorkflow.documentLoad( + doc, baseUri, loadingOptions); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final Map doc, final String baseUri) { + return loadDocument(doc, baseUri, null); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final Map doc) { + return loadDocument(doc, ensureBaseUri(null)); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final Path path) { + return loadDocument(readPath(path)); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final Path path, String baseUri) { + return loadDocument(readPath(path), baseUri); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final Path path, LoadingOptions loadingOptions) { + return loadDocument(readPath(path), loadingOptions); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final Path path, String baseUri, LoadingOptions loadingOptions) { + return loadDocument(readPath(path), baseUri, loadingOptions); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final File file) { + return loadDocument(file.toPath()); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final File file, String baseUri) { + return loadDocument(file.toPath(), baseUri); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final File file, LoadingOptions loadingOptions) { + return loadDocument(file.toPath(), loadingOptions); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final File file, String baseUri, LoadingOptions loadingOptions) { + return loadDocument(file.toPath(), baseUri, loadingOptions); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final String doc) { + return loadDocument(doc, ensureBaseUri(null)); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final String doc, final LoadingOptions loadingOptions) { + return loadDocument(doc, ensureBaseUri(null), loadingOptions); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final String doc, final String uri) { + return loadDocument(doc, uri, null); + } + + public static org.galaxyproject.gxformat2.v19_09.utils.OneOrListOf< + org.galaxyproject.gxformat2.v19_09.GalaxyWorkflow> + loadDocument(final String doc, final String uri_, final LoadingOptions loadingOptions_) { + final String uri = ensureBaseUri(uri_); + LoadingOptions loadingOptions = loadingOptions_; + if (loadingOptions == null) { + loadingOptions = new LoadingOptionsBuilder().setFileUri(uri).build(); + } + final Map result = YamlUtils.mapFromString(doc); + loadingOptions.idx.put(uri, result); + return loadDocument(result, uri, loadingOptions); + } + + static String readPath(final Path path) { + try { + return new String(Files.readAllBytes(path), "UTF8"); + } catch (final IOException e) { + throw new RuntimeException(e); + } + } + + static String ensureBaseUri(final String baseUri_) { + String baseUri = baseUri_; + if (baseUri == null) { + baseUri = Uris.fileUri(Paths.get(".").toAbsolutePath().normalize().toString()) + "/"; + } + return baseUri; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Savable.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Savable.java new file mode 100644 index 00000000..2dd02db5 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Savable.java @@ -0,0 +1,6 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +public interface Savable { + // TODO: implement writable interface + // public abstract void save(boolean top, String baseUrl, boolean relativeUris); +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/SavableImpl.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/SavableImpl.java new file mode 100644 index 00000000..81a430fb --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/SavableImpl.java @@ -0,0 +1,5 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +public class SavableImpl implements Savable { + public SavableImpl(Object doc, String baseUri, LoadingOptions loadingOptions, String docRoot) {} +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/TypeDslLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/TypeDslLoader.java new file mode 100644 index 00000000..93e8687a --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/TypeDslLoader.java @@ -0,0 +1,81 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TypeDslLoader implements Loader { + private final Loader innerLoader; + private final Integer refScope; + private static final Pattern TYPE_DSL_REGEX = Pattern.compile("^([^\\[?]+)(\\[\\])?(\\?)?$"); + + public TypeDslLoader(final Loader innerLoader, final Integer refScope) { + this.innerLoader = innerLoader; + this.refScope = refScope; + } + + private Object resolve( + final String doc_, final String baseUri, final LoadingOptions loadingOptions) { + final Matcher m = TYPE_DSL_REGEX.matcher(doc_); + if (m.matches()) { + final String first = + loadingOptions.expandUrl(m.group(1), baseUri, false, true, this.refScope); + Object second = null; + Object third = null; + if (m.group(2) != null && m.group(2).length() > 0) { + HashMap resolvedMap = new HashMap(); + resolvedMap.put("type", "array"); + resolvedMap.put("items", first); + second = resolvedMap; + } + if (m.group(3) != null && m.group(3).length() > 0) { + third = Arrays.asList("null", second != null ? second : first); + } + if (third != null) { + return third; + } else { + return second != null ? second : first; + } + } else { + return doc_; + } + } + + public T load( + final Object doc_, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + Object doc = doc_; + if (doc instanceof List) { + final List docList = (List) doc; + final List r = new ArrayList(); + for (final Object d : docList) { + if (d instanceof String) { + Object resolved = this.resolve((String) d, baseUri, loadingOptions); + if (resolved instanceof List) { + List resolvedList = (List) resolved; + for (Object i : resolvedList) { + if (!r.contains(i)) { + r.add(i); + } + } + } else { + if (!r.contains(resolved)) { + r.add(resolved); + } + } + } else { + r.add(d); + } + } + doc = docList; + } else if (doc instanceof String) { + doc = this.resolve((String) doc, baseUri, loadingOptions); + } + return this.innerLoader.load(doc, baseUri, loadingOptions); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/UnionLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/UnionLoader.java new file mode 100644 index 00000000..02092506 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/UnionLoader.java @@ -0,0 +1,33 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class UnionLoader implements Loader { + private final List alternates; + + public UnionLoader(List alternates) { + this.alternates = alternates; + } + + public UnionLoader(Loader[] alternates) { + this(Arrays.asList(alternates)); + } + + public Object load( + final Object doc, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + final List errors = new ArrayList(); + for (final Loader loader : this.alternates) { + try { + return loader.load(doc, baseUri, loadingOptions, docRoot); + } catch (ValidationException e) { + errors.add(e); + } + } + throw new ValidationException("Failed to match union type", errors); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/UriLoader.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/UriLoader.java new file mode 100644 index 00000000..58763a1d --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/UriLoader.java @@ -0,0 +1,52 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.ArrayList; +import java.util.List; + +public class UriLoader implements Loader { + private final Loader innerLoader; + private final boolean scopedId; + private final boolean vocabTerm; + private final Integer scopedRef; + + public UriLoader( + final Loader innerLoader, + final boolean scopedId, + final boolean vocabTerm, + final Integer scopedRef) { + this.innerLoader = innerLoader; + this.scopedId = scopedId; + this.vocabTerm = vocabTerm; + this.scopedRef = scopedRef; + } + + private Object expandUrl( + final Object object, final String baseUri, final LoadingOptions loadingOptions) { + if (object instanceof String) { + return loadingOptions.expandUrl( + (String) object, baseUri, this.scopedId, this.vocabTerm, this.scopedRef); + } else { + return object; + } + } + + public T load( + final Object doc_, + final String baseUri, + final LoadingOptions loadingOptions, + final String docRoot) { + Object doc = doc_; + if (doc instanceof List) { + List docList = (List) doc; + List docWithExpansion = new ArrayList(); + for (final Object el : docList) { + docWithExpansion.add(this.expandUrl(el, baseUri, loadingOptions)); + } + doc = docWithExpansion; + } + if (doc instanceof String) { + doc = this.expandUrl(doc, baseUri, loadingOptions); + } + return this.innerLoader.load(doc, baseUri, loadingOptions); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Uris.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Uris.java new file mode 100644 index 00000000..ae6fac53 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Uris.java @@ -0,0 +1,117 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; + +public class Uris { + + // Emulate Python's urlsplit. + public static class UriSplit { + String scheme; + String netloc; + String path; + String query; + String fragment; + + public UriSplit(String scheme, String netloc, String path, String query, String fragment) { + this.scheme = scheme; + this.netloc = netloc; + this.path = path; + this.query = query; + this.fragment = fragment; + } + + public String toString() { + return String.format( + "UriSplit[%s,%s,%s,%s,%s]", + this.scheme, this.netloc, this.path, this.query, this.fragment); + } + } + + public static String fileUri(final String path) { + return fileUri(path, false); + } + + public static String fileUri(final String path, final boolean splitFrag) { + if (path.equals("file://")) { + return path; + } + String frag; + String urlPath; + if (splitFrag) { + final String[] pathsp = path.split("#", 2); + // is quoting this? + urlPath = Uris.quote(pathsp[0]); + if (pathsp.length == 2) { + frag = "#" + Uris.quote(pathsp[1]); + } else { + frag = ""; + urlPath = Uris.quote(path); + } + } else { + urlPath = Uris.quote(path); + frag = ""; + } + if (urlPath.startsWith("//")) { + return "file:" + urlPath + frag; + } else { + return "file://" + urlPath + frag; + } + } + + public static UriSplit split(final String uriString) { + try { + final URI uri = new URI(uriString); + return new Uris.UriSplit( + uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment()); + } catch (URISyntaxException e) { + return new Uris.UriSplit(null, null, uriString, null, null); + } + } + + public static String unsplit( + final String scheme, + final String netloc, + final String path, + final String query, + final String fragment) { + try { + return new URI(scheme, netloc, path, query, fragment).toString(); + } catch (URISyntaxException e) { + if (scheme == null && path.startsWith("_:")) { + String uri = path; + if (fragment != null && fragment.length() > 0) { + uri += "#" + fragment; + } + return fragment; + } + throw new RuntimeException(e); + } + } + + public static URI toUri(final String url) { + try { + return new URI(url); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + + public static String quote(final String uri) { + try { + return java.net.URLDecoder.decode(uri, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + + public static String unquote(final String uri) { + try { + return java.net.URLEncoder.encode(uri, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ValidationException.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ValidationException.java new file mode 100644 index 00000000..835095e7 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/ValidationException.java @@ -0,0 +1,80 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ValidationException extends RuntimeException { + private final List children; + private String bullet = ""; + private String currentMessage; + + public ValidationException(final String message) { + this(message, (List) null); + } + + public ValidationException(final String message, final ValidationException child) { + this(message, Arrays.asList(child)); + } + + public ValidationException(final String message, final List children_) { + super(message); + this.currentMessage = message; + final List children = new ArrayList(); + if (children_ != null) { + for (final ValidationException child : children_) { + children.addAll(child.simplify()); + } + } + this.children = children; + } + + public ValidationException withBullet(final String bullet) { + this.bullet = bullet; + return this; + } + + public List simplify() { + if (getMessage().length() > 0) { + return Arrays.asList(this); + } else { + return this.children; + } + } + + public String summary(final int level, final boolean withBullet) { + final int indentPerLevel = 2; + final String spaces = new String(new char[level * indentPerLevel]).replace("\0", " "); + final String bullet; + if (this.bullet.length() > 0 && withBullet) { + bullet = this.bullet; + } else { + bullet = ""; + } + return spaces + bullet + this.currentMessage; + } + + public String prettyStr(final Integer level_) { + Integer level = level_; + if (level == null) { + level = 0; + } + final List parts = new ArrayList(); + int nextLevel; + if (this.currentMessage != null && this.currentMessage.length() > 0) { + parts.add(this.summary(level, true)); + nextLevel = level + 1; + } else { + nextLevel = level; + } + for (final ValidationException child : this.children) { + parts.add(child.prettyStr(nextLevel)); + } + final String ret = String.join("\n", parts); + return ret; + } + + public String getMessage() { + return this.prettyStr(null); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Validator.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Validator.java new file mode 100644 index 00000000..2337043e --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/Validator.java @@ -0,0 +1,14 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.io.File; + +public class Validator { + public static void main(final String[] args) throws Exception { + if (args.length != 1) { + throw new Exception("No argument supplied to validate."); + } + // TODO: allow URLs and such. + final File uri = new File(args[0]); + RootLoader.loadDocument(uri); + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/YamlUtils.java b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/YamlUtils.java new file mode 100644 index 00000000..f1bdf5f3 --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/YamlUtils.java @@ -0,0 +1,13 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.Map; +import org.yaml.snakeyaml.Yaml; + +public class YamlUtils { + + public static Map mapFromString(final String text) { + Yaml yaml = new Yaml(); + final Map result = yaml.load(text); + return result; + } +} diff --git a/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/package.html b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/package.html new file mode 100644 index 00000000..6b82709e --- /dev/null +++ b/src/main/java/org/galaxyproject/gxformat2/v19_09/utils/package.html @@ -0,0 +1,3 @@ + +This package contains utilities for working the SchemaSalad generated code for the org.galaxyproject.gxformat2.v19_09 package. + diff --git a/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/DefaultFetcherTest.java b/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/DefaultFetcherTest.java new file mode 100644 index 00000000..65efe8e8 --- /dev/null +++ b/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/DefaultFetcherTest.java @@ -0,0 +1,37 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import org.junit.Assert; +import org.junit.Test; + +public class DefaultFetcherTest { + @Test + public void testUnderscoreJoin() { + final DefaultFetcher fetcher = new DefaultFetcher(); + Assert.assertEquals(fetcher.urlJoin("http://googl.com/", "_:/moo"), "_:/moo"); + } + + @Test + public void testUnixJoin() { + final DefaultFetcher fetcher = new DefaultFetcher(); + String url; + + url = fetcher.urlJoin("file:///home/fred/foo.cwl", "soup.cwl"); + Assert.assertEquals(url, "file:///home/fred/soup.cwl"); + + url = fetcher.urlJoin("file:///home/fred/foo.cwl", "../alice/soup.cwl"); + Assert.assertEquals(url, "file:///home/alice/soup.cwl"); + // relative from root + url = fetcher.urlJoin("file:///home/fred/foo.cwl", "/baz/soup.cwl"); + Assert.assertEquals(url, "file:///baz/soup.cwl"); + + url = fetcher.urlJoin("file:///home/fred/foo.cwl", "http://example.com/bar/soup.cwl"); + Assert.assertEquals(url, "http://example.com/bar/soup.cwl"); + + url = fetcher.urlJoin("http://example.com/fred/foo.cwl", "soup.cwl"); + Assert.assertEquals(url, "http://example.com/fred/soup.cwl"); + + // Root-relative -- here relative to http host, not file:/// + url = fetcher.urlJoin("http://example.com/fred/foo.cwl", "/bar/soup.cwl"); + Assert.assertEquals(url, "http://example.com/bar/soup.cwl"); + } +} diff --git a/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/ExamplesTest.java b/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/ExamplesTest.java new file mode 100644 index 00000000..a9f3fdf0 --- /dev/null +++ b/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/ExamplesTest.java @@ -0,0 +1,31 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +public class ExamplesTest { + + @org.junit.Test + public void testvalid1ByString() throws Exception { + String path = java.nio.file.Paths.get(".").toAbsolutePath().normalize().toString(); + String baseUri = Uris.fileUri(path) + "/"; + java.net.URL url = getClass().getResource("valid1.yml"); + java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI()); + String yaml = new String(java.nio.file.Files.readAllBytes(resPath), "UTF8"); + RootLoader.loadDocument(yaml, baseUri); + } + + @org.junit.Test + public void testvalid1ByPath() throws Exception { + java.net.URL url = getClass().getResource("valid1.yml"); + java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI()); + RootLoader.loadDocument(resPath); + } + + @org.junit.Test + public void testvalid1ByMap() throws Exception { + java.net.URL url = getClass().getResource("valid1.yml"); + java.nio.file.Path resPath = java.nio.file.Paths.get(url.toURI()); + String yaml = new String(java.nio.file.Files.readAllBytes(resPath), "UTF8"); + java.util.Map doc; + doc = (java.util.Map) YamlUtils.mapFromString(yaml); + RootLoader.loadDocument(doc); + } +} diff --git a/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/YamlUtilsTest.java b/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/YamlUtilsTest.java new file mode 100644 index 00000000..a9c8ede5 --- /dev/null +++ b/src/test/java/org/galaxyproject/gxformat2/v19_09/utils/YamlUtilsTest.java @@ -0,0 +1,15 @@ +package org.galaxyproject.gxformat2.v19_09.utils; + +import java.util.Map; +import org.junit.Assert; +import org.junit.Test; + +public class YamlUtilsTest { + @Test + public void testSimpleLoad() { + final String yamlStr = "moo: cow\nbark: dog\n"; + final Map loaded = YamlUtils.mapFromString(yamlStr); + Assert.assertEquals(loaded.get("moo"), "cow"); + Assert.assertEquals(loaded.get("bark"), "dog"); + } +} diff --git a/src/test/resources/org/galaxyproject/gxformat2/v19_09/utils/valid1.yml b/src/test/resources/org/galaxyproject/gxformat2/v19_09/utils/valid1.yml new file mode 100644 index 00000000..b850e660 --- /dev/null +++ b/src/test/resources/org/galaxyproject/gxformat2/v19_09/utils/valid1.yml @@ -0,0 +1,16 @@ +class: GalaxyWorkflow +doc: | + Simple workflow that no-op cats a file. +inputs: + the_input: + type: File + doc: input doc +outputs: + the_output: + outputSource: cat/out_file1 +steps: + cat: + tool_id: cat1 + doc: cat doc + in: + input1: the_input \ No newline at end of file