use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class GraphImpl method removePort.
/**
* @param port
* @throws GraphException
*/
public void removePort(Port port) throws GraphException {
if (port == null) {
throw new IllegalArgumentException("null");
}
if (!this.ports.contains(port)) {
throw new GraphException("The graph doesn't contain the port that is being removed.");
}
// copy it so that we can remove edge without worrying about the
// iteration issue.
ArrayList<Edge> edgesToBeRemoved = new ArrayList<Edge>(port.getEdges());
for (Edge edge : edgesToBeRemoved) {
removeEdge(edge);
}
this.ports.remove(port);
}
use of org.apache.airavata.workflow.model.graph.GraphException 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.GraphException 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.GraphException in project airavata by apache.
the class S3InputNode 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 organize this.
if (edge instanceof DataEdge) {
DataEdge dataEdge = (DataEdge) edge;
DataPort toPort = dataEdge.getToPort();
DataType toType = toPort.getType();
List<DataEdge> edges = getEdges();
if (edges.size() == 1) {
// The first edge.
setParameterType(toType);
if (!isConfigured() && toPort instanceof WSPort) {
// Copy
copyDefaultConfiguration((WSPort) toPort);
}
} else if (edges.size() > 1) {
// Not the first edge.
DataType parameterType = getParameterType();
if (!toType.equals(WSConstants.XSD_ANY_TYPE) && !parameterType.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.GraphException in project airavata by apache.
the class DifferedInputNode method edgeWasAdded.
/**
* Called when an Edge was added to the parameter port. Change the name of
* this node.
*
* @throws GraphException
*
* @see edu.indiana.extreme.xbaya.graph.impl.NodeImpl#edgeWasAdded(edu.indiana.extreme.xbaya.graph.impl.EdgeImpl)
*/
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
super.edgeWasAdded(edge);
// TODO organize this.
if (edge instanceof DataEdge) {
DataEdge dataEdge = (DataEdge) edge;
DataPort toPort = dataEdge.getToPort();
DataType toType = toPort.getType();
List<DataEdge> edges = getEdges();
if (edges.size() == 1) {
// The first edge.
setParameterType(toType);
if (!isConfigured() && toPort instanceof WSPort) {
// Copy
copyDefaultConfiguration((WSPort) toPort);
}
} else if (edges.size() > 1) {
// Not the first edge.
DataType parameterType = getParameterType();
if (!toType.equals(WSConstants.XSD_ANY_TYPE) && !parameterType.equals(toType)) {
throw new GraphException("Cannot connect ports with different types.");
}
} else {
// Should not happen.
throw new WorkflowRuntimeException("edges.size(): " + edges.size());
}
}
}
Aggregations