Skip to content

Commit ee730f2

Browse files
committed
fix $import
1 parent ee5ba7c commit ee730f2

File tree

12 files changed

+1627
-36
lines changed

12 files changed

+1627
-36
lines changed

capture_kit.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: capture_kit
2+
type: record
3+
fields:
4+
- name: bait
5+
type: string

envvar.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class: EnvVarRequirement
2+
envDef:
3+
- envName: "TEST_ENV"
4+
envValue: "hello test env"

params_inc.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
- id: t1
2+
type: Any
3+
outputBinding:
4+
outputEval: $(inputs)
5+
- id: t2
6+
type: Any
7+
outputBinding:
8+
outputEval: $(inputs.bar)
9+
- id: t3
10+
type: Any
11+
outputBinding:
12+
outputEval: $(inputs['bar'])
13+
- id: t4
14+
type: Any
15+
outputBinding:
16+
outputEval: $(inputs["bar"])
17+
18+
- id: t5
19+
type: Any
20+
outputBinding:
21+
outputEval: $(inputs.bar.baz)
22+
- id: t6
23+
type: Any
24+
outputBinding:
25+
outputEval: $(inputs['bar'].baz)
26+
- id: t7
27+
type: Any
28+
outputBinding:
29+
outputEval: $(inputs['bar']["baz"])
30+
- id: t8
31+
type: Any
32+
outputBinding:
33+
outputEval: $(inputs.bar['baz'])
34+
35+
- id: t9
36+
type: Any
37+
outputBinding:
38+
outputEval: $(inputs.bar['b az'])
39+
- id: t10
40+
type: Any
41+
outputBinding:
42+
outputEval: $(inputs.bar['b\'az'])
43+
- id: t11
44+
type: Any
45+
outputBinding:
46+
outputEval: $(inputs.bar["b'az"])
47+
- id: t12
48+
type: "null"
49+
outputBinding:
50+
outputEval: $(inputs.bar['b"az'])
51+
52+
- id: t13
53+
type: Any
54+
outputBinding:
55+
outputEval: -$(inputs.bar.baz)
56+
- id: t14
57+
type: Any
58+
outputBinding:
59+
outputEval: -$(inputs['bar'].baz)
60+
- id: t15
61+
type: Any
62+
outputBinding:
63+
outputEval: -$(inputs['bar']["baz"])
64+
- id: t16
65+
type: Any
66+
outputBinding:
67+
outputEval: -$(inputs.bar['baz'])
68+
69+
- id: t17
70+
type: Any
71+
outputBinding:
72+
outputEval: $(inputs.bar.baz) $(inputs.bar.baz)
73+
- id: t18
74+
type: Any
75+
outputBinding:
76+
outputEval: $(inputs['bar'].baz) $(inputs['bar'].baz)
77+
- id: t19
78+
type: Any
79+
outputBinding:
80+
outputEval: $(inputs['bar']["baz"]) $(inputs['bar']["baz"])
81+
- id: t20
82+
type: Any
83+
outputBinding:
84+
outputEval: $(inputs.bar['baz']) $(inputs.bar['baz'])
85+
86+
- id: t21
87+
type: Any
88+
outputBinding:
89+
outputEval: $(inputs.bar['b az']) $(inputs.bar['b az'])
90+
- id: t22
91+
type: Any
92+
outputBinding:
93+
outputEval: $(inputs.bar['b\'az']) $(inputs.bar['b\'az'])
94+
- id: t23
95+
type: Any
96+
outputBinding:
97+
outputEval: $(inputs.bar["b'az"]) $(inputs.bar["b'az"])
98+
- id: t24
99+
type: Any
100+
outputBinding:
101+
outputEval: $(inputs.bar['b"az']) $(inputs.bar['b"az'])
102+
103+
- id: t25
104+
type: Any
105+
outputBinding:
106+
outputEval: $(inputs.bar.buz[1])
107+
- id: t26
108+
type: Any
109+
outputBinding:
110+
outputEval: $(inputs.bar.buz[1]) $(inputs.bar.buz[1])
111+
112+
- id: t27
113+
type: "null"
114+
outputBinding:
115+
outputEval: $(null)
116+
117+
- id: t28
118+
type: int
119+
outputBinding:
120+
outputEval: $(inputs.bar.buz.length)

schemadef-type.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class: SchemaDefRequirement
2+
types:
3+
- name: HelloType
4+
type: record
5+
fields:
6+
- name: a
7+
type: string
8+
- name: b
9+
type: string

src/main/java/org/w3id/cwl/cwl1_2/utils/DefaultFetcher.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package org.w3id.cwl.cwl1_2.utils;
22

3+
import java.io.IOException;
34
import java.net.URI;
5+
import java.util.Arrays;
6+
import java.util.Scanner;
47

58
public class DefaultFetcher implements Fetcher {
69

@@ -27,6 +30,19 @@ public String urlJoin(final String baseUrl, final String url) {
2730
}
2831

2932
public String fetchText(final String url) {
30-
return "fetched";
33+
final URI uri = Uris.toUri(url);
34+
final String scheme = uri.getScheme();
35+
if (Arrays.asList("http", "https", "file").contains(scheme)) {
36+
Scanner scanner;
37+
try {
38+
scanner = new Scanner(uri.toURL().openStream(), "UTF-8").useDelimiter("\\A");
39+
} catch (IOException e) {
40+
throw new ValidationException("Error fetching %s: %s.".format(url, e));
41+
}
42+
String result = scanner.next();
43+
scanner.close();
44+
return result;
45+
}
46+
throw new ValidationException("Unsupported scheme in URL: %s".format(url));
3147
}
3248
}

