-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package sources | ||
|
||
import java.io.File | ||
import java.util.Optional | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import technology.idlab.runner.Pipeline | ||
|
||
class OptionalsTest { | ||
@Test | ||
fun parameters() { | ||
val configPath = this.javaClass.getResource("/pipelines/optionals.ttl") | ||
val config = File(configPath!!.path) | ||
val pipeline = Pipeline(config) | ||
val processors = pipeline.processors | ||
|
||
// Get the sole processor in the pipeline. | ||
assertEquals(processors.size, 1) | ||
val processor = processors[0] | ||
|
||
// Retrieve arguments. | ||
val required: String = processor.getArgument("required") | ||
val present: Optional<String> = processor.getOptionalArgument("present") | ||
val missing: Optional<String> = processor.getOptionalArgument("missing") | ||
|
||
// Check if results are correct. | ||
assertEquals("A Required String", required) | ||
assertEquals("An Optional String", present.get()) | ||
assertEquals(Optional.empty<String>(), missing) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@prefix jvm: <https://w3id.org/conn/jvm#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix owl: <http://www.w3.org/2002/07/owl#>. | ||
|
||
# Include processor definitions. | ||
<> owl:imports | ||
<../pipeline.ttl>, | ||
<../processors/optionals.ttl>. | ||
|
||
# Define a filter processor. | ||
[] | ||
a jvm:Optionals; | ||
jvm:required "A Required String"^^xsd:string; | ||
jvm:present "An Optional String"^^xsd:string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@prefix jvm: <https://w3id.org/conn/jvm#>. | ||
@prefix fno: <https://w3id.org/function/ontology#>. | ||
@prefix fnom: <https://w3id.org/function/vocabulary/mapping#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix owl: <http://www.w3.org/2002/07/owl#>. | ||
@prefix : <https://w3id.org/conn#>. | ||
@prefix sh: <http://www.w3.org/ns/shacl#>. | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
|
||
<> owl:imports <../pipeline.ttl>. | ||
|
||
jvm:Optionals a jvm:Processor; | ||
jvm:file <../sources/Optionals.java>; | ||
jvm:language "Java". | ||
|
||
[] a sh:NodeShape; | ||
sh:targetClass jvm:Optionals; | ||
sh:property [ | ||
sh:path jvm:required; | ||
sh:datatype xsd:string; | ||
sh:minCount 1; | ||
sh:maxCount 1; | ||
], [ | ||
sh:path jvm:present; | ||
sh:datatype xsd:string; | ||
sh:maxCount 1; | ||
], [ | ||
sh:path jvm:missing; | ||
sh:datatype xsd:string; | ||
sh:maxCount 1; | ||
]; | ||
sh:closed true; | ||
sh:ignoredProperties (rdf:type). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import java.util.Optional; | ||
import java.util.Map; | ||
|
||
import technology.idlab.runner.Processor; | ||
|
||
public class Optionals extends Processor { | ||
// Parameters | ||
public final String required; | ||
public final Optional<String> present; | ||
public final Optional<String> missing; | ||
|
||
public Optionals(Map<String, Object> args) { | ||
// Call super constructor. | ||
super(args); | ||
|
||
// Parameters | ||
this.required = this.getArgument("required"); | ||
this.present = this.getOptionalArgument("present"); | ||
this.missing = this.getOptionalArgument("missing"); | ||
} | ||
|
||
public void exec() {} | ||
} |