diff --git a/.github/workflows/protect-master.yml b/.github/workflows/protect-master.yml index 6b372caf..2d306c10 100644 --- a/.github/workflows/protect-master.yml +++ b/.github/workflows/protect-master.yml @@ -25,6 +25,6 @@ jobs: # Test using proper JDK and MVN - name: Test - uses: docker://maven:3-eclipse-temurin-21 + uses: docker://maven:3-eclipse-temurin-17 with: args: mvn test diff --git a/s-pipes-cli/pom.xml b/s-pipes-cli/pom.xml index 73c6f9b4..4ad25f70 100644 --- a/s-pipes-cli/pom.xml +++ b/s-pipes-cli/pom.xml @@ -53,6 +53,11 @@ logback-core ${ch.qos.logback.version} + + org.projectlombok + lombok + provided + commons-io @@ -72,6 +77,8 @@ + + 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 69e846b3..e731cc61 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 @@ -7,6 +7,7 @@ import cz.cvut.spipes.manager.OntologyDocumentManager; import cz.cvut.spipes.manager.SPipesScriptManager; import cz.cvut.spipes.modules.Module; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.rdf.model.Model; @@ -29,7 +30,7 @@ import java.util.Map; import java.util.stream.Collectors; - +@Slf4j public class ExecuteModuleCLI { // cat input-data.rdf | s-pipes execute --instance "" @@ -39,7 +40,7 @@ public class ExecuteModuleCLI { // > output.data.rdf - private static final Logger LOG = LoggerFactory.getLogger(ExecuteModuleCLI.class); + private static final String DEFAULT_DELIMITER = ";"; //@Option(name = "-d", aliases = "--delimiter", metaVar = "DELIMITER", usage = "Input variables data delimiter ('" + DEFAULT_DELIMITER + "' by default)") //private String delimiter = DEFAULT_DELIMITER; @@ -98,24 +99,24 @@ public static void main(String[] args) throws IOException { CmdLineUtils.parseCommandLine(args, argParser); String output = String.join(" ", args); - LOG.info("Executing external module/function ... " + output); + log.info("Executing external module/function ... " + output); // ----- load input model Model inputDataModel = ModelFactory.createDefaultModel(); if (asArgs.inputDataFiles != null) { for (File idFile : asArgs.inputDataFiles) { - LOG.debug("Loading input data from file {} ...", idFile); + log.debug("Loading input data from file {} ...", idFile); inputDataModel.read(new FileInputStream(idFile), null, FileUtils.langTurtle); } } if (asArgs.isInputDataFromStdIn) { - LOG.info("Loading input data from std-in ..."); + log.info("Loading input data from std-in ..."); inputDataModel.read(System.in, null, FileUtils.langTurtle); } // ----- load modules and functions - LOG.debug("Loading scripts ..."); + log.debug("Loading scripts ..."); SPipesScriptManager scriptManager = scriptManager = createSPipesScriptManager(); OntoDocManager.registerAllSPINModules(); @@ -123,7 +124,7 @@ public static void main(String[] args) throws IOException { VariablesBinding inputVariablesBinding = new VariablesBinding(); if (asArgs.inputBindingParametersMap != null) { inputVariablesBinding = new VariablesBinding(transform(asArgs.inputBindingParametersMap)); - LOG.info("Loaded input variable binding ={}", inputVariablesBinding); + log.info("Loaded input variable binding ={}", inputVariablesBinding); } // ----- create execution context @@ -139,7 +140,7 @@ public static void main(String[] args) throws IOException { } ExecutionContext outputExecutionContext = engine.executePipeline(module, inputExecutionContext); - LOG.info("Processing successfully finished."); + log.info("Processing successfully finished."); // outputExecutionContext.getDefaultModel().write(System.out); // Model inputBindingModel = null; @@ -265,7 +266,7 @@ private static SPipesScriptManager createSPipesScriptManager() { // load from environment variables String spipesOntologiesPathsStr = System.getenv(AppConstants.SYSVAR_SPIPES_ONTOLOGIES_PATH); - LOG.debug("Loading scripts from system variable {} = {}", AppConstants.SYSVAR_SPIPES_ONTOLOGIES_PATH, spipesOntologiesPathsStr); + log.debug("Loading scripts from system variable {} = {}", AppConstants.SYSVAR_SPIPES_ONTOLOGIES_PATH, spipesOntologiesPathsStr); if (spipesOntologiesPathsStr != null) { scriptPaths.addAll( Arrays.stream(spipesOntologiesPathsStr.split(";")) @@ -303,7 +304,7 @@ public static List registerGlobalScripts(OntologyDocumentManager ontDocM ontoUri -> { String loc = locMapper.getAltEntry(ontoUri); if (loc.endsWith(".sms.ttl")) { - LOG.info("Registering script from file " + loc + "."); + log.info("Registering script from file " + loc + "."); _globalScripts.add(ontoUri); } } diff --git a/s-pipes-core/pom.xml b/s-pipes-core/pom.xml index d488b245..bc60adff 100644 --- a/s-pipes-core/pom.xml +++ b/s-pipes-core/pom.xml @@ -44,6 +44,12 @@ logback-classic + + org.projectlombok + lombok + provided + + org.junit.jupiter diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/engine/ExecutionEngineImpl.java b/s-pipes-core/src/main/java/cz/cvut/spipes/engine/ExecutionEngineImpl.java index f555a3fb..8eb3f66d 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/engine/ExecutionEngineImpl.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/engine/ExecutionEngineImpl.java @@ -1,6 +1,7 @@ package cz.cvut.spipes.engine; import cz.cvut.spipes.modules.Module; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; @@ -14,16 +15,16 @@ import java.util.function.Function; import java.util.stream.Collectors; +@Slf4j class ExecutionEngineImpl implements ExecutionEngine { - private static Logger LOG = LoggerFactory.getLogger(ExecutionEngineImpl.class); private Set listeners = new HashSet<>(); private static int i = 0 ; public ExecutionContext executePipeline(final Module module, final ExecutionContext inputContext) { - LOG.info("Executing script {} with context {}.", module.getResource(), inputContext.toSimpleString()); + log.info("Executing script {} with context {}.", module.getResource(), inputContext.toSimpleString()); final long pipelineExecutionId = Instant.now().toEpochMilli()*1000+(i++); fire((l) -> {l.pipelineExecutionStarted(pipelineExecutionId); return null;}); @@ -37,7 +38,7 @@ private void fire(final Function function) { try { function.apply(listener); } catch(final Exception e) { - LOG.warn("Listener {} failed.", listener, e); + log.warn("Listener {} failed.", listener, e); } }); } @@ -58,17 +59,17 @@ private ExecutionContext _executePipeline(long pipelineExecutionId, Module modul fire((l) -> {l.moduleExecutionStarted(pipelineExecutionId, moduleExecutionId, module, context, predecessorId); return null;}); if (module.getExecutionContext() != null) { - LOG.debug("Execution context for module {} already set.", module); + log.debug("Execution context for module {} already set.", module); } else { module.setInputContext(context); - LOG.info(" ##### " + module.getLabel()); - if (LOG.isTraceEnabled()) { - LOG.trace("Using input context {}", context.toTruncatedSimpleString()); //TODO redundant code -> merge + log.info(" ##### " + module.getLabel()); + if (log.isTraceEnabled()) { + log.trace("Using input context {}", context.toTruncatedSimpleString()); //TODO redundant code -> merge } ExecutionContext outputContext = module.execute(); - if (LOG.isTraceEnabled()) { - LOG.trace("Returning output context {}", outputContext.toSimpleString()); + if (log.isTraceEnabled()) { + log.trace("Returning output context {}", outputContext.toSimpleString()); } module.addOutputBindings(context.getVariablesBinding()); } @@ -80,18 +81,18 @@ private ExecutionContext _executePipeline(long pipelineExecutionId, Module modul .collect(Collectors.toMap(Module::getResource, mod -> this._executePipeline(pipelineExecutionId, mod, context, moduleExecutionId))); - LOG.info(" ##### " + module.getLabel()); + log.info(" ##### " + module.getLabel()); ExecutionContext mergedContext = mergeContexts(resource2ContextMap); - if (LOG.isTraceEnabled()) { - LOG.trace("Using input merged context {}", mergedContext.toTruncatedSimpleString()); + if (log.isTraceEnabled()) { + log.trace("Using input merged context {}", mergedContext.toTruncatedSimpleString()); } fire((l) -> {l.moduleExecutionStarted(pipelineExecutionId, moduleExecutionId, module, mergedContext, predecessorId); return null;}); module.setInputContext(mergedContext); ExecutionContext outputContext = module.execute(); - if (LOG.isTraceEnabled()) { - LOG.trace("Returning output context {}", outputContext.toSimpleString()); + if (log.isTraceEnabled()) { + log.trace("Returning output context {}", outputContext.toSimpleString()); } module.addOutputBindings(mergedContext.getVariablesBinding()); fire((l) -> {l.moduleExecutionFinished(pipelineExecutionId, moduleExecutionId, module); return null;}); @@ -128,7 +129,7 @@ private ExecutionContext mergeContexts(Map resource2 VariablesBinding conflictingBinding = variablesBinding.extendConsistently(b); if (! conflictingBinding.isEmpty()) { - LOG.warn("Module {} has conflicting variables binding {} with sibling modules ocurring in pipeline. ", modRes, context); + log.warn("Module {} has conflicting variables binding {} with sibling modules ocurring in pipeline. ", modRes, context); } }); 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 11d2c51c..2edc0958 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 @@ -13,6 +13,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; @@ -28,10 +30,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class PipelineFactory { - private static final Logger LOG = LoggerFactory.getLogger(PipelineFactory.class); - // TODO inheritence not involved, not static context static Map> moduleTypes = new HashMap<>(); @@ -54,12 +55,12 @@ public static void registerModuleType(Resource moduleType, Class moduleClass) { - LOG.info(" module: {} -> {}", moduleType, moduleClass); + log.info(" module: {} -> {}", moduleType, moduleClass); moduleTypes.put(moduleType, moduleClass); } private static void _registerFunctionType(Resource functionType, Class functionClass) { - LOG.info(" function: {} -> {}", functionType, functionClass); + log.info(" function: {} -> {}", functionType, functionClass); FunctionRegistry.get().put(functionType.getURI(), functionClass); } @@ -114,7 +115,7 @@ public static Module loadModule(@NotNull Resource moduleRes) { // TODO multiple module types per resource Resource moduleTypeRes = moduleRes.getPropertyResourceValue(RDF.type); if (moduleTypeRes == null) { - LOG.error("Cannot load module {} as its {} property value is missing.", moduleRes, RDF.type); + log.error("Cannot load module {} as its {} property value is missing.", moduleRes, RDF.type); return null; } return loadModule(moduleRes, moduleTypeRes); @@ -173,7 +174,7 @@ private static Map loadAllModules(@NotNull Model configModel) .map(st -> { Module m = res2ModuleMap.get(st.getObject().asResource()); if (m == null) { - LOG.error("Ignoring statement {}. The object of the triple must have rdf:type {}.", st, SM.Module); + log.error("Ignoring statement {}. The object of the triple must have rdf:type {}.", st, SM.Module); } return m; }).filter(m -> (m != null)).forEach( @@ -193,7 +194,7 @@ private static Module loadModule(@NotNull Resource moduleRes, @NotNull Resource Class moduleClass = moduleTypes.get(moduleTypeRes); if (moduleClass == null) { - LOG.error("Ignoring module {}. Its type {} is not registered.", moduleRes, moduleTypeRes); + log.error("Ignoring module {}. Its type {} is not registered.", moduleRes, moduleTypeRes); return null; } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/engine/VariablesBinding.java b/s-pipes-core/src/main/java/cz/cvut/spipes/engine/VariablesBinding.java index ed532209..f15c997d 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/engine/VariablesBinding.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/engine/VariablesBinding.java @@ -1,5 +1,6 @@ package cz.cvut.spipes.engine; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.rdf.model.*; @@ -14,11 +15,10 @@ import java.util.*; import java.util.stream.Collectors; +@Slf4j public class VariablesBinding { // TODO stream variables etc. - - private static Logger LOG = LoggerFactory.getLogger(VariablesBinding.class); private static final int MAX_TRUNCATED_VALUE_SIZE = 300; QuerySolutionMap binding = new QuerySolutionMap(); @@ -31,7 +31,7 @@ public VariablesBinding(QuerySolution querySolution) { key -> { RDFNode value = querySolution.get(key); if (value == null) { - LOG.error("Ignoring variable binding with null value for the variable name \"{}\".", key); + log.error("Ignoring variable binding with null value for the variable name \"{}\".", key); } else { binding.add(key, value); } @@ -79,7 +79,7 @@ public VariablesBinding extendConsistently(VariablesBinding newVarsBinding) { if ((oldNode != null) && (!oldNode.equals(newNode))) { conflictingBinding.add(v, newNode); - LOG.warn("Variable \"{}\" have been bind to value \"{}\", ignoring assignment to value \"{}\".", v, oldNode, newNode); + log.warn("Variable \"{}\" have been bind to value \"{}\", ignoring assignment to value \"{}\".", v, oldNode, newNode); } else { this.add(v, newNode); } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/logging/AdvancedLoggingProgressListener.java b/s-pipes-core/src/main/java/cz/cvut/spipes/logging/AdvancedLoggingProgressListener.java index 2c945d2b..64b65a5c 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/logging/AdvancedLoggingProgressListener.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/logging/AdvancedLoggingProgressListener.java @@ -15,6 +15,7 @@ import cz.cvut.spipes.util.DateUtils; import cz.cvut.spipes.util.Rdf4jUtils; import cz.cvut.spipes.util.TempFileUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; @@ -45,9 +46,8 @@ import java.nio.file.Paths; import java.util.*; +@Slf4j public class AdvancedLoggingProgressListener implements ProgressListener { - private static final Logger LOG = - LoggerFactory.getLogger(AdvancedLoggingProgressListener.class); /** * Maps pipeline executions and module executions to the transformation object. */ @@ -173,7 +173,7 @@ private void persistPipelineExecutionFinished2(final EntityManager em, final lon private void persistPipelineExecutionFinished(final EntityManager em, final long pipelineExecutionId) { if (em.isOpen()) { - LOG.debug("Saving metadata about finished pipeline execution {}.", pipelineExecutionId); + log.debug("Saving metadata about finished pipeline execution {}.", pipelineExecutionId); Date finishDate = new Date(); em.getTransaction().begin(); @@ -359,7 +359,7 @@ private void writeRawData(EntityManager em, URI contextUri, Model model) { connection.getValueFactory().createIRI(contextUri.toString())); connection.commit(); } catch (final RepositoryException | RDFParseException | RepositoryConfigException | IOException e) { - LOG.error(e.getMessage(), e); + log.error(e.getMessage(), e); } finally { if (connection != null && connection.isOpen()) { connection.close(); @@ -386,7 +386,7 @@ private void saveModelToFile(String filePath, Model model) { try (OutputStream fileIs = new FileOutputStream(file)) { model.write(fileIs, FileUtils.langTurtle); } catch (IOException e) { - LOG.error("Error during dataset snapshot saving.", e); + log.error("Error during dataset snapshot saving.", e); } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/logging/SemanticLoggingProgressListener.java b/s-pipes-core/src/main/java/cz/cvut/spipes/logging/SemanticLoggingProgressListener.java index 0bea3c36..acde2767 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/logging/SemanticLoggingProgressListener.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/logging/SemanticLoggingProgressListener.java @@ -11,6 +11,7 @@ import cz.cvut.spipes.model.Transformation; import cz.cvut.spipes.modules.Module; import cz.cvut.spipes.util.TempFileUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; import org.apache.jena.util.FileUtils; @@ -36,10 +37,8 @@ import java.util.Map; import java.util.Set; +@Slf4j public class SemanticLoggingProgressListener implements ProgressListener { - private static final Logger LOG = - LoggerFactory.getLogger(SemanticLoggingProgressListener.class); - /** * Maps pipeline executions and module executions to the transformation object. */ @@ -185,14 +184,14 @@ private String saveModelToFile(Path dir, String fileName, Model model) { file = Files.createFile(dir.resolve(TempFileUtils.createTimestampFileName(fileName))).toFile(); } catch (IOException e) { - LOG.error("Error during file creation.", e); + log.error("Error during file creation.", e); return null; } try (OutputStream fileIs = new FileOutputStream(file)) { model.write(fileIs, FileUtils.langTurtle); return file.toURI().toURL().toString(); } catch (IOException e) { - LOG.error("Error during dataset snapshot saving.", e); + log.error("Error during dataset snapshot saving.", e); return null; } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/manager/OntoDocManager.java b/s-pipes-core/src/main/java/cz/cvut/spipes/manager/OntoDocManager.java index ff95acc0..2904872e 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/manager/OntoDocManager.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/manager/OntoDocManager.java @@ -3,6 +3,7 @@ import cz.cvut.spipes.config.CompatibilityConfig; import cz.cvut.spipes.util.JenaUtils; import cz.cvut.spipes.util.SparqlMotionUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.atlas.web.HttpException; import org.apache.jena.ontology.OntDocumentManager; import org.apache.jena.ontology.OntModel; @@ -55,9 +56,9 @@ * caches the files * manages prefixes **/ +@Slf4j public class OntoDocManager implements OntologyDocumentManager { - private static final Logger LOG = LoggerFactory.getLogger(OntoDocManager.class); private static Instant lastTime = Instant.now(); private static boolean reloadFiles = false; @@ -103,7 +104,7 @@ public List getSupportedFileExtensions() { public void registerDocuments(Path directoryOrFilePath) { if (Files.isDirectory(directoryOrFilePath) && Files.isSymbolicLink(directoryOrFilePath)) { - LOG.warn("Ignoring to register documents from directory {}. Directories that are symbolic links " + + log.warn("Ignoring to register documents from directory {}. Directories that are symbolic links " + "are not supported.", directoryOrFilePath ); } @@ -181,7 +182,7 @@ public static Map getAllFile2Model(Path directoryOrFilePath) { } String lang = FileUtils.guessLang(file.getFileName().toString()); - LOG.debug("Loading model from {} ...", file.toUri().toString()); + log.debug("Loading model from {} ...", file.toUri().toString()); Model model = loadModel(file, lang); if (model != null) { @@ -194,7 +195,7 @@ public static Map getAllFile2Model(Path directoryOrFilePath) { } catch (IOException | DirectoryIteratorException e) { // IOException can never be thrown by the iteration. // In this snippet, it can only be thrown by newDirectoryStream. - LOG.error("Could not load ontologies from directory {} -- {} .", directoryOrFilePath, e); + log.error("Could not load ontologies from directory {} -- {} .", directoryOrFilePath, e); } return file2Model; } @@ -234,7 +235,7 @@ static Map getAllBaseIris(Path directoryorFilePath) { String baseURI = JenaUtils.getBaseUri(model); if (baseURI == null) { - LOG.info("Ignoring file \"" + file + "\" as it does not contain baseURI."); + log.info("Ignoring file \"" + file + "\" as it does not contain baseURI."); return; } baseUri2file.put(baseURI, file); @@ -365,7 +366,7 @@ public static String getBaseUri(Model model) { } public static void registerAllSPINModules() { - LOG.warn("WORKAROUND -- Applying a workaround to register all SPIN modules ..."); // TODO remove this workaround + log.warn("WORKAROUND -- Applying a workaround to register all SPIN modules ..."); // TODO remove this workaround Model model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); model.add(OntoDocManager.allLoadedFilesModel); SPINModuleRegistry.get().reset(); @@ -387,11 +388,11 @@ public void handleFailedRead(String url, Model model, Exception e) { if (e instanceof HttpException) { int responseCode = ((HttpException) e).getResponseCode(); if (responseCode == 404) { - LOG.warn("Attempt to read ontology from {} returned HTTP code '404 - Not Found'.", url); + log.warn("Attempt to read ontology from {} returned HTTP code '404 - Not Found'.", url); return; } } - LOG.warn("Attempt to read ontology from {} failed. Msg was {}. {}", url, e.getMessage(), e); + log.warn("Attempt to read ontology from {} failed. Msg was {}. {}", url, e.getMessage(), e); } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/manager/SPipesScriptManager.java b/s-pipes-core/src/main/java/cz/cvut/spipes/manager/SPipesScriptManager.java index 0121ef6d..41643f67 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/manager/SPipesScriptManager.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/manager/SPipesScriptManager.java @@ -9,6 +9,7 @@ import cz.cvut.spipes.repository.SMScriptCollectionRepository; import cz.cvut.spipes.repository.ScriptCollectionRepository; import cz.cvut.spipes.util.JenaPipelineUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,10 +28,9 @@ * TODO resource registry * */ +@Slf4j public class SPipesScriptManager { - private static final Logger LOG = LoggerFactory.getLogger(SPipesScriptManager.class); - // TODO instead of ontoDocManager should point to ScriptCollectionRepository private Set globalScripts; ///private final Map globalScriptsMap = new LinkedHashMap<>(); 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 ef43518e..3b1deb9a 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 @@ -10,6 +10,7 @@ import cz.cvut.spipes.exception.ValidationConstraintFailedException; import cz.cvut.spipes.util.JenaUtils; import cz.cvut.spipes.util.QueryUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.atlas.lib.NotImplemented; import org.apache.jena.ontology.OntModel; import org.apache.jena.query.*; @@ -37,9 +38,10 @@ import static java.util.stream.Collectors.joining; +@Slf4j public abstract class AbstractModule implements Module { - private static final Logger LOG = LoggerFactory.getLogger(AbstractModule.class); + Resource resource; List inputModules = new LinkedList<>(); ExecutionContext executionContext; @@ -65,14 +67,14 @@ public ExecutionContext execute() { String inputModelFilePath = null; if (AuditConfig.isEnabled() || isInDebugMode) { inputModelFilePath = saveModelToTemporaryFile(executionContext.getDefaultModel()); - LOG.debug("Saving module's execution input to file {}.", inputModelFilePath); + log.debug("Saving module's execution input to file {}.", inputModelFilePath); } if (ExecutionConfig.isCheckValidationConstrains()) { checkInputConstraints(); } outputContext = executeSelf(); if (AuditConfig.isEnabled() || isInDebugMode) { - LOG.debug("Saving module's execution output to file {}.", saveModelToTemporaryFile(outputContext.getDefaultModel())); + log.debug("Saving module's execution output to file {}.", saveModelToTemporaryFile(outputContext.getDefaultModel())); } if (ExecutionConfig.isCheckValidationConstrains()) { @@ -116,7 +118,7 @@ private void generateLinkToRerunExecution(String inputModelFilePath) { .collect(joining("&", SPIPES_SERVICE_URL + "/module?", "")); - LOG.debug("To rerun the execution visit {}", encodedURL); + log.debug("To rerun the execution visit {}", encodedURL); } @Override @@ -226,7 +228,7 @@ private void checkOutputConstraints() { mergedVarsBinding.extendConsistently(outputContext.getVariablesBinding()); if (!outputConstraintQueries.isEmpty()) { - LOG.debug("Validating module's output constraints ..."); + log.debug("Validating module's output constraints ..."); checkConstraints(defaultModel, mergedVarsBinding.asQuerySolution(), outputConstraintQueries); } } @@ -237,7 +239,7 @@ void checkInputConstraints() { QuerySolution bindings = executionContext.getVariablesBinding().asQuerySolution(); if (!inputConstraintQueries.isEmpty()) { - LOG.debug("Validating module's input constraints ..."); + log.debug("Validating module's input constraints ..."); checkConstraints(defaultModel, bindings, inputConstraintQueries); } } @@ -292,12 +294,12 @@ private void checkConstraints(Model model, QuerySolution bindings, List vars = new HashMap<>(); @@ -29,7 +30,7 @@ public void loadConfiguration() { vars.put(p.name(), f); } - LOG.trace("Processing parameter {} ", f.getName()); + log.trace("Processing parameter {} ", f.getName()); RDFNode node = this.getEffectiveValue(ResourceFactory.createProperty(p.urlPrefix()+p.name())); if ( node != null ) { 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 b47bc526..e69cad1d 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 @@ -8,6 +8,7 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.util.JenaUtils; import cz.cvut.spipes.util.QueryUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.Query; import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QuerySolution; @@ -27,10 +28,9 @@ /** * TODO Order of queries is not enforced. **/ +@Slf4j public class ApplyConstructModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ApplyConstructModule.class); - //sml:constructQuery private List constructQueries; @@ -121,9 +121,9 @@ public ExecutionContext executeSelf() { for (int i = 0; i < constructQueriesSorted.size(); i++) { Construct spinConstructRes = constructQueriesSorted.get(i); - if (LOG.isTraceEnabled()) { + if (log.isTraceEnabled()) { String queryComment = getQueryComment(spinConstructRes); - LOG.trace( + log.trace( "Executing iteration {}/{} with {}/{} query \"{}\" ...", count, iterationCount, i + 1, constructQueriesSorted.size(), queryComment ); @@ -138,12 +138,12 @@ public ExecutionContext executeSelf() { Model constructedModel = QueryUtils.execConstruct(query, extendedInferredModel, bindings); - if (LOG.isTraceEnabled()) { - LOG.trace("... the query returned {} triples.", constructedModel.size()); + if (log.isTraceEnabled()) { + log.trace("... the query returned {} triples.", constructedModel.size()); } if (AuditConfig.isEnabled() || ExecutionConfig.getEnvironment().equals(Environment.development)) { - LOG.debug("... saving module's partially computed output to file {}.", saveModelToTemporaryFile(constructedModel)); + log.debug("... saving module's partially computed output to file {}.", saveModelToTemporaryFile(constructedModel)); } inferredInSingleIterationModel = ModelFactory.createUnion(inferredInSingleIterationModel, constructedModel); @@ -152,7 +152,7 @@ public ExecutionContext executeSelf() { Model newModel = JenaUtils.createUnion(inferredModel, inferredInSingleIterationModel); inferredTriplesCount = newModel.size() - inferredModel.size(); - LOG.trace("Iteration {}/{} inferred {} new triples.", count, iterationCount, inferredTriplesCount); + log.trace("Iteration {}/{} inferred {} new triples.", count, iterationCount, inferredTriplesCount); inferredModel = newModel; } @@ -174,7 +174,7 @@ public void loadConfiguration() { // TODO does not work with string query as object is not RDF resource ??? constructQueries = getResourcesByProperty(SML.constructQuery); - LOG.debug("Loaded {} spin construct queries.", constructQueries.size()); + log.debug("Loaded {} spin construct queries.", constructQueries.size()); //TODO default value must be taken from template definition isReplace = this.getPropertyValue(SML.replace, false); 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 ddf2687e..6bec6022 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,6 +5,7 @@ import cz.cvut.spipes.engine.ExecutionContextFactory; import cz.cvut.spipes.engine.VariablesBinding; 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; @@ -16,9 +17,9 @@ import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Select; +@Slf4j public class BindBySelectModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(BindBySelectModule.class); private Select selectQuery; //sml:replace @@ -38,14 +39,14 @@ public ExecutionContext executeSelf() { VariablesBinding variablesBinding = new VariablesBinding(); if (!resultSet.hasNext()) { - LOG.debug("\"{}\" query did not return any values.", getLabel()); + log.debug("\"{}\" query did not return any values.", getLabel()); } else { QuerySolution qs = resultSet.next(); variablesBinding = new VariablesBinding(qs); if (resultSet.hasNext()) { - LOG.warn("\"{}\" query did not return unique value. If it is correct, the query should be restricted by additional statement (e.g. \"LIMIT 1\"). Returning binding {}, ignoring binding {}", getLabel(), variablesBinding.asQuerySolution(), resultSet.next()); + log.warn("\"{}\" query did not return unique value. If it is correct, the query should be restricted by additional statement (e.g. \"LIMIT 1\"). Returning binding {}, ignoring binding {}", getLabel(), variablesBinding.asQuerySolution(), resultSet.next()); } } 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 420b4617..3bfb4ded 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 @@ -6,14 +6,15 @@ import cz.cvut.spipes.engine.ExecutionContextFactory; import cz.cvut.spipes.engine.VariablesBinding; import cz.cvut.spipes.util.JenaUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ResourceFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class BindRDFContentHashModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(BindRDFContentHashModule.class); 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 40d903bf..68d8fa75 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 @@ -5,14 +5,15 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.engine.ExecutionContextFactory; import cz.cvut.spipes.engine.VariablesBinding; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.RDFNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class BindWithConstantModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(BindWithConstantModule.class); String outputVariable; RDFNode value; @@ -24,7 +25,7 @@ public ExecutionContext executeSelf() { VariablesBinding bindings = new VariablesBinding(outputVariable, value); - LOG.debug("\tBinding {} --> {}", outputVariable, value); + log.debug("\tBinding {} --> {}", outputVariable, value); return ExecutionContextFactory.createContext( 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 3da93d61..7179bffd 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 @@ -13,15 +13,16 @@ import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.Optional; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.ResourceFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class ImportFileFromURLModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ImportFileFromURLModule.class); - //sml:targetFilePath, required Path targetFilePath; //TODO $_executionDir ? @@ -36,7 +37,7 @@ public ExecutionContext executeSelf() { Path computedTargetFilePath = null; - LOG.debug("Importing file from url {}.", url); + log.debug("Importing file from url {}.", url); try (InputStream inputStream = url.openStream()) { computedTargetFilePath = @@ -46,7 +47,7 @@ public ExecutionContext executeSelf() { Files.copy(inputStream, computedTargetFilePath, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { - LOG.error("Could not download data from url {}.", url); + log.error("Could not download data from url {}.", url); throw new RuntimeException(e); } @@ -72,7 +73,7 @@ public void loadConfiguration() { try { url = new URL(urlNode.asLiteral().toString()); } catch (MalformedURLException e) { - LOG.error("Malformed url -- {}.", getEffectiveValue(SML.url)); + log.error("Malformed url -- {}.", getEffectiveValue(SML.url)); throw new RuntimeException(e); } 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 270815fb..5446d102 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 @@ -6,6 +6,7 @@ import cz.cvut.spipes.exception.ContextNotFoundException; import cz.cvut.spipes.manager.OntoDocManager; import cz.cvut.spipes.manager.OntologyDocumentManager; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; import org.slf4j.Logger; @@ -15,10 +16,9 @@ import java.nio.file.Paths; import java.util.Optional; +@Slf4j public class ImportRDFFromWorkspaceModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ImportRDFFromWorkspaceModule.class); - //TODO refactor -> should be part of execution context OntologyDocumentManager ontologyDocumentManager = OntoDocManager.getInstance(); 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 2f8a018b..8c2c7593 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 @@ -5,6 +5,7 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.manager.OntoDocManager; import cz.cvut.spipes.manager.OntologyDocumentManager; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.assembler.JA; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; @@ -47,8 +48,8 @@ * ja:prefix "owl" ] * . */ +@Slf4j public class RetrievePrefixesModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(RetrievePrefixesModule.class.getName()); private static String TYPE_URI = KBSS_MODULE.getURI() + "retrieve-prefixes"; diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/registry/StreamResourceRegistry.java b/s-pipes-core/src/main/java/cz/cvut/spipes/registry/StreamResourceRegistry.java index 29e4b2a7..84f8807b 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/registry/StreamResourceRegistry.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/registry/StreamResourceRegistry.java @@ -1,5 +1,6 @@ package cz.cvut.spipes.registry; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -7,8 +8,8 @@ import java.util.*; import java.util.stream.Collectors; +@Slf4j public class StreamResourceRegistry { - private static final Logger LOG = LoggerFactory.getLogger(StreamResourceRegistry.class); private static StreamResourceRegistry instance; private Set resourcePrefixMap = new HashSet<>(); @@ -40,15 +41,15 @@ public StreamResource getResourceById(String id) { } public StreamResource getResourceByUrl(String url) { - LOG.debug("Trying to find resource with url {}", url); - if (LOG.isTraceEnabled()) { - LOG.trace("Resource map content: {}", id2resourcesMap); + log.debug("Trying to find resource with url {}", url); + if (log.isTraceEnabled()) { + log.trace("Resource map content: {}", id2resourcesMap); } String id = resourcePrefixMap.stream() .filter(url::startsWith) .findAny().map(p -> url.substring(p.length())) .orElse(null); - LOG.debug("- found {}", id); + log.debug("- found {}", id); StreamResource res = id2resourcesMap.get(id).get(); if (res == null) { return null; @@ -57,11 +58,11 @@ public StreamResource getResourceByUrl(String url) { } public StreamResource registerResource(String id, byte[] content, String contentType) { - LOG.debug("Registering resource with id {}", id); + log.debug("Registering resource with id {}", id); StreamResource res = new StringStreamResource(id, content, contentType); id2resourcesMap.put(id, new WeakReference<>(res)); - if (LOG.isTraceEnabled()) { - LOG.trace("Resource map after the registration has {} entries: {}", id2resourcesMap.size(), id2resourcesMap); + if (log.isTraceEnabled()) { + log.trace("Resource map after the registration has {} entries: {}", id2resourcesMap.size(), id2resourcesMap); } cleanUpUnusedResources(); return res; @@ -72,8 +73,8 @@ private void cleanUpUnusedResources() { .filter(e -> e.getValue().get() == null) .map(Map.Entry::getKey) .collect(Collectors.toList()); - if (LOG.isTraceEnabled()) { - LOG.trace("Clearing {} resources from resource map: {}", keys.size(), keys); + if (log.isTraceEnabled()) { + log.trace("Clearing {} resources from resource map: {}", keys.size(), keys); } keys.forEach( k -> id2resourcesMap.remove(k) diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/repository/SMScriptCollectionRepository.java b/s-pipes-core/src/main/java/cz/cvut/spipes/repository/SMScriptCollectionRepository.java index c93a8b56..0a004234 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/repository/SMScriptCollectionRepository.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/repository/SMScriptCollectionRepository.java @@ -2,6 +2,7 @@ import cz.cvut.spipes.manager.OntologyDocumentManager; import cz.cvut.spipes.util.JenaPipelineUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.ontology.OntModel; import org.apache.jena.rdf.model.Resource; import org.jetbrains.annotations.NotNull; @@ -20,9 +21,8 @@ * Know nothing about alternative entity ids -- e.g. prefixed-names, local-names. *

