Search in sources :

Example 11 with XmlElement

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

the class InstanceDataPort method toXML.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.PortImpl#toXML()
 */
@Override
protected XmlElement toXML() {
    XmlElement portElement = super.toXML();
    portElement.setAttributeValue(GraphSchema.NS, GraphSchema.PORT_TYPE_ATTRIBUTE, GraphSchema.PORT_TYPE_INSTANCE);
    return portElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 12 with XmlElement

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

the class WorkflowWSDL method addParameter.

/**
 * Adds the parameter element.
 *
 * @param node
 * @param sequence
 * @param schema
 * @return The parameter element
 */
private XmlElement addParameter(ParameterNode node, XmlElement sequence, XmlElement schema) {
    XmlElement element;
    SystemDataPort port = node.getPort();
    element = addParameter(node, port, sequence, schema);
    // 
    // Annotation
    // 
    String description = node.getDescription();
    XmlElement appinfo = node.getMetadata();
    // description
    if (description != null && description.trim().length() != 0) {
        XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
        XmlElement documentation = annotation.addElement(WSConstants.DOCUMENTATION_TAG);
        documentation.setText(node.getDescription());
    }
    // appinfo
    if (appinfo != null) {
        XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
        try {
            annotation.addElement(XMLUtil.deepClone(appinfo));
        } catch (AiravataException e) {
            log.error(e.getMessage(), e);
        }
    }
    // 
    if (node instanceof InputNode) {
        InputNode inputNode = (InputNode) node;
        Object value = inputNode.getDefaultValue();
        if (value instanceof String) {
            element.setAttributeValue(WSConstants.DEFAULT_ATTRIBUTE, (String) value);
        } else if (value instanceof XmlElement) {
            // Add the default value in <annotation><default> because there
            // is no standard way.
            XmlElement valueElement = null;
            try {
                valueElement = XMLUtil.deepClone((XmlElement) value);
            } catch (AiravataException e) {
                log.error(e.getMessage(), e);
            }
            XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
            XmlElement defaultElement = annotation.addElement(WSComponentPort.DEFAULT);
            defaultElement.addElement(valueElement);
        }
    }
    return element;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) SystemDataPort(org.apache.airavata.workflow.model.graph.system.SystemDataPort) XmlElement(org.xmlpull.infoset.XmlElement) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 13 with XmlElement

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

the class DataEdge method toXML.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.EdgeImpl#toXML()
 */
@Override
protected XmlElement toXML() {
    XmlElement edgeElement = super.toXML();
    edgeElement.setAttributeValue(GraphSchema.NS, GraphSchema.EDGE_TYPE_ATTRIBUTE, GraphSchema.EDGE_TYPE_DATA);
    return edgeElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 14 with XmlElement

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

the class EPRPort method toXML.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.PortImpl#toXML()
 */
@Override
protected XmlElement toXML() {
    XmlElement portElement = super.toXML();
    portElement.setAttributeValue(GraphSchema.NS, GraphSchema.PORT_TYPE_ATTRIBUTE, GraphSchema.PORT_TYPE_EPR);
    return portElement;
}
Also used : XmlElement(org.xmlpull.infoset.XmlElement)

Example 15 with XmlElement

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

the class WSComponentPort method parse.

/**
 * @param element
 * @throws ComponentException
 */
private void parse(XmlElement element) throws ComponentException {
    this.name = element.attributeValue(WSConstants.NAME_ATTRIBUTE);
    // type
    String typeQNameString = element.attributeValue(WSConstants.TYPE_ATTRIBUTE);
    if (typeQNameString == null) {
    // Type might be defined inline.
    // TODO fix this.
    // this.type = WSConstants.XSD_ANY_TYPE;
    } else {
    }
    // annotation
    this.annotation = element.element(null, WSConstants.ANNOTATION_TAG);
    if (this.annotation != null) {
        XmlElement documentationElement = this.annotation.element(null, WSConstants.DOCUMENTATION_TAG);
        if (documentationElement != null) {
            // Sets the documentation.
            this.description = documentationElement.requiredText();
        }
        this.appinfo = this.annotation.element(null, WSConstants.APPINFO_TAG);
    }
    // defaut value
    this.defaultValue = element.attributeValue(WSConstants.DEFAULT_ATTRIBUTE);
    if (this.defaultValue == null && this.annotation != null) {
        XmlElement defaultElement = this.annotation.element(null, DEFAULT);
        if (defaultElement != null) {
            for (Object child : defaultElement.children()) {
                if (child instanceof XmlElement) {
                    this.defaultValue = XMLUtil.xmlElementToString((XmlElement) child);
                }
            }
        }
    }
    // minOccurs
    String minOccurs = element.attributeValue(WSConstants.MIN_OCCURS_ATTRIBUTE);
    if ("0".equals(minOccurs)) {
        this.optional = true;
    } else {
        this.optional = false;
    }
}
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