use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class WorkflowHarvester method getCandidates.
/**
* @param workflow
* @param dataType
* @return pair of nodeid and portid
*/
private LinkedList<Pair<String, String>> getCandidates(Workflow workflow, QName dataType) {
LinkedList<Pair<String, String>> candidates = new LinkedList<Pair<String, String>>();
List<NodeImpl> nodes = workflow.getGraph().getNodes();
for (NodeImpl node : nodes) {
if (node instanceof WSNode) {
List<DataPort> inputPorts = ((WSNode) node).getInputPorts();
for (DataPort dataPort : inputPorts) {
if (dataType.equals(dataPort.getType())) {
candidates.add(new Pair<String, String>(node.getID(), dataPort.getID()));
}
}
}
}
return candidates;
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class GraphUtil method propagateTypes.
/**
* @param graph
* @throws GraphException
*/
public static void propagateTypes(Graph graph) throws GraphException {
List<WSPort> wsPorts = getPorts(graph, WSPort.class);
for (WSPort wsPort : wsPorts) {
List<DataEdge> edges = wsPort.getEdges();
for (DataEdge edge : edges) {
DataPort fromPort = edge.getFromPort();
DataPort toPort = edge.getToPort();
if (fromPort == wsPort) {
toPort.copyType(wsPort);
} else if (toPort == wsPort) {
fromPort.copyType(wsPort);
} else {
throw new WorkflowRuntimeException();
}
}
}
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class DynamicNode method getFreeInPort.
public DataPort getFreeInPort() {
List<DataPort> inputPorts = this.getInputPorts();
for (DataPort dataPort : inputPorts) {
if (null == dataPort.getFromNode()) {
return dataPort;
}
}
// none found, so make a new one.
DynamicComponentPort comPort = new DynamicComponentPort(getComponent());
getComponent().addInputPort(comPort);
DataPort port = comPort.createPort();
((DynamicPort) port).setNode(this);
this.addInputPort(port);
return port;
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class XBayaUtil method getInputsForForEachNode.
public static Object getInputsForForEachNode(final ForEachNode forEachNode, final LinkedList<String> listOfValues, Map<Node, Invoker> invokerMap) throws WorkflowException {
Node forEachInputNode = forEachNode.getInputPort(0).getFromNode();
// if input node for for-each is WSNode
Object returnValForProvenance = null;
if (forEachInputNode instanceof InputNode) {
for (DataPort dataPort : forEachNode.getInputPorts()) {
returnValForProvenance = XBayaUtil.findInputFromPort(dataPort, invokerMap);
if (null == returnValForProvenance) {
throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
}
String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
listOfValues.addAll(Arrays.asList(vals));
}
}
return returnValForProvenance;
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class GraphCanvas method mouseReleased.
private void mouseReleased(MouseEvent event) {
Point point = event.getPoint();
if (this.draggedNode != null) {
NodeController.getGUI(this.draggedNode).setDraggedFlag(false);
this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
// Check if it s stream grouping
if (draggedNode instanceof InputNode) {
StreamSourceNode streamNode = NodeController.getGUI(this.graph).getStreamSourceAt(point);
if (streamNode != null) {
streamNode.addInputNode((InputNode) draggedNode);
}
}
this.draggedNode = null;
}
if (this.draggedPort != null) {
GraphPiece graphPiece = NodeController.getGUI(this.graph).getGraphPieceAt(point);
if (graphPiece instanceof DynamicNode) {
if (this.draggedPort.getKind() == Kind.DATA_OUT && draggedPort instanceof DataPort) {
this.panel.setCursor(SwingUtil.CROSSHAIR_CURSOR);
DynamicNode dynamicNode = (DynamicNode) graphPiece;
dynamicNode.getComponent();
DataPort freePort = dynamicNode.getFreeInPort();
try {
freePort.copyType((DataPort) draggedPort);
} catch (GraphException e) {
engine.getGUI().getErrorWindow().error(e);
return;
}
// selectInputPort(freePort);
connect(this.draggedPort, freePort);
this.dynamicNodeWithFreePort = null;
}
} else if (graphPiece instanceof Port) {
Port port = (Port) graphPiece;
if (this.draggedPort.getKind() == Kind.DATA_OUT && port.getKind() == Kind.DATA_IN) {
connect(this.draggedPort, port);
} else if (port.getKind() == Kind.DATA_OUT && this.draggedPort.getKind() == Kind.DATA_IN) {
connect(port, this.draggedPort);
} else if (this.draggedPort.getKind() == Kind.CONTROL_OUT && port.getKind() == Kind.CONTROL_IN) {
connect(this.draggedPort, port);
} else if (this.draggedPort.getKind() == Kind.CONTROL_IN && port.getKind() == Kind.CONTROL_OUT) {
connect(port, this.draggedPort);
} else if (this.draggedPort.getKind() == Kind.EPR && port.getKind() == Kind.DATA_IN) {
connect(this.draggedPort, port);
} else if (this.draggedPort.getKind() == Kind.DATA_IN && port.getKind() == Kind.EPR) {
connect(port, this.draggedPort);
}
}
this.draggedPort = null;
}
if (this.dynamicNodeWithFreePort != null) {
try {
this.dynamicNodeWithFreePort.removeLastDynamicallyAddedInPort();
} catch (GraphException e) {
this.engine.getGUI().getErrorWindow().error(e);
}
}
/*
* Multiple selected
*/
if (this.mousePointForSelection != null) {
double width = Math.abs(this.mousePoint.getX() - this.mousePointForSelection.getX());
double height = Math.abs(this.mousePoint.getY() - this.mousePointForSelection.getY());
int x = (int) (this.mousePoint.getX() > this.mousePointForSelection.getX() ? this.mousePointForSelection.getX() : this.mousePoint.getX());
int y = (int) (this.mousePoint.getY() > this.mousePointForSelection.getY() ? this.mousePointForSelection.getY() : this.mousePoint.getY());
this.multipleSelectedNodes = NodeController.getGUI(this.graph).getNodesIn(new Rectangle(x, y, (int) width, (int) height));
selectNodes(this.multipleSelectedNodes);
// clear mousepoint
this.mousePointForSelection = null;
}
if (this.multipleSelectedNodes != null) {
this.panel.setCursor(SwingUtil.DEFAULT_CURSOR);
}
maybeShowPopup(event);
updateSize();
this.panel.repaint();
event.consume();
}
Aggregations