use of org.apache.airavata.workflow.model.graph.impl.PortImpl in project airavata by apache.
the class IfNodeGUI method setPortPositions.
/**
* Sets up the position of ports
*/
@Override
protected void setPortPositions() {
List<? extends Port> inputPorts = this.node.getInputPorts();
for (int i = 0; i < inputPorts.size(); i++) {
Port port = inputPorts.get(i);
Point offset = new Point(PortGUI.DATA_PORT_SIZE / 2, this.headHeight + PORT_INITIAL_GAP + PORT_GAP * i);
NodeController.getGUI(port).setOffset(offset);
}
PortImpl controlInPort = this.node.getControlInPort();
if (controlInPort != null) {
Point offset = new Point(0, this.headHeight / 2);
NodeController.getGUI(controlInPort).setOffset(offset);
}
// There are two controlOutPorts.
List<? extends Port> controlOutPorts = this.node.getControlOutPorts();
Port controlOutPort1 = controlOutPorts.get(0);
Point offset = new Point(getBounds().width, +this.headHeight / 2);
PortGUI truePortGUI = NodeController.getGUI(controlOutPort1);
truePortGUI.setOffset(offset);
truePortGUI.setPortText("T");
Port controlOutPort2 = controlOutPorts.get(1);
offset = new Point(this.getBounds().width, getBounds().height - this.headHeight / 2);
PortGUI falsePortGUI = NodeController.getGUI(controlOutPort2);
falsePortGUI.setOffset(offset);
falsePortGUI.setPortText("F");
// No outputs
}
use of org.apache.airavata.workflow.model.graph.impl.PortImpl in project airavata by apache.
the class WorkflowModifier method createDifference.
/**
* @return The workflow that needs to be executed.
* @throws GraphException
* @throws MonitorException
*/
public Workflow createDifference() throws GraphException, MonitorException {
WSGraph originalGraph = this.modifiedWorkflow.getGraph();
Workflow workflow = this.modifiedWorkflow.clone();
String name = workflow.getName();
name += " (diff)";
workflow.setName(name);
WSGraph graph = workflow.getGraph();
// Remove the finished node.
removeFinishedNodes(originalGraph, graph);
Set<WSPort> originalFromPorts = getFinalOutputPorts(originalGraph, graph);
// Create input nodes for unconnected input ports.
createInputNodes(graph, originalFromPorts);
// Set default values.
for (WSPort originalFromPort : originalFromPorts) {
// TODO handle the case that node is not WSNode.
Node originalFromNode = originalFromPort.getNode();
String fromNodeID = originalFromNode.getID();
String output;
if (originalFromNode instanceof InputNode) {
// notification that includes the input of the workflow.
output = getWorkflowInput(fromNodeID);
} else if (originalFromNode instanceof WSNode) {
// Retrieve input value from notification.
WSComponent component = ((WSNode) originalFromNode).getComponent();
String messageName = component.getOutputTypeName();
String parameterName = originalFromPort.getComponentPort().getName();
output = getOutput(fromNodeID, messageName, parameterName);
} else {
// This should not happen.
throw new WorkflowRuntimeException(originalFromNode.getClass().getName());
}
Port originalToPort = originalFromPort.getToPorts().get(0);
PortImpl toPort = graph.getPort(originalToPort.getID());
InputNode inputNode = (InputNode) toPort.getFromNode();
inputNode.setDefaultValue(output);
}
return workflow;
}
Aggregations