From 2e23bd7eeef4876fd19afbff4f907794763d4edb Mon Sep 17 00:00:00 2001 From: Miroslav Blasko Date: Fri, 13 Sep 2024 10:50:56 +0200 Subject: [PATCH] [#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()); } }