private GpelSequence createBlockSequence(BlockNode blockNode, EndBlockNode endBlockNode, boolean blockBlock,
Collection<Node> parentBlock) throws GraphException {
Set<Node> block = getBlockBlock(blockNode, blockBlock);
parentBlock.removeAll(block);
GpelSequence sequence = new GpelSequence(this.bpelNS);
addBlock(block, sequence);
// Create a copy to global variable.
List<DataPort> outputPorts = endBlockNode.getOutputPorts();
ArrayList<GpelAssignCopy> copies = new ArrayList<GpelAssignCopy>();
for (int i = 0; i < outputPorts.size(); i++) {
DataPort outputPort = outputPorts.get(i);
String variable = outputPort.getID() + OUTPUT_SUFFIX;
int index = blockBlock ? i : i + outputPorts.size();
DataPort inputPort = endBlockNode.getInputPort(index);
Port fromPort = inputPort.getFromPort();
GpelAssignCopyFrom from = createAssignCopyFrom(fromPort);
GpelAssignCopyTo to = new GpelAssignCopyTo(this.bpelNS);
to.setVariable(variable);
GpelAssignCopy copy = new GpelAssignCopy(this.bpelNS, from, to);
copies.add(copy);
}
GpelAssign assign = new GpelAssign(this.bpelNS, copies);
sequence.addActivity(assign);
return sequence;
}