use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class SubWorkflowNodeGUI method openWorkflowTab.
public void openWorkflowTab(XBayaGUI xbayaGUI) {
try {
Workflow workflow = this.node.getComponent().getWorkflow();
xbayaGUI.selectOrCreateGraphCanvas(workflow);
} catch (GraphException e) {
xbayaGUI.getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
} catch (ComponentException e) {
xbayaGUI.getErrorWindow().error(ErrorMessages.COMPONENT_FORMAT_ERROR, e);
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class GraphUtil method validateConnection.
/**
* @param edge
* @throws GraphException
*/
public static void validateConnection(Edge edge) throws GraphException {
Port fromPort = edge.getFromPort();
Port toPort = edge.getToPort();
if (edge instanceof ControlEdge) {
if (!(fromPort instanceof ControlPort && toPort instanceof ControlPort)) {
throw new GraphException(MessageConstants.UNEXPECTED_ERROR);
}
} else if (edge instanceof DataEdge) {
if (fromPort instanceof EPRPort) {
// TODO
return;
}
if (!(fromPort instanceof DataPort || fromPort instanceof EPRPort) || !(toPort instanceof DataPort)) {
throw new GraphException(MessageConstants.UNEXPECTED_ERROR);
}
DataPort fromDataPort = (DataPort) fromPort;
DataPort toDataPort = (DataPort) toPort;
DataType fromType = fromDataPort.getType();
DataType toType = toDataPort.getType();
if (toDataPort.getEdges().size() > 1) {
throw new GraphException(MessageConstants.MORE_THAN_ONE_CONNECTIONS);
}
// ok
if (fromPort.getNode() instanceof WSNode) {
if ("registerStream".equals(((WSNode) fromPort.getNode()).getOperationName())) {
return;
}
}
if (!(fromType == null || fromType.equals(WSConstants.XSD_ANY_TYPE) || fromType.equals(new QName(WSConstants.XSD_NS_URI, "anyType")) || toType == null || toType.equals(WSConstants.XSD_ANY_TYPE) || toType.equals(new QName(WSConstants.XSD_NS_URI, "anyType")) || fromType.equals(toType)) && (fromType == null || fromType.equals(WSConstants.LEAD_ANY_TYPE) || fromType.equals(new QName(WSConstants.LEAD_NS_URI, "anyType")) || toType == null || toType.equals(WSConstants.LEAD_ANY_TYPE) || toType.equals(new QName(WSConstants.LEAD_NS_URI, "anyType")) || fromType.equals(toType))) {
throw new GraphException("Cannot connect ports with different types:" + " \nfrom=\t" + fromType + " \nto=\t" + toType + "");
}
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class WSGraph method topologicalSort.
/**
* @return
* @throws GraphException
*/
private LinkedList<Node> topologicalSort() throws GraphException {
List<EdgeImpl> alledges = this.getEdges();
HashSet<EdgeImpl> edgeSet = new HashSet<EdgeImpl>(alledges);
List<Node> workQueue = new LinkedList<Node>(GraphUtil.getInputNodes(this));
workQueue.addAll(GraphUtil.getStreamSourceNodes(this));
LinkedList<Node> sortedOrder = new LinkedList<Node>();
while (!workQueue.isEmpty()) {
Node currentNode = workQueue.remove(0);
sortedOrder.add(currentNode);
List<DataPort> outputPorts = currentNode.getOutputPorts();
for (DataPort dataPort : outputPorts) {
List<DataEdge> curentEdges = dataPort.getEdges();
for (DataEdge dataEdge : curentEdges) {
edgeSet.remove(dataEdge);
if (isAllEdgesRemoved(edgeSet, dataEdge.getToPort().getNode())) {
workQueue.add(dataEdge.getToPort().getNode());
}
}
}
}
if (edgeSet.isEmpty()) {
return sortedOrder;
} else {
throw new GraphException("Graph Topological sorting failed, Graph has at least one cycle");
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class WSGraphFactory method createGraph.
/**
* @param graphElement
* @return The graph created
* @throws GraphException
*/
public static WSGraph createGraph(XmlElement graphElement) throws GraphException {
try {
WSGraph graph = createWSGraph();
graph.parse(graphElement);
return graph;
} catch (RuntimeException e) {
throw new GraphException(MessageConstants.XML_ERROR, e);
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class WSGraphFactory method createGraph.
/**
* @param graphString
* @return the graph created
* @throws GraphException
*/
public static WSGraph createGraph(String graphString) throws GraphException {
XmlElement graphElement;
JsonObject graphElementJSON;
try {
// graphElement = XMLUtil.stringToXmlElement(graphString);
graphElementJSON = JSONUtil.stringToJSONObject(graphString);
} catch (RuntimeException e) {
throw new GraphException(MessageConstants.XML_ERROR, e);
}
return createGraph(graphElementJSON);
}
Aggregations