src/main/java/org/w3id/cwl/cwl1_2/utils/Loader.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,29 @@ default T documentLoad(
4949

5050
default T documentLoadByUrl(final String url, final LoadingOptions loadingOptions) {
5151
if (loadingOptions.idx.containsKey(url)) {
52-
return documentLoad(loadingOptions.idx.get(url), url, loadingOptions);
52+
Object result = loadingOptions.idx.get(url);
53+
if (result instanceof String) {
54+
return documentLoad((String) result, url, loadingOptions);
55+
} else if (result instanceof Map) {
56+
return documentLoad((Map<String, Object>) result, url, loadingOptions);
57+
}
58+
return load(result, url, loadingOptions);
5359
}
5460

5561
final String text = loadingOptions.fetcher.fetchText(url);
56-
final Map<String, Object> result = YamlUtils.mapFromString(text);
57-
loadingOptions.idx.put(url, result);
58-
final LoadingOptionsBuilder urlLoadingOptions =
59-
new LoadingOptionsBuilder().copiedFrom(loadingOptions).setFileUri(url);
60-
return documentLoad(result, url, urlLoadingOptions.build());
62+
try {
63+
Map<String, Object> resultMap = YamlUtils.mapFromString(text);
64+
loadingOptions.idx.put(url, resultMap);
65+
final LoadingOptionsBuilder urlLoadingOptions =
66+
new LoadingOptionsBuilder().copiedFrom(loadingOptions).setFileUri(url);
67+
return documentLoad(resultMap, url, urlLoadingOptions.build());
68+
} catch (ClassCastException e) {
69+
List<Object> resultList = YamlUtils.listFromString(text);
70+
loadingOptions.idx.put(url, resultList);
71+
final LoadingOptionsBuilder urlLoadingOptions =
72+
new LoadingOptionsBuilder().copiedFrom(loadingOptions).setFileUri(url);
73+
return documentLoad(resultList, url, urlLoadingOptions.build());
74+
}
6175
}
6276

6377
default T loadField(

src/main/java/org/w3id/cwl/cwl1_2/utils/LoadingOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class LoadingOptions {
1111
String fileUri;
1212
Map<String, String> namespaces;
1313
List<String> schemas;
14-
Map<String, Map<String, Object>> idx;
14+
Map<String, Object> idx;
1515
Map<String, String> vocab;
1616
Map<String, String> rvocab;
1717

@@ -20,7 +20,7 @@ public class LoadingOptions {
2020
final String fileUri,
2121
final Map<String, String> namespaces,
2222
final List<String> schemas,
23-
final Map<String, Map<String, Object>> idx) {
23+
final Map<String, Object> idx) {
2424
this.fetcher = fetcher;
2525
this.fileUri = fileUri;
2626
this.namespaces = namespaces;

src/main/java/org/w3id/cwl/cwl1_2/utils/LoadingOptionsBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public LoadingOptions build() {
3939
String fileUri = this.fileUri.orElse(null);
4040
List<String> schemas = this.schemas.orElse(null);
4141
Map<String, String> namespaces = this.namespaces.orElse(null);
42-
Map<String, Map<String, Object>> idx = new HashMap<String, Map<String, Object>>();
42+
Map<String, Object> idx = new HashMap<String, Object>();
4343
if (this.copyFrom.isPresent()) {
4444
final LoadingOptions copyFrom = this.copyFrom.get();
4545
idx = copyFrom.idx;

src/main/java/org/w3id/cwl/cwl1_2/utils/RootLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static Object loadDocument(
1313
final String baseUri = ensureBaseUri(baseUri_);
1414
LoadingOptions loadingOptions = loadingOptions_;
1515
if (loadingOptions == null) {
16-
loadingOptions = new LoadingOptionsBuilder().build();
16+
loadingOptions = new LoadingOptionsBuilder().setFileUri(baseUri).build();
1717
}
1818
return LoaderInstances.union_of_CommandLineTool_or_ExpressionTool_or_Workflow_or_Operation_or_array_of_union_of_CommandLineTool_or_ExpressionTool_or_Workflow_or_Operation.documentLoad(doc, baseUri, loadingOptions);
1919
}

src/main/java/org/w3id/cwl/cwl1_2/utils/YamlUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.w3id.cwl.cwl1_2.utils;
22

3+
import java.util.List;
34
import java.util.Map;
45
import org.yaml.snakeyaml.Yaml;
56

@@ -10,4 +11,10 @@ public static Map<String, Object> mapFromString(final String text) {
1011
final Map<String, Object> result = yaml.load(text);
1112
return result;
1213
}
14+
15+
public static List<Object> listFromString(final String text) {
16+
Yaml yaml = new Yaml();
17+
final List<Object> result = yaml.load(text);
18+
return result;
19+
}
1320
}

0 commit comments

Comments
 (0)