Search in sources :

Example 6 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class WorkflowInterpreterLaunchWindow method show.

/**
 * Shows the dialog.
 */
public void show() {
    this.workflow = this.engine.getGUI().getWorkflow();
    // Create input fields
    Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
    for (InputNode node : inputNodes) {
        String id = node.getID();
        DataType parameterType = node.getParameterType();
        JLabel nameLabel = new JLabel(id);
        JLabel typeField = new JLabel(parameterType.toString());
        XBayaTextField paramField = new XBayaTextField();
        Object value = node.getDefaultValue();
        String valueString;
        if (value == null) {
            valueString = "";
        } else {
            if (value instanceof XmlElement) {
                XmlElement valueElement = (XmlElement) value;
                valueString = XMLUtil.xmlElementToString(valueElement);
            } else {
                // Only string comes here for now.
                valueString = value.toString();
            }
        }
        paramField.setText(valueString);
        this.parameterPanel.add(nameLabel);
        this.parameterPanel.add(typeField);
        this.parameterPanel.add(paramField);
        this.parameterTextFields.add(paramField);
    }
    Map<String, String> hosts = null;
    try {
        hosts = airavataClient.getAllComputeResourceNames();
        if (hosts.isEmpty()) {
            JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "No Compute Resources found", "Compute Resources", JOptionPane.ERROR_MESSAGE);
            return;
        }
    } catch (InvalidRequestException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    } catch (AiravataClientException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    } catch (AiravataSystemException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    } catch (TException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    hostNames = new HashMap<String, String>();
    Iterator it = hosts.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry) it.next();
        String key = (String) pairs.getKey();
        String value = (String) pairs.getValue();
        if (!hostNames.containsKey(value)) {
            hostNames.put(value, key);
        }
    }
    host = new JComboBox();
    it = hostNames.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry) it.next();
        String key = (String) pairs.getKey();
        host.addItem(key);
    }
    host.setSelectedIndex(0);
    XBayaLabel hostLabel = new XBayaLabel("Host", host);
    this.parameterPanel.add(hostLabel);
    this.parameterPanel.add(host);
    this.parameterPanel.layout(inputNodes.size(), 3, GridPanel.WEIGHT_NONE, 2);
    this.dialog.show();
}
Also used : TException(org.apache.thrift.TException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) Iterator(java.util.Iterator) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) XmlElement(org.xmlpull.infoset.XmlElement) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) Map(java.util.Map) HashMap(java.util.HashMap) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 7 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class GraphCanvas method mouseReleased.

