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

common-workflow-language / cwlviewer / #1999

13 May 2026 10:23PM UTC coverage: 70.05% (-0.3%) from 70.334%
#1999

Pull #751

github

kinow
Last fixes to ease working with the SPARQL queries for a future PR, and more string concatenation removal
Pull Request #751: Bump org.springframework.boot:spring-boot-starter-parent from 3.1.4 to 4.1.0-RC1

120 of 208 new or added lines in 30 files covered. (57.69%)

21 existing lines in 5 files now uncovered.

1691 of 2414 relevant lines covered (70.05%)

0.7 hits per line

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

50.51
/src/main/java/org/commonwl/view/cwl/RDFService.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.commonwl.view.cwl;
21

22
import org.apache.commons.io.output.ByteArrayOutputStream;
23
import org.apache.jena.graph.Node;
24
import org.apache.jena.graph.NodeFactory;
25
import org.apache.jena.query.DatasetAccessor;
26
import org.apache.jena.query.DatasetAccessorFactory;
27
import org.apache.jena.query.ParameterizedSparqlString;
28
import org.apache.jena.query.Query;
29
import org.apache.jena.query.QueryExecution;
30
import org.apache.jena.query.QueryExecutionFactory;
31
import org.apache.jena.query.QueryFactory;
32
import org.apache.jena.query.ResultSet;
33
import org.apache.jena.query.ResultSetFactory;
34
import org.apache.jena.rdf.model.Model;
35
import org.apache.jena.riot.RDFFormat;
36
import org.apache.jena.web.DatasetGraphAccessorHTTP;
37
import org.springframework.beans.factory.annotation.Autowired;
38
import org.springframework.beans.factory.annotation.Value;
39
import org.springframework.stereotype.Service;
40

