Search in sources :

Example 6 with PortImpl

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
}
Also used : PortGUI(org.apache.airavata.xbaya.ui.graph.PortGUI) Port(org.apache.airavata.workflow.model.graph.Port) Point(java.awt.Point) Point(java.awt.Point) PortImpl(org.apache.airavata.workflow.model.graph.impl.PortImpl)

Example 7 with PortImpl

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;
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Workflow(org.apache.airavata.workflow.model.wf.Workflow) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) PortImpl(org.apache.airavata.workflow.model.graph.impl.PortImpl)

Aggregations

PortImpl (org.apache.airavata.workflow.model.graph.impl.PortImpl)7 Point (java.awt.Point)3 Port (org.apache.airavata.workflow.model.graph.Port)3 ControlPort (org.apache.airavata.workflow.model.graph.ControlPort)2 SystemDataPort (org.apache.airavata.workflow.model.graph.system.SystemDataPort)2 List (java.util.List)1 WSComponent (org.apache.airavata.workflow.model.component.ws.WSComponent)1 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)1 ControlEdge (org.apache.airavata.workflow.model.graph.ControlEdge)1 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)1 Node (org.apache.airavata.workflow.model.graph.Node)1 InstanceDataPort (org.apache.airavata.workflow.model.graph.amazon.InstanceDataPort)1 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)1 WSGraph (org.apache.airavata.workflow.model.graph.ws.WSGraph)1 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)1 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)1 Workflow (org.apache.airavata.workflow.model.wf.Workflow)1 PortGUI (org.apache.airavata.xbaya.ui.graph.PortGUI)1