*/ +@Slf4j public class SMScriptCollectionRepository implements ScriptCollectionRepository { - private static final Logger LOG = LoggerFactory.getLogger(SMScriptCollectionRepository.class); - private final OntologyDocumentManager ontoDocManager; //private final Set contexts; @@ -82,7 +82,7 @@ private OntModel getContextClosure(@NotNull String context) { model.getNsPrefixMap().forEach((name, url) -> { if (!isValidURL(url)){ - LOG.warn("Invalid URI prefix: <{}> within <{}> ontology.", url, context); + log.warn("Invalid URI prefix: <{}> within <{}> ontology.", url, context); } }); diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/util/CoreConfigProperies.java b/s-pipes-core/src/main/java/cz/cvut/spipes/util/CoreConfigProperies.java index 2131cc0e..64e18437 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/util/CoreConfigProperies.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/util/CoreConfigProperies.java @@ -1,5 +1,6 @@ package cz.cvut.spipes.util; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -7,10 +8,10 @@ import java.io.IOException; import java.io.InputStream; +@Slf4j public class CoreConfigProperies { private static final String CONFIG_FILE = "config-core.properties"; private static final java.util.Properties prop = new java.util.Properties(); - private static final Logger LOG = LoggerFactory.getLogger(CoreConfigProperies.class); private static final String variableAssignmentPrefix = "variable.assignment"; static { @@ -22,7 +23,7 @@ public class CoreConfigProperies { String ks = k.toString(); String envValue = getEnvValue(ks); if (envValue != null) { - LOG.debug("Overriding configuration property '{}' by system environment variable." + + log.debug("Overriding configuration property '{}' by system environment variable." + " Using new value: {}.", ks, envValue @@ -30,7 +31,7 @@ public class CoreConfigProperies { prop.setProperty(ks, envValue); } }); - LOG.info("Loaded configuration from {} and system environment : \n {}", CONFIG_FILE, prop.entrySet()); + log.info("Loaded configuration from {} and system environment : \n {}", CONFIG_FILE, prop.entrySet()); } else { throw new FileNotFoundException("Property file '" + CONFIG_FILE + "' not found in the classpath"); } @@ -42,7 +43,7 @@ public class CoreConfigProperies { public static String get(String name) { String value = prop.getProperty(name); if (value == null) { - LOG.error("Property with key {} does not exist in loaded configuration file {}.", name, CONFIG_FILE); + log.error("Property with key {} does not exist in loaded configuration file {}.", name, CONFIG_FILE); throw new IllegalArgumentException("Unable to load property " + name + " from configuration files."); } return value; diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/util/EncodingUtils.java b/s-pipes-core/src/main/java/cz/cvut/spipes/util/EncodingUtils.java index 902c84a6..308a41f6 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/util/EncodingUtils.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/util/EncodingUtils.java @@ -2,13 +2,14 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; + +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +@Slf4j public class EncodingUtils { - private static final Logger LOG = LoggerFactory.getLogger(EncodingUtils.class); public static final String UTF8 = "UTF-8"; @@ -16,7 +17,7 @@ public static String urlEncode(String str){ try{ return URLEncoder.encode(str, UTF8); } catch (UnsupportedEncodingException ex) { - LOG.error(String.format("Encoding {} is not supported.", UTF8),ex); + log.error(String.format("Encoding {} is not supported.", UTF8),ex); throw new RuntimeException(ex); } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/util/ExecUtils.java b/s-pipes-core/src/main/java/cz/cvut/spipes/util/ExecUtils.java index fc7fed8c..e570298a 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/util/ExecUtils.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/util/ExecUtils.java @@ -9,19 +9,20 @@ import java.nio.file.Files; import java.util.Arrays; import java.util.stream.Collectors; + +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +@Slf4j public class ExecUtils { - private static final Logger LOG = LoggerFactory.getLogger(ExecUtils.class); public static File stream2file(InputStream in) throws IOException { File tempFile = Files.createTempFile("execution-", ".txt").toFile(); //tempFile.deleteOnExit(); - LOG.trace("Using temporary file for input stream " + tempFile.getAbsolutePath()); + log.trace("Using temporary file for input stream " + tempFile.getAbsolutePath()); try (FileOutputStream out = new FileOutputStream(tempFile)) { IOUtils.copy(in, out); } @@ -36,7 +37,7 @@ public static File createTempFile() { e.printStackTrace(); } - LOG.trace("Using temporary file for output stream " + tempFile.getAbsolutePath()); + log.trace("Using temporary file for output stream " + tempFile.getAbsolutePath()); return tempFile; } @@ -71,7 +72,7 @@ public static InputStream execProgram(String[] programCall, InputStream inputStr //TODO remove public static InputStream execProgramWithoutExeption(String[] programCall, InputStream inputStream) { String programCallStr = "\"" + Arrays.asList(programCall).stream().collect(Collectors.joining(" ")) + "\"" ; - LOG.debug("Executing -- " + programCallStr); + log.debug("Executing -- " + programCallStr); try { return execProgram(programCall, inputStream); } catch (IOException e) { 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 787cafa7..ba7ac701 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 @@ -7,6 +7,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.jena.ontology.OntModel; import org.apache.jena.query.Query; @@ -19,11 +21,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class JenaPipelineUtils { - private static final Logger LOG = LoggerFactory.getLogger(JenaPipelineUtils.class); - - public static boolean isModule(Resource res) { return res.listProperties(RDF.type).filterKeep( @@ -51,7 +51,7 @@ public static Map getAllModulesWithTypes(Model config) { Resource moduleType = qs.get("moduleType").asResource(); Resource previous = module2moduleTypeMap.put(module, moduleType); if (previous != null) { - LOG.error("Module {} has colliding module types -- {}, {}. Ignoring type {}.", module, previous, moduleType, previous); + log.error("Module {} has colliding module types -- {}, {}. Ignoring type {}.", module, previous, moduleType, previous); } } ); @@ -72,10 +72,10 @@ public static Map getAllFunctionsWithReturnModules(Model con return; } Resource moduleType = qs.get("returnModule").asResource(); - LOG.debug("Registering function {} to return module {}.", module, moduleType); + log.debug("Registering function {} to return module {}.", module, moduleType); Resource previous = function2retModuleMap.put(module, moduleType); if (previous != null) { - LOG.error("Function {} has colliding return modules -- {}, {}. Ignoring type {}.", module, previous, moduleType, previous); + log.error("Function {} has colliding return modules -- {}, {}. Ignoring type {}.", module, previous, moduleType, previous); } } ); diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/util/JenaUtils.java b/s-pipes-core/src/main/java/cz/cvut/spipes/util/JenaUtils.java index 13c5fc77..e9967ab0 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/util/JenaUtils.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/util/JenaUtils.java @@ -1,5 +1,6 @@ package cz.cvut.spipes.util; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.apache.jena.graph.compose.MultiUnion; import org.apache.jena.rdf.model.Model; @@ -22,10 +23,9 @@ import java.util.List; import java.util.stream.Stream; +@Slf4j public class JenaUtils { - private static Logger LOG = LoggerFactory.getLogger(JenaUtils.class); - public static Model readModelFromString(String modelText, String lang) { Model model = ModelFactory.createDefaultModel(); @@ -109,7 +109,7 @@ public static Model createUnion(Model... model) { public static void saveModelToTemporaryFile(@NotNull Model model) { try { Path file = Files.createTempFile("model-output-", ".ttl"); - LOG.debug("Saving model to temporary file " + file.toString() + " ..."); + log.debug("Saving model to temporary file " + file.toString() + " ..."); model.write(Files.newOutputStream(file.toFile().toPath()), FileUtils.langTurtle); } catch (IOException e) { e.printStackTrace(); diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/util/QueryUtils.java b/s-pipes-core/src/main/java/cz/cvut/spipes/util/QueryUtils.java index 3143532d..2bd3250a 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/util/QueryUtils.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/util/QueryUtils.java @@ -1,6 +1,7 @@ package cz.cvut.spipes.util; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.*; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; @@ -14,10 +15,9 @@ import java.util.regex.Matcher; import java.util.stream.Collectors; +@Slf4j public class QueryUtils { - private static final Logger LOG = LoggerFactory.getLogger(QueryUtils.class); - /** * Returns new query by substituting marker within given query with given value. * Marker must be in syntax #${MARKER_NAME}. @@ -138,14 +138,14 @@ private static T execQuery(QueryExecutor queryExecutor, Query query, Mod QueryExecutionFactory.create(query, model, bindings), false); } catch (RuntimeException ex) { - LOG.error("Failed execution of query [1] for binding [2], due to exception [3]. " + + log.error("Failed execution of query [1] for binding [2], due to exception [3]. " + "The query [1] will be executed again with detailed logging turned on. " + "\n\t - query [1]: \"\n{}\n\"" + "\n\t - binding [2]: \"\n{}\n\"" + "\n\t - exception [3]: \"\n{}\n\"" , query, bindings, getStackTrace(ex)); } - LOG.error("Executing query [1] again to diagnose the cause ..."); + log.error("Executing query [1] again to diagnose the cause ..."); return execQuery( queryExecutor, QueryExecutionFactory.create(query, model, bindings), @@ -183,7 +183,7 @@ public static Query createQuery(org.topbraid.spin.model.Query spinQuery) { return ARQFactory.get().createQuery(spinQuery); } catch (QueryParseException e) { String query = ARQFactory.get().createCommandString(spinQuery); - LOG.error("Parse error [1] occurred in query [2].\n[1] ERROR:\n{}\n[2] QUERY:\n{}", e.getMessage(), query); + log.error("Parse error [1] occurred in query [2].\n[1] ERROR:\n{}\n[2] QUERY:\n{}", e.getMessage(), query); throw e; } } diff --git a/s-pipes-core/src/main/java/cz/cvut/spipes/util/Rdf4jUtils.java b/s-pipes-core/src/main/java/cz/cvut/spipes/util/Rdf4jUtils.java index a3a8153f..87f47a1f 100644 --- a/s-pipes-core/src/main/java/cz/cvut/spipes/util/Rdf4jUtils.java +++ b/s-pipes-core/src/main/java/cz/cvut/spipes/util/Rdf4jUtils.java @@ -1,6 +1,8 @@ package cz.cvut.spipes.util; import java.io.IOException; + +import lombok.extern.slf4j.Slf4j; import org.eclipse.rdf4j.repository.Repository; import org.eclipse.rdf4j.repository.RepositoryException; import org.eclipse.rdf4j.repository.config.RepositoryConfig; @@ -13,17 +15,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class Rdf4jUtils { - private static final Logger LOG = LoggerFactory.getLogger(Rdf4jUtils.class); - public static void createRdf4RepositoryIfNotExist(String rdf4jServerUrl, String repositoryName) { Repository repository = null; try { RepositoryManager repositoryManager = RepositoryProvider.getRepositoryManager(rdf4jServerUrl); repository = repositoryManager.getRepository(repositoryName); if (repository == null) { - LOG.info("Creating new repository {} within rdf4j server {} ...", + log.info("Creating new repository {} within rdf4j server {} ...", rdf4jServerUrl, repositoryName); RepositoryConfig repConfig = new RepositoryConfig(repositoryName); SailRepositoryConfig config = new SailRepositoryConfig(new NativeStoreConfig()); @@ -34,13 +35,13 @@ public static void createRdf4RepositoryIfNotExist(String rdf4jServerUrl, String repository.initialize(); } catch (final RepositoryException | RDFParseException | RepositoryConfigException e) { - LOG.error(e.getMessage(), e); + log.error(e.getMessage(), e); } finally { if ((repository != null) && (repository.isInitialized())) { try { repository.shutDown(); } catch (RepositoryException e) { - LOG.error("During finally: ", e); + log.error("During finally: ", e); } } } diff --git a/s-pipes-core/src/test/java/cz/cvut/jena/OntDocumentManagerTest.java b/s-pipes-core/src/test/java/cz/cvut/jena/OntDocumentManagerTest.java index 548b9339..4367ecf7 100644 --- a/s-pipes-core/src/test/java/cz/cvut/jena/OntDocumentManagerTest.java +++ b/s-pipes-core/src/test/java/cz/cvut/jena/OntDocumentManagerTest.java @@ -1,6 +1,5 @@ package cz.cvut.jena; - import org.apache.jena.ontology.OntDocumentManager; import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModelSpec; diff --git a/s-pipes-forms/pom.xml b/s-pipes-forms/pom.xml index 588dff85..cd17197b 100644 --- a/s-pipes-forms/pom.xml +++ b/s-pipes-forms/pom.xml @@ -83,7 +83,6 @@ org.projectlombok - 1.18.30 lombok test diff --git a/s-pipes-modules/module-ckan2rdf/pom.xml b/s-pipes-modules/module-ckan2rdf/pom.xml index dc0622e9..f41ab7b0 100644 --- a/s-pipes-modules/module-ckan2rdf/pom.xml +++ b/s-pipes-modules/module-ckan2rdf/pom.xml @@ -48,6 +48,11 @@ junit-jupiter-api test + + org.projectlombok + lombok + provided + 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 4217489f..5615addc 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 @@ -19,6 +19,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; @@ -27,12 +29,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j @SPipesModule(label = "ckan2rdf-v1", comment = "Convert ckan to rdf.") 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/"; - private static final Logger LOG = LoggerFactory.getLogger(Ckan2RdfModule.class); @Parameter(urlPrefix = TYPE_URI + "/", name = "p-ckan-url", comment = "URL of the CKAN server.") private String propCkanApiUrl; @@ -83,7 +85,7 @@ private CkanDataset processDataset(EntityManager em, final String dataset, CkanC } catch (CkanException e) { executionContext.getDefaultModel().add(iDescriptionSub, ResourceFactory.createProperty( NS_DDO + "has-error-result"), e.getMessage()); - LOG.warn("{}: Problem during dataset fetch {}", dataset, e.getMessage(), e); + log.warn("{}: Problem during dataset fetch {}", dataset, e.getMessage(), e); } return null; } @@ -146,19 +148,19 @@ ExecutionContext executeSelf() { try { datasets = cc.getDatasetList(); } catch (CkanException e) { - LOG.warn("Problem during datasets fetch {}", e.getMessage(), e); + log.warn("Problem during datasets fetch {}", e.getMessage(), e); executionContext.getDefaultModel().add(iDescription, ResourceFactory.createProperty( NS_DDO + "has-error-result"), e.getMessage()); } int max = datasets.size(); for (final String dataset : datasets) { - LOG.info("Processing Dataset {} / {} - {}", i.incrementAndGet(), max, dataset); + log.info("Processing Dataset {} / {} - {}", i.incrementAndGet(), max, dataset); CkanDataset ckanDataset = processDataset(em, dataset, cc, iDescription, iDatasetSnapshot); if (ckanDataset != null) { catalog.getDatasets().add(ckanDataset); if (i.get() > maxDatasets) { - LOG.info("Breaking execution {} / {} ", i.get(), maxDatasets); + log.info("Breaking execution {} / {} ", i.get(), maxDatasets); break; } } @@ -172,11 +174,11 @@ ExecutionContext executeSelf() { } catch (CkanException e) { executionContext.getDefaultModel().add(iDescription, ResourceFactory.createProperty( NS_DDO + "has-error-result"), e.getMessage()); - LOG.warn("Problem during userlist fetch {}", e.getMessage(), e); + log.warn("Problem during userlist fetch {}", e.getMessage(), e); } max = userList.size(); for (final CkanUser user : userList) { - LOG.info("Processing User {} / {} - {}", i.incrementAndGet(), max, user.getId()); + log.info("Processing User {} / {} - {}", i.incrementAndGet(), max, user.getId()); processUser(em, user, cc, iDescription, iDatasetSnapshot); } 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 6d8e07a4..b1606d24 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 @@ -24,8 +24,6 @@ public class SparqlEndpointDatasetExplorerModule extends AnnotatedAbstractModule { public static final String TYPE_URI = KBSS_MODULE.uri + "sparqlEndpointDatasetExplorer-v1"; - private static final Logger LOG = - LoggerFactory.getLogger(SparqlEndpointDatasetExplorerModule.class); 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.") diff --git a/s-pipes-modules/module-dataset-discovery/pom.xml b/s-pipes-modules/module-dataset-discovery/pom.xml index caede77b..a68fb56a 100644 --- a/s-pipes-modules/module-dataset-discovery/pom.xml +++ b/s-pipes-modules/module-dataset-discovery/pom.xml @@ -29,6 +29,12 @@ junit-jupiter-api test + + + org.projectlombok + lombok + provided + \ No newline at end of file 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 bb21ca9f..e60c2a1d 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 @@ -12,6 +12,7 @@ import java.util.TimeZone; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryExecutionFactory; import org.apache.jena.query.QueryFactory; @@ -26,13 +27,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j @SPipesModule(label = "dataset discovery v1", comment = "Discovers dataset based on keyword userInput in repository linked.opendata.cz-federated-descriptor-faceted-search " + "hosted at http://onto.fel.cvut.cz/rdf4j-server.") public class DatasetDiscoveryModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(DatasetDiscoveryModule.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "dataset-discovery-v1"; private static final Property P_USER_INPUT = getParameter("prp-user-input"); @@ -65,10 +65,10 @@ ExecutionContext executeSelf() { userInput = executionContext.getVariablesBinding().getNode("prp-user-input").toString(); if (userInput == null) { - LOG.error("No userInput supplied, terminating"); + log.error("No userInput supplied, terminating"); return executionContext; } else { - LOG.info("[USER-QUERY] " + userInput); + log.info("[USER-QUERY] " + userInput); } final UserQuery q2 = UserQuery.parse(userInput); 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 7233e922..aee310d9 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 @@ -3,6 +3,7 @@ import cz.cvut.spipes.constants.KBSS_MODULE; import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.*; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Property; @@ -18,12 +19,11 @@ import java.util.Collections; import java.util.Optional; +@Slf4j @SPipesModule(label = "get dataset descriptors v1", comment = "Retrieve dataset descriptor for dataset" + " with dataset-iri in endpoint-url.") public class GetDatasetDescriptorsModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(GetDatasetDescriptorsModule.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "get-dataset-descriptors-v1"; private static final String PARAM_URI = TYPE_URI + "/"; @@ -57,10 +57,10 @@ ExecutionContext executeSelf() { prpDatasetIri = executionContext.getVariablesBinding().getNode("p-dataset-iri").toString(); if (prpDatasetIri == null) { - LOG.error("No dataset IRI supplied, terminating"); + log.error("No dataset IRI supplied, terminating"); return executionContext; } else { - LOG.info("[DATASET] " + prpDatasetIri); + log.info("[DATASET] " + prpDatasetIri); } final String queryString; diff --git a/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/UserQuery.java b/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/UserQuery.java index aa4fa982..37327420 100644 --- a/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/UserQuery.java +++ b/s-pipes-modules/module-dataset-discovery/src/main/java/cz/cvut/spipes/modules/UserQuery.java @@ -11,13 +11,13 @@ import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; + +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +@Slf4j public class UserQuery { - private static final Logger LOGGER = LoggerFactory.getLogger(UserQuery.class); - private static final Map DATE_FORMAT_REGEXPS; static { @@ -58,7 +58,7 @@ public static UserQuery parse(final String userInput) { isDate = true; break; } catch (ParseException e) { - LOGGER.warn(MessageFormat.format( + log.warn(MessageFormat.format( "Date/time format {} matched {}, yet parsing into a Date object failed.", format, keyword),e); } diff --git a/s-pipes-modules/module-eccairs/pom.xml b/s-pipes-modules/module-eccairs/pom.xml index 9f4b1ed5..7a8ea4ac 100644 --- a/s-pipes-modules/module-eccairs/pom.xml +++ b/s-pipes-modules/module-eccairs/pom.xml @@ -52,5 +52,10 @@ rdf4j-rio-rdfxml ${org.eclipse.rdf4j.version} + + org.projectlombok + lombok + provided + \ No newline at end of file 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 6b2fa24b..57eb85a3 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 @@ -22,24 +22,21 @@ import cz.cvut.spipes.registry.StreamResource; import cz.cvut.spipes.registry.StreamResourceRegistry; import cz.cvut.spipes.util.JenaUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.util.FileUtils; import org.eclipse.rdf4j.repository.Repository; import org.eclipse.rdf4j.repository.RepositoryException; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.URI; import java.util.Arrays; +@Slf4j @SPipesModule(label = "import e5x", comment = "Convert e5x xml files to rdf.") public class ImportE5XModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ImportE5XModule.class); - // 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.") @@ -67,31 +64,31 @@ ExecutionContext executeSelf() { try { if ("text/xml".equals(e5xResource.getContentType()) || "application/xml".equals(e5xResource.getContentType())) { - LOG.debug("File considered XML (Content Type: {})", e5xResource.getContentType()); - LOG.debug("- content length: {}, content (as string) : ", e5xResource.getContent().length, new String(e5xResource.getContent())); + log.debug("File considered XML (Content Type: {})", e5xResource.getContentType()); + log.debug("- content length: {}, content (as string) : ", e5xResource.getContent().length, new String(e5xResource.getContent())); // create factory to parse eccairs values final E5XXMLParser e5xXMLParser = new E5XXMLParser(eaf); e5xXMLParser.parseDocument(e5xResourceStream); r = e5xXMLParser.getReport(); } else if ("application/zip".equals(e5xResource.getContentType()) || "application/octet-stream".equals(e5xResource.getContentType()) || e5xResource.getContentType() == null || e5xResource.getContentType().isEmpty()) { - LOG.debug("File considered ZIP (Content Type: {})", e5xResource.getContentType()); - LOG.debug("- content length: {}, content (as byte array): {}",e5xResource.getContent().length, Arrays.toString(e5xResource.getContent())); + log.debug("File considered ZIP (Content Type: {})", e5xResource.getContentType()); + log.debug("- content length: {}, content (as byte array): {}",e5xResource.getContent().length, Arrays.toString(e5xResource.getContent())); // ZIP by default final E5XMLLoader loader = new E5XMLLoader(e5xResourceStream, eaf); - LOG.debug("- loader created based on resource stream name:{}, email:{}, stream:{}, closed: {}", e5xResourceStream.getName(), e5xResourceStream.getEmailId(), e5xResourceStream.getContent(), e5xResourceStream.isCloased()); + log.debug("- loader created based on resource stream name:{}, email:{}, stream:{}, closed: {}", e5xResourceStream.getName(), e5xResourceStream.getEmailId(), e5xResourceStream.getContent(), e5xResourceStream.isCloased()); EccairsReport[] s = loader.loadData().toArray(EccairsReport[]::new); - LOG.debug("- found {} reports", s.length); + log.debug("- found {} reports", s.length); if ( s.length > 0 ) { r = s[0]; } } else { - LOG.debug("Unsupported Content Type {}", e5xResource.getContentType()); + log.debug("Unsupported Content Type {}", e5xResource.getContentType()); return outputExecutionContext; } if ( r == null ) { - LOG.debug("No report parsed, terminating."); + log.debug("No report parsed, terminating."); return outputExecutionContext; } @@ -134,9 +131,9 @@ ExecutionContext executeSelf() { sesameRepo.getConnection().close(); sesameRepo.shutDown(); } catch (IOException e) { - LOG.warn("An exception occurred during report processing.", e); + log.warn("An exception occurred during report processing.", e); } catch (RepositoryException e) { - LOG.warn("Failed to close sesame repository connection", e); + log.warn("Failed to close sesame repository connection", e); } return outputExecutionContext; } diff --git a/s-pipes-modules/module-eccairs/src/main/java/cz/cvut/spipes/modules/eccairs/SesameDataDao.java b/s-pipes-modules/module-eccairs/src/main/java/cz/cvut/spipes/modules/eccairs/SesameDataDao.java index 826a72f7..6f4f1531 100644 --- a/s-pipes-modules/module-eccairs/src/main/java/cz/cvut/spipes/modules/eccairs/SesameDataDao.java +++ b/s-pipes-modules/module-eccairs/src/main/java/cz/cvut/spipes/modules/eccairs/SesameDataDao.java @@ -1,5 +1,6 @@ package cz.cvut.spipes.modules.eccairs; +import lombok.extern.slf4j.Slf4j; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.repository.Repository; import org.eclipse.rdf4j.repository.RepositoryConnection; @@ -14,15 +15,9 @@ import java.io.ByteArrayOutputStream; import java.net.URI; - +@Slf4j public class SesameDataDao { - private static final Logger LOG = LoggerFactory.getLogger(SesameDataDao.class); - - - - - /** * Gets raw content of the repository. Use null for contextUri to get whole content of the repository. *

@@ -57,7 +52,7 @@ private static void getRepositoryData(Repository sesameRepository, URI contextUr connection.close(); } } catch (RepositoryException | RDFHandlerException e) { - LOG.error("Unable to read data from repository.", e); + log.error("Unable to read data from repository.", e); } } } diff --git a/s-pipes-modules/module-form/pom.xml b/s-pipes-modules/module-form/pom.xml index 983dff29..a5b8184d 100644 --- a/s-pipes-modules/module-form/pom.xml +++ b/s-pipes-modules/module-form/pom.xml @@ -82,5 +82,10 @@ ${project.version} test + + org.projectlombok + lombok + provided + \ No newline at end of file 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 b8d4ce41..0b7d3a76 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 @@ -5,25 +5,22 @@ import cz.cvut.spipes.constants.SML; import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.apache.jena.rdf.model.*; import org.apache.jena.vocabulary.RDF; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.LinkedList; import java.util.List; import static cz.cvut.spipes.form.JenaFormUtils.getAnswerOrigin; import static cz.cvut.spipes.form.JenaFormUtils.getQuestionOrigin; +@Slf4j @SPipesModule(label = "construct form metadata", comment = "Compute form:has-origin-path and form:has-origin-path-id properties.") public class ConstructFormMetadataModule extends AnnotatedAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ConstructFormMetadataModule.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "construct-form-metadata"; private static final String PATH_SEPARATOR = ","; private static final String INSTANCE_TYPE_SEPARATOR = "|"; @@ -55,9 +52,9 @@ ExecutionContext executeSelf() { List rootQuestions = getRootQuestions(inpModel); - LOG.debug("Found {} root questions.", rootQuestions.size()); - if (LOG.isTraceEnabled()) { - LOG.trace("Found root questions: {}", rootQuestions); + log.debug("Found {} root questions.", rootQuestions.size()); + if (log.isTraceEnabled()) { + log.trace("Found root questions: {}", rootQuestions); } Model constructedModel = ModelFactory.createDefaultModel(); 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 bceeb6fd..fc6168ef 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 @@ -13,6 +13,7 @@ import cz.cvut.spipes.form.JenaFormUtils; import cz.cvut.spipes.form.JopaPersistenceUtils; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; @@ -22,14 +23,13 @@ import java.util.List; import java.util.function.Predicate; +@Slf4j @SPipesModule(label = "construct textual view", comment = "For input Q&A models constructs textual view of specified questions. Each textual" + " view represent the question and its sub-questions recursively." ) public class ConstructTextualViewModule extends AnnotatedAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ConstructTextualViewModule.class); - 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.") @@ -62,9 +62,9 @@ ExecutionContext executeSelf() { List questions = getQuestions(inpModel, isProcessNonRootQuestions); - LOG.debug("Found {} questions.", questions.size()); - if (LOG.isTraceEnabled()) { - LOG.trace("Found questions: {}", questions); + log.debug("Found {} questions.", questions.size()); + if (log.isTraceEnabled()) { + log.trace("Found questions: {}", questions); } Model constructedModel = ModelFactory.createDefaultModel(); 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 c88501e1..3d3012c0 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 @@ -7,22 +7,20 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.form.JenaFormUtils; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.HashMap; import java.util.Map; +@Slf4j @SPipesModule(label = "fetch possible values", comment = "Fetches possible values for answers of questions. Inputs are forms using Q&A model. Possible values of " + "questions are added to questions that does not have any value attached and contains possible value query." ) 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" + @@ -50,11 +48,11 @@ ExecutionContext executeSelf() { PossibleValuesQueryProcessor qProcessor = query2possibleValue.get(possibleValuesQuery); if (qProcessor == null) { qProcessor = new PossibleValuesQueryProcessor(possibleValuesQuery); - LOG.debug("Retrieved {} new possible values for question {}.", + log.debug("Retrieved {} new possible values for question {}.", qProcessor.getPossibleValuesCount(), q.getURI()); query2possibleValue.put(possibleValuesQuery, qProcessor); } else { - LOG.debug("Using cache of {} possible values for question {}.", + log.debug("Using cache of {} possible values for question {}.", qProcessor.getPossibleValuesCount(), q.getURI()); } qProcessor.addQuestion(q); 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 c70b3b07..d7a52c6f 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 @@ -7,15 +7,14 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.form.JenaFormUtils; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.util.ResourceUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.Random; +@Slf4j @SPipesModule(label = "merge form metadata", comment = "Merges form metadata. Inputs are sample form and Q&A model. Questions from both models are remapped to new" + " IRIs based on question origin combined with executionId. New question instances are created using" + @@ -23,7 +22,6 @@ ) public class MergeFormMetadataModule extends AnnotatedAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(MergeFormMetadataModule.class); private static final Random RANDOM = new Random(); private static final String TYPE_URI = KBSS_MODULE.uri + "merge-form-metadata"; @@ -64,8 +62,8 @@ ExecutionContext executeSelf() { .replace(QUESTION_ORIGIN_HASH_VAR, originHash) .replace(EXECUTION_ID_VAR, executionId); if (!q.getURI().equals(newQuestionUrl)) { - if (LOG.isTraceEnabled()) { - LOG.trace("Renaming questions {} -> {}", q, newQuestionUrl); + if (log.isTraceEnabled()) { + log.trace("Renaming questions {} -> {}", q, newQuestionUrl); } ResourceUtils.renameResource(q, newQuestionUrl); } diff --git a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/PossibleValuesQueryProcessor.java b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/PossibleValuesQueryProcessor.java index d6f675ba..374d09e7 100644 --- a/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/PossibleValuesQueryProcessor.java +++ b/s-pipes-modules/module-form/src/main/java/cz/cvut/spipes/modules/PossibleValuesQueryProcessor.java @@ -1,11 +1,10 @@ package cz.cvut.spipes.modules; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; import org.apache.jena.util.FileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -19,9 +18,9 @@ import java.util.LinkedList; import java.util.List; +@Slf4j class PossibleValuesQueryProcessor { - private static final Logger LOG = LoggerFactory.getLogger(PossibleValuesQueryProcessor.class); String possibleValuesQuery; String retrievedPossibleValues; Model possibleValuesModel; @@ -49,7 +48,7 @@ private String fetchPossibleValues(String possibleValueQuery) { String.class); return result.getBody(); } catch (Exception e) { - LOG.error("Error when requesting remote data, url: {}.", urlWithQuery, e); + log.error("Error when requesting remote data, url: {}.", urlWithQuery, e); } return null; } diff --git a/s-pipes-modules/module-nlp/pom.xml b/s-pipes-modules/module-nlp/pom.xml index 4b388f31..116360c3 100644 --- a/s-pipes-modules/module-nlp/pom.xml +++ b/s-pipes-modules/module-nlp/pom.xml @@ -62,6 +62,11 @@ 0.4.0 test + + org.projectlombok + lombok + provided + 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 dd7b1e16..2395d264 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 @@ -19,6 +19,7 @@ import java.time.format.DateTimeFormatter; import java.util.*; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.*; import org.apache.jena.vocabulary.RDF; import org.slf4j.Logger; @@ -27,12 +28,10 @@ import java.nio.file.Path; import java.nio.file.Paths; - +@Slf4j @SPipesModule(label = "temporal v0.1", comment = "Annotate temporal expressions in literals in input model.") public class SUTimeModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(SUTimeModule.class); - public static final String TYPE_URI = KBSS_MODULE.getURI() + "temporal-v0.1"; @Parameter(urlPrefix = DescriptorModel.prefix, name = "has-rule-file", comment = "Rule file, multivalued.") // TODO - revise comment @@ -173,10 +172,10 @@ private ArrayList temporalAnalysis(AnnotationPipeline pipeline, Str afm = new AnnforModel(beginDateforModel, endDateforModel, typeDateforModel, extractionDateforModel); } catch (NullPointerException e) { - LOG.info("catched in temporalAnalyze " + e.getMessage()); + log.info("catched in temporalAnalyze " + e.getMessage()); } catch (ParseException e) { - LOG.info("catched in parse exception " + e.getMessage()); + log.info("catched in parse exception " + e.getMessage()); } afmArr = new ArrayList<>(); afmArr.add(afm); 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 605880da..35dd2e1a 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 @@ -15,6 +15,7 @@ import edu.stanford.nlp.time.TimeAnnotator; import edu.stanford.nlp.time.TimeExpression; import edu.stanford.nlp.util.CoreMap; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.Query; import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QuerySolution; @@ -33,12 +34,10 @@ import java.text.SimpleDateFormat; import java.util.*; - +@Slf4j @SPipesModule(label = "temporal-v1", comment = "Module annotates input triples using NLP analysis of time using library SUTime.") public class SUTimeModuleNew extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(SUTimeModuleNew.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "temporal-v1"; private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final int DEFAULT_PAGE_SIZE = 10000; @@ -158,7 +157,7 @@ public ExecutionContext executeSelf() { private Model analyzeModel(Model m) { - LOG.debug("Extracting temporal information from model of size {}", m.size()); + log.debug("Extracting temporal information from model of size {}", m.size()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); List temporalAnnotationStmts = new LinkedList<>(); m.listStatements() @@ -260,10 +259,10 @@ private ArrayList temporalAnalysis(AnnotationPipeline pipeline, Str afm = new AnnforModel(beginDateforModel, endDateforModel, typeDateforModel, extractionDateforModel); } catch (NullPointerException e) { - LOG.info("catched in temporalAnalyze " + e.getMessage()); + log.info("catched in temporalAnalyze " + e.getMessage()); } catch (ParseException e) { - LOG.info("catched in parse exception " + e.getMessage()); + log.info("catched in parse exception " + e.getMessage()); } afmArr = new ArrayList<>(); afmArr.add(afm); @@ -290,7 +289,7 @@ private AnnotationPipeline loadPipeline() { private String substituteQueryMarkers(int currentIteration, String queryStr) { int offset = pageSize * (currentIteration - 1); - LOG.debug("Creating query with LIMIT {} for OFFSET {}.", pageSize, offset); + log.debug("Creating query with LIMIT {} for OFFSET {}.", pageSize, offset); String markerValue = "\n" + "OFFSET " + offset + "\n" + "LIMIT " + pageSize + "\n"; diff --git a/s-pipes-modules/module-rdf4j/pom.xml b/s-pipes-modules/module-rdf4j/pom.xml index f8920ff7..8ef2d0d5 100644 --- a/s-pipes-modules/module-rdf4j/pom.xml +++ b/s-pipes-modules/module-rdf4j/pom.xml @@ -55,6 +55,12 @@ test + + org.projectlombok + lombok + provided + + 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 8faf53fe..f8f9ef0c 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 @@ -4,6 +4,7 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.exceptions.RepositoryAlreadyExistsException; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; import org.eclipse.rdf4j.repository.config.RepositoryConfig; @@ -11,14 +12,12 @@ import org.eclipse.rdf4j.repository.manager.RepositoryManager; import org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig; import org.eclipse.rdf4j.sail.nativerdf.config.NativeStoreConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Objects; +@Slf4j @SPipesModule(label = "rdf4j create repository", comment = "Module creates native store rdf4j repository on the given server with the given name.") public class Rdf4jCreateRepositoryModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(Rdf4jCreateRepositoryModule.class.getName()); private static final String TYPE_URI = KBSS_MODULE.uri + "rdf4j-create-repository"; private static final String PROPERTY_PREFIX_URI = KBSS_MODULE.uri + "rdf4j"; @@ -77,14 +76,14 @@ ExecutionContext executeSelf() { SailRepositoryConfig sailRepositoryConfig = new SailRepositoryConfig(nativeStoreConfig); repositoryManager.init(); - LOG.info("Server url:{}, Repsitory name:{}, Ignore if repository exist:{}.", + log.info("Server url:{}, Repsitory name:{}, Ignore if repository exist:{}.", rdf4jServerURL, rdf4jRepositoryName, rdf4jIgnoreIfExists); if((!rdf4jIgnoreIfExists) && repositoryManager.hasRepositoryConfig(rdf4jRepositoryName)){ - LOG.info("Repository \"{}\" already exists", + log.info("Repository \"{}\" already exists", rdf4jRepositoryName); throw new RepositoryAlreadyExistsException(rdf4jRepositoryName); } 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 1aed700f..01e8d597 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 @@ -6,6 +6,7 @@ import cz.cvut.spipes.exception.ModuleConfigurationInconsistentException; import cz.cvut.spipes.modules.annotations.SPipesModule; import cz.cvut.spipes.util.CoreConfigProperies; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.Dataset; import org.apache.jena.query.DatasetFactory; import org.apache.jena.rdf.model.Model; @@ -27,9 +28,6 @@ import org.eclipse.rdf4j.rio.RDFParseException; import org.eclipse.rdf4j.sail.nativerdf.config.NativeStoreConfig; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import javax.annotation.Nullable; import java.io.IOException; import java.io.StringReader; @@ -37,14 +35,13 @@ import java.util.ArrayList; import java.util.Optional; +@Slf4j @SPipesModule(label = "deploy", comment = "Module deploys content of input execution context into default context of repository (if p-rdf4j-context-iri " + "is not specified) or concrete context (if p-rdf4j-context-iri is specified)." ) public class Rdf4jDeployModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(Rdf4jDeployModule.class); - private final static String TYPE_URI = KBSS_MODULE.uri + "deploy"; private final static String PROPERTY_PREFIX_URI = KBSS_MODULE.uri + "rdf4j"; @@ -128,7 +125,7 @@ public void setReplaceContext(boolean replaceContext) { @Override ExecutionContext executeSelf() { - LOG.debug("Deploying data into {} of rdf4j server repository {}/{}.", + log.debug("Deploying data into {} of rdf4j server repository {}/{}.", getContextsInfo(), rdf4jServerURL, rdf4jRepositoryName); @@ -136,7 +133,7 @@ ExecutionContext executeSelf() { try { if (repository == null) { - LOG.info("Creating new repository {} within rdf4j server {} ...", + log.info("Creating new repository {} within rdf4j server {} ...", rdf4jServerURL, rdf4jRepositoryName); RepositoryConfig repConfig = new RepositoryConfig(rdf4jRepositoryName); SailRepositoryConfig config = new SailRepositoryConfig(new NativeStoreConfig()); @@ -148,7 +145,7 @@ ExecutionContext executeSelf() { Dataset dataset = createDataset(executionContext.getDefaultModel(), rdf4jContextIRI, inferContextIRIs); if (dataset.isEmpty()) { - LOG.info("No triples found to deploy."); + log.info("No triples found to deploy."); return ExecutionContextFactory.createContext(executionContext.getDefaultModel()); } @@ -171,20 +168,20 @@ ExecutionContext executeSelf() { connection.add(new StringReader(w.getBuffer().toString()), "", RDFFormat.NQUADS); connection.commit(); } catch (final RepositoryException | RDFParseException | RepositoryConfigException | IOException e) { - LOG.error(e.getMessage(),e); + log.error(e.getMessage(),e); } finally { try { if (connection != null && connection.isOpen()) { connection.close(); } } catch (RepositoryException e) { - LOG.error(e.getMessage(), e); + log.error(e.getMessage(), e); } finally { if ((repository != null) && (repository.isInitialized())) { try { repository.shutDown(); } catch (RepositoryException e) { - LOG.error("During finally: ", e); + log.error("During finally: ", e); } } } @@ -206,7 +203,7 @@ ExecutionContext executeSelf() { static Dataset createDataset(@NotNull Model model, String outputGraphId, boolean inferGraphsFromAnnotatedModel) { boolean isOutputGraphSpecified = (outputGraphId != null) && (!outputGraphId.isEmpty()); if (isOutputGraphSpecified && inferGraphsFromAnnotatedModel) { - LOG.error("Module is set to deploy in one context as well as infer contexts from annotated model. " + + log.error("Module is set to deploy in one context as well as infer contexts from annotated model. " + "Thus, ignoring deploy of triples."); return DatasetFactory.create(); } @@ -267,7 +264,7 @@ public void loadConfiguration() { } repository = repositoryManager.getRepository(rdf4jRepositoryName); inferContextIRIs = getPropertyValue(P_RDF4J_INFER_CONTEXT_IRIS,false); - LOG.debug("Inferring contexts from annotated input triples."); + log.debug("Inferring contexts from annotated input triples."); } private static @Nullable String getConfigurationVariable(String variableName) { if (variableName == null) { 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 141d0954..794d3c6c 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 @@ -7,6 +7,7 @@ import cz.cvut.spipes.exceptions.RepositoryAccessException; import cz.cvut.spipes.modules.annotations.SPipesModule; import cz.cvut.spipes.util.QueryUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; @@ -20,18 +21,16 @@ import org.eclipse.rdf4j.repository.RepositoryConnection; import org.eclipse.rdf4j.repository.RepositoryException; import org.eclipse.rdf4j.repository.sparql.SPARQLRepository; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.topbraid.spin.vocabulary.SP; import java.util.List; import java.util.stream.Collectors; +@Slf4j @SPipesModule(label = "rdf4j update", comment = "Updates sparql endpoint configured in rdf4jServerURL" + " using specified list updateQueries. The list of queries can be executed multiple times specified by " + " `has-max-iteration-count` property.") public class Rdf4jUpdateModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(Rdf4jUpdateModule.class.getName()); private static final String TYPE_URI = KBSS_MODULE.uri + "rdf4j-update"; private static final String PROPERTY_PREFIX_URI = KBSS_MODULE.uri + "rdf4j"; @@ -125,19 +124,19 @@ private static Property getParameter(final String name) { @Override ExecutionContext executeSelf() { try (RepositoryConnection updateConnection = updateRepository.getConnection()) { - LOG.debug("Connected to {}", rdf4jRepositoryName); + log.debug("Connected to {}", rdf4jRepositoryName); long newTriplesCount = updateConnection.size(); long oldTriplesCount; - LOG.debug("Number of triples before execution of updates: {}", newTriplesCount); + log.debug("Number of triples before execution of updates: {}", newTriplesCount); for(int i = 0;i < iterationCount; i++) { oldTriplesCount = newTriplesCount; for (int j = 0; j < updateQueries.size(); j++) { String updateQuery = updateQueries.get(j); - if (LOG.isTraceEnabled()) { + if (log.isTraceEnabled()) { String queryComment = QueryUtils.getQueryComment(updateQuery); - LOG.trace( + log.trace( "Executing iteration {}/{} with {}/{} query \"{}\" ...", i+1, iterationCount, j + 1, updateQueries.size(), queryComment ); @@ -145,11 +144,11 @@ ExecutionContext executeSelf() { makeUpdate(updateQuery, updateConnection); } newTriplesCount = updateConnection.size(); - LOG.debug("Number of triples after finishing iteration {}/{}: {}", + log.debug("Number of triples after finishing iteration {}/{}: {}", i+1, iterationCount, newTriplesCount ); if (onlyIfTripleCountChanges && (newTriplesCount == oldTriplesCount)) { - LOG.debug("Stopping execution of iterations as triples count did not change."); + log.debug("Stopping execution of iterations as triples count did not change."); break; } } @@ -165,20 +164,20 @@ void makeUpdate(String updateString, RepositoryConnection updateConnection) { try { prepareUpdate = updateConnection.prepareUpdate(QueryLanguage.SPARQL, updateString); } catch (MalformedQueryException e) { - LOG.error("Malformed Query, query text:\n{}", + log.error("Malformed Query, query text:\n{}", updateString); return; } catch (RepositoryException e) { - LOG.error("Repository exception\n{}", + log.error("Repository exception\n{}", e.getMessage()); return; } try { assert prepareUpdate != null; prepareUpdate.execute(); - LOG.debug("Update successful"); + log.debug("Update successful"); } catch (UpdateExecutionException e) { - LOG.error("Update execution exception, query text:\n{}\n{}", + log.error("Update execution exception, query text:\n{}\n{}", updateString, e.getMessage()); } @@ -195,7 +194,7 @@ public void loadConfiguration() { rdf4jRepositoryName = getEffectiveValue(P_RDF4J_REPOSITORY_NAME).asLiteral().getString(); iterationCount = getPropertyValue(KBSS_MODULE.has_max_iteration_count,1); onlyIfTripleCountChanges = getPropertyValue(P_RDF4J_STOP_ITERATION_ON_STABLE_TRIPLE_COUNT,false); - LOG.debug("Iteration count={}\nOnlyIf...Changes={}" + log.debug("Iteration count={}\nOnlyIf...Changes={}" ,iterationCount ,onlyIfTripleCountChanges); if (updateRepository != null && rdf4jServerURL != null) { diff --git a/s-pipes-modules/module-sparql-endpoint/pom.xml b/s-pipes-modules/module-sparql-endpoint/pom.xml index 12baa73c..9a52eaac 100644 --- a/s-pipes-modules/module-sparql-endpoint/pom.xml +++ b/s-pipes-modules/module-sparql-endpoint/pom.xml @@ -25,6 +25,12 @@ ${org.apache.jena} + + org.projectlombok + lombok + provided + + org.junit.jupiter diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/ModelLogger.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/ModelLogger.java index 6d2ea028..39c0a383 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/ModelLogger.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/ModelLogger.java @@ -3,14 +3,15 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.util.FileUtils; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j public class ModelLogger { - private static final Logger LOG = LoggerFactory.getLogger(ModelLogger.class); private Logger classLogger; private String logDirectoryPrefix = ""; private Path logDirectory; @@ -28,7 +29,7 @@ public void trace(String modelId, Model model) { classLogger.trace("Saving model with id " + modelId + " to " + filePath); model.write(Files.newOutputStream(filePath), FileUtils.langTurtle); } catch (IOException e) { - LOG.warn("Unnable to save model to " + filePath); + log.warn("Unnable to save model to " + filePath); } } } @@ -39,7 +40,7 @@ private Path getLogDirectory() { logDirectory = Files.createTempDirectory(logDirectoryPrefix); } } catch (IOException e) { - LOG.warn("Unnable to create temporary directory with prefix " + logDirectoryPrefix); + log.warn("Unnable to create temporary directory with prefix " + logDirectoryPrefix); } return logDirectory; } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/impl/GraphChunkedDownload.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/impl/GraphChunkedDownload.java index 95e0a1a1..c46b44c6 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/impl/GraphChunkedDownload.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/impl/GraphChunkedDownload.java @@ -1,13 +1,12 @@ package cz.cvut.spipes.impl; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.QueryExecutionFactory; import org.apache.jena.rdf.model.Model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +@Slf4j public abstract class GraphChunkedDownload { - - private static final Logger LOG = LoggerFactory.getLogger(GraphChunkedDownload.class); private static final int DEFAULT_PAGE_SIZE = 10000; @@ -34,7 +33,7 @@ public GraphChunkedDownload(String endpointUrl, String namedGrapheId, int pageSi public void execute() { long offset = 0; while (true) { - LOG.debug("Executing query for offset: {}", offset); + log.debug("Executing query for offset: {}", offset); String query = prepareQuery(offset); Model model = executeQuery(query); if (model.isEmpty()) { 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 0f20bd16..01144dcc 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 @@ -5,14 +5,13 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.util.JenaUtils; import cz.cvut.spipes.util.QueryUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.Query; import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QuerySolution; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Construct; import org.topbraid.spin.system.SPINModuleRegistry; @@ -20,9 +19,9 @@ import java.util.List; +@Slf4j public abstract class ApplyConstructAbstractModule extends AnnotatedAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ApplyConstructAbstractModule.class); private static final String TYPE_URI = KBSS_MODULE.uri + "abstract-apply-construct"; private static final String PROPERTY_PREFIX_URI = KBSS_MODULE.uri + ""; //sml:constructQuery @@ -181,7 +180,7 @@ public void loadConfiguration() { // TODO does not work with string query as object is not RDF resource ??? constructQueries = getResourcesByProperty(SML.constructQuery); - LOG.debug("Loaded {} spin construct queries.", constructQueries.size()); + log.debug("Loaded {} spin construct queries.", constructQueries.size()); //TODO default value must be taken from template definition isReplace = this.getPropertyValue(SML.replace, false); 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 5d34f56c..adffba66 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 @@ -11,8 +11,6 @@ @SPipesModule(label = "apply construct v2", comment = "Generates triples from input model using specified constructQueries.") public class ApplyConstructV2Module extends ApplyConstructAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ApplyConstructV2Module.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "apply-construct-v2"; @Override 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 09f92abb..b77322b9 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 @@ -9,6 +9,7 @@ import cz.cvut.spipes.recursion.QueryTemplateRecursionProvider; 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; @@ -18,8 +19,6 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Select; @@ -28,11 +27,10 @@ * TODO issue with redundant call {@link ScrollableCursorProvider} * TODO supports only one CONSTRUCT query */ +@Slf4j @SPipesModule(label = "apply construct with chunked values and scrollable cursor", comment = "Apply construct with chunked values and scrollable cursor") public class ApplyConstructWithChunkedValuesAndScrollableCursorModule extends ApplyConstructAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ApplyConstructWithChunkedValuesAndScrollableCursorModule.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "apply-construct-with-chunked-values-and-scrollable-cursor"; private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final int DEFAULT_CHUNK_SIZE = 10; @@ -81,14 +79,14 @@ private ResultSet getSelectQueryResultSet() { QueryExecution execution = QueryExecutionFactory.create(query, executionContext.getDefaultModel(), inputBindings); - LOG.debug("Executing query of chunk provider ..."); + log.debug("Executing query of chunk provider ..."); ResultSet selectResultSet = execution.execSelect(); VariablesBinding variablesBinding = new VariablesBinding(); if (!selectResultSet.hasNext()) { - LOG.debug("\"{}\" query did not return any values.", getLabel()); + log.debug("\"{}\" query did not return any values.", getLabel()); } return selectResultSet; } 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 d505afad..b94efd06 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 @@ -6,6 +6,8 @@ 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; @@ -15,19 +17,16 @@ import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Select; /** * TODO Order of queries is not enforced. */ +@Slf4j @SPipesModule(label = "apply construct with chunked values", comment = "Apply construct with chunked values.") public class ApplyConstructWithChunkedValuesModule extends ApplyConstructAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ApplyConstructWithChunkedValuesModule.class); - private static final String TYPE_URI = KBSS_MODULE.uri + ""; private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final int DEFAULT_CHUNK_SIZE = 10; @@ -72,14 +71,14 @@ public void initializeQuery() { QueryExecution execution = QueryExecutionFactory.create(query, executionContext.getDefaultModel(), inputBindings); - LOG.debug("Executing query of chunk provider ..."); + log.debug("Executing query of chunk provider ..."); selectResultSet = execution.execSelect(); VariablesBinding variablesBinding = new VariablesBinding(); if (! selectResultSet.hasNext()) { - LOG.debug("\"{}\" query did not return any values.", getLabel()); + log.debug("\"{}\" query did not return any values.", getLabel()); } } @@ -109,7 +108,7 @@ protected String substituteQueryMarkers(int currentIteration, String queryStr) { String markerValue = QueryUtils.nextResultsToValuesClause(getCurrentResultSetInstance(), chunkSize); - LOG.debug("Creating query with values clause: \n{}.", markerValue ); + log.debug("Creating query with values clause: \n{}.", markerValue ); return QueryUtils .substituteMarkers(VALUES_CLAUSE_MARKER_NAME, 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 bf6754f5..79ed2a6c 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 @@ -3,15 +3,15 @@ import cz.cvut.spipes.constants.KBSS_MODULE; import cz.cvut.spipes.modules.annotations.SPipesModule; import cz.cvut.spipes.util.QueryUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * TODO Order of queries is not enforced. */ +@Slf4j @SPipesModule(label = "apply construct with scrollable cursor", comment = "Runs one or more construct queries (bound to sml:constructQuery) on the input triples. Queries are " + "executed multiple times with scrollable cursor that is injected through query marker #${LIMIT_OFFSET}. " + @@ -20,8 +20,6 @@ "the input triples.") public class ApplyConstructWithScrollableCursorModule extends ApplyConstructAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ApplyConstructWithScrollableCursorModule.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "apply-construct-with-scrollable-cursor"; private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final int DEFAULT_PAGE_SIZE = 10000; @@ -68,7 +66,7 @@ protected boolean shouldTerminate(int currentIteration, Model previousInferredMo protected String substituteQueryMarkers(int currentIteration, String queryStr) { int offset = pageSize * (currentIteration - 1); - LOG.debug("Creating query with LIMIT {} for OFFSET {}.", pageSize, offset ); + log.debug("Creating query with LIMIT {} for OFFSET {}.", pageSize, offset ); String markerValue = "\n" + "OFFSET " + offset + "\n" + "LIMIT " + pageSize + "\n"; 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 587473b5..04bcb835 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 @@ -12,20 +12,18 @@ import java.nio.file.Path; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFDataMgr; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +@Slf4j @SPipesModule(label = "sparql endpoint download graph", comment = "Downloads named graph namedGraphId from sparql endpoint endpointUrl.") public class DownloadGraphModule extends AnnotatedAbstractModule { private static final String TYPE_URI = KBSS_MODULE.uri + "sparql-endpoint-download-graph"; private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final int DEFAULT_PAGE_SIZE = 10000; - private static final Logger LOG = LoggerFactory.getLogger(DownloadGraphModule.class); @Parameter(urlPrefix = TYPE_PREFIX, name = "named-graph-id", comment = "Named graph id") private String namedGraphId; @@ -96,7 +94,7 @@ ExecutionContext executeSelf() { @Override protected void processPartialModel(Model partialModel) { numberOfDownloadedTriples += partialModel.size(); - LOG.trace("persisting partial download, {} triples from (<{}>,<{}>)", + log.trace("persisting partial download, {} triples from (<{}>,<{}>)", partialModel.size(), endpointUrl, namedGraphId); RDFDataMgr.write(os, partialModel, Lang.NTRIPLES); } @@ -120,7 +118,7 @@ private Path createTempFile() { Path file; try { file = Files.createTempFile("downloaded-graph-", ".nt"); - LOG.trace("persisting downloaded graph (<{}>,<{}>), to file \"{}\"", endpointUrl, namedGraphId, file.toString()); + log.trace("persisting downloaded graph (<{}>,<{}>), to file \"{}\"", endpointUrl, namedGraphId, file.toString()); } catch (IOException e) { throw new RuntimeException("Could not create temporary file.", e); } 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 626c6457..a8946413 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 @@ -22,6 +22,8 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.Query; import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QueryParseException; @@ -35,12 +37,11 @@ import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.util.FileUtils; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * TODO Order of queries is not enforced. */ +@Slf4j @SPipesModule(label = "improve spo with marginals", comment = "Constructs improved spo-summary descriptor with knowledge " + "of provided marginals of weakly described resources. This module expects as an input graph computed spo-summary " + "patterns (or possibly whole spo-summary descriptor) compliant with data provided in ?data-service-url. Within the " + @@ -50,8 +51,6 @@ "knowledge of marginals.") public class ImproveSPOWithMarginalsModule extends AnnotatedAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ImproveSPOWithMarginalsModule.class); - private static final String MODULE_ID = "improve-spo-with-marginals"; private static final String TYPE_URI = KBSS_MODULE.uri + MODULE_ID; private static final String TYPE_PREFIX = TYPE_URI + "/"; @@ -89,21 +88,21 @@ private static Model loadModelFromTemporaryFile(String fileName) { @Override ExecutionContext executeSelf() { - final ModelLogger mLOG = new ModelLogger(MODULE_ID, LOG); + final ModelLogger mLOG = new ModelLogger(MODULE_ID, log); final Model inputModel = executionContext.getDefaultModel(); final VariablesBinding inputVB = executionContext.getVariablesBinding(); - LOG.debug("Retrieving relevant snapshots ..."); + log.debug("Retrieving relevant snapshots ..."); // TODO it should be taken from parameter somehow Model relevantSnapshotsModel = retrieveRelevantSnapshots(executionContext.getVariablesBinding()); mLOG.trace("relevant-snapshots", relevantSnapshotsModel); - LOG.debug("Loading marginals ..."); + log.debug("Loading marginals ..."); Model marginalsModel = loadModelFromFile(marginalsFileUrl); mLOG.trace("marginals", marginalsModel); - LOG.debug("Loading marginal definitions ..."); + log.debug("Loading marginal definitions ..."); Model marginalDefsModel = loadModelFromFile(marginalsDefsFileUrl); mLOG.trace("marginal-defs", marginalDefsModel); @@ -211,13 +210,13 @@ private Model getPatternData(ResultSet breakablePatternsRS, String spoPatternDat // substitute values String valuesStr = QueryUtils.nextResultsToValuesClause(breakablePatternsRS, 1); - LOG.debug("Executing query to download patterns data with values: \n{}", valuesStr); + log.debug("Executing query to download patterns data with values: \n{}", valuesStr); String patternDataQueryStr = QueryUtils.substituteMarkers("VALUES", valuesStr, spoPatternDataQueryTemplate); Query patternDataQuery = parseQuery(patternDataQueryStr); VariablesBinding variablesBinding = new VariablesBinding("dataServiceUrl", ResourceFactory.createResource(dataServiceUrl)); - LOG.trace("Pattern data query:\n" + patternDataQueryStr); - LOG.trace("Variables bindings:" + variablesBinding); + log.trace("Pattern data query:\n" + patternDataQueryStr); + log.trace("Variables bindings:" + variablesBinding); Model patternDataModel = TDBTempFactory.createTDBModel(); patternDataModel = QueryUtils.execConstruct(// TODO !? implement scrollable cursor patternDataQuery, @@ -229,7 +228,7 @@ private Model getPatternData(ResultSet breakablePatternsRS, String spoPatternDat private Model computeSPOWithWeight(Model spoPatternDataWithMarginalsModel, VariablesBinding variablesBinding) { - LOG.debug("Computing SPO with weight for pattern data with marginals ..."); + log.debug("Computing SPO with weight for pattern data with marginals ..."); Model spoModel = QueryUtils.execConstruct( loadQueryFromFile("/compute-spo-with-weight.rq"), spoPatternDataWithMarginalsModel, @@ -239,7 +238,7 @@ private Model computeSPOWithWeight(Model spoPatternDataWithMarginalsModel, Varia } private Model computeSPOWithSnapshots(Model spoPatternDataWithMarginalsModel, VariablesBinding variablesBinding) { - LOG.debug("Computing SPO with snapshots for pattern data with marginals ..."); + log.debug("Computing SPO with snapshots for pattern data with marginals ..."); Model spoModel = QueryUtils.execConstruct( loadQueryFromFile("/compute-spo-with-snapshots.rq"), spoPatternDataWithMarginalsModel, @@ -249,7 +248,7 @@ private Model computeSPOWithSnapshots(Model spoPatternDataWithMarginalsModel, Va } private Model computeMarginalTypesModel(Model patternDataModel, Model marginalWithDefsModel) { - LOG.debug("Executing query to get typed marginals ..."); + log.debug("Executing query to get typed marginals ..."); Model marginalTypesModel = QueryUtils.execConstruct( loadQueryFromFile("/get-marginal-types.rq"), ModelFactory.createUnion(patternDataModel, marginalWithDefsModel), @@ -312,7 +311,7 @@ private Model loadModelFromFile(String marginalsFilePath) { cachedModel.read(marginalsFilePath); marginalDefsModelCache.put(key, cachedModel); } else { - LOG.debug("Using cached model of file {}", marginalsFilePath); + log.debug("Using cached model of file {}", marginalsFilePath); } return cachedModel; } @@ -321,7 +320,7 @@ private String computeFileContentHashKey(String filePath) { try { return filePath + " -- " + Files.getLastModifiedTime(Paths.get(URI.create(filePath))).toMillis(); } catch (IOException e) { - LOG.warn("Could not access file from path " + filePath + ": " + e); + log.warn("Could not access file from path " + filePath + ": " + e); throw new IllegalArgumentException("Could not access modification time of file from path " + filePath, e); } } @@ -367,7 +366,7 @@ private String getFilePrefix() { private void saveModelToTemporaryFile(Model model, String fileName) { String filePath = getFilePrefix() + fileName; try { - LOG.debug("Saving model to temporary file " + filePath + " ..."); + log.debug("Saving model to temporary file " + filePath + " ..."); model.write(new FileOutputStream(filePath), FileUtils.langTurtle); } catch (IOException e) { e.printStackTrace(); 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 a244e22f..500c9304 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 @@ -5,18 +5,17 @@ import cz.cvut.spipes.engine.ExecutionContextFactory; import cz.cvut.spipes.impl.GraphChunkedDownload; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; // TODO - lable = SpEP retrieve graph +@Slf4j @SPipesModule(label = "sparql endpoint retrieve graph", comment = "Retrieves graph from sparql endpoint specified by " + "?endpointUrl and optionaly ?namedGraphId. If ?namedGraphId is not specified it retreaves the default graph.") public class RetrieveGraphModule extends AnnotatedAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(RetrieveGraphModule.class); protected static final String TYPE_URI = KBSS_MODULE.uri + "sparql-endpoint-retrieve-graph"; private static final String TYPE_PREFIX = TYPE_URI + "/"; private static final int DEFAULT_PAGE_SIZE = 10000; @@ -65,7 +64,7 @@ ExecutionContext executeSelf() { GraphChunkedDownload downloader = new GraphChunkedDownload(endpointUrl, namedGraphId, pageSize) { @Override protected void processPartialModel(Model partialModel) { - LOG.trace("persisting partial download, {} triples from (<{}>,<{}>)", + log.trace("persisting partial download, {} triples from (<{}>,<{}>)", partialModel.size(), endpointUrl, namedGraphId); outputModel.add(partialModel); } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/ChunkedValuesProvider.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/ChunkedValuesProvider.java index 221ba504..bea20bbb 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/ChunkedValuesProvider.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/ChunkedValuesProvider.java @@ -3,14 +3,15 @@ import cz.cvut.spipes.util.QueryUtils; import java.util.Objects; import java.util.Optional; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.ResultSet; import org.apache.jena.rdf.model.Model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j public class ChunkedValuesProvider implements QueryTemplateRecursionProvider { - private static final Logger LOG = LoggerFactory.getLogger(ChunkedValuesProvider.class); + private static final String VALUES_CLAUSE_MARKER_NAME = "VALUES"; private final int iterationCount; private ResultSet inputResultSet; @@ -29,7 +30,7 @@ public ChunkedValuesProvider(ResultSet inputResultSet, Integer outputChunkSize, public String substituteQueryMarkers(int currentIteration, String queryStr) { String markerValue = QueryUtils.nextResultsToValuesClause(inputResultSet, outputChunkSize); - LOG.debug("Creating query with values clause: \n{}.", markerValue); + log.debug("Creating query with values clause: \n{}.", markerValue); return QueryUtils .substituteMarkers(VALUES_CLAUSE_MARKER_NAME, diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/CombinedQueryTemplateRecursionProvider.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/CombinedQueryTemplateRecursionProvider.java index 922c8d09..6ae082a0 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/CombinedQueryTemplateRecursionProvider.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/CombinedQueryTemplateRecursionProvider.java @@ -3,13 +3,13 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j public class CombinedQueryTemplateRecursionProvider implements QueryTemplateRecursionProvider { - - private static final Logger LOG = LoggerFactory.getLogger(CombinedQueryTemplateRecursionProvider.class); +; private final QueryTemplateRecursionProvider parentProvider; private final QueryTemplateRecursionProvider childProvder; private final int iterationCount; @@ -37,7 +37,7 @@ public boolean shouldTerminate(int currentIteration, Model previousInferredModel } } childIteration++; - LOG.debug("Executing iteration {} --> ({}, {}).", currentIteration, parentIteration, childIteration); + log.debug("Executing iteration {} --> ({}, {}).", currentIteration, parentIteration, childIteration); if (currentIteration == iterationCount) { return true; diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/ScrollableCursorProvider.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/ScrollableCursorProvider.java index 46bb4a3a..26593f78 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/ScrollableCursorProvider.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/recursion/ScrollableCursorProvider.java @@ -1,16 +1,14 @@ package cz.cvut.spipes.recursion; import cz.cvut.spipes.util.QueryUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * TODO !!! scrolling detects one iteration later than it supposed to. If there is a knowledge about how many results a subquery with LIMIT+OFFSET returned, it would be more clear ... */ +@Slf4j public class ScrollableCursorProvider implements QueryTemplateRecursionProvider { - private static final Logger LOG = LoggerFactory.getLogger(ScrollableCursorProvider.class); private static final String LIMIT_OFFSET_CLAUSE_MARKER_NAME = "LIMIT_OFFSET"; private final int pageSize; private final int iterationCount; @@ -43,7 +41,7 @@ public boolean shouldTerminate(int currentIteration, Model previousInferredModel public String substituteQueryMarkers(int currentIteration, String queryStr) { int offset = pageSize * (currentIteration - 1); - LOG.debug("Creating query with LIMIT {} for OFFSET {}.", pageSize, offset ); + log.debug("Creating query with LIMIT {} for OFFSET {}.", pageSize, offset ); String markerValue = "\n" + "OFFSET " + offset + "\n" + "LIMIT " + pageSize + "\n"; diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/tdb/TDBModelFinalizer.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/tdb/TDBModelFinalizer.java index 5e19db01..49d05f9f 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/tdb/TDBModelFinalizer.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/tdb/TDBModelFinalizer.java @@ -4,14 +4,14 @@ import java.io.IOException; import java.lang.ref.PhantomReference; import java.lang.ref.ReferenceQueue; + +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.jena.rdf.model.Model; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j public class TDBModelFinalizer extends PhantomReference { - private static final Logger LOG = LoggerFactory.getLogger(TDBModelFinalizer.class); private final String datasetLocation; public TDBModelFinalizer(Model referent, ReferenceQueue q) { @@ -20,11 +20,11 @@ public TDBModelFinalizer(Model referent, ReferenceQueue q) { } public void finalizeResources() { - LOG.debug("Removing temporary TDB dataset at directory {}.", datasetLocation); + log.debug("Removing temporary TDB dataset at directory {}.", datasetLocation); try { FileUtils.deleteDirectory(new File(datasetLocation)); } catch (IOException e) { - LOG.error("Could not remove directory at {}, reason: {}.", datasetLocation, e); + log.error("Could not remove directory at {}, reason: {}.", datasetLocation, e); } } } diff --git a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/tdb/TDBTempFactory.java b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/tdb/TDBTempFactory.java index e672e308..b2812cea 100644 --- a/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/tdb/TDBTempFactory.java +++ b/s-pipes-modules/module-sparql-endpoint/src/main/java/cz/cvut/spipes/tdb/TDBTempFactory.java @@ -11,23 +11,23 @@ import java.util.Random; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; + +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.jena.query.Dataset; import org.apache.jena.rdf.model.Model; import org.apache.jena.tdb.TDBFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j public class TDBTempFactory { - private static final Logger LOG = LoggerFactory.getLogger(TDBTempFactory.class); private static final ReferenceQueue referenceQueue = new ReferenceQueue<>(); private static final Set references = ConcurrentHashMap.newKeySet(); public static Model createTDBModel() { finalizePhantomModels(); Path tempDir = getTempDir(); - LOG.debug("Creating temporary TDB dataset at directory {}.", tempDir); + log.debug("Creating temporary TDB dataset at directory {}.", tempDir); Dataset ds = TDBFactory.createDataset(tempDir.toString()); Model outModel = ds.getNamedModel(getRandomModelUri()); setUpFinalization(outModel); @@ -51,7 +51,7 @@ private static Path getTempDir() { private static void setUpFinalization(Model tdbModel) { String modelLocation = TDBModelHelper.getLocation(tdbModel); - LOG.trace("Scheduling removal of directory {} on JVM exit.", modelLocation); + log.trace("Scheduling removal of directory {} on JVM exit.", modelLocation); Runtime.getRuntime().addShutdownHook(new Thread(() -> FileUtils.deleteQuietly(new File(modelLocation)))); references.add(new TDBModelFinalizer(tdbModel, referenceQueue)); } diff --git a/s-pipes-modules/module-tarql/pom.xml b/s-pipes-modules/module-tarql/pom.xml index 40b7be70..d0606b17 100644 --- a/s-pipes-modules/module-tarql/pom.xml +++ b/s-pipes-modules/module-tarql/pom.xml @@ -57,5 +57,11 @@ junit-jupiter-api test + + + org.projectlombok + lombok + provided + \ No newline at end of file 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 ad6e8bf6..46234a8f 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 @@ -4,24 +4,22 @@ import cz.cvut.spipes.engine.ExecutionContext; import cz.cvut.spipes.engine.ExecutionContextFactory; import cz.cvut.spipes.modules.annotations.SPipesModule; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.ResourceFactory; import org.deri.tarql.tarql; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.*; import java.nio.file.Files; import java.nio.file.Paths; +@Slf4j @Deprecated //TODO merge with TarqlModule functionality @SPipesModule(label = "tarql-XXX-2", comment = "Module to convert CSV file to RDF and query it using SPRQL query. The module wraps org.deri.tarql.tarql. This module is depracated.") public class ModuleTarql extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ModuleTarql.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "tarql" + "-XXX-2"; private static Property getParameter(final String name) { @@ -48,7 +46,7 @@ private static Property getParameter(final String name) { @Override public ExecutionContext executeSelf() { - LOG.info("Running TARQL on " + inputFile); + log.info("Running TARQL on " + inputFile); Model model = ModelFactory.createDefaultModel(); try { 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 265a794b..8796779a 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 @@ -9,6 +9,7 @@ import cz.cvut.spipes.registry.StreamResource; import cz.cvut.spipes.registry.StreamResourceRegistry; import cz.cvut.spipes.util.QueryUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.ext.com.google.common.io.Files; import org.apache.jena.query.Query; import org.apache.jena.rdf.model.Model; @@ -16,8 +17,6 @@ import org.apache.jena.rdf.model.Resource; import org.apache.jena.util.FileUtils; import org.deri.tarql.tarql; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Construct; @@ -29,11 +28,11 @@ import java.util.stream.Collectors; // TODO merge with ModuleTarql functionality +@Slf4j @SPipesModule(label = "tarql", comment = "\"Runs one or more TARQL Construct queries on the input triples. The output RDF " + "will consist of the constructed triples and (unless sml:replace is true) the input triples.\"") public class TarqlModule extends AbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(TarqlModule.class); //tarql [options] query.sparql [table.csv [...]] private static final String TARQL_PROGRAM = AppConstants.BIN_DIR + "/tarql"; @@ -97,7 +96,7 @@ public ExecutionContext executeSelf() { tabularDataFilePath = sourceFilePath; } - LOG.debug("Processing tabular data from file path {}.", tabularDataFilePath); + log.debug("Processing tabular data from file path {}.", tabularDataFilePath); // set up variable bindings for (Resource constructQueryRes : constructQueries) { @@ -158,7 +157,7 @@ public void loadConfiguration() { .map(st -> st.getObject().asResource()) .collect(Collectors.toList()); - LOG.debug("Loaded {} spin construct queries.", constructQueries.size()); + log.debug("Loaded {} spin construct queries.", constructQueries.size()); //TODO default value must be taken from template definition isReplace = this.getPropertyValue(SML.replace, false); diff --git a/s-pipes-modules/module-text-analysis/pom.xml b/s-pipes-modules/module-text-analysis/pom.xml index e7a7f4b5..40c58a6c 100644 --- a/s-pipes-modules/module-text-analysis/pom.xml +++ b/s-pipes-modules/module-text-analysis/pom.xml @@ -71,5 +71,10 @@ 2.6 compile + + org.projectlombok + lombok + provided + 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 abe13e01..8026ddd2 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 @@ -72,8 +72,6 @@ ) public class ExtractTermOccurrencesModule extends AnnotatedAbstractModule { - private static final Logger LOG = LoggerFactory.getLogger(ExtractTermOccurrencesModule.class); - private static final String TYPE_URI = KBSS_MODULE.uri + "extract-term-occurrences"; private static final String TYPE_PREFIX = TYPE_URI + "/"; 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 1f75e11e..4c683c64 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 @@ -6,6 +6,7 @@ import cz.cvut.spipes.modules.annotations.SPipesModule; import cz.cvut.spipes.modules.constants.Termit; import cz.cvut.spipes.util.QueryUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; @@ -21,8 +22,7 @@ import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + import org.topbraid.spin.arq.ARQFactory; import org.topbraid.spin.model.Select; @@ -34,6 +34,7 @@ import static org.apache.commons.lang.StringEscapeUtils.escapeHtml; import static org.apache.commons.lang.StringEscapeUtils.unescapeHtml; +@Slf4j @SPipesModule(label = "Text analysis module", comment = "Module for text analysis.\n" + "

\n" + @@ -44,7 +45,6 @@ ) public class TextAnalysisModule extends AnnotatedAbstractModule{ - private static final Logger LOG = LoggerFactory.getLogger(TextAnalysisModule.class); private static final String TYPE_URI = KBSS_MODULE.uri + "text-analysis"; private static final String TYPE_PREFIX = TYPE_URI + "/"; @@ -88,7 +88,7 @@ ExecutionContext executeSelf() { Model outputModel = ModelFactory.createDefaultModel(); if (selectQuery == null) { - LOG.warn("Select query is empty therefore returning input model."); + log.warn("Select query is empty therefore returning input model."); return executionContext; } @@ -107,14 +107,14 @@ ExecutionContext executeSelf() { RDFNode object = solution.get(variableBindings.next()); if (!object.isLiteral() || !(object.asLiteral().getDatatype() instanceof XSDBaseStringType)) { - LOG.warn("Object {} is not a literal. Skipping.", object); + log.warn("Object {} is not a literal. Skipping.", object); continue; } Literal literal = object.asLiteral(); String textElement = escapeHtml(literal.getString()); if (counter >= literalsPerRequest) { - LOG.debug("Annotating {} literals. Progress {}%.", literalsPerRequest, totalCounter * 100L / inputModel.size()); + log.debug("Annotating {} literals. Progress {}%.", literalsPerRequest, totalCounter * 100L / inputModel.size()); String annotatedText = annotateObjectLiteral(sb.toString()); String[] elements = splitAnnotatedText(annotatedText); @@ -136,7 +136,7 @@ ExecutionContext executeSelf() { } if (counter > 0) { - LOG.debug("Annotating {} literals. Progress {}%.", literalsPerRequest, totalCounter * 100L / inputModel.size()); + log.debug("Annotating {} literals. Progress {}%.", literalsPerRequest, totalCounter * 100L / inputModel.size()); String annotatedText = annotateObjectLiteral(sb.toString()); String[] elements = splitAnnotatedText(annotatedText); diff --git a/s-pipes-parent/pom.xml b/s-pipes-parent/pom.xml index 6dadd6a5..71388053 100644 --- a/s-pipes-parent/pom.xml +++ b/s-pipes-parent/pom.xml @@ -29,6 +29,7 @@ 5.2.0 2.21.0 2.7 + 1.18.24 @@ -228,7 +229,8 @@ org.projectlombok lombok - 1.18.2 + ${lombok.version} + provided diff --git a/s-pipes-test/pom.xml b/s-pipes-test/pom.xml index daa4a803..257dab71 100644 --- a/s-pipes-test/pom.xml +++ b/s-pipes-test/pom.xml @@ -34,5 +34,11 @@ org.junit.jupiter junit-jupiter-api + + org.projectlombok + lombok + provided + + \ No newline at end of file diff --git a/s-pipes-test/src/main/java/cz/cvut/spipes/test/JenaTestUtils.java b/s-pipes-test/src/main/java/cz/cvut/spipes/test/JenaTestUtils.java index c8e6b58e..d583a68f 100644 --- a/s-pipes-test/src/main/java/cz/cvut/spipes/test/JenaTestUtils.java +++ b/s-pipes-test/src/main/java/cz/cvut/spipes/test/JenaTestUtils.java @@ -1,5 +1,6 @@ package cz.cvut.spipes.test; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.ontology.OntDocumentManager; import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModelSpec; @@ -17,10 +18,9 @@ import static org.junit.jupiter.api.Assertions.fail; +@Slf4j public class JenaTestUtils { - private static Logger LOG = LoggerFactory.getLogger(JenaTestUtils.class); - public static void mapLocalSPipesDefinitionFiles() { OntDocumentManager dm = OntDocumentManager.getInstance(); dm.setFileManager(FileManager.getInternal()); @@ -64,9 +64,9 @@ public static Model laodModelFromResource(String path) { public static void assertIsomorphic(Model actualModel, Model expectedModel) { if (!actualModel.isIsomorphicWith(expectedModel)) { - LOG.debug("Saving actual model ... "); + log.debug("Saving actual model ... "); saveModelToTemporaryFile(actualModel); - LOG.debug("Saving expected model ... "); + log.debug("Saving expected model ... "); saveModelToTemporaryFile(expectedModel); fail("Actual model is not isomorphic with expected model (see additional information above)."); } @@ -75,7 +75,7 @@ public static void assertIsomorphic(Model actualModel, Model expectedModel) { private static void saveModelToTemporaryFile(Model model) { try { Path file = Files.createTempFile("model-output-", ".ttl"); - LOG.debug("Saving model to temporary file " + file.toString() + " ..."); + log.debug("Saving model to temporary file " + file.toString() + " ..."); model.write(Files.newOutputStream(file.toFile().toPath()), FileUtils.langTurtle); } catch (IOException e) { e.printStackTrace(); diff --git a/s-pipes-web/pom.xml b/s-pipes-web/pom.xml index 344a04ee..337940aa 100644 --- a/s-pipes-web/pom.xml +++ b/s-pipes-web/pom.xml @@ -24,6 +24,15 @@ + + + + org.projectlombok + lombok + provided + + + cz.cvut.kbss diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/config/RDFMediaTypeConverter.java b/s-pipes-web/src/main/java/cz/cvut/spipes/config/RDFMediaTypeConverter.java index 2de2502e..c1397060 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/config/RDFMediaTypeConverter.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/config/RDFMediaTypeConverter.java @@ -1,6 +1,7 @@ package cz.cvut.spipes.config; import cz.cvut.spipes.util.RDFMimeType; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.riot.RDFLanguages; @@ -17,11 +18,10 @@ import java.io.IOException; import java.util.List; +@Slf4j @Component public class RDFMediaTypeConverter extends AbstractHttpMessageConverter { - private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(RDFMediaTypeConverter.class); - public RDFMediaTypeConverter() { super( RDFMimeType.transform(RDFLanguages.N3), @@ -33,7 +33,7 @@ public RDFMediaTypeConverter() { } private String getRDFLanguageForContentType( final HttpMessage m, final String defaultValue) { - LOG.debug("Getting RDF Language for content type " + m + ", message: " + defaultValue); + log.debug("Getting RDF Language for content type " + m + ", message: " + defaultValue); MediaType contentType = m.getHeaders().getContentType(); if ( contentType == null ) { contentType = MediaType.parseMediaType(defaultValue); } return RDFLanguages.contentTypeToLang(contentType.toString().split(";")[0]).getLabel(); @@ -41,7 +41,7 @@ private String getRDFLanguageForContentType( final HttpMessage m, final String d @Override protected Object readInternal(Class aClass, HttpInputMessage httpInputMessage) throws IOException, HttpMessageNotReadableException { - LOG.debug("Reading " + aClass + ", message: " + httpInputMessage.getHeaders()); + log.debug("Reading " + aClass + ", message: " + httpInputMessage.getHeaders()); if ( ! aClass.isAssignableFrom( Model.class ) ) { throw new UnsupportedOperationException(); } @@ -52,11 +52,11 @@ protected Object readInternal(Class aClass, HttpInputMessage httpInputMessage) t @Override protected void writeInternal(Object o, HttpOutputMessage httpOutputMessage) throws IOException, HttpMessageNotWritableException { - if (LOG.isTraceEnabled()) { - LOG.trace("Writing object " + o + ", message: " + httpOutputMessage.getHeaders()); + if (log.isTraceEnabled()) { + log.trace("Writing object " + o + ", message: " + httpOutputMessage.getHeaders()); } if (o instanceof Model) { - LOG.debug("Writing model of size " + ((Model)o).size() + ", message: " + httpOutputMessage.getHeaders()); + log.debug("Writing model of size " + ((Model)o).size() + ", message: " + httpOutputMessage.getHeaders()); } else { throw new UnsupportedOperationException(); } @@ -65,7 +65,7 @@ protected void writeInternal(Object o, HttpOutputMessage httpOutputMessage) thro @Override protected boolean supports(Class aClass) { - LOG.debug("Supports {} ? ", aClass); + log.debug("Supports {} ? ", aClass); return Model.class.isAssignableFrom(aClass); } } 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 33edca72..02c8e44b 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 @@ -7,6 +7,7 @@ import cz.cvut.spipes.rest.util.ContextLoaderHelper; 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.vocabulary.OWL; import org.apache.jena.vocabulary.RDF; @@ -19,12 +20,11 @@ import java.util.List; import java.util.stream.Collectors; +@Slf4j @RestController @EnableWebMvc public class SPipesContextController { - - private static final Logger LOG = LoggerFactory.getLogger(SPipesServiceController.class); private SPipesScriptManager scriptManager; private List globalScripts; private OntologyDocumentManager ontoDocManager; diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/SPipesServiceController.java b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/SPipesServiceController.java index 8feec825..bdf3e911 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/SPipesServiceController.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/SPipesServiceController.java @@ -10,6 +10,7 @@ import cz.cvut.spipes.util.RDFMimeType; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.rdf.model.Model; @@ -34,11 +35,11 @@ import java.util.*; import java.util.stream.Collectors; +@Slf4j @RestController @EnableWebMvc public class SPipesServiceController { - private static final Logger LOG = LoggerFactory.getLogger(SPipesServiceController.class); private final ResourceRegisterHelper resourceRegisterHelper; private final SPipesScriptManager scriptManager; @@ -59,7 +60,7 @@ public SPipesServiceController() { } ) public Model processGetRequest(@RequestParam MultiValueMap parameters) { - LOG.info("Processing GET request."); + log.info("Processing GET request."); return runModule(ModelFactory.createDefaultModel(), parameters); } @@ -105,7 +106,7 @@ public Model processPostRequest( String pOutputBindingURL, @RequestParam MultiValueMap parameters ) { - LOG.info("Processing POST request."); + log.info("Processing POST request."); // TODO process internal params passed arguments not parameters map return runModule(inputModel, parameters); } @@ -120,7 +121,7 @@ public Model processPostRequest( } ) public Model processServiceGetRequest(@RequestParam MultiValueMap parameters) { - LOG.info("Processing service GET request."); + log.info("Processing service GET request."); return runService(ModelFactory.createDefaultModel(), parameters); } @@ -152,10 +153,10 @@ public Model processServicePostRequest(@RequestParam MultiValueMap parameters) // TODO merge it with implementation in /module private Model runService(final Model inputDataModel, final MultiValueMap parameters) { - LOG.info("- parameters={}", parameters); + log.info("- parameters={}", parameters); String id = extractId(parameters); @@ -207,12 +208,12 @@ private Model runService(final Model inputDataModel, final MultiValueMap parameters) { - LOG.info("- parameters={}", parameters); + log.info("- parameters={}", parameters); String id = extractId(parameters); @@ -232,7 +233,7 @@ private Model runModule(final Model inputDataModel, final MultiValueMap JenaUtils.createUnion(inputDataModel, loadModelFromUrl(url.toString()))) @@ -333,7 +334,7 @@ private ExecutionEngine createExecutionEngine(Model configModel) { } private void logParam(String parameterKey, String parameterValue) { - LOG.info("- {}={}", parameterKey, parameterValue); + log.info("- {}={}", parameterKey, parameterValue); } private @NotNull @@ -362,16 +363,16 @@ private void extendBindingFromURL(VariablesBinding inputVariablesBinding, URL in vb2.load(inputBindingURL.openStream(), FileUtils.langTurtle); VariablesBinding vb3 = inputVariablesBinding.extendConsistently(vb2); if (vb3.isEmpty()) { - LOG.debug("- no conflict between bindings loaded from '{}' and those provided in query string.", + log.debug("- no conflict between bindings loaded from '{}' and those provided in query string.", ReservedParams.P_INPUT_BINDING_URL ); } else { - LOG.info("- conflicts found between bindings loaded from '{}' and those provided in query string: {}", + log.info("- conflicts found between bindings loaded from '{}' and those provided in query string: {}", ReservedParams.P_INPUT_BINDING_URL, vb3 ); } } catch (IOException e) { - LOG.warn("Could not read data from parameter {}={}, caused by: {}", ReservedParams.P_INPUT_BINDING_URL, inputBindingURL, e); + log.warn("Could not read data from parameter {}={}, caused by: {}", ReservedParams.P_INPUT_BINDING_URL, inputBindingURL, e); } } diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/StreamResourceController.java b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/StreamResourceController.java index fc9c3074..d27a1d07 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/StreamResourceController.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/StreamResourceController.java @@ -3,6 +3,7 @@ import cz.cvut.spipes.registry.StreamResourceRegistry; import cz.cvut.spipes.rest.util.ResourceRegisterHelper; import cz.cvut.spipes.util.RestUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,11 +20,11 @@ import java.io.*; import java.util.UUID; +@Slf4j @RestController @EnableWebMvc public class StreamResourceController { - private static final Logger LOG = LoggerFactory.getLogger(StreamResourceController.class); private final ResourceRegisterHelper resourceRegisterHelper; public StreamResourceController() { @@ -76,7 +77,7 @@ public ResponseEntity registerStreamResource2(@RequestHeader( resourceRegisterHelper.getRegisteredResourceLocation() ); - LOG.info("Registering new stream resource with url {} " + res.getPersistentUri()); + log.info("Registering new stream resource with url {} " + res.getPersistentUri()); StreamResourceRegistry.getInstance().registerResource(res.getId(), IOUtils.toByteArray(fis), contentType); //LOG.debug("Resource content : {}", body); diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ContextLoaderHelper.java b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ContextLoaderHelper.java index 5de7240d..d5ade253 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ContextLoaderHelper.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ContextLoaderHelper.java @@ -8,18 +8,19 @@ import java.nio.file.Path; import java.util.LinkedList; import java.util.List; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.util.LocationMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class ContextLoaderHelper { - private static final Logger LOG = LoggerFactory.getLogger(ContextLoaderHelper.class); - // TODO should not point to scriptManager public static void updateContextsIfNecessary(SPipesScriptManager scriptManager) { if (isKeepUpdated()) { - LOG.warn("Updating contexts which is not thread safe -- don't use in in production environment."); + log.warn("Updating contexts which is not thread safe -- don't use in in production environment."); OntologyDocumentManager ontoDocManager = OntoDocManager.getInstance(); OntoDocManager.setReloadFiles(true); List globalScripts = ContextLoaderHelper.registerGlobalScripts(ontoDocManager); @@ -41,7 +42,7 @@ public static List registerGlobalScripts(OntologyDocumentManager ontDocM ontoUri -> { String loc = locMapper.getAltEntry(ontoUri); if (loc.endsWith(".sms.ttl")) { - LOG.info("Registering script from file " + loc + "."); + log.info("Registering script from file " + loc + "."); _globalScripts.add(ontoUri); } } diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/MultipartFileResourceResolver.java b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/MultipartFileResourceResolver.java index 0a6cd537..0415f855 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/MultipartFileResourceResolver.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/MultipartFileResourceResolver.java @@ -1,6 +1,7 @@ package cz.cvut.spipes.rest.util; import cz.cvut.spipes.rest.StreamResourceDTO; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -18,11 +19,10 @@ /** * Resolver of multipart files references within query parameters. */ +@Slf4j @Component public class MultipartFileResourceResolver { - private static final Logger LOG = LoggerFactory.getLogger(MultipartFileResourceResolver.class); - private final ResourceRegisterHelper resourceRegisterHelper; @Autowired @@ -66,7 +66,7 @@ public MultiValueMap resolveResources( .findFirst().get(); // must be at least one present due to previous logic if (e.getValue().size() > 1) { - LOG.warn("Multiple values for url parameter: {}, using only first value: {}", e.getKey(), paramFilename); + log.warn("Multiple values for url parameter: {}, using only first value: {}", e.getKey(), paramFilename); } String filename = paramFilename.replaceFirst("@", ""); @@ -81,10 +81,10 @@ public MultiValueMap resolveResources( newStreamResources.add(res); newParameters.replace(e.getKey(), Collections.singletonList(res.getPersistentUri())); } catch (IOException ex) { - LOG.error(ex.getMessage(), ex); + log.error(ex.getMessage(), ex); } } else { - LOG.error("Missing multipart file for url parameter: {} with value: {}", e.getKey(), paramFilename); + log.error("Missing multipart file for url parameter: {} with value: {}", e.getKey(), paramFilename); } }); diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ProgressListenerLoader.java b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ProgressListenerLoader.java index 015b986b..576b9fd3 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ProgressListenerLoader.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ProgressListenerLoader.java @@ -6,14 +6,16 @@ import java.lang.reflect.InvocationTargetException; import java.util.LinkedList; import java.util.List; + +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.Resource; import org.apache.jena.vocabulary.RDF; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Slf4j public class ProgressListenerLoader { - private static final Logger LOG = LoggerFactory.getLogger(ProgressListenerLoader.class); public static List createListeners(Model configModel) { final List progressListeners = new LinkedList<>(); @@ -32,7 +34,7 @@ public static List createListeners(Model configModel) { InstantiationException | IllegalAccessException | InvocationTargetException e) { - LOG.error("Could not construct progress listener of classname {}, cause: {}", className, e); + log.error("Could not construct progress listener of classname {}, cause: {}", className, e); throw new RuntimeException("Could not construct progress listener of classname " + className + ".", e); } } diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ResourceRegisterHelper.java b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ResourceRegisterHelper.java index 3df6866c..ff8592b8 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ResourceRegisterHelper.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ResourceRegisterHelper.java @@ -3,6 +3,7 @@ import cz.cvut.spipes.registry.StreamResource; import cz.cvut.spipes.registry.StreamResourceRegistry; import cz.cvut.spipes.rest.StreamResourceDTO; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,11 +14,10 @@ import java.io.InputStream; import java.util.UUID; +@Slf4j @Component public class ResourceRegisterHelper { - private static final Logger LOG = LoggerFactory.getLogger(ResourceRegisterHelper.class); - public StreamResourceDTO registerStreamResource(String contentType, InputStream body) { StreamResourceDTO res = new StreamResourceDTO( UUID.randomUUID().toString(), @@ -25,7 +25,7 @@ public StreamResourceDTO registerStreamResource(String contentType, InputStream getRegisteredResourceLocation() ); - LOG.info("Registering new stream resource with id {} and url {} ", res.getId(), res.getPersistentUri()); + log.info("Registering new stream resource with id {} and url {} ", res.getId(), res.getPersistentUri()); final byte[] data; try { @@ -33,9 +33,9 @@ public StreamResourceDTO registerStreamResource(String contentType, InputStream StreamResource streamResource = StreamResourceRegistry.getInstance() .registerResource(res.getId(), data, contentType); res.attachStreamResource(streamResource); - LOG.info("Resource content size: {}", data.length); + log.info("Resource content size: {}", data.length); } catch (IOException e) { - LOG.error("Unable to read payload: ", e); + log.error("Unable to read payload: ", e); } return res; diff --git a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ServiceParametersHelper.java b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ServiceParametersHelper.java index 2aa54bd0..c4393a14 100644 --- a/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ServiceParametersHelper.java +++ b/s-pipes-web/src/main/java/cz/cvut/spipes/rest/util/ServiceParametersHelper.java @@ -7,15 +7,16 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; + +import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.MultiValueMap; +@Slf4j public class ServiceParametersHelper { - private static final Logger LOG = LoggerFactory.getLogger(ServiceParametersHelper.class); - @NotNull final MultiValueMap parameters; @@ -38,7 +39,7 @@ public String getParameterValue(@NotNull final String parameterKey) { List values = parameters.get(parameterKey); String lastValue = values.get(values.size() - 1); if (parameters.get(parameterKey).size() > 1) { - LOG.warn("Parameter {} has multiple values: {}. Last assignment of the parameter, i.e. {}, will be used.", + log.warn("Parameter {} has multiple values: {}. Last assignment of the parameter, i.e. {}, will be used.", parameterKey, values, lastValue); diff --git a/s-pipes-web/src/test/java/cz/cvut/spipes/rest/SPipesServiceControllerTest.java b/s-pipes-web/src/test/java/cz/cvut/spipes/rest/SPipesServiceControllerTest.java index a88bc3e7..2a6d12ab 100644 --- a/s-pipes-web/src/test/java/cz/cvut/spipes/rest/SPipesServiceControllerTest.java +++ b/s-pipes-web/src/test/java/cz/cvut/spipes/rest/SPipesServiceControllerTest.java @@ -4,6 +4,7 @@ import cz.cvut.spipes.engine.VariablesBinding; import cz.cvut.spipes.rest.util.ReservedParams; import cz.cvut.spipes.util.RDFMimeType; +import lombok.extern.slf4j.Slf4j; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.ResourceFactory; @@ -38,12 +39,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +@Slf4j @ExtendWith(SpringExtension.class) @WebAppConfiguration @ContextConfiguration(classes = WebAppConfig.class) public class SPipesServiceControllerTest { - private static final Logger LOGGER = LoggerFactory.getLogger(SPipesServiceControllerTest.class); public static final String SAMPLE_IDENTITY_MODULE = "http://onto.fel.cvut.cz/ontologies/s-pipes/identity#SampleIdentity"; public static final String CREATE_SAMPLE_TRIPLES = "http://onto.fel.cvut.cz/ontologies/test/apply-construct#CreateSampleTriples"; @@ -95,7 +96,7 @@ public void testRunExistingModule() throws Exception { MvcResult result = mockMvc.perform(createDefaultIdentityModuleBuilder(). accept(RDFMimeType.LD_JSON_STRING) ).andExpect(status().isOk()).andReturn(); - LOGGER.info("Resulting JSON: " + result.getResponse().getContentAsString()); + log.info("Resulting JSON: " + result.getResponse().getContentAsString()); } @Test @@ -110,7 +111,7 @@ private void testMimeType( final String mimeType, boolean pass ) throws Exceptio MvcResult result = mockMvc.perform(createDefaultIdentityModuleBuilder(). accept(mimeType) ).andExpect(pass ? status().isOk() : status().is4xxClientError()).andReturn(); - LOGGER.info("Result: {}", result.getResponse().getContentAsString()); + log.info("Result: {}", result.getResponse().getContentAsString()); final Model m = ModelFactory.createDefaultModel(); try { m.read(new ByteArrayInputStream(result.getResponse().getContentAsByteArray()), "", RDFLanguages.contentTypeToLang(mimeType).getName()); @@ -138,7 +139,7 @@ private void testModule( int expectedNumberOfStatements ) throws Exception { - LOGGER.info("Testing module with parameters:\n - id={},\n - cfg={},\n - inputBinding={}", id, resourceConfig,inputVariablesBinding); + log.info("Testing module with parameters:\n - id={},\n - cfg={},\n - inputBinding={}", id, resourceConfig,inputVariablesBinding); if ( inputVariablesBinding == null ) { inputVariablesBinding = new VariablesBinding(); } @@ -167,7 +168,7 @@ private void testModule( outputBinding.load(new FileInputStream(outputBindingFile), "TURTLE"); // Assert.assertEquals(Lists.newArrayList(outputBinding.getVarNames()), Lists.newArrayList(expectedOutputVariablesBinding.getVarNames())); TODO uncomment !!! - LOGGER.info(" - content returned: {}", result.getResponse().getContentAsString()); + log.info(" - content returned: {}", result.getResponse().getContentAsString()); final StringReader res = new StringReader(result.getResponse().getContentAsString()); final Model mOutput = ModelFactory.createDefaultModel();