Search in sources :

Example 26 with XmlElement

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

the class EdgeImpl method toXML.

/**
 * @return the XmlElement
 */
protected XmlElement toXML() {
    XmlElement edgeXml = XMLUtil.BUILDER.newFragment(GraphSchema.NS, GraphSchema.EDGE_TAG);
    XmlElement fromEle = edgeXml.addElement(GraphSchema.NS, GraphSchema.EDGE_FROM_PORT_TAG);
    fromEle.addChild(this.fromPort.getID());
    XmlElement toEle = edgeXml.addElement(GraphSchema.NS, GraphSchema.EDGE_TO_PORT_TAG);
    toEle.addChild(this.toPort.getID());
    return edgeXml;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 27 with XmlElement

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

the class GraphImpl method toXML.

/**
 * @see org.apache.airavata.workflow.model.graph.Graph#toXML()
 */
public XmlElement toXML() {
    XmlElement graphElement = XMLUtil.BUILDER.newFragment(GraphSchema.NS, GraphSchema.GRAPH_TAG);
    graphElement.setAttributeValue(GraphSchema.NS, GraphSchema.XBAYA_VERSION_ATTRIBUTE, ApplicationVersion.VERSION.getVersion());
    XmlElement idElement = graphElement.addElement(GraphSchema.NS, GraphSchema.GRAPH_ID_TAG);
    idElement.addChild(getID());
    if (this.name != null) {
        XmlElement nameElement = graphElement.addElement(GraphSchema.NS, GraphSchema.GRAPH_NAME_TAG);
        nameElement.addChild(getName());
    }
    if (this.description != null) {
        XmlElement descriptionElement = graphElement.addElement(GraphSchema.NS, GraphSchema.GRAPH_DESCRIPTION_TAG);
        descriptionElement.addChild(getDescription());
    }
    toXML(graphElement);
    for (NodeImpl node : this.nodes) {
        XmlElement nodeElement = node.toXML();
        graphElement.addChild(nodeElement);
    }
    for (PortImpl port : this.ports) {
        XmlElement portElement = port.toXML();
        graphElement.addChild(portElement);
    }
    for (EdgeImpl edge : this.edges) {
        XmlElement edgeElement = edge.toXML();
        graphElement.addChild(edgeElement);
    }
    return graphElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 28 with XmlElement

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

the class GraphImpl method parse.

/**
 * @param graphElement
 * @throws GraphException
 */
protected void parse(XmlElement graphElement) throws GraphException {
    String version = graphElement.attributeValue(GraphSchema.NS, GraphSchema.XBAYA_VERSION_ATTRIBUTE);
    logger.debug("parsing a workflow created by version " + version);
    XmlElement idElement = graphElement.element(GraphSchema.GRAPH_ID_TAG);
    if (idElement != null) {
        this.id = idElement.requiredText();
    }
    XmlElement nameElement = graphElement.element(GraphSchema.GRAPH_NAME_TAG);
    if (nameElement != null) {
        this.name = nameElement.requiredText();
    }
    XmlElement descriptionElement = graphElement.element(GraphSchema.GRAPH_DESCRIPTION_TAG);
    if (descriptionElement != null) {
        this.description = descriptionElement.requiredText();
    }
    for (XmlElement nodeElement : graphElement.elements(null, GraphSchema.NODE_TAG)) {
        NodeImpl nodeImpl = this.factory.createNode(nodeElement);
        // need to call this to set this graph to the node.
        addNode(nodeImpl);
    }
    for (XmlElement portElement : graphElement.elements(null, GraphSchema.PORT_TAG)) {
        PortImpl port = this.factory.createPort(portElement);
        // need to call this to set this graph to the port.
        this.addPort(port);
    }
    for (XmlElement edgeElement : graphElement.elements(null, GraphSchema.EDGE_TAG)) {
        EdgeImpl edge = this.factory.createEdge(edgeElement);
        // need to call this to set this graph to the edge.
        this.addEdge(edge);
    }
    indexToPointer();
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 29 with XmlElement

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

the class PortImpl method parse.

/**
 * Parses XML
 *
 * @param portElement
 */
protected void parse(XmlElement portElement) {
    XmlElement idElement = portElement.element(GraphSchema.PORT_ID_TAG);
    this.id = idElement.requiredText();
    XmlElement nameElement = portElement.element(GraphSchema.PORT_NAME_TAG);
    if (nameElement != null) {
        // TODO control ports might have name?
        this.name = nameElement.requiredText();
    }
    XmlElement nodeElement = portElement.element(GraphSchema.PORT_NODE_TAG);
    this.nodeID = nodeElement.requiredText();
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 30 with XmlElement

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

the class NodeImpl method toXML.

/**
 * @return the node xml
 */
protected XmlElement toXML() {
    XmlElement nodeElement = XMLUtil.BUILDER.newFragment(GraphSchema.NS, GraphSchema.NODE_TAG);
    XmlElement idElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_ID_TAG);
    idElement.addChild(this.id);
    XmlElement nameElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_NAME_TAG);
    nameElement.addChild(this.name);
    // Output ports
    for (PortImpl port : this.outputPorts) {
        XmlElement portElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_OUTPUT_PORT_TAG);
        portElement.addChild(port.getID());
    }
    // Input ports
    for (PortImpl port : this.inputPorts) {
        XmlElement portElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_INPUT_PORT_TAG);
        portElement.addChild(port.getID());
    }
    // Control-in port
    if (this.controlInPort != null) {
        XmlElement portElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_CONTROL_IN_PORT_TAG);
        portElement.addChild(this.controlInPort.getID());
    }
    // EPR Port
    if (this.eprPort != null) {
        XmlElement portElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_EPR_PORT_TAG);
        portElement.addChild(this.eprPort.getID());
    }
    // Control-out ports
    for (PortImpl port : this.controlOutPorts) {
        XmlElement portElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_CONTROL_OUT_PORT_TAG);
        portElement.addChild(port.getID());
    }
    XmlElement xElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_X_LOCATION_TAG);
    xElement.addChild(Integer.toString(this.position.x));
    XmlElement yElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_Y_LOCATION_TAG);
    yElement.addChild(Integer.toString(this.position.y));
    addConfigurationElement(nodeElement);
    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