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