Search in sources :

Example 1 with XmlElement

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

the class WSDLUtil method replaceAttributeValue.

/**
 * @param element
 * @param name
 * @param oldValue
 * @param newValue
 */
public static void replaceAttributeValue(XmlElement element, String name, String oldValue, String newValue) {
    XmlAttribute attribute = element.attribute(name);
    if (null != attribute && oldValue.equals(attribute.getValue())) {
        element.removeAttribute(attribute);
        element.setAttributeValue(name, newValue);
    }
    Iterable iterator = element.children();
    for (Object object : iterator) {
        if (object instanceof XmlElement) {
            replaceAttributeValue((XmlElement) object, name, oldValue, newValue);
        }
    }
}
Also used : XmlAttribute(org.xmlpull.infoset.XmlAttribute) XmlElement(org.xmlpull.infoset.XmlElement)

Example 2 with XmlElement

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

the class WSDLUtil method attributeExist.

public static boolean attributeExist(XmlElement element, String name, String value) {
    XmlAttribute attribute = element.attribute(name);
    if (null != attribute && value.equals(attribute.getValue())) {
        return true;
    }
    Iterable iterator = element.children();
    boolean ret = false;
    for (Object object : iterator) {
        if (object instanceof XmlElement) {
            ret = ret || attributeExist((XmlElement) object, name, value);
        }
    }
    return ret;
}
Also used : XmlAttribute(org.xmlpull.infoset.XmlAttribute) XmlElement(org.xmlpull.infoset.XmlElement)

Example 3 with XmlElement

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

the class WorkflowFiler method getWorkflow.

/**
 * @param workflow
 * @return
 */
public Workflow getWorkflow() {
    Workflow workflow = null;
    int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = this.graphFileChooser.getSelectedFile();
        logger.debug(file.getPath());
        try {
            String path = file.getPath();
            if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
                WSGraph graph = WSGraphFactory.createGraph(file);
                workflow = Workflow.graphToWorkflow(graph);
            } else {
                XmlElement workflowElement = XMLUtil.loadXML(file);
                workflow = new Workflow(workflowElement);
            }
        } catch (IOException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
        } catch (GraphException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (ComponentException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (RuntimeException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        } catch (Error e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        }
    }
    return workflow;
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Workflow(org.apache.airavata.workflow.model.wf.Workflow) XmlElement(org.xmlpull.infoset.XmlElement) IOException(java.io.IOException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) File(java.io.File)

Example 4 with XmlElement

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

the class WorkflowFiler method importWorkflow.

/**
 * Imports a workflow from the local file to the current workflow.
 */
public void importWorkflow() {
    int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = this.graphFileChooser.getSelectedFile();
        try {
            String path = file.getPath();
            Workflow importedWorkflow;
            if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
                WSGraph importedGraph = WSGraphFactory.createGraph(file);
                importedWorkflow = Workflow.graphToWorkflow(importedGraph);
            } else {
                XmlElement importedWorkflowElement = XMLUtil.loadXML(file);
                importedWorkflow = new Workflow(importedWorkflowElement);
            }
            GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
            newGraphCanvas.setWorkflow(importedWorkflow);
            this.engine.getGUI().setWorkflow(importedWorkflow);
            engine.getGUI().getGraphCanvas().setWorkflowFile(file);
        } catch (IOException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
        } catch (GraphException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (ComponentException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (RuntimeException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        } catch (Error e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Workflow(org.apache.airavata.workflow.model.wf.Workflow) XmlElement(org.xmlpull.infoset.XmlElement) IOException(java.io.IOException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) File(java.io.File) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 5 with XmlElement

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

the class WSNode method toXML.

/**
 * @return the node xml
 */
@Override
public XmlElement toXML() {
    XmlElement nodeElement = super.toXML();
    nodeElement.setAttributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE, GraphSchema.NODE_TYPE_WS);
    // XmlElement wsdlElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_WSDL_QNAME_TAG);
    // // wsdlElement.setText(getWSDLQName().toString());
    // wsdlElement.setText(getWSDLID());
    // 
    // XmlElement portTypeElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_WSDL_PORT_TYPE_TAG);
    // portTypeElement.setText(getPortTypeQName().toString());
    // 
    // XmlElement operationElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_WSDL_OPERATION_TAG);
    // operationElement.setText(getOperationName());
    XmlElement xml = getComponent().toXML();
    xml.setParent(null);
    nodeElement.addElement(xml);
    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