Search in sources :

Example 6 with XmlElement

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

the class Workflow method clone.

/**
 * @see java.lang.Object#clone()
 */
@Override
public Workflow clone() {
    XmlElement originalXML = toXML();
    try {
        XmlElement newXML = XMLUtil.deepClone(originalXML);
        Workflow newWorkflow = new Workflow(newXML);
        return newWorkflow;
    } catch (GraphException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (WorkflowException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (AiravataException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) XmlElement(org.xmlpull.infoset.XmlElement) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 7 with XmlElement

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

the class XMLUtil method stringToXmlElement.

/**
 * Parses a specified string and returns the XmlElement (XPP5).
 *
 * @param string
 * @return The XmlElement (XPP5) parsed.
 */
public static org.xmlpull.infoset.XmlElement stringToXmlElement(String string) {
    XmlDocument document = BUILDER.parseString(string);
    org.xmlpull.infoset.XmlElement element = document.getDocumentElement();
    return element;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement) XmlDocument(org.xmlpull.infoset.XmlDocument)

Example 8 with XmlElement

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

the class XMLUtil method removeElements.

/**
 * @param xml
 * @param name
 */
public static void removeElements(XmlElement xml, String name) {
    Iterable<XmlElement> removeElements = xml.elements(null, name);
    LinkedList<XmlElement> removeList = new LinkedList<XmlElement>();
    for (XmlElement xmlElement : removeElements) {
        removeList.add(xmlElement);
    }
    for (XmlElement xmlElement : removeList) {
        xml.removeChild(xmlElement);
    }
    Iterable children = xml.children();
    for (Object object : children) {
        if (object instanceof XmlElement) {
            XmlElement element = (XmlElement) object;
            removeElements(element, name);
        }
    }
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement) XmlObject(org.apache.xmlbeans.XmlObject) LinkedList(java.util.LinkedList)

Example 9 with XmlElement

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

the class InstanceNode method parseConfiguration.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#parseConfiguration(org.xmlpull.infoset.XmlElement)
 */
@Override
protected void parseConfiguration(XmlElement configElement) {
    super.parseConfiguration(configElement);
    // new instance
    XmlElement element = configElement.element(null, NEW_TAG_NAME);
    if (element != null) {
        for (Object child : element.children()) {
            this.startNewInstance = Boolean.valueOf((String) child).booleanValue();
        }
    }
    if (this.startNewInstance) {
        // ami id
        XmlElement element2 = configElement.element(null, AMI_ID_TAG_NAME);
        if (element != null) {
            for (Object child : element2.children()) {
                this.amiId = (String) child;
            }
        }
        // instance type
        XmlElement element3 = configElement.element(null, INSTANCE_TYPE_TAG_NAME);
        if (element != null) {
            for (Object child : element3.children()) {
                this.instanceType = (String) child;
            }
        }
    } else {
        // instance id
        XmlElement element2 = configElement.element(null, INSTANCE_ID_TAG_NAME);
        if (element != null) {
            for (Object child : element2.children()) {
                this.instanceId = (String) child;
            }
        }
    }
    // username
    XmlElement element2 = configElement.element(null, USERNAME_TAG_NAME);
    if (element != null) {
        for (Object child : element2.children()) {
            this.username = (String) child;
        }
    }
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 10 with XmlElement

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

the class TerminateInstanceNode method toXML.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#toXML()
 */
@Override
protected XmlElement toXML() {
    XmlElement nodeElement = super.toXML();
    nodeElement.setAttributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE, GraphSchema.NODE_TYPE_TERMINATE);
    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