Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package cz.cvut.spipes.config;

import cz.cvut.spipes.util.CoreConfigProperies;
import cz.cvut.spipes.util.CoreConfigProperties;
import java.nio.file.Path;
import java.nio.file.Paths;

public class AuditConfig {

public static Path getResourcesPath() {
return Paths.get(CoreConfigProperies.get("audit.resourcesPath"));
return Paths.get(CoreConfigProperties.get("audit.resourcesPath"));
}

public static boolean isEnabled() {
return Boolean.parseBoolean(CoreConfigProperies.get("audit.enable"));
return Boolean.parseBoolean(CoreConfigProperties.get("audit.enable"));
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cz.cvut.spipes.config;

import cz.cvut.spipes.util.CoreConfigProperies;
import cz.cvut.spipes.util.CoreConfigProperties;

public class CompatibilityConfig {

public static boolean isLoadSparqlMotionFiles() {
return Boolean.parseBoolean(CoreConfigProperies.get("compatibility.loadSparqlMotionFiles", "false"));
return Boolean.parseBoolean(CoreConfigProperties.get("compatibility.loadSparqlMotionFiles", "false"));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cz.cvut.spipes.config;

import cz.cvut.spipes.util.CoreConfigProperies;
import cz.cvut.spipes.util.CoreConfigProperties;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
Expand All @@ -12,8 +12,8 @@ public class ContextsConfig {

public static List<Path> getScriptPaths() {
return Arrays
.stream(CoreConfigProperies.get("contexts.scriptPaths").split(";"))
.map(path -> Paths.get(path))
.stream(CoreConfigProperties.get("contexts.scriptPaths").split(";"))
.map(Paths::get)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
package cz.cvut.spipes.config;

import cz.cvut.spipes.util.CoreConfigProperies;
import cz.cvut.spipes.util.CoreConfigProperties;
import java.nio.file.Path;
import java.nio.file.Paths;

public class ExecutionConfig {

public static Path getTempDirectoryPath() {
return Paths.get(CoreConfigProperies.get("execution.tempDirectoryPath", System.getProperty("java.io.tmpdir")));
return Paths.get(CoreConfigProperties.get("execution.tempDirectoryPath", System.getProperty("java.io.tmpdir")));
}

public static boolean isExitOnError() {
return Boolean.parseBoolean(CoreConfigProperies.get(
return Boolean.parseBoolean(CoreConfigProperties.get(
"execution.exitOnError",
"false"));
}

public static boolean isCheckValidationConstrains() {
return Boolean.parseBoolean(CoreConfigProperies.get(
return Boolean.parseBoolean(CoreConfigProperties.get(
"execution.validation.checkConstraints",
"true"));
}

public static int getEvidenceNumber() {
return Integer.parseInt(CoreConfigProperies.get("execution.validation.maxNumberOfConstraintFailureEvidences", "3"));
return Integer.parseInt(CoreConfigProperties.get("execution.validation.maxNumberOfConstraintFailureEvidences", "3"));
}

public static String getConfigUrl() {
return CoreConfigProperies.get("execution.configUrl", "config.ttl");
return CoreConfigProperties.get("execution.configUrl", "config.ttl");
}

public static Environment getEnvironment() {
return Environment.valueOf(CoreConfigProperies.get(
return Environment.valueOf(CoreConfigProperties.get(
"execution.environment",
Environment.production.toString())
);
}

public static String getDevelopmentServiceUrl() {
return CoreConfigProperies.get("execution.developmentServiceUrl", "http://localhost:8080/s-pipes/");
return CoreConfigProperties.get("execution.developmentServiceUrl", "http://localhost:8080/s-pipes/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class KBSS_TIMEF {
*/
public static final String uri = "http://onto.fel.cvut.cz/ontologies/lib/function/time/";

protected static final Property property(String local )
protected static Property property(String local)
{ return ResourceFactory.createProperty( uri, local ); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class SPIF {
*/
public static final String uri = "http://spinrdf.org/spif#";

protected static final Property property(String local )
protected static Property property(String local)
{ return ResourceFactory.createProperty( uri, local ); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class SPIPES {
*/
public static final String uri = "http://onto.fel.cvut.cz/ontologies/s-pipes/";

protected static final org.apache.jena.rdf.model.Resource resource(String local )
protected static org.apache.jena.rdf.model.Resource resource(String local)
{ return ResourceFactory.createResource( uri + local ); }

protected static final Property property(String local )
protected static Property property(String local)
{ return ResourceFactory.createProperty( uri, local ); }

public static final Resource ProgressListener = resource("progress-listener");
Expand Down
4 changes: 2 additions & 2 deletions s-pipes-core/src/main/java/cz/cvut/spipes/constants/SPL.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class SPL {
*/
private static final String uri = "http://spinrdf.org/spl#";

protected static final Resource resource(String local )
protected static Resource resource(String local)
{ return ResourceFactory.createResource( uri + local ); }

protected static final Property property(String local )
protected static Property property(String local)
{ return ResourceFactory.createProperty( uri, local ); }

public static final Resource tarql = resource("Argument");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ public interface ExecutionContext {

// TODO named graphs ? -- in merge rather having multiple graphs (for debugging)
// TODO variable binding supporting stream etc .. ?
// TODO prefixe map ??
// TODO prefix map ??
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

public class ExecutionContextFactory {

/**
* @return
*/

public static ExecutionContext createEmptyContext() {
ExecutionContextImpl context = new ExecutionContextImpl();
context.setDefaultModel(ModelFactory.createDefaultModel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private ExecutionContext _executePipeline(long pipelineExecutionId, Module modul
return module.getOutputContext();
}

// module has no predeccesor
// module has no predecessor
if (module.getInputModules().isEmpty()) {
fire((l) -> {l.moduleExecutionStarted(pipelineExecutionId, moduleExecutionId, module, context, predecessorId); return null;});

Expand All @@ -62,7 +62,7 @@ private ExecutionContext _executePipeline(long pipelineExecutionId, Module modul
} else {
module.setInputContext(context);

log.info(" ##### " + module.getLabel());
log.info(" ##### {}", module.getLabel());
if (log.isTraceEnabled()) {
log.trace("Using input context {}", context.toTruncatedSimpleString()); //TODO redundant code -> merge
}
Expand All @@ -80,7 +80,7 @@ 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());
Expand Down Expand Up @@ -114,21 +114,18 @@ private ExecutionContext mergeContexts(Map<Resource, ExecutionContext> resource2
VariablesBinding variablesBinding = new VariablesBinding();


resource2ContextMap.entrySet().stream().forEach(e -> {

Resource modRes = e.getKey();
ExecutionContext context = e.getValue();
resource2ContextMap.forEach((modRes, context) -> {

// merge models
newModel.add(context.getDefaultModel());

// merge variable bindings
VariablesBinding b = e.getValue().getVariablesBinding();
VariablesBinding b = context.getVariablesBinding();

VariablesBinding conflictingBinding = variablesBinding.extendConsistently(b);

if (! conflictingBinding.isEmpty()) {
log.warn("Module {} has conflicting variables binding {} with sibling modules ocurring in pipeline. ", modRes, context);
if (!conflictingBinding.isEmpty()) {
log.warn("Module {} has conflicting variables binding {} with sibling modules occurring in pipeline. ", modRes, context);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

public class PipelineFactory {

private static final Logger log = LoggerFactory.getLogger(PipelineFactory.class);

// TODO inheritence not involved, not static context
static Map<Resource, Class<? extends Module>> moduleTypes = new HashMap<>();
// TODO inheritance not involved, not static context
static final Map<Resource, Class<? extends Module>> moduleTypes = new HashMap<>();

//TODO move to ModuleRegistry
static {
Expand Down Expand Up @@ -75,7 +73,7 @@ public static void registerModuleTypesOnClassPath() {

List<Class<? extends Module>> moduleClasses = reflections.getSubTypesOf(Module.class).stream().filter(
c -> !Modifier.isAbstract(c.getModifiers())
).collect(Collectors.toList());
).toList();

moduleClasses.forEach(
mClass -> {
Expand All @@ -96,7 +94,7 @@ public static void registerFunctionsOnClassPath() {

List<Class<? extends ARQFunction>> functionClasses = reflections.getSubTypesOf(ARQFunction.class).stream().filter(
c -> !Modifier.isAbstract(c.getModifiers())
).collect(Collectors.toList());
).toList();

functionClasses.forEach(
fClass -> {
Expand Down Expand Up @@ -124,13 +122,13 @@ public static Module loadModule(@NotNull Resource moduleRes) {
// TODO not very effective
public static Module loadPipeline(@NotNull Resource resource) {
return loadPipelines(resource.getModel()).stream().filter(m -> {
//TODO does not work on annonymous node
//TODO does not work on anonymous node
return resource.getURI().equals(m.getResource().getURI());
}).findAny().orElse(null);
}

/**
* @param configModel
* @param configModel configuration model containing pipeline definition
* @return List of output modules.
*/
public static List<Module> loadPipelines(@NotNull Model configModel) {
Expand All @@ -139,7 +137,7 @@ public static List<Module> loadPipelines(@NotNull Model configModel) {

Set<Module> inputModulesSet = res2ModuleMap.values().stream().flatMap(m -> m.getInputModules().stream()).collect(Collectors.toSet());

List<Module> outputModulesList = res2ModuleMap.values().stream().collect(Collectors.toList());
List<Module> outputModulesList = new ArrayList<>(res2ModuleMap.values());
outputModulesList.removeAll(inputModulesSet);

return outputModulesList;
Expand All @@ -151,37 +149,31 @@ private static Map<Resource, Module> loadAllModules(@NotNull Model configModel)
Map<Resource, Module> res2ModuleMap = new HashMap<>();

JenaPipelineUtils.getAllModulesWithTypes(configModel)
.entrySet()
.forEach(e -> {
Module m = loadModule(e.getKey(), e.getValue());
.forEach((key, value) -> {
Module m = loadModule(key, value);
if (m != null) {
res2ModuleMap.put(e.getKey(), m);
res2ModuleMap.put(key, m);
}
});
// .collect(Collectors.toMap(Map.Entry::getKey, e -> loadModule(e.getKey(), e.getValue())));


// set appropriate links //TODO problem 2 files reusing module inconsistently ? do i need to solve it ?
res2ModuleMap.entrySet()
.forEach(e -> {
Resource res = e.getKey();

// set up input modules
res.listProperties(SM.JENA.next).toList().stream()
.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);
}
return m;
}).filter(m -> (m != null)).forEach(
m -> {

m.getInputModules().add(e.getValue());
}
res2ModuleMap.forEach((res, value) -> {

// set up input modules
res.listProperties(SM.JENA.next).toList().stream()
.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);
}
return m;
}).filter(Objects::nonNull).forEach(
m -> m.getInputModules().add(value)
);

});
});

return res2ModuleMap;
}
Expand All @@ -195,12 +187,12 @@ private static Module loadModule(@NotNull Resource moduleRes, @NotNull Resource
return null;
}

Module module = null;
Module module;

try {
module = moduleClass.newInstance();
module = moduleClass.getDeclaredConstructor().newInstance();
module.setConfigurationResource(moduleRes);
} catch (InstantiationException | IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new IllegalArgumentException("Could not instantiate module of type " + moduleTypeRes, e);
}

Expand All @@ -209,16 +201,16 @@ private static Module loadModule(@NotNull Resource moduleRes, @NotNull Resource

public static Module instantiateModule(Class<? extends Module> moduleClass) {
try {
return moduleClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return moduleClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new IllegalArgumentException("Could not instantiate module of type " + moduleClass);
}
}

public static ARQFunction instantiateFunction(Class<? extends ARQFunction> functionClass) {
try {
return functionClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return functionClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new IllegalArgumentException("Could not instantiate function of type " + functionClass);
}
}
Expand All @@ -232,7 +224,7 @@ public static Module loadModule(@NotNull Path configFilePath, @NotNull String mo
configModel.read(new FileInputStream(configFilePath.toFile()), null, FileUtils.langTurtle);
return PipelineFactory.loadModule(configModel.createResource(moduleResourceUri));
} catch (FileNotFoundException e) {
e.printStackTrace();
log.error("Loading of module failed.", e);
throw new RuntimeException("Loading of module failed.");
}
}
Expand Down
Loading