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;
}
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;
}
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();
}
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();
}
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;
}
Aggregations