
be.ugent.rml.functions.StaticMultipleRecordsFunctionExecutor Maven / Gradle / Ivy
package be.ugent.rml.functions;
import be.ugent.rml.records.Record;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class StaticMultipleRecordsFunctionExecutor implements MultipleRecordsFunctionExecutor {
private final FunctionModel functionModel;
private final Map parameters;
public StaticMultipleRecordsFunctionExecutor(FunctionModel model, Map parameters) {
this.functionModel = model;
this.parameters = parameters;
}
@Override
public Object execute(Map records) throws Exception {
Map filledInParameters = new HashMap<>();
for (Map.Entry entry : this.parameters.entrySet()) {
SingleRecordFunctionExecutor executor = (SingleRecordFunctionExecutor) entry.getValue()[1];
String recordType = (String) entry.getValue()[0];
Object o = executor.execute(records.get(recordType));
if (o != null) {
filledInParameters.put(entry.getKey(), o);
} else {
// TODO check whether key is actually optional!
filledInParameters.put(entry.getKey(), null);
}
}
return this.functionModel.execute(filledInParameters);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy