From 969f1209b760441666727fa6a4cc78a0b6e36830 Mon Sep 17 00:00:00 2001 From: Miroslav Blasko Date: Thu, 12 Sep 2024 17:19:07 +0200 Subject: [PATCH 1/5] [#258] Refactor @Parameter to include iri instead of (urlPrefix, name) --- .../cz/cvut/spipes/constants/KBSS_MODULE.java | 33 +++++--- .../java/cz/cvut/spipes/constants/SM.java | 29 ++++--- .../java/cz/cvut/spipes/constants/SML.java | 77 ++++++++++++------- .../cvut/spipes/engine/PipelineFactory.java | 21 ++--- .../cvut/spipes/modules/AbstractModule.java | 8 +- .../modules/AnnotatedAbstractModule.java | 18 ++--- .../spipes/modules/ApplyConstructModule.java | 12 +-- .../spipes/modules/BindBySelectModule.java | 13 +--- .../modules/BindRDFContentHashModule.java | 2 +- .../modules/BindWithConstantModule.java | 8 +- .../spipes/modules/ExportToRDFFileModule.java | 2 +- .../modules/ImportFileFromURLModule.java | 16 ++-- .../modules/ImportRDFFromWorkspaceModule.java | 6 +- .../cz/cvut/spipes/modules/MergeModule.java | 2 +- .../cz/cvut/spipes/modules/Parameter.java | 4 +- .../modules/RetrievePrefixesModule.java | 2 +- .../cvut/spipes/modules/ReturnRDFModule.java | 6 +- .../java/cz/cvut/spipes/util/URIUtils.java | 19 +++++ .../spipes/modules/AbstractModuleTest.java | 2 +- .../main/java/RdfAnnotationProcessorMojo.java | 9 ++- .../cvut/spipes/modules/Ckan2RdfModule.java | 6 +- .../SparqlEndpointDatasetExplorerModule.java | 6 +- .../modules/DatasetDiscoveryModule.java | 2 +- .../modules/GetDatasetDescriptorsModule.java | 4 +- .../cvut/spipes/modules/ImportE5XModule.java | 4 +- .../modules/ConstructFormMetadataModule.java | 2 +- .../modules/ConstructTextualViewModule.java | 12 +-- .../modules/FetchPossibleValuesModule.java | 2 +- .../modules/MergeFormMetadataModule.java | 6 +- .../cz/cvut/spipes/modules/SUTimeModule.java | 22 +++--- .../cvut/spipes/modules/SUTimeModuleNew.java | 32 ++++---- .../cvut/spipes/sutime/DescriptorModel.java | 34 ++++---- .../modules/Rdf4jCreateRepositoryModule.java | 6 +- .../spipes/modules/Rdf4jDeployModule.java | 16 ++-- .../spipes/modules/Rdf4jUpdateModule.java | 12 +-- .../modules/ApplyConstructAbstractModule.java | 12 +-- .../modules/ApplyConstructV2Module.java | 2 +- ...hunkedValuesAndScrollableCursorModule.java | 10 +-- ...ApplyConstructWithChunkedValuesModule.java | 10 +-- ...lyConstructWithScrollableCursorModule.java | 6 +- .../spipes/modules/DownloadGraphModule.java | 8 +- .../spipes/modules/ExternalSchemExModule.java | 9 ++- .../ImproveSPOWithMarginalsModule.java | 8 +- .../spipes/modules/RetrieveGraphModule.java | 6 +- .../cz/cvut/spipes/modules/RDF2CSVModule.java | 2 +- .../cz/cvut/spipes/modules/TabularModule.java | 18 ++--- .../cz/cvut/spipes/modules/ModuleTarql.java | 6 +- .../cz/cvut/spipes/modules/TarqlModule.java | 10 +-- .../modules/ExtractTermOccurrencesModule.java | 2 +- .../spipes/modules/TextAnalysisModule.java | 14 ++-- 50 files changed, 317 insertions(+), 261 deletions(-) create mode 100644 s-pipes-core/src/main/java/cz/cvut/spipes/util/URIUtils.java diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/constants/KBSS_MODULE.java b/s-pipes-core/src/main/java/cz/cvut/spipes/constants/KBSS_MODULE.java index 4e9c0970..07c3e9fe 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/constants/KBSS_MODULE.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/constants/KBSS_MODULE.java @@ -1,7 +1,8 @@ package cz.cvut.spipes.constants; import org.apache.jena.rdf.model.Property; -import org.apache.jena.rdf.model.ResourceFactory; + +import static org.apache.jena.rdf.model.ResourceFactory.createProperty; public class KBSS_MODULE { @@ -10,17 +11,25 @@ public class KBSS_MODULE { */ public static final String uri = "http://onto.fel.cvut.cz/ontologies/lib/module/"; - protected static final Property property(String local ) - { return ResourceFactory.createProperty( uri, local ); } - - public static final Property has_input_graph_constraint = property("has-input-graph-constraint"); - public static final Property has_output_graph_constraint = property("has-output-graph-constraint"); - public static final Property has_target_module_flag = property("has-target-module-flag"); - public static final Property has_debug_mode_flag = property("has-debug-mode-flag"); - public static final Property is_parse_text = property("is-parse-text"); - public static final Property has_max_iteration_count = property("has-max-iteration-count"); - public static final Property has_resource_uri = property("has-resource-uri"); + public static final String has_input_graph_constraint = uri + "has-input-graph-constraint"; + public static final String has_output_graph_constraint = uri + "has-output-graph-constraint"; + public static final String has_target_module_flag = uri + "has-target-module-flag"; + public static final String has_debug_mode_flag = uri + "has-debug-mode-flag"; + public static final String is_parse_text = uri + "is-parse-text"; + public static final String has_max_iteration_count = uri + "has-max-iteration-count"; + public static final String has_resource_uri = uri + "has-resource-uri"; // states that reified statement belongs to specific named graph identified by uri - public static final Property is_part_of_graph = property("is-part-of-graph"); + public static final String is_part_of_graph = uri + "is-part-of-graph"; + + public static class JENA { + public static final Property has_input_graph_constraint = createProperty(KBSS_MODULE.has_input_graph_constraint); + public static final Property has_output_graph_constraint = createProperty(KBSS_MODULE.has_output_graph_constraint); + public static final Property has_target_module_flag = createProperty(KBSS_MODULE.has_target_module_flag); + public static final Property has_debug_mode_flag = createProperty(KBSS_MODULE.has_debug_mode_flag); + public static final Property is_parse_text = createProperty(KBSS_MODULE.is_parse_text); + public static final Property has_max_iteration_count = createProperty(KBSS_MODULE.has_max_iteration_count); + public static final Property has_resource_uri = createProperty(KBSS_MODULE.has_resource_uri); + public static final Property is_part_of_graph = createProperty(KBSS_MODULE.is_part_of_graph); + } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SM.java b/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SM.java index 2bfdf3a3..7d3007c8 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SM.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SM.java @@ -1,8 +1,9 @@ package cz.cvut.spipes.constants; import org.apache.jena.rdf.model.Property; -import org.apache.jena.rdf.model.Resource; -import org.apache.jena.rdf.model.ResourceFactory; + +import static org.apache.jena.rdf.model.ResourceFactory.createProperty; +import static org.apache.jena.rdf.model.ResourceFactory.createResource; public class SM { @@ -11,18 +12,22 @@ public class SM { */ public static final String uri = "http://topbraid.org/sparqlmotion#"; - protected static final Resource resource(String local ) - { return ResourceFactory.createResource( uri + local ); } + public static final String next = uri + "next"; + public static final String outputVariable = uri + "outputVariable"; + public static final String returnModule = uri + "returnModule"; - protected static final Property property(String local ) - { return ResourceFactory.createProperty( uri, local ); } + public static final String Function = uri + "Function"; + public static final String Module = uri + "Module"; + public static final String Modules = uri + "Modules"; - public static final Property next = property("next"); - public static final Property outputVariable = property("outputVariable"); - public static final Property returnModule = property("returnModule"); + public static class JENA { + public static final Property next = createProperty(SM.next); + public static final Property outputVariable = createProperty(SM.outputVariable); + public static final Property returnModule = createProperty(SM.returnModule); - public static final Resource Function = resource("Function"); - public static final Resource Module = resource("Module"); - public static final Resource Modules = resource("Modules"); + public static final org.apache.jena.rdf.model.Resource Function = createResource(SM.Function); + public static final org.apache.jena.rdf.model.Resource Module = createResource(SM.Module); + public static final org.apache.jena.rdf.model.Resource Modules = createResource(SM.Modules); + } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SML.java b/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SML.java index c763ff75..491be513 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SML.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SML.java @@ -2,7 +2,9 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; -import org.apache.jena.rdf.model.ResourceFactory; + +import static org.apache.jena.rdf.model.ResourceFactory.createProperty; +import static org.apache.jena.rdf.model.ResourceFactory.createResource; public class SML { @@ -11,32 +13,49 @@ public class SML { */ public static final String uri = "http://topbraid.org/sparqlmotionlib#"; - protected static final org.apache.jena.rdf.model.Resource resource(String local ) - { return ResourceFactory.createResource( uri + local ); } - - protected static final Property property(String local ) - { return ResourceFactory.createProperty( uri, local ); } - - public static final Property replace = property( "replace"); - public static final Property constructQuery = property("constructQuery"); - public static final Property value = property("value"); - public static final Property selectQuery = property("selectQuery"); - public static final Property updateQuery = property("updateQuery"); - public static final Property sourceFilePath = property("sourceFilePath"); - public static final Property url = property("url"); - public static final Property targetFilePath = property("targetFilePath"); - public static final Property baseURI = property("baseURI"); - public static final Property serialization = property("serialization"); - public static final Property ignoreImports = property("ignoreImports"); - - public static final Resource ApplyConstruct = resource("ApplyConstruct"); - public static final Resource ExportToRDFFile = resource("ExportToRDFFile"); - public static final Resource ImportRDFFromWorkspace = resource("ImportRDFFromWorkspace"); - public static final Resource ImportFileFromURL = resource("ImportFileFromURL"); - public static final Resource BindWithConstant = resource("BindWithConstant"); - public static final Resource BindBySelect = resource("BindBySelect"); - public static final Resource Merge = resource("Merge"); - public static final Resource ReturnRDF = resource("ReturnRDF"); - - public static final Resource JSONLD = resource("JSONLD"); + public static final String replace = uri + "replace"; + public static final String constructQuery = uri + "constructQuery"; + public static final String value = uri + "value"; + public static final String selectQuery = uri + "selectQuery"; + public static final String updateQuery = uri + "updateQuery"; + public static final String sourceFilePath = uri + "sourceFilePath"; + public static final String url = uri + "url"; + public static final String targetFilePath = uri + "targetFilePath"; + public static final String baseURI = uri + "baseURI"; + public static final String serialization = uri + "serialization"; + public static final String ignoreImports = uri + "ignoreImports"; + + public static final String ApplyConstruct = uri + "ApplyConstruct"; + public static final String ExportToRDFFile = uri + "ExportToRDFFile"; + public static final String ImportRDFFromWorkspace = uri + "ImportRDFFromWorkspace"; + public static final String ImportFileFromURL = uri + "ImportFileFromURL"; + public static final String BindWithConstant = uri + "BindWithConstant"; + public static final String BindBySelect = uri + "BindBySelect"; + public static final String Merge = uri + "Merge"; + public static final String ReturnRDF = uri + "ReturnRDF"; + public static final String JSONLD = uri + "JSONLD"; + + public static class JENA { + public static final Property replace = createProperty(SML.replace); + public static final Property constructQuery = createProperty(SML.constructQuery); + public static final Property value = createProperty(SML.value); + public static final Property selectQuery = createProperty(SML.selectQuery); + public static final Property updateQuery = createProperty(SML.updateQuery); + public static final Property sourceFilePath = createProperty(SML.sourceFilePath); + public static final Property url = createProperty(SML.url); + public static final Property targetFilePath = createProperty(SML.targetFilePath); + public static final Property baseURI = createProperty(SML.baseURI); + public static final Property serialization = createProperty(SML.serialization); + public static final Property ignoreImports = createProperty(SML.ignoreImports); + + public static final Resource ApplyConstruct = createResource("ApplyConstruct"); + public static final Resource ExportToRDFFile = createResource("ExportToRDFFile"); + public static final Resource ImportRDFFromWorkspace = createResource("ImportRDFFromWorkspace"); + public static final Resource ImportFileFromURL = createResource("ImportFileFromURL"); + public static final Resource BindWithConstant = createResource("BindWithConstant"); + public static final Resource BindBySelect = createResource("BindBySelect"); + public static final Resource Merge = createResource("Merge"); + public static final Resource ReturnRDF = createResource("ReturnRDF"); + public static final Resource JSONLD = createResource("JSONLD"); + } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/engine/PipelineFactory.java b/s-pipes-core/src/main/java/cz/cvut/spipes/engine/PipelineFactory.java index 9099aa19..16996bc3 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/engine/PipelineFactory.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/engine/PipelineFactory.java @@ -4,15 +4,6 @@ import cz.cvut.spipes.function.ARQFunction; import cz.cvut.spipes.modules.Module; import cz.cvut.spipes.util.JenaPipelineUtils; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.lang.reflect.Modifier; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; @@ -28,6 +19,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.lang.reflect.Modifier; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + public class PipelineFactory { private static final Logger log = LoggerFactory.getLogger(PipelineFactory.class); @@ -166,7 +167,7 @@ private static Map loadAllModules(@NotNull Model configModel) Resource res = e.getKey(); // set up input modules - res.listProperties(SM.next).toList().stream() + res.listProperties(SM.JENA.next).toList().stream() .map(st -> { Module m = res2ModuleMap.get(st.getObject().asResource()); if (m == null) { diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/AbstractModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/AbstractModule.java index 17ababa5..8bf714df 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/AbstractModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/AbstractModule.java @@ -213,13 +213,13 @@ protected String saveFullModelToTemporaryFile(OntModel model) { } private void loadModuleConstraints() { - inputConstraintQueries = getResourcesByProperty(KBSS_MODULE.has_input_graph_constraint); - outputConstraintQueries = getResourcesByProperty(KBSS_MODULE.has_output_graph_constraint); + inputConstraintQueries = getResourcesByProperty(KBSS_MODULE.JENA.has_input_graph_constraint); + outputConstraintQueries = getResourcesByProperty(KBSS_MODULE.JENA.has_output_graph_constraint); } private void loadModuleFlags() { - isTargetModule = getPropertyValue(KBSS_MODULE.has_debug_mode_flag, false); - isInDebugMode = getPropertyValue(KBSS_MODULE.has_debug_mode_flag, false); + isTargetModule = getPropertyValue(KBSS_MODULE.JENA.has_debug_mode_flag, false); + isInDebugMode = getPropertyValue(KBSS_MODULE.JENA.has_debug_mode_flag, false); } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/AnnotatedAbstractModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/AnnotatedAbstractModule.java index bdedf8b7..ee680b8d 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/AnnotatedAbstractModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/AnnotatedAbstractModule.java @@ -1,15 +1,15 @@ package cz.cvut.spipes.modules; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import cz.cvut.spipes.modules.handlers.*; import org.apache.jena.rdf.model.ResourceFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * The `AnnotatedAbstractModule` class extends the `AbstractModule` class and provides * an implementation for loading the module's configuration using {@link Parameter} annotation. @@ -35,10 +35,10 @@ public void loadConfiguration() { final Parameter p = f.getAnnotation(Parameter.class); if ( p == null ) { continue; - } else if (vars.containsKey(p.name())) { - throw new RuntimeException(String.format("Two parameters are named the same %s, except prefix", p.name())); + } else if (vars.containsKey(p.iri())) { + throw new RuntimeException(String.format("Two parameters have same iri %s", p.iri())); } else { - vars.put(p.name(), f); + vars.put(p.iri(), f); } log.trace("Processing parameter {} ", f.getName()); @@ -51,7 +51,7 @@ public void loadConfiguration() { } HandlerRegistry handlerRegistry = HandlerRegistry.getInstance(); Handler handler = handlerRegistry.getHandler(f.getType(), resource, executionContext, setter); - handler.setValueByProperty(ResourceFactory.createProperty(p.urlPrefix()+p.name())); + handler.setValueByProperty(ResourceFactory.createProperty(p.iri())); } } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ApplyConstructModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ApplyConstructModule.java index ccbef41c..d4de7855 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ApplyConstructModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ApplyConstructModule.java @@ -31,21 +31,23 @@ public class ApplyConstructModule extends AnnotatedAbstractModule { private static final Logger log = LoggerFactory.getLogger(ApplyConstructModule.class); + //sml:constructQuery - @Parameter(urlPrefix = SML.uri, name = "constructQuery") + @Parameter(iri = SML.constructQuery) private List constructQueries; //sml:replace - @Parameter(urlPrefix = SML.uri, name = "replace") + @Parameter(iri = SML.replace) private boolean isReplace = false; //kbss:parseText /** * Whether the query should be taken from sp:text property instead of from SPIN serialization */ - @Parameter(urlPrefix = KBSS_MODULE.uri, name = "is-parse-text") + @Parameter(iri = KBSS_MODULE.is_parse_text) private boolean parseText = false; + //kbss:iterationCount /** * Maximal number of iterations of the whole rule set. 0 means 0 iterations. The actual number of iterations can be smaller, @@ -59,7 +61,7 @@ public class ApplyConstructModule extends AnnotatedAbstractModule { *

* Within each iteration, all queries are evaluated on the same model. */ - @Parameter(urlPrefix = KBSS_MODULE.uri, name = "has-max-iteration-count") + @Parameter(iri = KBSS_MODULE.has_max_iteration_count) private int iterationCount = 1; public ApplyConstructModule() { @@ -166,7 +168,7 @@ public ExecutionContext executeSelf() { @Override public String getTypeURI() { - return SML.ApplyConstruct.getURI(); + return SML.ApplyConstruct; } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindBySelectModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindBySelectModule.java index ecb5c224..81fde158 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindBySelectModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindBySelectModule.java @@ -5,26 +5,21 @@ import cz.cvut.spipes.engine.ExecutionContextFactory; import cz.cvut.spipes.engine.VariablesBinding; import cz.cvut.spipes.util.QueryUtils; -import org.apache.jena.query.Query; -import org.apache.jena.query.QueryExecution; -import org.apache.jena.query.QueryExecutionFactory; -import org.apache.jena.query.QuerySolution; -import org.apache.jena.query.ResultSet; +import org.apache.jena.query.*; import org.apache.jena.rdf.model.ModelFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Select; public class BindBySelectModule extends AnnotatedAbstractModule { private static final Logger log = LoggerFactory.getLogger(BindBySelectModule.class); - @Parameter(urlPrefix = SML.uri, name = "selectQuery") + @Parameter(iri = SML.selectQuery) private Select selectQuery; //sml:replace - @Parameter(urlPrefix = SML.uri, name = "replace") + @Parameter(iri = SML.replace) private boolean isReplace = false; @Override @@ -60,7 +55,7 @@ public ExecutionContext executeSelf() { @Override public String getTypeURI() { - return SML.BindBySelect.getURI(); + return SML.BindBySelect; } public Select getSelectQuery() { diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindRDFContentHashModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindRDFContentHashModule.java index dc674e0b..09174443 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindRDFContentHashModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindRDFContentHashModule.java @@ -14,7 +14,7 @@ public class BindRDFContentHashModule extends AnnotatedAbstractModule { private static final Logger log = LoggerFactory.getLogger(BindRDFContentHashModule.class); - @Parameter(urlPrefix = SM.uri, name="outputVariable") + @Parameter(iri = SM.outputVariable) String outputVariable; @Override diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindWithConstantModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindWithConstantModule.java index 58bbb3a1..f84781a4 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindWithConstantModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindWithConstantModule.java @@ -13,13 +13,13 @@ public class BindWithConstantModule extends AnnotatedAbstractModule { private static final Logger log = LoggerFactory.getLogger(BindWithConstantModule.class); - @Parameter(urlPrefix = SM.uri, name = "outputVariable") + @Parameter(iri = SM.outputVariable) String outputVariable; - @Parameter(urlPrefix = SML.uri, name = "value") + @Parameter(iri = SML.value) RDFNode value; - @Parameter(urlPrefix = SML.uri, name = "replace") + @Parameter(iri = SML.replace) private boolean isReplace = false; @Override @@ -38,7 +38,7 @@ public ExecutionContext executeSelf() { @Override public String getTypeURI() { - return SML.BindWithConstant.getURI(); + return SML.BindWithConstant; } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ExportToRDFFileModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ExportToRDFFileModule.java index 05ce9e2a..fcc25dc8 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ExportToRDFFileModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ExportToRDFFileModule.java @@ -15,7 +15,7 @@ public ExecutionContext executeSelf() { @Override public String getTypeURI() { - return SML.ExportToRDFFile.getURI(); + return SML.ExportToRDFFile; } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ImportFileFromURLModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ImportFileFromURLModule.java index 34a04686..38b9ab83 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ImportFileFromURLModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ImportFileFromURLModule.java @@ -4,19 +4,17 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.engine.ExecutionContextFactory; import cz.cvut.spipes.engine.VariablesBinding; +import org.apache.jena.rdf.model.ResourceFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.Optional; -import org.apache.jena.rdf.model.RDFNode; -import org.apache.jena.rdf.model.ResourceFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class ImportFileFromURLModule extends AnnotatedAbstractModule { @@ -24,14 +22,14 @@ public class ImportFileFromURLModule extends AnnotatedAbstractModule { //sml:targetFilePath, required - @Parameter(urlPrefix = SML.uri, name = "targetFilePath") + @Parameter(iri = SML.targetFilePath) Path targetFilePath; //TODO $_executionDir ? //kbss:targetResourceVariable String targetResourceVariable; //sml:url, required - @Parameter(urlPrefix = SML.uri, name = "url") + @Parameter(iri = SML.url) URL url; @Override @@ -65,7 +63,7 @@ public ExecutionContext executeSelf() { @Override public String getTypeURI() { - return SML.ImportFileFromURL.getURI(); + return SML.ImportFileFromURL; } public Path getTargetFilePath() { diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ImportRDFFromWorkspaceModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ImportRDFFromWorkspaceModule.java index 80a1994c..17f739cc 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ImportRDFFromWorkspaceModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ImportRDFFromWorkspaceModule.java @@ -23,16 +23,16 @@ public class ImportRDFFromWorkspaceModule extends AnnotatedAbstractModule { OntologyDocumentManager ontologyDocumentManager = OntoDocManager.getInstance(); // sml:baseURI : xsd:string - @Parameter(urlPrefix = SML.uri, name = "baseURI") + @Parameter(iri = SML.baseURI) String baseUri; // sml:ignoreImports : xsd:boolean - @Parameter(urlPrefix = SML.uri, name = "ignoreImports") + @Parameter(iri = SML.ignoreImports) boolean isIgnoreImports = false; // TODO reconsider support for this property (might change identification of module type) // sml:sourceFilePath : xsd:string - @Parameter(urlPrefix = SML.uri, name = "sourceFilePath") + @Parameter(iri = SML.sourceFilePath) Path sourceFilePath; diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/MergeModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/MergeModule.java index c88bef1c..d7e74396 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/MergeModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/MergeModule.java @@ -13,7 +13,7 @@ public ExecutionContext executeSelf() { @Override public String getTypeURI() { - return SML.Merge.getURI(); + return SML.Merge; } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/Parameter.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/Parameter.java index 26a833d9..48d22521 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/Parameter.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/Parameter.java @@ -1,6 +1,5 @@ package cz.cvut.spipes.modules; -import cz.cvut.spipes.constants.KBSS_MODULE; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -9,7 +8,6 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Parameter { - String urlPrefix() default KBSS_MODULE.uri; - String name(); + String iri(); String comment() default ""; } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/RetrievePrefixesModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/RetrievePrefixesModule.java index e65721f8..75e02508 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/RetrievePrefixesModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/RetrievePrefixesModule.java @@ -53,7 +53,7 @@ public class RetrievePrefixesModule extends AnnotatedAbstractModule { private static final String TYPE_URI = KBSS_MODULE.uri + "retrieve-prefixes"; //sml:replace - @Parameter(urlPrefix = SML.uri, name = "replace") + @Parameter(iri = SML.replace) private boolean isReplace = false; //TODO refactor -> should be part of execution context diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ReturnRDFModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ReturnRDFModule.java index 6496d103..bc90f3f8 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ReturnRDFModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ReturnRDFModule.java @@ -5,9 +5,9 @@ import org.apache.jena.rdf.model.Resource; public class ReturnRDFModule extends AnnotatedAbstractModule { - @Parameter(urlPrefix = SML.uri, name = "serialization") + @Parameter(iri = SML.serialization) private Resource serialization; - @Parameter(urlPrefix = SML.uri, name = "baseURI") + @Parameter(iri = SML.baseURI) private String baseURI; @Override @@ -17,7 +17,7 @@ public ExecutionContext executeSelf() { @Override public String getTypeURI() { - return SML.ReturnRDF.getURI(); + return SML.ReturnRDF; } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/util/URIUtils.java b/s-pipes-core/src/main/java/cz/cvut/spipes/util/URIUtils.java new file mode 100644 index 00000000..6beb7446 --- /dev/null +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/util/URIUtils.java @@ -0,0 +1,19 @@ +package cz.cvut.spipes.util; + +public class URIUtils { + + public static String getLocalName(String uri) { + + int lastSlashIndex = uri.lastIndexOf('/'); + int lastHashIndex = uri.lastIndexOf('#'); + + int lastIndex = Math.max(lastSlashIndex, lastHashIndex); + + // Return substring after last '/' or '#' + if (lastIndex != -1 && lastIndex + 1 < uri.length()) { + return uri.substring(lastIndex + 1); + } + + return uri; + } +} diff --git a/s-pipes-core/src/test/java/cz/cvut/spipes/modules/AbstractModuleTest.java b/s-pipes-core/src/test/java/cz/cvut/spipes/modules/AbstractModuleTest.java index 15b2c96f..7e26b985 100644 --- a/s-pipes-core/src/test/java/cz/cvut/spipes/modules/AbstractModuleTest.java +++ b/s-pipes-core/src/test/java/cz/cvut/spipes/modules/AbstractModuleTest.java @@ -31,7 +31,7 @@ public void getEffectiveValueReturnsComputedValue() throws Exception { module.setInputContext( ExecutionContextFactory.createContext(ModelFactory.createDefaultModel(), variablesBinding)); - RDFNode node = ((AbstractModule) module).getEffectiveValue(SML.value); + RDFNode node = ((AbstractModule) module).getEffectiveValue(SML.JENA.value); assertEquals(node, ResourceFactory.createPlainLiteral("Hello James"), "Effective value computed incorrectly."); diff --git a/s-pipes-modules-utils/s-pipes-module-creator-maven-plugin/src/main/java/RdfAnnotationProcessorMojo.java b/s-pipes-modules-utils/s-pipes-module-creator-maven-plugin/src/main/java/RdfAnnotationProcessorMojo.java index 8c515bf2..3f070a22 100644 --- a/s-pipes-modules-utils/s-pipes-module-creator-maven-plugin/src/main/java/RdfAnnotationProcessorMojo.java +++ b/s-pipes-modules-utils/s-pipes-module-creator-maven-plugin/src/main/java/RdfAnnotationProcessorMojo.java @@ -1,6 +1,7 @@ import cz.cvut.spipes.constants.KBSS_MODULE; import cz.cvut.spipes.constants.SM; import cz.cvut.spipes.modules.annotations.SPipesModule; +import cz.cvut.spipes.util.URIUtils; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.ResourceFactory; @@ -129,7 +130,7 @@ private void generateRdfForAllModules() throws MalformedURLException, ClassNotFo for (MavenProject submodule : project.getCollectedProjects()) { //find module's main class - var moduleClasses = readAllModuleClasses(submodule); + var moduleClasses = readAllModuleClasses(submodule); getLog().info("Scanned maven module '" + submodule.getName() + "' and found " + moduleClasses.size() + " SPipes Module(s): [" + moduleClasses.stream() .map(Class::getSimpleName) @@ -346,13 +347,13 @@ private void writeConstraintsToModel(Model baseRdfModel, for (var annotation : constraintAnnotations) { final var modelConstraint = ResourceFactory.createResource(); baseRdfModel.add(modelConstraint, RDF.type, SPL.Argument); - baseRdfModel.add(modelConstraint, SPL.predicate, ResourceFactory.createResource(annotation.urlPrefix() + annotation.name())); - baseRdfModel.add(modelConstraint, RDFS.label, annotation.name()); + baseRdfModel.add(modelConstraint, SPL.predicate, ResourceFactory.createResource(annotation.iri())); + baseRdfModel.add(modelConstraint, RDFS.label, URIUtils.getLocalName(annotation.iri())); baseRdfModel.add(modelConstraint, RDFS.comment, annotation.comment()); baseRdfModel.add(root, SPIN.constraint, modelConstraint); getLog().debug("Added model constraint based on annotation: " + - "(name = " + annotation.name() + ", urlPrefix = " + annotation.urlPrefix() + ")"); + "(iri = " + annotation.iri() + ")"); } } diff --git a/s-pipes-modules/module-ckan2rdf/src/main/java/cz/cvut/spipes/modules/Ckan2RdfModule.java b/s-pipes-modules/module-ckan2rdf/src/main/java/cz/cvut/spipes/modules/Ckan2RdfModule.java index 5615addc..babd36cc 100644 --- a/s-pipes-modules/module-ckan2rdf/src/main/java/cz/cvut/spipes/modules/Ckan2RdfModule.java +++ b/s-pipes-modules/module-ckan2rdf/src/main/java/cz/cvut/spipes/modules/Ckan2RdfModule.java @@ -36,14 +36,14 @@ public class Ckan2RdfModule extends AnnotatedAbstractModule { public static final String TYPE_URI = KBSS_MODULE.uri + "ckan2rdf-v1"; public static final String NS_DDO = "http://onto.fel.cvut.cz/ontologies/dataset-descriptor/"; - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-ckan-url", comment = "URL of the CKAN server.") + @Parameter(iri = TYPE_URI + "/" + "p-ckan-url", comment = "URL of the CKAN server.") private String propCkanApiUrl; - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-rdf4j-repository-url", comment = "URL of the RDF4J repository.") + @Parameter(iri = TYPE_URI + "/" + "p-rdf4j-repository-url", comment = "URL of the RDF4J repository.") private String propRdf4jRepositoryUrl; // TODO - revise comment - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-max-datasets", comment = "Limits the number of processed datasets.") + @Parameter(iri = TYPE_URI + "/" + "p-max-datasets", comment = "Limits the number of processed datasets.") private Integer maxDatasets = Integer.MAX_VALUE; private Resource createInstance(final String classIri, final Model m) { diff --git a/s-pipes-modules/module-ckan2rdf/src/main/java/cz/cvut/spipes/modules/SparqlEndpointDatasetExplorerModule.java b/s-pipes-modules/module-ckan2rdf/src/main/java/cz/cvut/spipes/modules/SparqlEndpointDatasetExplorerModule.java index 70cc6d77..a1931ccc 100644 --- a/s-pipes-modules/module-ckan2rdf/src/main/java/cz/cvut/spipes/modules/SparqlEndpointDatasetExplorerModule.java +++ b/s-pipes-modules/module-ckan2rdf/src/main/java/cz/cvut/spipes/modules/SparqlEndpointDatasetExplorerModule.java @@ -28,13 +28,13 @@ public class SparqlEndpointDatasetExplorerModule extends AnnotatedAbstractModule public static final String TYPE_URI = KBSS_MODULE.uri + "sparqlEndpointDatasetExplorer-v1"; private final String nsHttp = "http://onto.fel.cvut.cz/ontologies/http/"; - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-sparql-endpoint-url", comment = "URL of the SPARQL endpoint.") + @Parameter(iri = TYPE_URI + "/" + "p-sparql-endpoint-url", comment = "URL of the SPARQL endpoint.") private String propSparqlEndpointUrl; - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-connection-timeout", comment = "Connection Timeout in ms. Default 3000.") + @Parameter(iri = TYPE_URI + "/" + "p-connection-timeout", comment = "Connection Timeout in ms. Default 3000.") private long propConnectionTimeout = 3000; - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-query-timeout", comment = "Query Timeout. Default 60000") + @Parameter(iri = TYPE_URI + "/" + "p-query-timeout", comment = "Query Timeout. Default 60000") private long propQueryTimeout = 60000; @Override diff --git a/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/DatasetDiscoveryModule.java b/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/DatasetDiscoveryModule.java index e60c2a1d..c596bb5a 100644 --- a/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/DatasetDiscoveryModule.java +++ b/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/DatasetDiscoveryModule.java @@ -36,7 +36,7 @@ public class DatasetDiscoveryModule extends AbstractModule { private static final String TYPE_URI = KBSS_MODULE.uri + "dataset-discovery-v1"; private static final Property P_USER_INPUT = getParameter("prp-user-input"); - @Parameter(urlPrefix = TYPE_URI + "/", name = "prp-user-input", comment = "Keywords query. Keywords are separated by space.") + @Parameter(iri = TYPE_URI + "/" + "prp-user-input", comment = "Keywords query. Keywords are separated by space.") private String userInput; private static Property getParameter(final String name) { diff --git a/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/GetDatasetDescriptorsModule.java b/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/GetDatasetDescriptorsModule.java index aee310d9..1754b87d 100644 --- a/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/GetDatasetDescriptorsModule.java +++ b/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/GetDatasetDescriptorsModule.java @@ -33,10 +33,10 @@ public class GetDatasetDescriptorsModule extends AbstractModule { private static final Property P_DATASET_IRI = getParameter("p-dataset-iri"); private static final Property P_ENDPOINT_URL = getParameter("endpoint-url"); - @Parameter(urlPrefix = PARAM_URI, name = "p-dataset-iri", comment = "IRI of the dataset.")// TODO - revise comment + @Parameter(iri = TYPE_URI + "/" + "p-dataset-iri", comment = "IRI of the dataset.")// TODO - revise comment private String prpDatasetIri; - @Parameter(urlPrefix = PARAM_URI, name = "endpoint-url", comment = "URL of the SPARQL endpoint. Default value" + + @Parameter(iri = TYPE_URI + "/" + "endpoint-url", comment = "URL of the SPARQL endpoint. Default value" + " is 'http://onto.fel.cvut.cz/rdf4j-server/repositories/descriptors-metadata'") private String endpointUrl = "http://onto.fel.cvut.cz/rdf4j-server/repositories/descriptors-metadata"; diff --git a/s-pipes-modules/module-eccairs/src/main/java/cz/cvut/spipes/modules/ImportE5XModule.java b/s-pipes-modules/module-eccairs/src/main/java/cz/cvut/spipes/modules/ImportE5XModule.java index c4690687..0f860c2b 100644 --- a/s-pipes-modules/module-eccairs/src/main/java/cz/cvut/spipes/modules/ImportE5XModule.java +++ b/s-pipes-modules/module-eccairs/src/main/java/cz/cvut/spipes/modules/ImportE5XModule.java @@ -39,7 +39,7 @@ public class ImportE5XModule extends AbstractModule { // TODO - this parameter id defined with IRI in s-pipes-modules\module.sms.ttl // TODO - we should be able to annotate directly "StreamResource e5xResource" instead - @Parameter(name = "has-resource-uri", comment = "Uri of a resource referencing content of an e5x file.") + @Parameter(iri = KBSS_MODULE.has_resource_uri, comment = "Uri of a resource referencing content of an e5x file.") private String e5xResourceUriStr; StreamResource e5xResource; @@ -149,7 +149,7 @@ public String getTypeURI() { @Override public void loadConfiguration() { - e5xResourceUriStr = getEffectiveValue(KBSS_MODULE.has_resource_uri).asLiteral().toString(); + e5xResourceUriStr = getEffectiveValue(KBSS_MODULE.JENA.has_resource_uri).asLiteral().toString(); e5xResource = getResourceByUri(e5xResourceUriStr); } diff --git a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/ConstructFormMetadataModule.java b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/ConstructFormMetadataModule.java index b439b21b..2457578d 100644 --- a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/ConstructFormMetadataModule.java +++ b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/ConstructFormMetadataModule.java @@ -28,7 +28,7 @@ public class ConstructFormMetadataModule extends AnnotatedAbstractModule { private static final String PATH_SEPARATOR = ","; private static final String INSTANCE_TYPE_SEPARATOR = "|"; - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Replace context flag. Default value is false.") + @Parameter(iri = SML.replace, comment = "Replace context flag. Default value is false.") private boolean isReplace = false; private enum Origin { diff --git a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/ConstructTextualViewModule.java b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/ConstructTextualViewModule.java index 89d8b1db..06dbd7b5 100644 --- a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/ConstructTextualViewModule.java +++ b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/ConstructTextualViewModule.java @@ -32,26 +32,26 @@ public class ConstructTextualViewModule extends AnnotatedAbstractModule { private static final String TYPE_URI = KBSS_MODULE.uri + "construct-textual-view"; - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Replace context flag. Default value is false.") + @Parameter(iri = SML.replace, comment = "Replace context flag. Default value is false.") private boolean isReplace = false; - @Parameter(urlPrefix = FORM_MODULE.uri, name = "serialize-unanswered-questions", + @Parameter(iri = FORM_MODULE.uri + "serialize-unanswered-questions", comment = "If true (default), outputs questions not having answers") private boolean isSerializeUnansweredQuestions = true; - @Parameter(urlPrefix = FORM_MODULE.uri, name = "serialize-answers", + @Parameter(iri = FORM_MODULE.uri + "serialize-answers", comment = "If true (default), outputs answers not only questions") private boolean isSerializeAnswers = true; - @Parameter(urlPrefix = FORM_MODULE.uri, name = "process-non-root-questions", + @Parameter(iri = FORM_MODULE.uri + "process-non-root-questions", comment = "If true (default), process all questions, otherwise process only root questions") private boolean isProcessNonRootQuestions = true; - @Parameter(urlPrefix = FORM_MODULE.uri, name = "indentation-string", + @Parameter(iri = FORM_MODULE.uri + "indentation-string", comment = "Indentation string indents subquestion from questions. By default ' ' is used.") private String indentationString = " "; - @Parameter(urlPrefix = FORM_MODULE.uri, name = "language", + @Parameter(iri = FORM_MODULE.uri + "language", comment = "Language to be used to retrieve labels of questions. By default 'en' is used.") private String language = "en"; diff --git a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/FetchPossibleValuesModule.java b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/FetchPossibleValuesModule.java index 6369b5e6..294a01df 100644 --- a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/FetchPossibleValuesModule.java +++ b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/FetchPossibleValuesModule.java @@ -25,7 +25,7 @@ public class FetchPossibleValuesModule extends AnnotatedAbstractModule { private static final Logger log = LoggerFactory.getLogger(FetchPossibleValuesModule.class); private static final String TYPE_URI = KBSS_MODULE.uri + "fetch-possible-values"; - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Specifies whether a module should overwrite triples" + + @Parameter(iri = SML.replace, comment = "Specifies whether a module should overwrite triples" + " from its predecessors. When set to true (default is false), it prevents" + " passing through triples from the predecessors.") private boolean isReplace = false; diff --git a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/MergeFormMetadataModule.java b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/MergeFormMetadataModule.java index 43c6f878..b3ea2692 100644 --- a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/MergeFormMetadataModule.java +++ b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/MergeFormMetadataModule.java @@ -31,15 +31,15 @@ public class MergeFormMetadataModule extends AnnotatedAbstractModule { private static final String QUESTION_ORIGIN_HASH_VAR = "{_questionOriginHash}"; private static final String EXECUTION_ID_VAR = "{_executionId}"; - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Specifies whether a module should overwrite triples" + + @Parameter(iri = SML.replace, comment = "Specifies whether a module should overwrite triples" + " from its predecessors. When set to true (default is false), it prevents" + " passing through triples from the predecessors.") private boolean isReplace = false; - @Parameter(name = "execution-id", comment = "Execution id that will be used to construct question IRIs") + @Parameter(iri = KBSS_MODULE.uri + "execution-id", comment = "Execution id that will be used to construct question IRIs") private String executionId = DigestUtils.md5Hex(Long.toString(RANDOM.nextLong())); - @Parameter(name = "question-instance-template", comment = "URL Template to create URL for question instances. " + + @Parameter(iri = KBSS_MODULE.uri + "question-instance-template", comment = "URL Template to create URL for question instances. " + "Default is 'http://onto.fel.cvut.cz/ontologies/documentation/question-{_questionOriginHash}-{_executionId}'") private String questionInstanceTemplate = SFormsVocabularyJena.s_c_question.toString() diff --git a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModule.java b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModule.java index 5188ccf0..0c400fdf 100644 --- a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModule.java +++ b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModule.java @@ -34,10 +34,10 @@ public class SUTimeModule extends AbstractModule { public static final String TYPE_URI = KBSS_MODULE.uri + "temporal-v0.1"; - @Parameter(urlPrefix = DescriptorModel.prefix, name = "has-rule-file", comment = "Rule file, multivalued.") // TODO - revise comment + @Parameter(iri = DescriptorModel.has_rule_file, comment = "Rule file, multivalued.") // TODO - revise comment private List ruleFilePaths = new LinkedList<>(); - @Parameter(urlPrefix = DescriptorModel.prefix, name = "has-document-date", comment = "Document date format.") // TODO - revise comment + @Parameter(iri = DescriptorModel.has_document_date, comment = "Document date format.") // TODO - revise comment private String documentDate; // TODO support other formats ? @@ -52,12 +52,12 @@ public String getTypeURI() { @Override public void loadConfiguration() { - if (this.resource.getProperty(DescriptorModel.has_document_date) != null) { // TODO set current date if not specified - documentDate = getEffectiveValue(DescriptorModel.has_document_date).asLiteral().toString(); + if (this.resource.getProperty(DescriptorModel.JENA.has_document_date) != null) { // TODO set current date if not specified + documentDate = getEffectiveValue(DescriptorModel.JENA.has_document_date).asLiteral().toString(); } - if (this.resource.getProperty(DescriptorModel.has_rule_file) != null) { //TODO support more rule files - ruleFilePaths.add(Paths.get(getEffectiveValue(DescriptorModel.has_rule_file).asLiteral().toString())); + if (this.resource.getProperty(DescriptorModel.JENA.has_rule_file) != null) { //TODO support more rule files + ruleFilePaths.add(Paths.get(getEffectiveValue(DescriptorModel.JENA.has_rule_file).asLiteral().toString())); } } @@ -93,12 +93,12 @@ private Model analyzeModel(Model m) { Literal beginLiteral = mm.createTypedLiteral(s.getDateBegin()); Literal endLiteral = mm.createTypedLiteral(s.getDateEnd()); - reifiedSt.addProperty(RDF.type, DescriptorModel.sutime_extraction); + reifiedSt.addProperty(RDF.type, DescriptorModel.JENA.sutime_extraction); - reifiedSt.addProperty(DescriptorModel.extracted, s.getDateExtracted()); - reifiedSt.addProperty(DescriptorModel.beginDate, beginLiteral); - reifiedSt.addProperty(DescriptorModel.endDate, endLiteral); - reifiedSt.addProperty(DescriptorModel.type, s.getDateType()); + reifiedSt.addProperty(DescriptorModel.JENA.extracted, s.getDateExtracted()); + reifiedSt.addProperty(DescriptorModel.JENA.beginDate, beginLiteral); + reifiedSt.addProperty(DescriptorModel.JENA.endDate, endLiteral); + reifiedSt.addProperty(DescriptorModel.JENA.type, s.getDateType()); temporalAnnotationStmts.add(reifiedSt); } diff --git a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java index daf7c7d7..b2fdeb7b 100644 --- a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java +++ b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java @@ -41,27 +41,27 @@ public class SUTimeModuleNew extends AbstractModule { private static final String LIMIT_OFFSET_CLAUSE_MARKER_NAME = "LIMIT_OFFSET"; private static final Property P_PAGE_SIZE = ResourceFactory.createProperty(TYPE_PREFIX + "page-size"); - @Parameter(urlPrefix = TYPE_PREFIX, name = "page-size", comment = "Page size. Default value is 10000.") + @Parameter(iri = TYPE_PREFIX + "page-size", comment = "Page size. Default value is 10000.") private Integer pageSize = DEFAULT_PAGE_SIZE; - @Parameter(urlPrefix = SML.uri, name = "constructQuery", + @Parameter(iri = SML.constructQuery, comment = "List of construct queries. The module annotates the lexical form of objects of the output statements of these queries.")// TODO - revise comment private List constructQueries; //sml:replace - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Replace context flag. Default value is false." ) + @Parameter(iri = SML.replace, comment = "Replace context flag. Default value is false." ) private boolean isReplace; //kbss:parseText - @Parameter(urlPrefix = KBSS_MODULE.uri, name = "is-parse-text", + @Parameter(iri = KBSS_MODULE.uri + "is-parse-text", comment = "Whether the query should be taken from sp:text property instead of from SPIN serialization," + " default is true.") private boolean parseText; - @Parameter(urlPrefix = DescriptorModel.prefix, name = "has-rule-file", comment = "Rule file, multivalued.")// TODO - review comment + @Parameter(iri = DescriptorModel.has_rule_file, comment = "Rule file, multivalued.")// TODO - review comment private List ruleFilePaths = new LinkedList<>(); - @Parameter(urlPrefix = DescriptorModel.prefix, name = "has-document-date", comment = "Document date format.")// TODO - review comment + @Parameter(iri = DescriptorModel.has_document_date, comment = "Document date format.")// TODO - review comment private String documentDate; // TODO support other formats ? private AnnotationPipeline pipeline; @@ -84,14 +84,14 @@ public void setPageSize(int pageSize) { @Override public void loadConfiguration() { - if (this.resource.getProperty(DescriptorModel.has_document_date) != null) { // TODO set current date if not specified - documentDate = getEffectiveValue(DescriptorModel.has_document_date).asLiteral().toString(); + if (this.resource.getProperty(DescriptorModel.JENA.has_document_date) != null) { // TODO set current date if not specified + documentDate = getEffectiveValue(DescriptorModel.JENA.has_document_date).asLiteral().toString(); } - if (this.resource.getProperty(DescriptorModel.has_rule_file) != null) { //TODO support more rule files - ruleFilePaths.add(Paths.get(getEffectiveValue(DescriptorModel.has_rule_file).asLiteral().toString())); + if (this.resource.getProperty(DescriptorModel.JENA.has_rule_file) != null) { //TODO support more rule files + ruleFilePaths.add(Paths.get(getEffectiveValue(DescriptorModel.JENA.has_rule_file).asLiteral().toString())); } - parseText = this.getPropertyValue(KBSS_MODULE.is_parse_text, true); + parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); pageSize = this.getPropertyValue(P_PAGE_SIZE, DEFAULT_PAGE_SIZE); constructQueries = getResourcesByProperty(SML.constructQuery); @@ -174,12 +174,12 @@ private Model analyzeModel(Model m) { Literal beginLiteral = mm.createTypedLiteral(sdf.format(s.getDateBegin().getTime())); Literal endLiteral = mm.createTypedLiteral(sdf.format(s.getDateEnd().getTime())); - reifiedSt.addProperty(RDF.type, DescriptorModel.sutime_extraction); + reifiedSt.addProperty(RDF.type, DescriptorModel.JENA.sutime_extraction); - reifiedSt.addProperty(DescriptorModel.extracted, s.getDateExtracted()); - reifiedSt.addProperty(DescriptorModel.beginDate, beginLiteral); - reifiedSt.addProperty(DescriptorModel.endDate, endLiteral); - reifiedSt.addProperty(DescriptorModel.type, s.getDateType()); + reifiedSt.addProperty(DescriptorModel.JENA.extracted, s.getDateExtracted()); + reifiedSt.addProperty(DescriptorModel.JENA.beginDate, beginLiteral); + reifiedSt.addProperty(DescriptorModel.JENA.endDate, endLiteral); + reifiedSt.addProperty(DescriptorModel.JENA.type, s.getDateType()); temporalAnnotationStmts.add(reifiedSt); } diff --git a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/sutime/DescriptorModel.java b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/sutime/DescriptorModel.java index 239141e6..c69040a6 100644 --- a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/sutime/DescriptorModel.java +++ b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/sutime/DescriptorModel.java @@ -2,28 +2,36 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; -import org.apache.jena.rdf.model.ResourceFactory; +import static org.apache.jena.rdf.model.ResourceFactory.createProperty; +import static org.apache.jena.rdf.model.ResourceFactory.createResource; public class DescriptorModel { + /** * The namespace of the vocabulary as a string */ public static final String prefix = "http://onto.fel.cvut.cz/ontologies/dataset-descriptor/temporal-v1/"; - protected static final Resource resource(String local ) - { return ResourceFactory.createResource( prefix + local ); } + public static final String sutime_extraction = prefix + "sutime-extraction"; + + public static final String has_document_date = prefix + "has-document-date"; + public static final String has_rule_file = prefix + "has-rule-file"; - protected static final Property property(String local ) - { return ResourceFactory.createProperty( prefix, local ); } + public static final String beginDate = prefix + "beginDate"; + public static final String endDate = prefix + "endDate"; + public static final String type = prefix + "type"; + public static final String extracted = prefix + "extracted"; - public static final Resource sutime_extraction = resource("sutime-extraction"); + public static class JENA { + public static final Resource sutime_extraction = createResource(DescriptorModel.sutime_extraction); - public static final Property has_document_date = property("has-document-date"); - public static final Property has_rule_file = property("has-rule-file"); + public static final Property has_document_date = createProperty(DescriptorModel.has_document_date); + public static final Property has_rule_file = createProperty(DescriptorModel.has_rule_file); - public static final Property beginDate = property("beginDate"); - public static final Property endDate = property("endDate"); - public static final Property type = property("type"); - public static final Property extracted = property("extracted"); -} + public static final Property beginDate = createProperty(DescriptorModel.beginDate); + public static final Property endDate = createProperty(DescriptorModel.endDate); + public static final Property type = createProperty(DescriptorModel.type); + public static final Property extracted = createProperty(DescriptorModel.extracted); + } +} \ No newline at end of file diff --git a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jCreateRepositoryModule.java b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jCreateRepositoryModule.java index f8f9ef0c..ca3ace88 100644 --- a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jCreateRepositoryModule.java +++ b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jCreateRepositoryModule.java @@ -23,16 +23,16 @@ public class Rdf4jCreateRepositoryModule extends AbstractModule { static final Property P_RDF4J_SERVER_URL = getParameter("p-rdf4j-server-url"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-server-url", comment = "URL of the Rdf4j server") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-server-url", comment = "URL of the Rdf4j server") private String rdf4jServerURL; static final Property P_RDF4J_REPOSITORY_NAME = getParameter("p-rdf4j-repository-name"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-repository-name", comment = "Rdf4j repository ID") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-repository-name", comment = "Rdf4j repository ID") private String rdf4jRepositoryName; static final Property P_RDF4J_IGNORE_IF_EXISTS = getParameter("p-rdf4j-ignore-if-exists"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-ignore-if-exists", + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-ignore-if-exists", comment = "Don't try to create new repository if it already exists (Default value is false)") private boolean rdf4jIgnoreIfExists; diff --git a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jDeployModule.java b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jDeployModule.java index 01e8d597..eaf7f988 100644 --- a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jDeployModule.java +++ b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jDeployModule.java @@ -50,27 +50,27 @@ private static Property getParameter(final String name) { } static final Property P_RDF4J_SERVER_URL = getParameter("p-rdf4j-server-url"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-server-url", comment = "URL of the Rdf4j server") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-server-url", comment = "URL of the Rdf4j server") private String rdf4jServerURL; static final Property P_RDF4J_REPOSITORY_NAME = getParameter("p-rdf4j-repository-name"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-repository-name", comment = "Rdf4j repository ID") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-repository-name", comment = "Rdf4j repository ID") private String rdf4jRepositoryName; static final Property P_RDF4J_CONTEXT_IRI = getParameter("p-rdf4j-context-iri"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-context-iri", comment = "IRI of the context that should be used for deployment.") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-context-iri", comment = "IRI of the context that should be used for deployment.") private String rdf4jContextIRI; static final Property P_RDF4J_INFER_CONTEXT_IRIS = getParameter("p-rdf4j-infer-context-iris"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-infer-context-iris", + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-infer-context-iris", comment = "IRI of contexts is inferred from annotated input triples. Only reified triples that contain triple " + "?reifiedStatement kbss-module:is-part-of-graph ?graph are processed." + " Actual triples related to reified statement are not processed/needed.") private boolean inferContextIRIs; static final Property P_RDF4J_REPOSITORY_USERNAME = getParameter("p-rdf4j-secured-username-variable"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-secured-username-variable", comment = "User name if the repository requires authentication.") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-secured-username-variable", comment = "User name if the repository requires authentication.") private String rdf4jSecuredUsernameVariable; private RepositoryManager repositoryManager; @@ -82,11 +82,11 @@ public void setRepositoryManager(RepositoryManager repositoryManager) { } static final Property P_RDF4J_REPOSITORY_PASSWORD = getParameter("p-rdf4j-secured-password-variable"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-secured-password-variable", comment = "Password if the repository requires authentication.") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-secured-password-variable", comment = "Password if the repository requires authentication.") private String rdf4jSecuredPasswordVariable; static final Property P_IS_REPLACE_CONTEXT_IRI = getParameter("p-is-replace"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-is-replace", comment = + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-is-replace", comment = "Whether data should be replaced (true) / appended (false) into the specified context or repository.\n" + "Default is false.") private boolean isReplaceContext; @@ -220,7 +220,7 @@ static Dataset createDatasetFromAnnotatedModel(@NotNull Model model) { Dataset dataset = DatasetFactory.create(); model.listReifiedStatements().forEachRemaining( rs -> { - rs.listProperties(KBSS_MODULE.is_part_of_graph) + rs.listProperties(KBSS_MODULE.JENA.is_part_of_graph) .mapWith( gs -> gs.getObject().toString()) .forEachRemaining( u -> { diff --git a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java index 794d3c6c..de1385f7 100644 --- a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java +++ b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java @@ -35,30 +35,30 @@ public class Rdf4jUpdateModule extends AbstractModule { private static final String PROPERTY_PREFIX_URI = KBSS_MODULE.uri + "rdf4j"; static final Property P_RDF4J_SERVER_URL = getParameter("p-rdf4j-server-url"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-server-url", comment = "URL of the Rdf4j server") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-server-url", comment = "URL of the Rdf4j server") private String rdf4jServerURL; static final Property P_RDF4J_REPOSITORY_NAME = getParameter("p-rdf4j-repository-name"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-rdf4j-repository-name", comment = "Rdf4j repository ID") + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-rdf4j-repository-name", comment = "Rdf4j repository ID") private String rdf4jRepositoryName; /** * List of SPARQL Update queries that will be executed in this order. */ - @Parameter(urlPrefix = SML.uri, name = "updateQuery", comment = "SPARQL Update query (sp:Update) that should" + + @Parameter(iri = SML.updateQuery, comment = "SPARQL Update query (sp:Update) that should" + " be executed by this module. The query is read from sp:text property.") private List updateQueries; static final Property P_RDF4J_STOP_ITERATION_ON_STABLE_TRIPLE_COUNT = getParameter("p-stop-iteration-on-stable-triple-count"); - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "p-stop-iteration-on-stable-triple-count", + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "p-stop-iteration-on-stable-triple-count", comment = "Stops iteration (i.e. execution of list of queries) if triple count " + "in the last iteration did not change. Default is false.") private boolean onlyIfTripleCountChanges; - @Parameter(urlPrefix = PROPERTY_PREFIX_URI + "/", name = "has-max-iteration-count", + @Parameter(iri = PROPERTY_PREFIX_URI + "/" + "has-max-iteration-count", comment = "Limits the number of iterations (i.e. executions of list of queries)" + " to the specified value. Default value is 1, which means that all" + " update queries are executed only once.") @@ -192,7 +192,7 @@ public String getTypeURI() { public void loadConfiguration() { rdf4jServerURL = getEffectiveValue(P_RDF4J_SERVER_URL).asLiteral().getString(); rdf4jRepositoryName = getEffectiveValue(P_RDF4J_REPOSITORY_NAME).asLiteral().getString(); - iterationCount = getPropertyValue(KBSS_MODULE.has_max_iteration_count,1); + iterationCount = getPropertyValue(KBSS_MODULE.JENA.has_max_iteration_count,1); onlyIfTripleCountChanges = getPropertyValue(P_RDF4J_STOP_ITERATION_ON_STABLE_TRIPLE_COUNT,false); log.debug("Iteration count={}\nOnlyIf...Changes={}" ,iterationCount diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java index 42161c75..ab76a868 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java @@ -26,26 +26,26 @@ public abstract class ApplyConstructAbstractModule extends AnnotatedAbstractModu private static final String PROPERTY_PREFIX_URI = KBSS_MODULE.uri; //sml:constructQuery // TODO - this parameter is reused in ApplyConstructWithChunkedValuesAndScrollableCursorModule. There the comment should be extended by a note, i.e. "The construct queries with markers #${VALUES} and #${LIMIT_OFFSET}." - @Parameter(urlPrefix = SML.uri, name = "constructQuery", comment = "SPARQL Construct query (sp:Construct)" + + @Parameter(iri = SML.constructQuery, comment = "SPARQL Construct query (sp:Construct)" + " that should be executed by this module. The query is read from sp:text property." + " The output of query execution is returned by the module.") protected List constructQueries; //sml:replace - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Specifies whether a module should overwrite triples" + + @Parameter(iri = SML.replace, comment = "Specifies whether a module should overwrite triples" + " from its predecessors. When set to true (default is false), it prevents" + " passing through triples from the predecessors.") protected boolean isReplace; //kbss:parseText - @Parameter(urlPrefix = KBSS_MODULE.uri, name = "is-parse-text", + @Parameter(iri = KBSS_MODULE.is_parse_text, comment = "Whether the query should be taken from sp:text property instead of from SPIN serialization," + " default is true." ) protected boolean parseText; //kbss:iterationCount - @Parameter(name = "has-max-iteration-count", + @Parameter(iri = KBSS_MODULE.has_max_iteration_count, comment = "Maximal number of iterations of the whole rule set. 0 means 0 iterations. The actual number of iterations can be smaller,\n" + "if no new inferences are generated any more.\n" + @@ -185,8 +185,8 @@ public void loadConfiguration() { //TODO default value must be taken from template definition isReplace = this.getPropertyValue(SML.replace, false); - parseText = this.getPropertyValue(KBSS_MODULE.is_parse_text, true); - iterationCount = this.getPropertyValue(KBSS_MODULE.has_max_iteration_count, -1); + parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); + iterationCount = this.getPropertyValue(KBSS_MODULE.JENA.has_max_iteration_count, -1); } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructV2Module.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructV2Module.java index adffba66..efc626f9 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructV2Module.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructV2Module.java @@ -22,6 +22,6 @@ public String getTypeURI() { @Override public void loadConfiguration() { super.loadConfiguration(); - iterationCount = this.getPropertyValue(KBSS_MODULE.has_max_iteration_count, 1); + iterationCount = this.getPropertyValue(KBSS_MODULE.JENA.has_max_iteration_count, 1); } } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java index b77322b9..8be85ee3 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java @@ -38,13 +38,13 @@ public class ApplyConstructWithChunkedValuesAndScrollableCursorModule extends Ap private static final Property P_CHUNK_SIZE = ResourceFactory.createProperty(TYPE_PREFIX + "chunk-size"); private static final Property P_PAGE_SIZE = ResourceFactory.createProperty(TYPE_PREFIX + "page-size"); - @Parameter(urlPrefix = TYPE_PREFIX, name = "chunk-size", comment = "Chunk size. Default is 10.") + @Parameter(iri = TYPE_PREFIX + "chunk-size", comment = "Chunk size. Default is 10.") private Integer chunkSize = DEFAULT_CHUNK_SIZE; - @Parameter(urlPrefix = TYPE_PREFIX, name = "page-size", comment = "Page size for the scrollable cursor. Default is 10000.") + @Parameter(iri = TYPE_PREFIX + "page-size", comment = "Page size for the scrollable cursor. Default is 10000.") private Integer pageSize = DEFAULT_PAGE_SIZE; - @Parameter(urlPrefix = SML.uri, name = "selectQuery", + @Parameter(iri = SML.selectQuery, comment = "The select query that will be used to iterate over construct query templates.") private Select selectQuery; @@ -113,8 +113,8 @@ protected String substituteQueryMarkers(int currentIteration, String queryStr) { @Override public void loadConfiguration() { super.loadConfiguration(); - //iterationCount = this.getPropertyValue(KBSS_MODULE.has_max_iteration_count, 1); - parseText = this.getPropertyValue(KBSS_MODULE.is_parse_text, true); + //iterationCount = this.getPropertyValue(KBSS_MODULE.JENA.s_max_iteration_count, 1); + parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); chunkSize = this.getPropertyValue(P_CHUNK_SIZE, DEFAULT_CHUNK_SIZE); selectQuery = getPropertyValue(SML.selectQuery).asResource().as(Select.class); pageSize = this.getPropertyValue(P_PAGE_SIZE, DEFAULT_PAGE_SIZE); diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java index c5922b17..e91e0ab5 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java @@ -33,11 +33,11 @@ public class ApplyConstructWithChunkedValuesModule extends ApplyConstructAbstrac private static final String VALUES_CLAUSE_MARKER_NAME = "VALUES"; private static final Property P_CHUNK_SIZE = ResourceFactory.createProperty(TYPE_PREFIX + "chunk-size"); - @Parameter(urlPrefix = TYPE_PREFIX, name = "chunk-size", comment = "Chunk size. Default is 10.") + @Parameter(iri = TYPE_PREFIX + "chunk-size", comment = "Chunk size. Default is 10.") private Integer chunkSize = DEFAULT_CHUNK_SIZE; - @Parameter(urlPrefix = SML.uri, name = "selectQuery" - , comment = "The select query that will be used to iterate over construct query templates.") + @Parameter(iri = SML.selectQuery, + comment = "The select query that will be used to iterate over construct query templates.") private Select selectQuery; @@ -120,8 +120,8 @@ protected String substituteQueryMarkers(int currentIteration, String queryStr) { @Override public void loadConfiguration() { super.loadConfiguration(); - //iterationCount = this.getPropertyValue(KBSS_MODULE.has_max_iteration_count, 1); - parseText = this.getPropertyValue(KBSS_MODULE.is_parse_text, true); + //iterationCount = this.getPropertyValue(KBSS_MODULE.JENA.s_max_iteration_count, 1); + parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); chunkSize = this.getPropertyValue(P_CHUNK_SIZE, DEFAULT_CHUNK_SIZE); selectQuery = getPropertyValue(SML.selectQuery).asResource().as(Select.class); } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithScrollableCursorModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithScrollableCursorModule.java index 79ed2a6c..915d064d 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithScrollableCursorModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithScrollableCursorModule.java @@ -26,7 +26,7 @@ public class ApplyConstructWithScrollableCursorModule extends ApplyConstructAbst private static final String LIMIT_OFFSET_CLAUSE_MARKER_NAME = "LIMIT_OFFSET"; private static final Property P_PAGE_SIZE = ResourceFactory.createProperty(TYPE_PREFIX + "page-size"); - @Parameter(urlPrefix = TYPE_PREFIX, name = "page-size", comment = "Page size. Default value is 10000.") + @Parameter(iri = TYPE_PREFIX + "page-size", comment = "Page size. Default value is 10000.") private Integer pageSize = DEFAULT_PAGE_SIZE; @Override @@ -78,8 +78,8 @@ protected String substituteQueryMarkers(int currentIteration, String queryStr) { @Override public void loadConfiguration() { super.loadConfiguration(); - //iterationCount = this.getPropertyValue(KBSS_MODULE.has_max_iteration_count, 1); - parseText = this.getPropertyValue(KBSS_MODULE.is_parse_text, true); + //iterationCount = this.getPropertyValue(KBSS_MODULE.JENA.s_max_iteration_count, 1); + parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); pageSize = this.getPropertyValue(P_PAGE_SIZE , DEFAULT_PAGE_SIZE); } } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/DownloadGraphModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/DownloadGraphModule.java index 04bcb835..37e94ad9 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/DownloadGraphModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/DownloadGraphModule.java @@ -25,16 +25,16 @@ public class DownloadGraphModule extends AnnotatedAbstractModule { private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final int DEFAULT_PAGE_SIZE = 10000; - @Parameter(urlPrefix = TYPE_PREFIX, name = "named-graph-id", comment = "Named graph id") + @Parameter(iri = TYPE_PREFIX + "named-graph-id", comment = "Named graph id") private String namedGraphId; - @Parameter(urlPrefix = TYPE_PREFIX, name = "endpoint-url", comment = "Endpoint url") + @Parameter(iri = TYPE_PREFIX + "endpoint-url", comment = "Endpoint url") private String endpointUrl; - @Parameter(urlPrefix = TYPE_PREFIX, name = "output-resource-variable", comment = "Output resource variable") + @Parameter(iri = TYPE_PREFIX + "output-resource-variable", comment = "Output resource variable") private String outputResourceVariable; - @Parameter(urlPrefix = TYPE_PREFIX, name = "page-size", comment = "Page size. Default value is 10000.") + @Parameter(iri = TYPE_PREFIX + "page-size", comment = "Page size. Default value is 10000.") private Integer pageSize = DEFAULT_PAGE_SIZE; protected long numberOfDownloadedTriples; diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ExternalSchemExModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ExternalSchemExModule.java index 46fb4741..5effc985 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ExternalSchemExModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ExternalSchemExModule.java @@ -6,13 +6,14 @@ import cz.cvut.spipes.engine.ExecutionContextFactory; import cz.cvut.spipes.modules.annotations.SPipesModule; import cz.cvut.spipes.util.ExecUtils; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.util.FileUtils; + import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import org.apache.jena.rdf.model.ModelFactory; -import org.apache.jena.util.FileUtils; @SPipesModule(label = "external schemex", comment = "Compute schemex using external script for a specified sourceFilePath.") public class ExternalSchemExModule extends AbstractModule { @@ -22,7 +23,7 @@ public class ExternalSchemExModule extends AbstractModule { private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final String SCHEMEX_PROGRAM = "schemex"; //sml:sourceFilePath - @Parameter(urlPrefix = SML.uri, name = "sourceFilePath", comment = "Source file in nt format.") + @Parameter(iri = SML.sourceFilePath, comment = "Source file in nt format.") private Path sourceFilePath; @Override @@ -65,7 +66,7 @@ public String getTypeURI() { @Override public void loadConfiguration() { - sourceFilePath = Paths.get(getEffectiveValue(SML.sourceFilePath).asLiteral().toString()); + sourceFilePath = Paths.get(getEffectiveValue(SML.JENA.sourceFilePath).asLiteral().toString()); } } \ No newline at end of file diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ImproveSPOWithMarginalsModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ImproveSPOWithMarginalsModule.java index a3f52460..28941d2c 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ImproveSPOWithMarginalsModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ImproveSPOWithMarginalsModule.java @@ -56,13 +56,13 @@ public class ImproveSPOWithMarginalsModule extends AnnotatedAbstractModule { private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final Map marginalDefsModelCache = new HashMap<>(); - @Parameter(urlPrefix = TYPE_PREFIX, name = "marginal-constraint", comment = "Marginal constraint") + @Parameter(iri = TYPE_PREFIX + "marginal-constraint", comment = "Marginal constraint") private String marginalConstraint; - @Parameter(urlPrefix = TYPE_PREFIX, name = "marginals-defs-file-url", comment = "Marginal definitions file url") + @Parameter(iri = TYPE_PREFIX + "marginals-defs-file-url", comment = "Marginal definitions file url") private String marginalsDefsFileUrl; - @Parameter(urlPrefix = TYPE_PREFIX, name = "marginals-file-url", comment = "Marginals file url") // TODO - review comment + @Parameter(iri = TYPE_PREFIX + "marginals-file-url", comment = "Marginals file url") // TODO - review comment private String marginalsFileUrl; - @Parameter(urlPrefix = TYPE_PREFIX, name = "data-service-url", comment = "Data service url") + @Parameter(iri = TYPE_PREFIX + "data-service-url", comment = "Data service url") private String dataServiceUrl; private static final String VAR_EXECUTION_ID = "executionId"; diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/RetrieveGraphModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/RetrieveGraphModule.java index 500c9304..4fd07e66 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/RetrieveGraphModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/RetrieveGraphModule.java @@ -20,13 +20,13 @@ public class RetrieveGraphModule extends AnnotatedAbstractModule { private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final int DEFAULT_PAGE_SIZE = 10000; - @Parameter(urlPrefix = TYPE_PREFIX, name = "named-graph-id", comment = "Named graph id") + @Parameter(iri = TYPE_PREFIX + "named-graph-id", comment = "Named graph id") private String namedGraphId; - @Parameter(urlPrefix = TYPE_PREFIX, name = "endpoint-url", comment = "Endpoint url") + @Parameter(iri = TYPE_PREFIX + "endpoint-url", comment = "Endpoint url") private String endpointUrl; - @Parameter(urlPrefix = TYPE_PREFIX, name = "page-size", comment = "Page size. Default is 10000.") + @Parameter(iri = TYPE_PREFIX + "page-size", comment = "Page size. Default is 10000.") private Integer pageSize = DEFAULT_PAGE_SIZE; public String getNamedGraphId() { diff --git a/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/RDF2CSVModule.java b/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/RDF2CSVModule.java index 44aa27f6..93a881c6 100644 --- a/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/RDF2CSVModule.java +++ b/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/RDF2CSVModule.java @@ -35,7 +35,7 @@ public class RDF2CSVModule extends AnnotatedAbstractModule { private static final Logger LOG = LoggerFactory.getLogger(RDF2CSVModule.class); - @Parameter(urlPrefix = TYPE_PREFIX, name = "file-output-path", + @Parameter(iri = TYPE_PREFIX + "file-output-path", comment = "The parameter representing where the output file will be stored.") private String fileOutputPath; diff --git a/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/TabularModule.java b/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/TabularModule.java index 4e5e4f21..72135a59 100644 --- a/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/TabularModule.java +++ b/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/TabularModule.java @@ -112,30 +112,30 @@ public class TabularModule extends AbstractModule { private final Property P_PROCESS_TABLE_AT_INDEX = getSpecificParameter("process-table-at-index"); //sml:replace - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Specifies whether a module should overwrite triples" + + @Parameter(iri = SML.replace, comment = "Specifies whether a module should overwrite triples" + " from its predecessors. When set to true (default is false), it prevents" + " passing through triples from the predecessors.") private boolean isReplace; - @Parameter(urlPrefix = PARAM_URL_PREFIX, name = "source-resource-uri", comment = "URI of resource" + + @Parameter(iri = PARAM_URL_PREFIX + "source-resource-uri", comment = "URI of resource" + " that represent tabular data (e.g. resource representing CSV file).") //:source-resource-uri private StreamResource sourceResource; //:delimiter - @Parameter(urlPrefix = PARAM_URL_PREFIX, name = "delimiter", comment = "Column delimiter. Default value is comma ','.") + @Parameter(iri = PARAM_URL_PREFIX + "delimiter", comment = "Column delimiter. Default value is comma ','.") private int delimiter; //:quote-character - @Parameter(urlPrefix = PARAM_URL_PREFIX, name = "quote-character", comment = "Quote character. Default is '\"' if delimiter is ',', '\\0' otherwize.") + @Parameter(iri = PARAM_URL_PREFIX + "quote-character", comment = "Quote character. Default is '\"' if delimiter is ',', '\\0' otherwize.") private char quoteCharacter; //:data-prefix - @Parameter(urlPrefix = PARAM_URL_PREFIX, name = "data-prefix", comment = "Data prefix")// TODO - improve comment + @Parameter(iri = PARAM_URL_PREFIX + "data-prefix", comment = "Data prefix")// TODO - improve comment private String dataPrefix; //:skip-header - @Parameter(urlPrefix = PARAM_URL_PREFIX, name = "skip-header", comment = "Skip header. Default is false.") + @Parameter(iri = PARAM_URL_PREFIX + "skip-header", comment = "Skip header. Default is false.") private boolean skipHeader; //:process-table-at-index @@ -146,7 +146,7 @@ public class TabularModule extends AbstractModule { //:output-mode // TODO - revise comment - @Parameter(urlPrefix = PARAM_URL_PREFIX, name = "output-mode", comment = "Output mode. Default is standard-mode('http://onto.fel.cvut.cz/ontologies/lib/module/tabular/standard-mode)") + @Parameter(iri = PARAM_URL_PREFIX + "output-mode", comment = "Output mode. Default is standard-mode('http://onto.fel.cvut.cz/ontologies/lib/module/tabular/standard-mode)") private Mode outputMode; //:source-resource-format @@ -164,7 +164,7 @@ public class TabularModule extends AbstractModule { private ResourceFormat sourceResourceFormat = ResourceFormat.PLAIN; //:accept-invalid-quoting - @Parameter(urlPrefix = PARAM_URL_PREFIX, name = "accept-invalid-quoting", comment = "Accept invalid quoting. Default is false.") + @Parameter(iri = PARAM_URL_PREFIX + "accept-invalid-quoting", comment = "Accept invalid quoting. Default is false.") private boolean acceptInvalidQuoting; /** @@ -482,7 +482,7 @@ public void loadConfiguration() { getPropertyValue(P_SOURCE_RESOURCE_FORMAT, ResourceFormat.PLAIN.getValue()) ); delimiter = getPropertyValue(P_DELIMITER, getDefaultDelimiterSupplier(sourceResourceFormat)); - isReplace = getPropertyValue(SML.replace, false); + isReplace = getPropertyValue(SML.JENA.replace, false); skipHeader = getPropertyValue(P_SKIP_HEADER, false); processTableAtIndex = getPropertyValue(P_PROCESS_TABLE_AT_INDEX, 0); acceptInvalidQuoting = getPropertyValue(P_ACCEPT_INVALID_QUOTING, false); diff --git a/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/ModuleTarql.java b/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/ModuleTarql.java index 46234a8f..a8541857 100644 --- a/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/ModuleTarql.java +++ b/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/ModuleTarql.java @@ -27,15 +27,15 @@ private static Property getParameter(final String name) { } static final Property P_TARQL_STRING = getParameter("p-tarql-string"); - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-tarql-string", comment = "File with the TARQL script." ) + @Parameter(iri = TYPE_URI + "/" + "p-tarql-string", comment = "File with the TARQL script." ) private String tarqlString; static final Property P_ONTOLOGY_IRI = getParameter("p-ontology-iri"); - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-ontology-iri", comment = "Ontology IRI") + @Parameter(iri = TYPE_URI + "/" + "p-ontology-iri", comment = "Ontology IRI") private String ontologyIRI; static final Property P_INPUT_FILE = getParameter("p-input-file"); - @Parameter(urlPrefix = TYPE_URI + "/", name = "p-input-file", comment = "Input File") + @Parameter(iri = TYPE_URI + "/" + "p-input-file", comment = "Input File") private String inputFile; // /** diff --git a/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java b/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java index 317dcaca..b6ece902 100644 --- a/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java +++ b/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java @@ -37,20 +37,20 @@ public class TarqlModule extends AbstractModule { private static final String TARQL_PROGRAM = AppConstants.BIN_DIR + "/tarql"; //sml:constructQuery - @Parameter(urlPrefix = SML.uri, name = "constructQuery", comment = "The TARQL Construct queries that deliver the triples that shall be added.") + @Parameter(iri = SML.constructQuery, comment = "The TARQL Construct queries that deliver the triples that shall be added.") private List constructQueries; // TODO not used field private String tableFilePath; //sml:replace - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "If set to true, the output triples will only contain the " + + @Parameter(iri = SML.replace, comment = "If set to true, the output triples will only contain the " + "constructed triples. If no values or false are specified, the output will be the union of the input triples " + "and the constructed triples.") private boolean isReplace; //sml:sourceFilePath - @Parameter(urlPrefix = SML.uri, name = "sourceFilePath", comment = "Source CSV file.") + @Parameter(iri = SML.sourceFilePath, comment = "Source CSV file.") private String sourceFilePath; public TarqlModule() { @@ -159,9 +159,9 @@ public void loadConfiguration() { log.debug("Loaded {} spin construct queries.", constructQueries.size()); //TODO default value must be taken from template definition - isReplace = this.getPropertyValue(SML.replace, false); + isReplace = this.getPropertyValue(SML.JENA.replace, false); - sourceFilePath = getEffectiveValue(SML.sourceFilePath).asLiteral().toString(); // TODO should be Path + sourceFilePath = getEffectiveValue(SML.JENA.sourceFilePath).asLiteral().toString(); // TODO should be Path } diff --git a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/ExtractTermOccurrencesModule.java b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/ExtractTermOccurrencesModule.java index 8026ddd2..c0e6b5f3 100644 --- a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/ExtractTermOccurrencesModule.java +++ b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/ExtractTermOccurrencesModule.java @@ -75,7 +75,7 @@ public class ExtractTermOccurrencesModule extends AnnotatedAbstractModule { private static final String TYPE_URI = KBSS_MODULE.uri + "extract-term-occurrences"; private static final String TYPE_PREFIX = TYPE_URI + "/"; - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Specifies whether a module should overwrite triples" + + @Parameter(iri = SML.replace, comment = "Specifies whether a module should overwrite triples" + " from its predecessors. When set to true (default is false), it prevents" + " passing through triples from the predecessors.") private boolean isReplace; diff --git a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java index 4c683c64..6af15a07 100644 --- a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java +++ b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java @@ -48,26 +48,26 @@ public class TextAnalysisModule extends AnnotatedAbstractModule{ private static final String TYPE_URI = KBSS_MODULE.uri + "text-analysis"; private static final String TYPE_PREFIX = TYPE_URI + "/"; - @Parameter(urlPrefix = TYPE_PREFIX, name = "service-url", comment = "The URL of the text analysis service to be used.") + @Parameter(iri = TYPE_PREFIX + "service-url", comment = "The URL of the text analysis service to be used.") private String serviceUrl; - @Parameter(urlPrefix = TYPE_PREFIX, name = "vocabulary-iri", comment = "The IRI of the vocabulary to be used for entity recognition.") + @Parameter(iri = TYPE_PREFIX + "vocabulary-iri", comment = "The IRI of the vocabulary to be used for entity recognition.") private String vocabularyIri; - @Parameter(urlPrefix = TYPE_PREFIX, name = "vocabulary-repository", comment = "The IRI of the repository where the vocabulary is stored.") + @Parameter(iri = TYPE_PREFIX + "vocabulary-repository", comment = "The IRI of the repository where the vocabulary is stored.") private String vocabularyRepository; - @Parameter(urlPrefix = TYPE_PREFIX, name = "language", comment = "The language of the text to be analyzed.") + @Parameter(iri = TYPE_PREFIX + "language", comment = "The language of the text to be analyzed.") private String language; //sml:replace - @Parameter(urlPrefix = SML.uri, name = "replace", comment = "Replace context flag, default is false.") + @Parameter(iri = SML.replace, comment = "Replace context flag, default is false.") private boolean isReplace = false; - @Parameter(urlPrefix = TYPE_PREFIX, name = "literals-per-request", comment = "The number of literals to be processed per request to the web service.") + @Parameter(iri = TYPE_PREFIX + "literals-per-request", comment = "The number of literals to be processed per request to the web service.") private Integer literalsPerRequest; - @Parameter(urlPrefix = SML.uri, name = "selectQuery", + @Parameter(iri = SML.selectQuery, comment = "The SPARQL query to be used for selecting literals from the repository.\n" + "

\n" + From 8b8dde25fad949ec821fdc3d5230cafca93f7c83 Mon Sep 17 00:00:00 2001 From: Daniil Palagin Date: Fri, 13 Sep 2024 06:28:22 +0200 Subject: [PATCH 2/5] [#258] Fix missing JENA properties --- .../src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java | 4 ++-- .../main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java | 2 +- .../cz/cvut/spipes/modules/ApplyConstructAbstractModule.java | 4 ++-- ...lyConstructWithChunkedValuesAndScrollableCursorModule.java | 2 +- .../spipes/modules/ApplyConstructWithChunkedValuesModule.java | 2 +- .../src/main/java/cz/cvut/spipes/modules/TarqlModule.java | 2 +- .../main/java/cz/cvut/spipes/modules/TextAnalysisModule.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java index b2fdeb7b..83334042 100644 --- a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java +++ b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java @@ -93,9 +93,9 @@ public void loadConfiguration() { } parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); pageSize = this.getPropertyValue(P_PAGE_SIZE, DEFAULT_PAGE_SIZE); - constructQueries = getResourcesByProperty(SML.constructQuery); + constructQueries = getResourcesByProperty(SML.JENA.constructQuery); - isReplace = this.getPropertyValue(SML.replace, false); + isReplace = this.getPropertyValue(SML.JENA.replace, false); } @Override diff --git a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java index de1385f7..f10a2f48 100644 --- a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java +++ b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java @@ -208,7 +208,7 @@ public void loadConfiguration() { } private List loadUpdateQueries() { - return getResourcesByProperty(SML.updateQuery).stream().map( + return getResourcesByProperty(SML.JENA.updateQuery).stream().map( r -> r.getProperty(SP.text).getLiteral().getString()).collect(Collectors.toList()); } } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java index ab76a868..4efd352a 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java @@ -178,12 +178,12 @@ public void loadConfiguration() { // TODO load default values from configuration // TODO does not work with string query as object is not RDF resource ??? - constructQueries = getResourcesByProperty(SML.constructQuery); + constructQueries = getResourcesByProperty(SML.JENA.constructQuery); log.debug("Loaded {} spin construct queries.", constructQueries.size()); //TODO default value must be taken from template definition - isReplace = this.getPropertyValue(SML.replace, false); + isReplace = this.getPropertyValue(SML.JENA.replace, false); parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); iterationCount = this.getPropertyValue(KBSS_MODULE.JENA.has_max_iteration_count, -1); diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java index 8be85ee3..7008abc8 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java @@ -116,7 +116,7 @@ public void loadConfiguration() { //iterationCount = this.getPropertyValue(KBSS_MODULE.JENA.s_max_iteration_count, 1); parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); chunkSize = this.getPropertyValue(P_CHUNK_SIZE, DEFAULT_CHUNK_SIZE); - selectQuery = getPropertyValue(SML.selectQuery).asResource().as(Select.class); + selectQuery = getPropertyValue(SML.JENA.selectQuery).asResource().as(Select.class); pageSize = this.getPropertyValue(P_PAGE_SIZE, DEFAULT_PAGE_SIZE); } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java index e91e0ab5..cc79f722 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java @@ -123,7 +123,7 @@ public void loadConfiguration() { //iterationCount = this.getPropertyValue(KBSS_MODULE.JENA.s_max_iteration_count, 1); parseText = this.getPropertyValue(KBSS_MODULE.JENA.is_parse_text, true); chunkSize = this.getPropertyValue(P_CHUNK_SIZE, DEFAULT_CHUNK_SIZE); - selectQuery = getPropertyValue(SML.selectQuery).asResource().as(Select.class); + selectQuery = getPropertyValue(SML.JENA.selectQuery).asResource().as(Select.class); } @NotNull diff --git a/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java b/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java index b6ece902..1db616a0 100644 --- a/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java +++ b/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java @@ -151,7 +151,7 @@ public void loadConfiguration() { // TODO does not work with string query as object is not RDF resource ??? constructQueries = resource - .listProperties(SML.constructQuery) + .listProperties(SML.JENA.constructQuery) .toList().stream() .map(st -> st.getObject().asResource()) .collect(Collectors.toList()); diff --git a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java index 6af15a07..5332f23b 100644 --- a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java +++ b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java @@ -192,7 +192,7 @@ private String annotateObjectLiteral(String objectValue) { @Override public void loadConfiguration() { super.loadConfiguration(); - selectQuery = getPropertyValue(SML.selectQuery).asResource().as(Select.class); + selectQuery = getPropertyValue(SML.JENA.selectQuery).asResource().as(Select.class); } @Override From 84a5e01d16cde3e7f9d31f07ba3ef011047af663 Mon Sep 17 00:00:00 2001 From: Miroslav Blasko Date: Fri, 13 Sep 2024 10:50:56 +0200 Subject: [PATCH 3/5] [#258] Fix issues related to refactoring of @Parameter annotation --- .../cz/cvut/spipes/cli/ExecuteModuleCLI.java | 2 +- .../java/cz/cvut/spipes/constants/SML.java | 18 +++++++++--------- .../cz/cvut/spipes/util/JenaPipelineUtils.java | 2 +- .../cz/cvut/spipes/transform/SPipesUtil.java | 2 +- .../cvut/spipes/transform/Script2FormTest.java | 2 +- .../main/java/RdfAnnotationProcessorMojo.java | 2 +- .../cz/cvut/spipes/modules/IdentityModule.java | 2 +- .../cvut/spipes/modules/Rdf4jUpdateModule.java | 2 +- .../modules/ApplyConstructAbstractModule.java | 1 - ...ChunkedValuesAndScrollableCursorModule.java | 7 +------ .../ApplyConstructWithChunkedValuesModule.java | 11 +++-------- .../spipes/modules/TextAnalysisModule.java | 2 -- .../spipes/rest/SPipesContextController.java | 15 +++++++++------ 13 files changed, 29 insertions(+), 39 deletions(-) diff --git a/s-pipes-cli/src/main/java/cz/cvut/spipes/cli/ExecuteModuleCLI.java b/s-pipes-cli/src/main/java/cz/cvut/spipes/cli/ExecuteModuleCLI.java index 90f5f037..d718a4c5 100644 --- a/s-pipes-cli/src/main/java/cz/cvut/spipes/cli/ExecuteModuleCLI.java +++ b/s-pipes-cli/src/main/java/cz/cvut/spipes/cli/ExecuteModuleCLI.java @@ -133,7 +133,7 @@ public static void main(String[] args) throws IOException { // ----- execute pipeline ExecutionEngine engine = ExecutionEngineFactory.createEngine(); Module module = scriptManager.loadFunction(asArgs.executionTarget); -// module = PipelineFactory.loadModulePipeline(inputDataModel.listObjectsOfProperty(SM.returnModule).next().asResource()); +// module = PipelineFactory.loadModulePipeline(inputDataModel.listObjectsOfProperty(SM.JENA.returnModule).next().asResource()); if ( module == null ) { throw new RuntimeException("Cannot load module/function with id=" + asArgs.executionTarget); diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SML.java b/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SML.java index 491be513..21db62d7 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SML.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/constants/SML.java @@ -48,14 +48,14 @@ public static class JENA { public static final Property serialization = createProperty(SML.serialization); public static final Property ignoreImports = createProperty(SML.ignoreImports); - public static final Resource ApplyConstruct = createResource("ApplyConstruct"); - public static final Resource ExportToRDFFile = createResource("ExportToRDFFile"); - public static final Resource ImportRDFFromWorkspace = createResource("ImportRDFFromWorkspace"); - public static final Resource ImportFileFromURL = createResource("ImportFileFromURL"); - public static final Resource BindWithConstant = createResource("BindWithConstant"); - public static final Resource BindBySelect = createResource("BindBySelect"); - public static final Resource Merge = createResource("Merge"); - public static final Resource ReturnRDF = createResource("ReturnRDF"); - public static final Resource JSONLD = createResource("JSONLD"); + public static final Resource ApplyConstruct = createResource(SML.ApplyConstruct); + public static final Resource ExportToRDFFile = createResource(SML.ExportToRDFFile); + public static final Resource ImportRDFFromWorkspace = createResource(SML.ImportRDFFromWorkspace); + public static final Resource ImportFileFromURL = createResource(SML.ImportFileFromURL); + public static final Resource BindWithConstant = createResource(SML.BindWithConstant); + public static final Resource BindBySelect = createResource(SML.BindBySelect); + public static final Resource Merge = createResource(SML.Merge); + public static final Resource ReturnRDF = createResource(SML.ReturnRDF); + public static final Resource JSONLD = createResource(SML.JSONLD); } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/util/JenaPipelineUtils.java b/s-pipes-core/src/main/java/cz/cvut/spipes/util/JenaPipelineUtils.java index e3600ff2..a2014d29 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/util/JenaPipelineUtils.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/util/JenaPipelineUtils.java @@ -33,7 +33,7 @@ public static boolean isModule(Resource res) { return false; } Resource objRes = st.getObject().asResource(); - return objRes.hasProperty(RDF.type, SM.Module); + return objRes.hasProperty(RDF.type, SM.JENA.Module); } ).toList().size() > 0; } diff --git a/s-pipes-forms/src/main/java/cz/cvut/spipes/transform/SPipesUtil.java b/s-pipes-forms/src/main/java/cz/cvut/spipes/transform/SPipesUtil.java index a74a9dfe..dbddfd08 100644 --- a/s-pipes-forms/src/main/java/cz/cvut/spipes/transform/SPipesUtil.java +++ b/s-pipes-forms/src/main/java/cz/cvut/spipes/transform/SPipesUtil.java @@ -111,7 +111,7 @@ protected static List getMatchingResourceClasses(Class cls, Model m) { private static final Set S_PIPES_TERMS = new HashSet() { { - add(SM.next.getURI()); + add(SM.next); add(RDF.type.getURI()); } }; diff --git a/s-pipes-forms/src/test/java/cz/cvut/spipes/transform/Script2FormTest.java b/s-pipes-forms/src/test/java/cz/cvut/spipes/transform/Script2FormTest.java index ffc7127c..406ec4f7 100644 --- a/s-pipes-forms/src/test/java/cz/cvut/spipes/transform/Script2FormTest.java +++ b/s-pipes-forms/src/test/java/cz/cvut/spipes/transform/Script2FormTest.java @@ -188,7 +188,7 @@ private Question generateRootQuestion() { Resource module = sampleScript.listSubjects().filterKeep(s -> s.getURI() != null && s.getURI().endsWith("bind-person") ).next(); - Resource moduleType = sampleScript.getResource(SML.BindWithConstant.toString()); + Resource moduleType = sampleScript.getResource(SML.BindWithConstant); return new TransformerImpl().script2Form(module, moduleType); } diff --git a/s-pipes-modules-utils/s-pipes-module-creator-maven-plugin/src/main/java/RdfAnnotationProcessorMojo.java b/s-pipes-modules-utils/s-pipes-module-creator-maven-plugin/src/main/java/RdfAnnotationProcessorMojo.java index 3f070a22..e748e4e0 100644 --- a/s-pipes-modules-utils/s-pipes-module-creator-maven-plugin/src/main/java/RdfAnnotationProcessorMojo.java +++ b/s-pipes-modules-utils/s-pipes-module-creator-maven-plugin/src/main/java/RdfAnnotationProcessorMojo.java @@ -341,7 +341,7 @@ private void writeConstraintsToModel(Model baseRdfModel, KBSS_MODULE.uri + a.label().replaceAll(" ", "-").toLowerCase()) //todo can be added to the annotation ).ifPresent(r -> baseRdfModel.add(root, RDFS.subClassOf, r)); - baseRdfModel.add(root, RDF.type, SM.Module); + baseRdfModel.add(root, RDF.type, SM.JENA.Module); baseRdfModel.add(root, RDFS.comment, moduleAnnotation.comment()); baseRdfModel.add(root, RDFS.label, moduleAnnotation.label()); for (var annotation : constraintAnnotations) { diff --git a/s-pipes-modules/module-identity/src/main/java/cz/cvut/spipes/modules/IdentityModule.java b/s-pipes-modules/module-identity/src/main/java/cz/cvut/spipes/modules/IdentityModule.java index f2e32a01..bfb2e4bd 100644 --- a/s-pipes-modules/module-identity/src/main/java/cz/cvut/spipes/modules/IdentityModule.java +++ b/s-pipes-modules/module-identity/src/main/java/cz/cvut/spipes/modules/IdentityModule.java @@ -19,7 +19,7 @@ ExecutionContext executeSelf() { @Override public String getTypeURI() { - return KBSS_MODULE.uri+"identity"; + return KBSS_MODULE.uri + "identity"; } @Override diff --git a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java index f10a2f48..b72dd2cb 100644 --- a/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java +++ b/s-pipes-modules/module-rdf4j/src/main/java/cz/cvut/spipes/modules/Rdf4jUpdateModule.java @@ -113,7 +113,7 @@ void setUpdateRepository(Repository updateRepository) { public static Resource createUpdateQueryResource(Model model, String updateQuery) { return model.createResource() - .addProperty(RDF.type, SML.updateQuery) + .addProperty(RDF.type, SML.JENA.updateQuery) .addProperty(SP.text, ResourceFactory.createPlainLiteral(updateQuery)); } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java index 4efd352a..076350f9 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java @@ -12,7 +12,6 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; -import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Construct; import org.topbraid.spin.system.SPINModuleRegistry; import org.topbraid.spin.vocabulary.SP; diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java index 7008abc8..bd6af6d4 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesAndScrollableCursorModule.java @@ -10,16 +10,11 @@ import cz.cvut.spipes.recursion.ScrollableCursorProvider; import cz.cvut.spipes.util.QueryUtils; import lombok.extern.slf4j.Slf4j; -import org.apache.jena.query.Query; -import org.apache.jena.query.QueryExecution; -import org.apache.jena.query.QueryExecutionFactory; -import org.apache.jena.query.QuerySolution; -import org.apache.jena.query.ResultSet; +import org.apache.jena.query.*; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; import org.jetbrains.annotations.NotNull; -import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Select; /** diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java index cc79f722..43768152 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructWithChunkedValuesModule.java @@ -5,21 +5,16 @@ import cz.cvut.spipes.engine.VariablesBinding; import cz.cvut.spipes.modules.annotations.SPipesModule; import cz.cvut.spipes.util.QueryUtils; -import java.util.Objects; - import lombok.extern.slf4j.Slf4j; -import org.apache.jena.query.Query; -import org.apache.jena.query.QueryExecution; -import org.apache.jena.query.QueryExecutionFactory; -import org.apache.jena.query.QuerySolution; -import org.apache.jena.query.ResultSet; +import org.apache.jena.query.*; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; import org.jetbrains.annotations.NotNull; -import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Select; +import java.util.Objects; + /** * TODO Order of queries is not enforced. */ diff --git a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java index 5332f23b..1a3e20c5 100644 --- a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java +++ b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java @@ -22,8 +22,6 @@ import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; - -import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Select; import java.io.IOException; diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/SPipesContextController.java b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/SPipesContextController.java index 9eaa1ef6..0984c1f0 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/SPipesContextController.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/SPipesContextController.java @@ -8,12 +8,15 @@ import cz.cvut.spipes.rest.util.ScriptManagerFactory; import cz.cvut.spipes.util.RDFMimeType; import lombok.extern.slf4j.Slf4j; -import org.apache.jena.rdf.model.*; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.apache.jena.rdf.model.Statement; import org.apache.jena.vocabulary.OWL; import org.apache.jena.vocabulary.RDF; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import java.util.LinkedList; @@ -59,7 +62,7 @@ public Model retrieveContextData(@PathVariable("id") String id) { outModel.add(inModel); outModel.add(SPipesContextController.createInferences(inModel)); - outModel.add(SM.next, RDF.type, OWL.ObjectProperty); + outModel.add(SM.JENA.next, RDF.type, OWL.ObjectProperty); return outModel; } @@ -70,7 +73,7 @@ static List createInferences(Model model) { return PipelineFactory.getModuleTypes().keySet().stream() .flatMap(mt -> model.listSubjectsWithProperty(RDF.type, mt).toSet().stream()) .map(m -> model.createStatement( - m, RDF.type, SM.Modules + m, RDF.type, SM.JENA.Modules )).collect(Collectors.toList()); } } From 4aba5c6e2a654cad2228519aecb153bec41f7a90 Mon Sep 17 00:00:00 2001 From: Miroslav Blasko Date: Fri, 13 Sep 2024 12:50:54 +0200 Subject: [PATCH 4/5] [#258] Improve refactoring of @Parameter annotation --- .../src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java index 83334042..61357ba4 100644 --- a/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java +++ b/s-pipes-modules/module-nlp/src/main/java/cz/cvut/spipes/modules/SUTimeModuleNew.java @@ -48,12 +48,10 @@ public class SUTimeModuleNew extends AbstractModule { comment = "List of construct queries. The module annotates the lexical form of objects of the output statements of these queries.")// TODO - revise comment private List constructQueries; - //sml:replace @Parameter(iri = SML.replace, comment = "Replace context flag. Default value is false." ) private boolean isReplace; - //kbss:parseText - @Parameter(iri = KBSS_MODULE.uri + "is-parse-text", + @Parameter(iri = KBSS_MODULE.is_parse_text, comment = "Whether the query should be taken from sp:text property instead of from SPIN serialization," + " default is true.") private boolean parseText; From c1d2865f9c27fecab977de078fc27f59459e0d16 Mon Sep 17 00:00:00 2001 From: Miroslav Blasko Date: Fri, 13 Sep 2024 12:52:12 +0200 Subject: [PATCH 5/5] [#258] Remove useless comments of parameters --- .../java/cz/cvut/spipes/modules/ApplyConstructModule.java | 6 ------ .../java/cz/cvut/spipes/modules/BindBySelectModule.java | 1 - .../cz/cvut/spipes/modules/RetrievePrefixesModule.java | 1 - .../cvut/spipes/modules/ApplyConstructAbstractModule.java | 5 +---- .../main/java/cz/cvut/spipes/modules/TabularModule.java | 8 -------- .../src/main/java/cz/cvut/spipes/modules/TarqlModule.java | 3 --- .../java/cz/cvut/spipes/modules/TextAnalysisModule.java | 1 - 7 files changed, 1 insertion(+), 24 deletions(-) diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ApplyConstructModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ApplyConstructModule.java index d4de7855..f0e53ece 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ApplyConstructModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/ApplyConstructModule.java @@ -31,24 +31,18 @@ public class ApplyConstructModule extends AnnotatedAbstractModule { private static final Logger log = LoggerFactory.getLogger(ApplyConstructModule.class); - - //sml:constructQuery @Parameter(iri = SML.constructQuery) private List constructQueries; - //sml:replace @Parameter(iri = SML.replace) private boolean isReplace = false; - //kbss:parseText /** * Whether the query should be taken from sp:text property instead of from SPIN serialization */ @Parameter(iri = KBSS_MODULE.is_parse_text) private boolean parseText = false; - - //kbss:iterationCount /** * Maximal number of iterations of the whole rule set. 0 means 0 iterations. The actual number of iterations can be smaller, * if no new inferences are generated any more. diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindBySelectModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindBySelectModule.java index 81fde158..6d308b5f 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindBySelectModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/BindBySelectModule.java @@ -18,7 +18,6 @@ public class BindBySelectModule extends AnnotatedAbstractModule { @Parameter(iri = SML.selectQuery) private Select selectQuery; - //sml:replace @Parameter(iri = SML.replace) private boolean isReplace = false; diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/RetrievePrefixesModule.java b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/RetrievePrefixesModule.java index 75e02508..48b10370 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/modules/RetrievePrefixesModule.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/modules/RetrievePrefixesModule.java @@ -52,7 +52,6 @@ public class RetrievePrefixesModule extends AnnotatedAbstractModule { private static final Logger log = LoggerFactory.getLogger(RetrievePrefixesModule.class); private static final String TYPE_URI = KBSS_MODULE.uri + "retrieve-prefixes"; - //sml:replace @Parameter(iri = SML.replace) private boolean isReplace = false; diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java index 076350f9..6dbea902 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/modules/ApplyConstructAbstractModule.java @@ -23,27 +23,24 @@ public abstract class ApplyConstructAbstractModule extends AnnotatedAbstractModu private static final String TYPE_URI = KBSS_MODULE.uri + "abstract-apply-construct"; private static final String PROPERTY_PREFIX_URI = KBSS_MODULE.uri; - //sml:constructQuery + // TODO - this parameter is reused in ApplyConstructWithChunkedValuesAndScrollableCursorModule. There the comment should be extended by a note, i.e. "The construct queries with markers #${VALUES} and #${LIMIT_OFFSET}." @Parameter(iri = SML.constructQuery, comment = "SPARQL Construct query (sp:Construct)" + " that should be executed by this module. The query is read from sp:text property." + " The output of query execution is returned by the module.") protected List constructQueries; - //sml:replace @Parameter(iri = SML.replace, comment = "Specifies whether a module should overwrite triples" + " from its predecessors. When set to true (default is false), it prevents" + " passing through triples from the predecessors.") protected boolean isReplace; - //kbss:parseText @Parameter(iri = KBSS_MODULE.is_parse_text, comment = "Whether the query should be taken from sp:text property instead of from SPIN serialization," + " default is true." ) protected boolean parseText; - //kbss:iterationCount @Parameter(iri = KBSS_MODULE.has_max_iteration_count, comment = "Maximal number of iterations of the whole rule set. 0 means 0 iterations. The actual number of iterations can be smaller,\n" + diff --git a/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/TabularModule.java b/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/TabularModule.java index 72135a59..2467a319 100644 --- a/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/TabularModule.java +++ b/s-pipes-modules/module-tabular/src/main/java/cz/cvut/spipes/modules/TabularModule.java @@ -111,7 +111,6 @@ public class TabularModule extends AbstractModule { private final Property P_SOURCE_RESOURCE_FORMAT = getSpecificParameter("source-resource-format"); private final Property P_PROCESS_TABLE_AT_INDEX = getSpecificParameter("process-table-at-index"); - //sml:replace @Parameter(iri = SML.replace, comment = "Specifies whether a module should overwrite triples" + " from its predecessors. When set to true (default is false), it prevents" + " passing through triples from the predecessors.") @@ -119,22 +118,17 @@ public class TabularModule extends AbstractModule { @Parameter(iri = PARAM_URL_PREFIX + "source-resource-uri", comment = "URI of resource" + " that represent tabular data (e.g. resource representing CSV file).") - //:source-resource-uri private StreamResource sourceResource; - //:delimiter @Parameter(iri = PARAM_URL_PREFIX + "delimiter", comment = "Column delimiter. Default value is comma ','.") private int delimiter; - //:quote-character @Parameter(iri = PARAM_URL_PREFIX + "quote-character", comment = "Quote character. Default is '\"' if delimiter is ',', '\\0' otherwize.") private char quoteCharacter; - //:data-prefix @Parameter(iri = PARAM_URL_PREFIX + "data-prefix", comment = "Data prefix")// TODO - improve comment private String dataPrefix; - //:skip-header @Parameter(iri = PARAM_URL_PREFIX + "skip-header", comment = "Skip header. Default is false.") private boolean skipHeader; @@ -144,7 +138,6 @@ public class TabularModule extends AbstractModule { */ private int processTableAtIndex; - //:output-mode // TODO - revise comment @Parameter(iri = PARAM_URL_PREFIX + "output-mode", comment = "Output mode. Default is standard-mode('http://onto.fel.cvut.cz/ontologies/lib/module/tabular/standard-mode)") private Mode outputMode; @@ -163,7 +156,6 @@ public class TabularModule extends AbstractModule { */ private ResourceFormat sourceResourceFormat = ResourceFormat.PLAIN; - //:accept-invalid-quoting @Parameter(iri = PARAM_URL_PREFIX + "accept-invalid-quoting", comment = "Accept invalid quoting. Default is false.") private boolean acceptInvalidQuoting; diff --git a/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java b/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java index 1db616a0..9839f781 100644 --- a/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java +++ b/s-pipes-modules/module-tarql/src/main/java/cz/cvut/spipes/modules/TarqlModule.java @@ -36,20 +36,17 @@ public class TarqlModule extends AbstractModule { private static final String TARQL_PROGRAM = AppConstants.BIN_DIR + "/tarql"; - //sml:constructQuery @Parameter(iri = SML.constructQuery, comment = "The TARQL Construct queries that deliver the triples that shall be added.") private List constructQueries; // TODO not used field private String tableFilePath; - //sml:replace @Parameter(iri = SML.replace, comment = "If set to true, the output triples will only contain the " + "constructed triples. If no values or false are specified, the output will be the union of the input triples " + "and the constructed triples.") private boolean isReplace; - //sml:sourceFilePath @Parameter(iri = SML.sourceFilePath, comment = "Source CSV file.") private String sourceFilePath; diff --git a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java index 1a3e20c5..a8916543 100644 --- a/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java +++ b/s-pipes-modules/module-text-analysis/src/main/java/cz/cvut/spipes/modules/TextAnalysisModule.java @@ -58,7 +58,6 @@ public class TextAnalysisModule extends AnnotatedAbstractModule{ @Parameter(iri = TYPE_PREFIX + "language", comment = "The language of the text to be analyzed.") private String language; - //sml:replace @Parameter(iri = SML.replace, comment = "Replace context flag, default is false.") private boolean isReplace = false;