All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.ugent.rml.functions.StaticMultipleRecordsFunctionExecutor Maven / Gradle / Ivy

Go to download

The RMLMapper executes RML rules to generate high quality Linked Data from multiple originally (semi-)structured data sources.

There is a newer version: 7.2.0
Show newest version
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