be.ugent.rml.functions.DynamicMultipleRecordsFunctionExecutor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rmlmapper Show documentation
Show all versions of rmlmapper Show documentation
The RMLMapper executes RML rules to generate high quality Linked Data from multiple originally (semi-)structured data sources.
package be.ugent.rml.functions;
import be.ugent.rml.NAMESPACES;
import be.ugent.rml.records.Record;
import be.ugent.rml.term.NamedNode;
import be.ugent.rml.term.Term;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
public class DynamicMultipleRecordsFunctionExecutor implements MultipleRecordsFunctionExecutor {
private static final Logger logger = LoggerFactory.getLogger(DynamicMultipleRecordsFunctionExecutor.class);
private List parameterValuePairs;
private FunctionLoader functionLoader;
public DynamicMultipleRecordsFunctionExecutor(List parameterValuePairs, FunctionLoader functionLoader) {
this.parameterValuePairs = parameterValuePairs;
this.functionLoader = functionLoader;
}
@Override
public Object execute(Map records) throws Exception {
final ArrayList fnTerms = new ArrayList<>();
final ArrayList args = new ArrayList<>();
parameterValuePairs.forEach(pv -> {
ArrayList parameters = new ArrayList<>();
ArrayList values = new ArrayList<>();
pv.getParameterGenerators().forEach(parameterGen -> {
try {
parameters.addAll(parameterGen.generate(records.get("child")));
} catch (Exception e) {
//todo be more nice and gentle
e.printStackTrace();
}
});
pv.getValueGeneratorPairs().forEach(pair -> {
try {
values.addAll(pair.getTermGenerator().generate(records.get(pair.getOrigin())));
} catch (Exception e) {
//todo be more nice and gentle
e.printStackTrace();
}
});
if (parameters.contains(new NamedNode(NAMESPACES.FNO + "executes")) || parameters.contains(new NamedNode(NAMESPACES.FNO_S + "executes"))) {
if (parameters.contains(new NamedNode(NAMESPACES.FNO + "executes"))) {
logger.warn("http is used instead of https for " + NAMESPACES.FNO_S + ". " +
"Still works for now, but will be deprecated in the future.");
}
fnTerms.add(values.get(0));
} else {
parameters.forEach(parameter -> {
ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy