*/
private GpelAssignCopyFrom createAssignCopyFrom(Port port) throws GraphException {
GpelAssignCopyFrom from = new GpelAssignCopyFrom(this.bpelNS);
Port fromPort = port.getFromPort();
Node fromNode = fromPort.getNode();
if (fromNode instanceof InputNode) {
from.setVariable(WORKFLOW_INPUT_NAME);
from.setPart(WorkflowWSDL.INPUT_PART_NAME);
from.setQuery("/" + this.typesNamespace.getPrefix() + ":"
+ this.workflowWSDL.getWorkflowInputMessageElelmentName() + "/" + fromNode.getID());
} else if (fromNode instanceof ConstantNode) {
ConstantNode constNode = (ConstantNode) fromNode;
Object value = constNode.getValue();
// The namaspace and name of the literal element will be set
// correctly in from.setLiteral().
XmlElement literalElement = XMLUtil.BUILDER.newFragment(GpelAssignCopyFrom.LITERAL_EL);
literalElement.addChild(value);
from.setLiteral(literalElement);
} else if (fromNode instanceof WSNode) {
String fromID = fromNode.getID();
WSComponent fromWsdlComponent = (WSComponent) fromNode.getComponent();
WSComponentPort fromWsdlPort = (WSComponentPort) fromPort.getComponentPort();
from.setVariable(fromID + OUTPUT_SUFFIX);
from.setPart(fromWsdlComponent.getOutputPartName());
if (fromWsdlPort.isSchemaUsed()) {
String typesTargetNamespace = fromWsdlPort.getTargetNamespace();
XmlNamespace namespace = XMLUtil.declareNamespaceIfNecessary(fromID.toLowerCase() + TYPENS_SUFFIX,
typesTargetNamespace, false, this.process.xml());
from.setQuery("/" + namespace.getPrefix() + ":" + fromWsdlComponent.getOutputTypeName() + "/"
+ fromWsdlPort.getName());
} else {
// No query needed?
}
} else if (fromNode instanceof ForEachNode) {
from.setVariable(fromNode.getID() + FOREACH_VALUE_SUFFIX);
} else if (fromNode instanceof EndForEachNode) {
from.setVariable(fromNode.getID() + ARRAY_SUFIX);
} else if (fromNode instanceof EndifNode) {
// endif has multiple outputs, so we use port ID here.
from.setVariable(fromPort.getID() + OUTPUT_SUFFIX);
} else if (fromNode instanceof ReceiveNode) {
if (fromPort instanceof EPRPort) {
from.setPartnerLink(fromNode.getID() + PARTNER_LINK_NAME_SUFFIX);
from.setEndpointReference("myRole");
} else {
from.setVariable(fromNode.getID() + INPUT_SUFFIX);
}
} else if (fromNode instanceof InstanceNode) {
// no op
} else {
throw new GraphException("Unexpected node," + fromNode.getClass().getName() + " is connected");
}
return from;
}