Search in sources :

Example 16 with XmlElement

use of org.xmlpull.infoset.XmlElement in project airavata by apache.

the class BlockNode method toXML.

@Override
protected XmlElement toXML() {
    XmlElement nodeElement = super.toXML();
    nodeElement.setAttributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE, GraphSchema.NODE_TYPE_IF);
    return nodeElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 17 with XmlElement

use of org.xmlpull.infoset.XmlElement 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 18 with XmlElement

use of org.xmlpull.infoset.XmlElement 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 19 with XmlElement

use of org.xmlpull.infoset.XmlElement 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 20 with XmlElement

use of org.xmlpull.infoset.XmlElement in project airavata by apache.

the class EndBlockNode method toXML.

@Override
protected XmlElement toXML() {
    XmlElement nodeElement = super.toXML();
    nodeElement.setAttributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE, GraphSchema.NODE_TYPE_ENDBLOCK);
    return nodeElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Aggregations

XmlElement (org.xmlpull.infoset.XmlElement)79 AiravataException (org.apache.airavata.common.exception.AiravataException)5 GraphException (org.apache.airavata.workflow.model.graph.GraphException)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)4 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)4 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)4 LinkedList (java.util.LinkedList)3 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)3 Workflow (org.apache.airavata.workflow.model.wf.Workflow)3 XmlAttribute (org.xmlpull.infoset.XmlAttribute)3 JsonObject (com.google.gson.JsonObject)2 File (java.io.File)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 WSComponent (org.apache.airavata.workflow.model.component.ws.WSComponent)2 WorkflowException (org.apache.airavata.workflow.model.exceptions.WorkflowException)2 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)2