Port fromPort = port.getFromPort();
if (fromPort != null) {
String variableName = port.getID() + INPUT_SUFFIX;
GpelVariable ifVar = new GpelVariable(this.process.xml().getNamespace(), variableName);
XmlNamespace xsdNS = process.xml().lookupNamespaceByName(WSConstants.XSD_NS_URI);
if (null != xsdNS && xsdNS.getPrefix() != null) {
ifVar.xml().setAttributeValue("element",
xsdNS.getPrefix() + ":" + WSConstants.XSD_ANY_TYPE.getLocalPart());
} else {
this.process.xml().declareNamespace(WSConstants.XSD_NS);
ifVar.xml().setAttributeValue("element",
WSConstants.XSD_NS.getPrefix() + ":" + WSConstants.XSD_ANY_TYPE.getLocalPart());
}
this.process.getVariables().addVariable(ifVar);
GpelAssignCopyFrom from = createAssignCopyFrom(fromPort);
GpelAssignCopyTo to = new GpelAssignCopyTo(this.bpelNS);
to.setVariable(variableName);
GpelAssignCopy copy = new GpelAssignCopy(this.bpelNS, from, to);
copies.add(copy);
booleanExpression = booleanExpression.replaceAll("\\$" + i, "\\$" + variableName);
}
}
if (copies.size() > 0) {
GpelAssign assign = new GpelAssign(this.bpelNS, copies);
sequence.addActivity(assign);
}
GpelCondition condition = new GpelCondition(this.bpelNS, booleanExpression);
//
// If block
//
EndifNode endifNode = getEndifNode(ifNode);
GpelSequence ifSequence = createIfSequence(ifNode, endifNode, true, parentBlock);
GpelIf gpelIf = new GpelIf(this.bpelNS, condition, ifSequence);
//
// Else block
//
GpelSequence elseSequence = createIfSequence(ifNode, endifNode, false, parentBlock);
GpelElse gpelElse = new GpelElse(this.bpelNS, elseSequence);
gpelIf.setElse(gpelElse);
//
// Create global variables for endif.
//
for (Port outputPort : endifNode.getOutputPorts()) {
String variable = outputPort.getID() + OUTPUT_SUFFIX;
GpelVariable ifVar = new GpelVariable(this.process.xml().getNamespace(), variable);
XmlNamespace xsdNS = process.xml().lookupNamespaceByName(WSConstants.XSD_NS_URI);
if (null != xsdNS && xsdNS.getPrefix() != null) {
ifVar.xml().setAttributeValue("element",
xsdNS.getPrefix() + ":" + WSConstants.XSD_ANY_TYPE.getLocalPart());
} else {
this.process.xml().declareNamespace(WSConstants.XSD_NS);
ifVar.xml().setAttributeValue("element",
WSConstants.XSD_NS.getPrefix() + ":" + WSConstants.XSD_ANY_TYPE.getLocalPart());
}