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;
}
Aggregations