Search in sources :

Example 1 with PropertyTransformationFactory

use of eu.esdihumboldt.hale.common.align.extension.transformation.PropertyTransformationFactory in project hale by halestudio.

the class FunctionExecutor method processValid.

/**
 * @see CellNodeValidator#processValid(Cell, ListMultimap, ListMultimap)
 */
@Override
protected void processValid(Cell cell, ListMultimap<String, Pair<SourceNode, Entity>> sources, ListMultimap<String, Pair<TargetNode, Entity>> targets) {
    if (cell.getPriority() != functionPriority) {
        // ignore the priorities that do not match
        return;
    }
    /*
		 * if the result node is only one and its value had already been set, it
		 * is not necessary to execute this function of a lower priority. (if
		 * there are more than one target node we will need to execute them all
		 * and check at the end of the transformation.
		 */
    if (targets.size() == 1) {
        TargetNode targetNode = targets.values().iterator().next().getFirst();
        if (targetNode.isDefined()) {
            // pass
            return;
        }
    }
    String functionId = cell.getTransformationIdentifier();
    List<PropertyTransformationFactory> transformations = this.transformations.getPropertyTransformations(functionId);
    if (transformations == null || transformations.isEmpty()) {
        reporter.error(new TransformationMessageImpl(cell, MessageFormat.format("No transformation for function {0} found. Skipping property transformation.", functionId), null));
    } else {
        // TODO select based on e.g. preferred transformation engine?
        PropertyTransformationFactory transformation = transformations.iterator().next();
        executeTransformation(transformation, cell, sources, targets);
    }
}
Also used : TargetNode(eu.esdihumboldt.hale.common.align.model.transformation.tree.TargetNode) PropertyTransformationFactory(eu.esdihumboldt.hale.common.align.extension.transformation.PropertyTransformationFactory) TransformationMessageImpl(eu.esdihumboldt.hale.common.align.transformation.report.impl.TransformationMessageImpl)

Example 2 with PropertyTransformationFactory

use of eu.esdihumboldt.hale.common.align.extension.transformation.PropertyTransformationFactory in project hale by halestudio.

the class AbstractDefaultTransformationFunctionService method getPropertyTransformations.

@Override
public List<PropertyTransformationFactory> getPropertyTransformations(String functionId) {
    List<PropertyTransformationFactory> functions = super.getPropertyTransformations(functionId);
    Alignment al = getCurrentAlignment();
    if (al != null) {
        List<PropertyTransformationFactory> cfs = new ArrayList<>(functions);
        String localId = functionId;
        if (localId.startsWith(PREFIX_ALIGNMENT_FUNCTION)) {
            localId = localId.substring(PREFIX_ALIGNMENT_FUNCTION.length());
        }
        CustomPropertyFunction cf = al.getAllCustomPropertyFunctions().get(localId);
        if (cf != null) {
            cfs.add(new CustomPropertyFunctionFactory(cf));
        }
        functions = cfs;
    }
    return functions;
}
Also used : Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) ArrayList(java.util.ArrayList) PropertyTransformationFactory(eu.esdihumboldt.hale.common.align.extension.transformation.PropertyTransformationFactory) CustomPropertyFunction(eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)

Aggregations

PropertyTransformationFactory (eu.esdihumboldt.hale.common.align.extension.transformation.PropertyTransformationFactory)2 CustomPropertyFunction (eu.esdihumboldt.hale.common.align.extension.function.custom.CustomPropertyFunction)1 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1 TargetNode (eu.esdihumboldt.hale.common.align.model.transformation.tree.TargetNode)1 TransformationMessageImpl (eu.esdihumboldt.hale.common.align.transformation.report.impl.TransformationMessageImpl)1 ArrayList (java.util.ArrayList)1