private void mouseReleased(MouseEvent event) {
    Point point = event.getPoint();
    if (this.draggedNode != null) {
        NodeController.getGUI(this.draggedNode).setDraggedFlag(false);
        this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
        // Check if it s stream grouping
        if (draggedNode instanceof InputNode) {
            StreamSourceNode streamNode = NodeController.getGUI(this.graph).getStreamSourceAt(point);
            if (streamNode != null) {
                streamNode.addInputNode((InputNode) draggedNode);
            }
        }
        this.draggedNode = null;
    }
    if (this.draggedPort != null) {
        GraphPiece graphPiece = NodeController.getGUI(this.graph).getGraphPieceAt(point);
        if (graphPiece instanceof DynamicNode) {
            if (this.draggedPort.getKind() == Kind.DATA_OUT && draggedPort instanceof DataPort) {
                this.panel.setCursor(SwingUtil.CROSSHAIR_CURSOR);
                DynamicNode dynamicNode = (DynamicNode) graphPiece;
                dynamicNode.getComponent();
                DataPort freePort = dynamicNode.getFreeInPort();
                try {
                    freePort.copyType((DataPort) draggedPort);
                } catch (GraphException e) {
                    engine.getGUI().getErrorWindow().error(e);
                    return;
                }
                // selectInputPort(freePort);
                connect(this.draggedPort, freePort);
                this.dynamicNodeWithFreePort = null;
            }
        } else if (graphPiece instanceof Port) {
            Port port = (Port) graphPiece;
            if (this.draggedPort.getKind() == Kind.DATA_OUT && port.getKind() == Kind.DATA_IN) {
                connect(this.draggedPort, port);
            } else if (port.getKind() == Kind.DATA_OUT && this.draggedPort.getKind() == Kind.DATA_IN) {
                connect(port, this.draggedPort);
            } else if (this.draggedPort.getKind() == Kind.CONTROL_OUT && port.getKind() == Kind.CONTROL_IN) {
                connect(this.draggedPort, port);
            } else if (this.draggedPort.getKind() == Kind.CONTROL_IN && port.getKind() == Kind.CONTROL_OUT) {
                connect(port, this.draggedPort);
            } else if (this.draggedPort.getKind() == Kind.EPR && port.getKind() == Kind.DATA_IN) {
                connect(this.draggedPort, port);
            } else if (this.draggedPort.getKind() == Kind.DATA_IN && port.getKind() == Kind.EPR) {
                connect(port, this.draggedPort);
            }
        }
        this.draggedPort = null;
    }
    if (this.dynamicNodeWithFreePort != null) {
        try {
            this.dynamicNodeWithFreePort.removeLastDynamicallyAddedInPort();
        } catch (GraphException e) {
            this.engine.getGUI().getErrorWindow().error(e);
        }
    }
    /*
         * Multiple selected
         */
    if (this.mousePointForSelection != null) {
        double width = Math.abs(this.mousePoint.getX() - this.mousePointForSelection.getX());
        double height = Math.abs(this.mousePoint.getY() - this.mousePointForSelection.getY());
        int x = (int) (this.mousePoint.getX() > this.mousePointForSelection.getX() ? this.mousePointForSelection.getX() : this.mousePoint.getX());
        int y = (int) (this.mousePoint.getY() > this.mousePointForSelection.getY() ? this.mousePointForSelection.getY() : this.mousePoint.getY());
        this.multipleSelectedNodes = NodeController.getGUI(this.graph).getNodesIn(new Rectangle(x, y, (int) width, (int) height));
        selectNodes(this.multipleSelectedNodes);
        // clear mousepoint
        this.mousePointForSelection = null;
    }
    if (this.multipleSelectedNodes != null) {
        this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
    }
    maybeShowPopup(event);
    updateSize();
    this.panel.repaint();
    event.consume();
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) GraphPiece(org.apache.airavata.workflow.model.graph.GraphPiece) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) Rectangle(java.awt.Rectangle) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Point(java.awt.Point) Point(java.awt.Point)

Example 8 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class ParameterPropertyWindow method ok.

private void ok() {
    String inputMetadataText = this.inputPanel.getMetadata();
    XmlElement inputMetadata;
    if (inputMetadataText.length() == 0) {
        inputMetadata = null;
    } else {
        try {
            inputMetadata = XMLUtil.stringToXmlElement(inputMetadataText);
        } catch (RuntimeException e) {
            String warning = "The input metadata is ill-formed.";
            this.engine.getGUI().getErrorWindow().error(warning, e);
            return;
        }
    }
    String outputMetadataText = this.outputPanel.getMetadata();
    XmlElement outputMetadata;
    if (outputMetadataText.length() == 0) {
        outputMetadata = null;
    } else {
        try {
            outputMetadata = XMLUtil.stringToXmlElement(outputMetadataText);
        } catch (RuntimeException e) {
            String warning = "The output metadata is ill-formed.";
            this.engine.getGUI().getErrorWindow().error(warning, e);
            return;
        }
    }
    // outputs, and the rest.
    for (int i = 0; i < this.inputNodes.size(); i++) {
        InputNode inputNode = this.inputNodes.get(i);
        Collections.swap(this.nodes, i, this.nodes.indexOf(inputNode));
    }
    for (int i = 0; i < this.outputNodes.size(); i++) {
        OutputNode outputNode = this.outputNodes.get(i);
        Collections.swap(this.nodes, this.inputNodes.size() + i, this.nodes.indexOf(outputNode));
    }
    hide();
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) XmlElement(org.xmlpull.infoset.XmlElement)

Example 9 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class JythonScript method writeSetup.

/**
 * @param pw
 */
