use of org.apache.airavata.workflow.model.graph.DataEdge 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.DataEdge in project airavata by apache.
the class EndDoWhileNode method edgeWasAdded.
/**
* @throws GraphException
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
*/
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
// XXX cannot detect if the type is array or not from WSDL at this
// point. so no check here.
// super.edgeWasAdded(edge);
Port fromPort = edge.getFromPort();
Port toPort = edge.getToPort();
if (edge instanceof DataEdge) {
if (fromPort instanceof EPRPort) {
// TODO
return;
}
DataPort fromDataPort = (DataPort) fromPort;
DataPort toDataPort = (DataPort) toPort;
DataType fromType = fromDataPort.getType();
DataType toType = toDataPort.getType();
if (fromDataPort.getNode() == this) {
if (!(toType == null || toType.equals(WSConstants.XSD_ANY_TYPE))) {
fromDataPort.copyType(toDataPort);
}
} else if (toDataPort.getNode() == this) {
if (!(fromType == null || fromType.equals(WSConstants.XSD_ANY_TYPE))) {
toDataPort.copyType(fromDataPort);
}
} else {
throw new WorkflowRuntimeException();
}
}
}
use of org.apache.airavata.workflow.model.graph.DataEdge in project airavata by apache.
the class GraphImpl method removeNode.
/**
* @see org.apache.airavata.workflow.model.graph.Graph#removeNode(org.apache.airavata.workflow.model.graph.Node)
*/
public void removeNode(Node node) throws GraphException {
if (node == null) {
throw new IllegalArgumentException("null");
}
if (!this.nodes.contains(node)) {
throw new GraphException("The graph doesn't contain the node that is being removed.");
}
NodeImpl nodeImpl = (NodeImpl) node;
// Remove edges connected to input ports.
for (Iterator<DataPort> portItr = nodeImpl.getInputPorts().iterator(); portItr.hasNext(); ) {
DataPort port = portItr.next();
for (Iterator<DataEdge> edgeItr = port.getEdges().iterator(); edgeItr.hasNext(); ) {
DataEdge edge = edgeItr.next();
// Remove the edge from from-port.
DataPort fromPort = edge.getFromPort();
fromPort.removeEdge(edge);
// remove the edge from this port. This is necessary so that
// type update works properly.
edgeItr.remove();
// Remove the edge from the graph.
this.edges.remove(edge);
fromPort.getNode().edgeWasRemoved(edge);
}
// Remove the port from the node.
portItr.remove();
// Remove the port from the graph.
this.ports.remove(port);
}
// Remove edges connected to output ports.
for (Iterator<DataPort> portItr = nodeImpl.getOutputPorts().iterator(); portItr.hasNext(); ) {
DataPort port = portItr.next();
for (Iterator<DataEdge> edgeItr = port.getEdges().iterator(); edgeItr.hasNext(); ) {
DataEdge edge = edgeItr.next();
DataPort toPort = edge.getToPort();
toPort.removeEdge(edge);
edgeItr.remove();
this.edges.remove(edge);
toPort.getNode().edgeWasRemoved(edge);
}
portItr.remove();
this.ports.remove(port);
}
for (Iterator<ControlPort> portItr = nodeImpl.getControlOutPorts().iterator(); portItr.hasNext(); ) {
PortImpl port = portItr.next();
for (Iterator<? extends EdgeImpl> edgeItr = port.getEdges().iterator(); edgeItr.hasNext(); ) {
EdgeImpl edge = edgeItr.next();
PortImpl toPort = edge.getToPort();
toPort.removeEdge(edge);
edgeItr.remove();
this.edges.remove(edge);
toPort.getNode().edgeWasRemoved(edge);
}
portItr.remove();
this.ports.remove(port);
}
PortImpl controlInPort = nodeImpl.getControlInPort();
if (controlInPort != null) {
for (Iterator<? extends EdgeImpl> edgeItr = controlInPort.getEdges().iterator(); edgeItr.hasNext(); ) {
EdgeImpl edge = edgeItr.next();
PortImpl fromPort = edge.getFromPort();
fromPort.removeEdge(edge);
edgeItr.remove();
this.edges.remove(edge);
fromPort.getNode().edgeWasRemoved(edge);
}
this.ports.remove(controlInPort);
}
PortImpl eprPort = nodeImpl.getEPRPort();
if (eprPort != null) {
for (Iterator<? extends EdgeImpl> edgeItr = eprPort.getEdges().iterator(); edgeItr.hasNext(); ) {
EdgeImpl edge = edgeItr.next();
PortImpl toPort = edge.getToPort();
toPort.removeEdge(edge);
edgeItr.remove();
this.edges.remove(edge);
toPort.getNode().edgeWasRemoved(edge);
}
this.ports.remove(eprPort);
}
this.nodes.remove(node);
}
use of org.apache.airavata.workflow.model.graph.DataEdge in project airavata by apache.
the class ConstantNode method edgeWasAdded.
/**
* Called whan an Edge was added to the parameter port. Change the name of this node.
*
* @throws GraphException
*
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
*/
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
super.edgeWasAdded(edge);
// TODO this method can be removed.
Port toPort = edge.getToPort();
if (edge instanceof DataEdge) {
DataPort toDataPort = (DataPort) toPort;
DataType toType = toDataPort.getType();
List edges = getEdges();
if (edges.size() == 1) {
// The first edge.
this.type = toType;
} else if (edges.size() > 1) {
// Not the first edge.
if (!toType.equals(WSConstants.XSD_ANY_TYPE) && !this.type.equals(toType)) {
throw new GraphException("Cannot connect ports with different types.");
}
} else {
// Should not happen.
throw new WorkflowRuntimeException("edges.size(): " + edges.size());
}
}
}
use of org.apache.airavata.workflow.model.graph.DataEdge in project airavata by apache.
the class InputNode method edgeWasRemoved.
/**
* Called whan an Edge was removed from the parameter port. Change the name of the node.
*
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasRemoved(org.apache.airavata.workflow.model.graph.impl.EdgeImpl)
*/
@Override
protected void edgeWasRemoved(Edge removedEdge) {
super.edgeWasRemoved(removedEdge);
// TODO organize this.
List<DataEdge> edges = getEdges();
if (edges.size() == 0) {
setParameterType(null);
if (!isConfigured()) {
// Reset
setName(getComponent().getName());
setDescription("");
setDefaultValue(null);
setMetadata(null);
}
} else {
Edge edge = edges.get(0);
Port toPort = edge.getToPort();
WSPort toWsPort = (WSPort) toPort;
DataType toType = toWsPort.getType();
setParameterType(toType);
if (!isConfigured()) {
// Copy
copyDefaultConfiguration(toWsPort);
}
}
}
Aggregations