Search in sources :

Example 1 with Leftovers

use of eu.esdihumboldt.hale.common.align.model.transformation.tree.Leftovers in project hale by halestudio.

the class DuplicationVisitor method visit.

/**
 * @see AbstractTransformationNodeVisitor#visit(SourceNode)
 */
@Override
public boolean visit(SourceNode source) {
    Leftovers leftovers = source.getLeftovers();
    if (leftovers != null) {
        // identify context match (if possible)
        TransformationContext context = source.getContext();
        if (context == null) {
            // no transformation context match defined
            log.warn(log.createMessage("Multiple values for source node w/o transformation context match", null));
        } else {
            Pair<SourceNode, Set<Cell>> leftover;
            // completely consume leftovers
            while ((leftover = leftovers.consumeValue()) != null) {
                context.duplicateContext(source, leftover.getFirst(), leftover.getSecond(), log);
                // XXX is this the place where this should be propagated to
                // the duplicated source children?
                // XXX trying it out
                SourceNode node = leftover.getFirst();
                Object value = node.getValue();
                if (value instanceof Group) {
                    InstanceVisitor instanceVisitor = new InstanceVisitor(null, null, log);
                    for (SourceNode child : node.getChildren(instanceVisitor.includeAnnotatedNodes())) {
                        // annotate children with leftovers
                        child.accept(instanceVisitor);
                        // run the duplication on the children
                        child.accept(this);
                    }
                }
            }
        }
    }
    return true;
}
Also used : Leftovers(eu.esdihumboldt.hale.common.align.model.transformation.tree.Leftovers) Group(eu.esdihumboldt.hale.common.instance.model.Group) SourceNode(eu.esdihumboldt.hale.common.align.model.transformation.tree.SourceNode) Set(java.util.Set) TransformationContext(eu.esdihumboldt.hale.common.align.model.transformation.tree.context.TransformationContext)

Aggregations

Leftovers (eu.esdihumboldt.hale.common.align.model.transformation.tree.Leftovers)1 SourceNode (eu.esdihumboldt.hale.common.align.model.transformation.tree.SourceNode)1 TransformationContext (eu.esdihumboldt.hale.common.align.model.transformation.tree.context.TransformationContext)1 Group (eu.esdihumboldt.hale.common.instance.model.Group)1 Set (java.util.Set)1