private void writeSetup(PrintWriter pw) {
    // Initialize some variables.
    pw.println(GFAC_VARIABLE + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + GFAC_VARIABLE + "')");
    pw.println(TOPIC_VARIABLE + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + TOPIC_VARIABLE + "')");
    pw.println(BROKER_URL_VARIABLE + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + BROKER_URL_VARIABLE + "')");
    pw.println(MESSAGE_BOX_URL_VARIABLE + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + MESSAGE_BOX_URL_VARIABLE + "')");
    // Initialize a notification sender.
    // pw.println(NOTIFICATION_VARIABLE + " = " + NOTIFICATION_CLASS + "(" + BROKER_URL_VARIABLE + ", "
    // + TOPIC_VARIABLE + ")");
    // Send a START_WORKFLOW notification.
    pw.println(NOTIFICATION_VARIABLE + "." + WORKFLOW_STARTED_METHOD + "(");
    boolean first = true;
    for (InputNode inputNode : this.inputNodes) {
        String id = inputNode.getID();
        if (first) {
            first = false;
        } else {
            pw.println(",");
        }
        pw.print(TAB + id + "=" + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + id + "')");
    }
    pw.println(")");
    pw.println();
    // The biggining of try
    pw.println("try:");
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode)

Example 10 with InputNode

use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.

the class JythonScript method writeInvocation.

/**
 * @param node
 * @param thread
 * @param pw
 */
private void writeInvocation(WSNode node, boolean thread, PrintWriter pw) {
    String id = node.getID();
    String wsdlID = getWSDLID(node);
    WSComponent component = node.getComponent();
    QName portTypeQName = component.getPortTypeQName();
    String operation = component.getOperationName();
    pw.println(TAB + "# Invoke " + id + ".");
    pw.println(TAB + id + QNAME_SUFFIX + " = QName('" + portTypeQName.getNamespaceURI() + "', '" + portTypeQName.getLocalPart() + "')");
    pw.println(TAB + wsdlID + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + wsdlID + "')");
    pw.println(TAB + id + INVOKER_SUFFIX + " = " + "(" + id + QNAME_SUFFIX + ", " + wsdlID + ", '" + id + "',");
    pw.println(TAB + TAB + MESSAGE_BOX_URL_VARIABLE + ", " + GFAC_VARIABLE + ", " + NOTIFICATION_VARIABLE + ")");
    pw.println(TAB + "def " + INVOKE_METHOD + id + "():");
    pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SETUP_METHOD + "()");
    pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SET_OPERATION_METHOD + "('" + operation + "')");
    // Ports
    for (Port port : node.getInputPorts()) {
        String portName = port.getName();
        String value;
        Node fromNode = port.getFromNode();
        if (fromNode instanceof InputNode) {
            value = PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + fromNode.getID() + "')";
        } else {
            Port fromPort = port.getFromPort();
            value = "" + fromNode.getID() + INVOKER_SUFFIX + "." + GET_OUTPUT_METHOD + "('" + fromPort.getName() + "')";
            // This might try to remove a node that has been removed
            // already, but it's OK.
            this.executingNodes.remove(fromNode);
        }
        pw.println(TAB + TAB + portName + VALUE_SUFFIX + " = " + value);
        pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + SET_INPUT_METHOD + "('" + portName + "', " + portName + VALUE_SUFFIX + ")");
    }
    pw.println(TAB + TAB + "print 'Invoking " + id + ".'");
    pw.println(TAB + TAB + id + INVOKER_SUFFIX + "." + INVOKE_METHOD + "()");
    if (thread) {
        pw.println(TAB + "thread.start_new_thread(" + INVOKE_METHOD + id + ", ())");
    } else {
        pw.println(TAB + INVOKE_METHOD + id + "()");
    }
    pw.println();
    this.executingNodes.add(node);
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) QName(javax.xml.namespace.QName) Port(org.apache.airavata.workflow.model.graph.Port) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent)

Aggregations

InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)29 Node (org.apache.airavata.workflow.model.graph.Node)14 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)10 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)10 Port (org.apache.airavata.workflow.model.graph.Port)9 DataPort (org.apache.airavata.workflow.model.graph.DataPort)7 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)7 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)7 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)7 GraphException (org.apache.airavata.workflow.model.graph.GraphException)6 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)6 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)6 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)6 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)6 LinkedList (java.util.LinkedList)5 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)5 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 Workflow (org.apache.airavata.workflow.model.wf.Workflow)4 WorkFlowInterpreterException (org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)3