Search in sources :

Example 1 with DataType

use of org.apache.airavata.model.appcatalog.appinterface.DataType 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 2 with DataType

use of org.apache.airavata.model.appcatalog.appinterface.DataType in project airavata by apache.

the class DifferedInputConfigurationDialog method setInput.

private void setInput() {
    DataType type = this.node.getParameterType();
    XBayaTextComponent textComponent;
    textComponent = this.valueTextField;
    String name = this.nameTextField.getText();
    String description = this.descriptionTextArea.getText();
    String valueString = textComponent.getText();
    String metadataText = this.metadataTextArea.getText();
    if (name.length() == 0) {
        String warning = "The name cannot be empty.";
        this.xbayaGUI.getErrorWindow().error(warning);
        return;
    }
    Object value = null;
    if (valueString.length() > 0) {
        if (!this.node.isInputValid(valueString)) {
            String warning = "The defalut value is not valid for " + this.node.getParameterType() + ".";
            this.xbayaGUI.getErrorWindow().error(warning);
        }
        value = valueString;
    }
    XmlElement metadata;
    if (metadataText.length() == 0) {
        metadata = null;
    } else {
        try {
            metadata = XMLUtil.stringToXmlElement(metadataText);
        } catch (RuntimeException e) {
            String warning = "The metadata is ill-formed.";
            this.xbayaGUI.getErrorWindow().error(warning, e);
            return;
        }
    }
    this.node.setConfigured(true);
    this.node.setConfiguredName(name);
    this.node.setDescription(description);
    this.node.setDefaultValue(value);
    this.node.setMetadata(metadata);
    this.node.setState(NodeExecutionState.FINISHED);
    hide();
    this.xbayaGUI.getGraphCanvas().repaint();
}
Also used : XBayaTextComponent(org.apache.airavata.xbaya.ui.widgets.XBayaTextComponent) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) XmlElement(org.xmlpull.infoset.XmlElement)

Example 3 with DataType

use of org.apache.airavata.model.appcatalog.appinterface.DataType in project airavata by apache.

the class ForEachNode method portTypeChanged.

/**
 * @param port
 * @throws GraphException
 */
@Override
protected void portTypeChanged(SystemDataPort port) throws GraphException {
    super.portTypeChanged(port);
    List<DataPort> inputPorts = getInputPorts();
    List<DataPort> outputPorts = getOutputPorts();
    Kind kind = port.getKind();
    int index;
    if (kind == Kind.DATA_IN) {
        index = inputPorts.indexOf(port);
    } else if (kind == Kind.DATA_OUT) {
        index = outputPorts.indexOf(port);
    } else {
        throw new WorkflowRuntimeException();
    }
    SystemDataPort inputPort = (SystemDataPort) inputPorts.get(index);
    SystemDataPort outputPort = (SystemDataPort) outputPorts.get(index);
    DataType inputType = inputPort.getType();
    DataType outputType = outputPort.getType();
    DataType portType = port.getType();
    if (portType == null || portType.equals(WSConstants.XSD_ANY_TYPE)) {
        // Do nothing
        return;
    }
    if (port == inputPort) {
        // input -> output
        if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
        // outputPort.copyType(port, -1);
        } else if (outputType.equals(portType)) {
        // Do nothing.
        } else {
        // XXX cannot parse array from WSDL.
        // String message = "The type of input " + index + " ("
        // + inputType + ") of " + getID()
        // + " must be same as the type of output " + index + " ("
        // + outputType + ").";
        // throw new GraphException(message);
        }
    } else if (port == outputPort) {
        // output -> input1
        if (inputType.equals(WSConstants.XSD_ANY_TYPE)) {
        // inputPort.copyType(port, 1);
        } else if (inputType.equals(portType)) {
        // Do nothing.
        } else {
        // XXX cannot parse array from WSDL.
        // String message = "The type of input " + index + " ("
        // + inputType + ") of " + getID()
        // + " must be same as the type of output " + index + " ("
        // + outputType + ").";
        // throw new GraphException(message);
        }
    } else {
        throw new WorkflowRuntimeException();
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) Kind(org.apache.airavata.workflow.model.graph.Port.Kind) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 4 with DataType

use of org.apache.airavata.model.appcatalog.appinterface.DataType in project airavata by apache.

the class InputNode method edgeWasRemoved.

/**
 * Called whan an Edge was removed from the parameter port. Change the name of the node.
 *
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasRemoved(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
 */
@Override
protected void edgeWasRemoved(Edge removedEdge) {
    super.edgeWasRemoved(removedEdge);
    // TODO organize this.
    List<DataEdge> edges = getEdges();
    if (edges.size() == 0) {
        setParameterType(null);
        if (!isConfigured()) {
            // Reset
            setName(getComponent().getName());
            setDescription("");
            setDefaultValue(null);
            setMetadata(null);
        }
    } else {
        Edge edge = edges.get(0);
        Port toPort = edge.getToPort();
        WSPort toWsPort = (WSPort) toPort;
        DataType toType = toWsPort.getType();
        setParameterType(toType);
        if (!isConfigured()) {
            // Copy
            copyDefaultConfiguration(toWsPort);
        }
    }
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSComponentPort(org.apache.airavata.workflow.model.component.ws.WSComponentPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) Edge(org.apache.airavata.workflow.model.graph.Edge) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge)

Example 5 with DataType

use of org.apache.airavata.model.appcatalog.appinterface.DataType in project airavata by apache.

the class S3InputNode method edgeWasRemoved.

/**
 * Called whan an Edge was removed from the parameter port. Change the name of the node.
 *
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasRemoved(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
 */
@Override
protected void edgeWasRemoved(Edge removedEdge) {
    super.edgeWasRemoved(removedEdge);
    // TODO organize this.
    List<DataEdge> edges = getEdges();
    if (edges.size() == 0) {
        setParameterType(null);
        if (!isConfigured()) {
            // Reset
            setName(getComponent().getName());
            setDescription("");
            setDefaultValue(null);
            setMetadata(null);
        }
    } else {
        Edge edge = edges.get(0);
        Port toPort = edge.getToPort();
        WSPort toWsPort = (WSPort) toPort;
        DataType toType = toWsPort.getType();
        setParameterType(toType);
        if (!isConfigured()) {
            // Copy
            copyDefaultConfiguration(toWsPort);
        }
    }
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSComponentPort(org.apache.airavata.workflow.model.component.ws.WSComponentPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) Edge(org.apache.airavata.workflow.model.graph.Edge) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge)

Aggregations

DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)15 DataPort (org.apache.airavata.workflow.model.graph.DataPort)10 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)8 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)5 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)4 Port (org.apache.airavata.workflow.model.graph.Port)4 XmlElement (org.xmlpull.infoset.XmlElement)4 GraphException (org.apache.airavata.workflow.model.graph.GraphException)3 XBayaTextComponent (org.apache.airavata.xbaya.ui.widgets.XBayaTextComponent)3 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 JComboBox (javax.swing.JComboBox)2 JLabel (javax.swing.JLabel)2 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)2 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)2 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)2 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)2 WSComponentPort (org.apache.airavata.workflow.model.component.ws.WSComponentPort)2 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)2