use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class XBayaGUI method activeTabChanged.
private void activeTabChanged() {
GraphCanvas graphPanel = getGraphCanvas();
if (graphPanel != null) {
// Reset the port viewers.
Port inputPort = graphPanel.getSelectedInputPort();
Port outputPort = graphPanel.getSelectedOutputPort();
this.portViewer.setInputPort(inputPort);
this.portViewer.setOutputPort(outputPort);
// Reset component viewer.
Node node = graphPanel.getSelectedNode();
Component component;
if (node != null) {
component = node.getComponent();
} else {
component = this.componentSelector.getSelectedComponent();
}
this.componentViewer.setComponent(component);
String name = graphPanel.getWorkflow().getName();
setFrameName(name);
} else {
// TODO what to do when no tabs are present???
}
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class WorkflowModifier method removeFinishedNodes.
/**
* @param originalGraph
* @param graph
* @throws GraphException
*/
private void removeFinishedNodes(WSGraph originalGraph, WSGraph graph) throws GraphException {
ArrayList<Node> finishedNodes = new ArrayList<Node>();
for (Node node : originalGraph.getNodes()) {
Color color = NodeController.getGUI(node).getBodyColor();
if (NodeState.FINISHED.color.equals(color)) {
finishedNodes.add(node);
}
}
for (Node finishedNode : finishedNodes) {
Node node = graph.getNode(finishedNode.getID());
graph.removeNode(node);
}
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class BPELScript method getWSDLs.
/**
* Returns the WSDLs of components in the workflow.
*
* @return The WSDLs of components.
*/
public Collection<XmlElement> getWSDLs() {
Collection<XmlElement> wsdls = new ArrayList<XmlElement>();
for (Node node : this.graph.getNodes()) {
if (node instanceof WSNode) {
WSNode wsNode = (WSNode) node;
WSComponent component = wsNode.getComponent();
wsdls.add(component.toXML());
}
}
return wsdls;
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class BPELScript method getSpecialBlock.
/**
* @param node
* @param depth
* @param block
* It's a set so that duplicated nodes won't be added.
* @param startClass
* @param endClass
* @throws GraphException
*/
private void getSpecialBlock(Node node, int depth, Set<Node> block, Class startClass, Class endClass) throws GraphException {
List<Node> nextNodes = GraphUtil.getNextNodes(node);
for (Node nextNode : nextNodes) {
if (nextNode instanceof OutputNode) {
throw new GraphException("Nodes after " + startClass.getName() + " cannot be connected to the output without going through " + endClass.getName() + ".");
} else if (endClass.isInstance(nextNode)) {
block.add(nextNode);
if (depth == 0) {
// Stop the recursion here.
} else {
getSpecialBlock(nextNode, depth - 1, block, startClass, endClass);
}
} else if (startClass.isInstance(nextNode)) {
// handle embedded forEach
block.add(nextNode);
getSpecialBlock(nextNode, depth + 1, block, startClass, endClass);
} else {
block.add(nextNode);
getSpecialBlock(nextNode, depth, block, startClass, endClass);
}
}
}
use of org.apache.airavata.workflow.model.graph.Node in project airavata by apache.
the class BPELScript method isExecutable.
private <S extends Node, E extends Node> boolean isExecutable(S node, Collection<Node> nodes, Class<S> startClass, Class<E> endClass) throws GraphException {
// copy remainNodes so that it doesn't break the original one.
LinkedList<Node> copiedRemainNodes = new LinkedList<Node>(nodes);
Set<Node> block = new HashSet<Node>();
getSpecialBlock(node, 0, block, startClass, endClass);
copiedRemainNodes.remove(node);
while (block.size() > 0) {
List<Node> doneNodeInBlock = new LinkedList<Node>();
for (Node nodeInBlock : block) {
if (isExecutable(nodeInBlock, copiedRemainNodes)) {
copiedRemainNodes.remove(nodeInBlock);
doneNodeInBlock.add(nodeInBlock);
}
}
if (doneNodeInBlock.size() == 0) {
// on outer nodes that haven't finished.
return false;
}
block.removeAll(doneNodeInBlock);
}
return true;
}
Aggregations