final RequestNodeInput target,
Map<RequestNode, ProcessingElement> peToActivity,
Map<Location, PipelineWorkflow> workflows)
throws RepeatEnoughMissingControlInputException
{
RequestNode node = target.getRequestNode();
Connection connection = null;
for (Entry<String, Map<Integer, Connection>> entry: node.getAllInputs().entrySet())
{
for (Entry<Integer, Connection> input : entry.getValue().entrySet())
{
// ignore the literal output
if (input.getValue() == literal.getOutput())
{
continue;
}
else
{
// use the first connection we come across
// except other infinite repeaters
connection = input.getValue();
if (connection.getSource() instanceof LiteralValuesNode)
{
LiteralValuesNode lit = (LiteralValuesNode) connection.getSource();
// we can't use an infinite repeater as a control
if (isInfiniteRepeater(lit.getValues()))
{
connection = null;
continue;
}
}
if (connection != null)
{
break;
}
}
}
if (connection != null)
{
break;
}
}
if (connection == null)
{
throw new RepeatEnoughMissingControlInputException(node);
}
ProcessingElement controlledRepeat =
new ProcessingElement(ControlledRepeat.DEFAULT_ACTIVITY_NAME);
controlledRepeat.createInput(ControlledRepeat.INPUT_CONTROL);
controlledRepeat.createInput(ControlledRepeat.INPUT_REPEATED);
controlledRepeat.createOutput(ControlledRepeat.OUTPUT_CONTROL);
controlledRepeat.createOutput(ControlledRepeat.OUTPUT_REPEATED);
Location location = (Location)node.getAnnotation(AnnotationKeys.LOCATION);
workflows.get(location).add(controlledRepeat);
ProcessingElement targetActivity = peToActivity.get(node);
Repeater repeater = (Repeater)literal.getValues().get(0);
Object value = repeater.getValue();