41
/** Handles the parsing of CWL RDF files */
42
@Service
43
public class RDFService {
44

45
  // Context for SPARQL queries
46
  private final String queryCtx =
1✔
47
      """
48
          PREFIX cwl: <https://w3id.org/cwl/cwl#>
49
          PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
50
          PREFIX sld: <https://w3id.org/cwl/salad#>
51
          PREFIX dct: <http://purl.org/dc/terms/>
52
          PREFIX doap: <http://usefulinc.com/ns/doap#>
53
          PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
54
          PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
55
          PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
56
          PREFIX s: <http://schema.org/>""";
57

58
  private final String rdfService;
59

60
  /**
61
   * Create the RDFService with configuration
62
   *
63
   * @param rdfService The SPARQL endpoint from configuration
64
   */
65
  @Autowired
66
  public RDFService(@Value("${sparql.endpoint}") String rdfService) {
1✔
67
    this.rdfService = rdfService;
1✔
68
  }
1✔
69

70
  /**
71
   * Add to ontologies in the triple store
72
   *
73
   * @param model The model to be stored
74
   */
75
  public void addToOntologies(Model model) {
76
    DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(rdfService);
×
77
    accessor.add("ontologies", model);
×
78
  }
×
79

80
  /**
81
   * Get a model from the triple store in a given format
82
   *
83
   * @param graphName The name of the graph for the model
84
   * @param format The name of the writer (format to be written)
85
   * @return A byte array representing the model in the given format
86
   */
87
  public byte[] getModel(String graphName, String format) {
88
    DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(rdfService);
×
89
    Model model = accessor.getModel(graphName);
×
90
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
×
91
    model.write(outputStream, format);
×
92
    return outputStream.toByteArray();
×
93
  }
94

95
  /**
96
   * Store a model with triples in the triple store
97
   *
98
   * @param graphName The name of the graph to store the model in
99
   * @param model The model to be stored
100
   */
101
  public void storeModel(String graphName, Model model) {
102
    DatasetGraphAccessorHTTP accessor = new DatasetGraphAccessorHTTP(rdfService);
×
103
    accessor.setOutboundSyntax(RDFFormat.TURTLE);
×
104
    Node name = NodeFactory.createURI(graphName);
×
105
    accessor.httpPut(name, model.getGraph());
×
106
  }
×
107

108
  /**
109
   * Check if a graph exists within the triple store
110
   *
111
   * @param graphName The name of the graph
112
   * @return Whether the graph exists
113
   */
114
  public boolean graphExists(String graphName) {
115
    ParameterizedSparqlString graphQuery = new ParameterizedSparqlString();
×
116
    graphQuery.setCommandText("ASK WHERE { GRAPH ?graphName { ?s ?p ?o } }");
×
117
    graphQuery.setIri("graphName", graphName);
×
118
    Query query = QueryFactory.create(graphQuery.toString());
×
119
    try (QueryExecution qexec = QueryExecutionFactory.createServiceRequest(rdfService, query)) {
×
120
      return qexec.execAsk();
×
121
    }
122
  }
123

124
  /**
125
   * Check if a property of the ontology exists within the triple store
126
   *
127
   * @param ontUri The URI of the property
128
   * @return Whether the graph exists
129
   */
130
  public boolean ontPropertyExists(String ontUri) {
131
    ParameterizedSparqlString graphQuery = new ParameterizedSparqlString();
×
132
    graphQuery.setCommandText(
×
133
        """
134
        PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
135
        ASK WHERE { GRAPH ?graphName { ?ont rdfs:label ?label } }
136
        """);
137
    graphQuery.setIri("ont", ontUri);
×
138
    graphQuery.setIri("graphName", rdfService + "ontologies");
×
139
    Query query = QueryFactory.create(graphQuery.toString());
×
140
    try (QueryExecution qexec = QueryExecutionFactory.createServiceRequest(rdfService, query)) {
×
141
      return qexec.execAsk();
×
142
    }
143
  }
144

145
  /**
146
   * Get the label and doc strings for a workflow resource
147
   *
148
   * @param workflowURI The URI of the workflow
149
   * @return Result set with label and doc strings
150
   */
151
  public ResultSet getLabelAndDoc(String workflowURI) {
152
    ParameterizedSparqlString labelQuery = new ParameterizedSparqlString();
1✔
153
    labelQuery.setCommandText(
1✔
154
        queryCtx
155
            + """
156
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
157
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
158
            PREFIX sld: <https://w3id.org/cwl/salad#>
159
            PREFIX dct: <http://purl.org/dc/terms/>
160
            PREFIX doap: <http://usefulinc.com/ns/doap#>
161
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
162
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
163
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
164
            PREFIX s: <http://schema.org/>
165
            SELECT ?label ?doc
166
            WHERE {
167
              GRAPH ?wf {
168
                ?wf rdf:type ?type .
169
                OPTIONAL { ?wf sld:label|rdfs:label ?label }
170
                OPTIONAL { ?wf sld:doc|rdfs:comment ?doc }
171
              }
172
            }
173
            """);
174
    labelQuery.setIri("wf", workflowURI);
1✔
175
    return runQuery(labelQuery);
1✔
176
  }
177

178
  /**
179
   * Get the label for an ontology URL TODO: can be merged with getLabelAndDoc when
180
   * common-workflow-language/cwltool#427 is resolved
181
   *
182
   * @param ontologyURI The format URI for the ontology
183
   * @return Result set with label and doc strings
184
   */
185
  public String getOntLabel(String ontologyURI) {
186
    ParameterizedSparqlString labelQuery = new ParameterizedSparqlString();
×
187
    labelQuery.setCommandText(
×
188
        """
189
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\
190
            SELECT ?label
191
            WHERE {
192
              GRAPH ?graphName {
193
                ?ont rdfs:label ?label
194
              }
195
            }
196
            """);
197
    labelQuery.setIri("ont", ontologyURI);
×
198
    labelQuery.setIri("graphName", rdfService + "ontologies");
×
199
    ResultSet result = runQuery(labelQuery);
×
200
    if (result.hasNext()) {
×
201
      return result.next().get("label").toString();
×
202
    }
203
    return null;
×
204
  }
205

206
  /**
207
   * Get the inputs for the workflow in the model
208
   *
209
   * @param workflowURI URI of the workflow
210
   * @return The result set of inputs
211
   */
212
  public ResultSet getInputs(String workflowURI) {
213
    ParameterizedSparqlString inputsQuery = new ParameterizedSparqlString();
1✔
214
    inputsQuery.setCommandText(
1✔
215
        queryCtx
216
            + """
217
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
218
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
219
            PREFIX sld: <https://w3id.org/cwl/salad#>
220
            PREFIX dct: <http://purl.org/dc/terms/>
221
            PREFIX doap: <http://usefulinc.com/ns/doap#>
222
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
223
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
224
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
225
            PREFIX s: <http://schema.org/>
226
            SELECT ?name ?type ?items ?null ?format ?label ?doc
227
            WHERE {
228
              GRAPH ?wf {
229
                ?wf rdf:type cwl:Workflow .
230
                ?wf cwl:inputs ?name .
231
                OPTIONAL {
232
                  {\s
233
                    ?name sld:type ?type
234
                    FILTER(?type != sld:null)\s
235
                    FILTER (!isBlank(?type))
236
                  } UNION {\s
237
                    ?name sld:type ?arraytype .
238
                    ?arraytype sld:type ?type .
239
                    ?arraytype sld:items ?items\s
240
                  }
241
                }
242
                OPTIONAL {\s
243
                  ?name sld:type ?null
244
                  FILTER(?null = sld:null)
245
                }
246
                OPTIONAL { ?name cwl:format ?format }
247
                OPTIONAL { ?name sld:label|rdfs:label ?label }
248
                OPTIONAL { ?name sld:doc|rdfs:comment ?doc }
249
              }
250
            }
251
            """);
252
    inputsQuery.setIri("wf", workflowURI);
1✔
253
    return runQuery(inputsQuery);
1✔
254
  }
255

256
  /**
257
   * Get the outputs for the workflow in the model
258
   *
259
   * @param workflowURI URI of the workflow
260
   * @return The result set of outputs
261
   */
262
  public ResultSet getOutputs(String workflowURI) {
263
    ParameterizedSparqlString outputsQuery = new ParameterizedSparqlString();
1✔
264
    outputsQuery.setCommandText(
1✔
265
        queryCtx
266
            + """
267
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
268
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
269
            PREFIX sld: <https://w3id.org/cwl/salad#>
270
            PREFIX dct: <http://purl.org/dc/terms/>
271
            PREFIX doap: <http://usefulinc.com/ns/doap#>
272
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
273
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
274
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
275
            PREFIX s: <http://schema.org/>
276
            SELECT ?name ?type ?items ?null ?format ?label ?doc
277
            WHERE {
278
              GRAPH ?wf {
279
                ?wf rdf:type cwl:Workflow .
280
                ?wf cwl:outputs ?name .
281
                OPTIONAL {
282
                  {\s
283
                    ?name sld:type ?type
284
                    FILTER(?type != sld:null)\s
285
                    FILTER (!isBlank(?type))
286
                  } UNION {\s
287
                    ?name sld:type ?arraytype .
288
                    ?arraytype sld:type ?type .
289
                    ?arraytype sld:items ?items\s
290
                  }
291
                }
292
                OPTIONAL {\s
293
                  ?name sld:type ?null
294
                  FILTER(?null = sld:null)
295
                }
296
                OPTIONAL { ?name cwl:format ?format }
297
                OPTIONAL { ?name sld:label|rdfs:label ?label }
298
                OPTIONAL { ?name sld:doc|rdfs:comment ?doc }
299
              }
300
            }
301
            """);
302
    outputsQuery.setIri("wf", workflowURI);
1✔
303
    return runQuery(outputsQuery);
1✔
304
  }
305

306
  /**
307
   * Get the steps for the workflow in the model
308
   *
309
   * @param workflowURI URI of the workflow
310
   * @return The result set of steps
311
   */
312
  public ResultSet getSteps(String workflowURI) {
313
    ParameterizedSparqlString stepQuery = new ParameterizedSparqlString();
1✔
314
    stepQuery.setCommandText(
1✔
315
        queryCtx
316
            + """
317
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
318
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
319
            PREFIX sld: <https://w3id.org/cwl/salad#>
320
            PREFIX dct: <http://purl.org/dc/terms/>
321
            PREFIX doap: <http://usefulinc.com/ns/doap#>
322
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
323
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
324
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
325
            PREFIX s: <http://schema.org/>
326
            SELECT ?step ?run ?runtype ?label ?doc ?stepinput ?default ?src
327
            WHERE {
328
              GRAPH ?wf {
329
                ?wf Workflow:steps ?step .
330
                ?step cwl:run ?run .
331
                ?run rdf:type ?runtype .
332
                OPTIONAL {\s
333
                    ?step cwl:in ?stepinput .
334
                    { ?stepinput cwl:source ?src } UNION { ?stepinput cwl:default ?default }
335
                }
336
                OPTIONAL { ?run sld:label|rdfs:label ?label }
337
                OPTIONAL { ?run sld:doc|rdfs:comment ?doc }
338
              }
339
            }
340
            """);
341
    stepQuery.setIri("wf", workflowURI);
1✔
342
    return runQuery(stepQuery);
1✔
343
  }
344

345
  /**
346
   * Get links between steps for the workflow in the model
347
   *
348
   * @param workflowURI URI of the workflow
349
   * @return The result set of step links
350
   */
351
  public ResultSet getStepLinks(String workflowURI) {
352
    ParameterizedSparqlString linkQuery = new ParameterizedSparqlString();
1✔
353
    linkQuery.setCommandText(
1✔
354
        queryCtx
355
            + """
356
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
357
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
358
            PREFIX sld: <https://w3id.org/cwl/salad#>
359
            PREFIX dct: <http://purl.org/dc/terms/>
360
            PREFIX doap: <http://usefulinc.com/ns/doap#>
361
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
362
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
363
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
364
            PREFIX s: <http://schema.org/>
365
            SELECT ?src ?dest ?default
366
            WHERE {
367
              GRAPH ?wf {
368
                ?wf Workflow:steps ?step .
369
                ?step cwl:in ?dest .
370
                { ?dest cwl:source ?src } UNION { ?dest cwl:default ?default }
371
              }
372
            }
373
            """);
374
    linkQuery.setIri("wf", workflowURI);
1✔
375
    return runQuery(linkQuery);
1✔
376
  }
377

378
  /**
379
   * Get links between steps and outputs for the workflow in the model
380
   *
381
   * @param workflowURI URI of the workflow
382
   * @return The result set of steps
383
   */
384
  public ResultSet getOutputLinks(String workflowURI) {
385
    ParameterizedSparqlString linkQuery = new ParameterizedSparqlString();
1✔
386
    linkQuery.setCommandText(
1✔
387
        queryCtx
388
            + """
389
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
390
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
391
            PREFIX sld: <https://w3id.org/cwl/salad#>
392
            PREFIX dct: <http://purl.org/dc/terms/>
393
            PREFIX doap: <http://usefulinc.com/ns/doap#>
394
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
395
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
396
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
397
            PREFIX s: <http://schema.org/>
398
            SELECT ?src ?dest
399
            WHERE {
400
              GRAPH ?wf {
401
                ?wf rdf:type cwl:Workflow .
402
                ?wf cwl:outputs ?dest .
403
                ?dest cwl:outputSource ?src
404
              }
405
            }
406
            """);
407
    linkQuery.setIri("wf", workflowURI);
1✔
408
    return runQuery(linkQuery);
1✔
409
  }
410

411
  /**
412
   * Gets the docker requirement and pull link for a workflow
413
   *
414
   * @param workflowURI URI of the workflow
415
   * @return Result set of docker hint and pull link
416
   */
417
  public ResultSet getDockerLink(String workflowURI) {
418
    ParameterizedSparqlString dockerQuery = new ParameterizedSparqlString();
1✔
419
    dockerQuery.setCommandText(
1✔
420
        queryCtx
421
            + """
422
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
423
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
424
            PREFIX sld: <https://w3id.org/cwl/salad#>
425
            PREFIX dct: <http://purl.org/dc/terms/>
426
            PREFIX doap: <http://usefulinc.com/ns/doap#>
427
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
428
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
429
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
430
            PREFIX s: <http://schema.org/>
431
            SELECT ?docker ?pull
432
            WHERE {
433
              GRAPH ?wf {
434
                ?wf rdf:type cwl:Workflow .
435
                { ?wf cwl:requirements ?docker } UNION { ?wf cwl:hints ?docker} .
436
                ?docker rdf:type cwl:DockerRequirement
437
                OPTIONAL { ?docker DockerRequirement:dockerPull ?pull }
438
              }
439
            }
440
            """);
441
    dockerQuery.setIri("wf", workflowURI);
1✔
442
    return runQuery(dockerQuery);
1✔
443
  }
444

445
  /**
446
   * Get authors from schema.org creator fields for a file
447
   *
448
   * @param path The path within the Git repository to the file
449
   * @param fileUri URI of the file
450
   * @return The result set of step links
451
   */
452
  public ResultSet getAuthors(String path, String fileUri) {
453
    ParameterizedSparqlString linkQuery = new ParameterizedSparqlString();
×
454
    linkQuery.setCommandText(
×
455
        queryCtx
456
            + """
457
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
458
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
459
            PREFIX sld: <https://w3id.org/cwl/salad#>
460
            PREFIX dct: <http://purl.org/dc/terms/>
461
            PREFIX doap: <http://usefulinc.com/ns/doap#>
462
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
463
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
464
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
465
            PREFIX s: <http://schema.org/>
466
            SELECT ?email ?name ?orcid
467
            WHERE {
468
              GRAPH ?graphName {
469
                ?file s:author|s:contributor|s:creator ?author .
470
                {
471
                  ?creator rdf:type s:Person .
472
                  OPTIONAL { ?author s:email ?email }
473
                  OPTIONAL { ?author s:name ?name }
474
                  OPTIONAL { ?author s:id|s:sameAs ?orcid }
475
                } UNION {
476
                  ?author rdf:type s:Organization .
477
                  ?author s:department* ?dept .
478
                  ?dept s:member ?member
479
                  OPTIONAL { ?member s:email ?email }
480
                  OPTIONAL { ?member s:name ?name }
481
                  OPTIONAL { ?member s:id|s:sameAs ?orcid }
482
                }
483
                FILTER(regex(str(?orcid), "^https?://orcid.org/" ))
484
                FILTER(regex(str(?file), ?wfFilter, "i" ))
485
              }
486
            }
487
            """);
488
    linkQuery.setLiteral("wfFilter", path + "$");
×
489
    linkQuery.setIri("graphName", fileUri);
×
490
    return runQuery(linkQuery);
×
491
  }
492

493
  /**
494
   * Gets the step name from a full URI
495
   *
496
   * @param baseUrl the URL of the workflow
497
   * @param uri The URI
498
   * @return The step ID
499
   */
500
  public String stepNameFromURI(String baseUrl, String uri) {
501
    uri = uri.substring(uri.indexOf(baseUrl));
1✔
502
    uri = uri.replace(baseUrl, "");
1✔
503
    uri = uri.replace("#", "/");
1✔
504
    uri = uri.substring(1);
1✔
505
    if (uri.indexOf("/") > 0) {
1✔
506
      return uri.substring(0, uri.indexOf("/"));
1✔
507
    }
508
    return uri;
1✔
509
  }
510

511
  /**
512
   * Format a default value
513
   *
514
   * @param defaultVal The default value
515
   * @return Default value suitable for a node label
516
   */
517
  public String formatDefault(String defaultVal) {
518
    int lastCaret = defaultVal.indexOf("^^");
1✔
519
    if (lastCaret != -1) {
1✔
520
      return defaultVal.substring(0, lastCaret);
1✔
521
    }
522
    return "\\\"" + defaultVal + "\\\"";
1✔
523
  }
524

525
  /**
526
   * Convert an RDF type to cwl process
527
   *
528
   * @param runtype The string from the RDF
529
   * @return CWL process the string refers to
530
   */
531
  public CWLProcess strToRuntype(String runtype) {
532
    return switch (runtype) {
1✔
NEW
533
      case "https://w3id.org/cwl/cwl#Workflow" -> CWLProcess.WORKFLOW;
×
534
      case "https://w3id.org/cwl/cwl#CommandLineTool" -> CWLProcess.COMMANDLINETOOL;
1✔
NEW
535
      case "https://w3id.org/cwl/cwl#ExpressionTool" -> CWLProcess.EXPRESSIONTOOL;
×
NEW
536
      default -> null;
×
537
    };
538
  }
539

540
  /**
541
   * Get the label for the node from its name
542
   *
543
   * @param name The name in the form filename#step
544
   * @return The second part of the name, just the step
545
   */
546
  public String labelFromName(String name) {
547
    name = name.substring(name.indexOf('#') + 1);
1✔
548
    int slashIndex = name.indexOf("/");
1✔
549
    if (slashIndex > 0) {
1✔
550
      name = name.substring(slashIndex + 1);
1✔
551
    }
552
    return name;
1✔
553
  }
554

555
  /**
556
   * Run a SPARQL query on a given model
557
   *
558
   * @param queryString The query to be run
559
   * @return The result set of the query
560
   */
561
  ResultSet runQuery(ParameterizedSparqlString queryString) {
562
    Query query = QueryFactory.create(queryString.toString());
×
563
    try (QueryExecution qexec = QueryExecutionFactory.createServiceRequest(rdfService, query)) {
×
564
      return ResultSetFactory.copyResults(qexec.execSelect());
×
565
    }
566
  }
567

568
  public ResultSet getLicense(String workflowURI) {
569
    ParameterizedSparqlString licenseQuery = new ParameterizedSparqlString();
×
570
    licenseQuery.setCommandText(
×
571
        queryCtx
572
            + """
573
            PREFIX cwl: <https://w3id.org/cwl/cwl#>
574
            PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
575
            PREFIX sld: <https://w3id.org/cwl/salad#>
576
            PREFIX dct: <http://purl.org/dc/terms/>
577
            PREFIX doap: <http://usefulinc.com/ns/doap#>
578
            PREFIX Workflow: <https://w3id.org/cwl/cwl#Workflow/>
579
            PREFIX DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/>
580
            PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
581
            PREFIX s: <http://schema.org/>
582
            SELECT ?license\s
583
            WHERE {
584
              GRAPH ?wf {
585
                ?wf rdf:type cwl:Workflow .
586
                { ?wf s:license ?license }\s
587
            UNION { ?wf doap:license ?license }\s
588
            UNION { ?wf dct:license ?license }\s
589
              }
590
            }
591
            """);
592
    licenseQuery.setIri("wf", workflowURI);
×
593
    return runQuery(licenseQuery);
×
594
  }
595
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc