use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class InputNode 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.ws.WSPort in project airavata by apache.
the class OutputNode method getParameterType.
/**
* Returns the type of the parameter
*
* @return The type of the parameter (e.g. string, int)
*/
@Override
public DataType getParameterType() {
List<DataEdge> edges = getEdges();
DataType parameterType = super.getParameterType();
if (parameterType == null && getEdges().size() > 0) {
Edge edge = edges.get(0);
WSPort fromPort = (WSPort) edge.getFromPort();
setParameterType(fromPort.getType());
}
return parameterType;
}
use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class OutputNode 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
Port fromPort = edge.getFromPort();
if (edge instanceof DataEdge) {
DataPort fromDataPort = (DataPort) fromPort;
DataType fromType = fromDataPort.getType();
List<DataEdge> edges = getEdges();
if (edges.size() == 1) {
setParameterType(fromType);
if (!isConfigured() && fromDataPort instanceof WSPort) {
setName(fromDataPort.getName());
WSComponentPort componentPort = ((WSPort) fromDataPort).getComponentPort();
setDescription(componentPort.getDescription());
setMetadata(componentPort.getAppinfo());
}
} else {
throw new GraphException("Cannot connect more than one output ports to the output parameter.");
}
}
}
use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class SystemDataPort method copyType.
/**
* @param port
* @param arrayIncrement
* @throws GraphException
*/
public void copyType(DataPort port, int arrayIncrement) throws GraphException {
DataType newType = port.getType();
if (this.type != newType) {
this.type = newType;
if (port instanceof WSPort) {
WSPort wsPort = (WSPort) port;
this.wsComponentPort = wsPort.getComponentPort();
this.arrayDimension = 0;
} else if (port instanceof SystemDataPort) {
SystemDataPort systemPort = (SystemDataPort) port;
this.wsComponentPort = systemPort.getWSComponentPort();
this.arrayDimension = systemPort.getArrayDimension() + arrayIncrement;
}
// propagate to other ports of this node.
getNode().portTypeChanged(this);
// propagate to the connected ports.
Kind kind = getKind();
for (DataEdge edge : getEdges()) {
if (kind == Kind.DATA_IN) {
DataPort fromPort = edge.getFromPort();
fromPort.copyType(this);
} else if (kind == Kind.DATA_OUT) {
DataPort toPort = edge.getToPort();
toPort.copyType(this);
} else {
throw new WorkflowRuntimeException();
}
}
}
}
use of org.apache.airavata.workflow.model.graph.ws.WSPort in project airavata by apache.
the class WorkflowModifier method createInputNodes.
/**
* @param graph
* @param originalFromPorts
* @throws GraphException
*/
private void createInputNodes(WSGraph graph, Set<WSPort> originalFromPorts) throws GraphException {
InputComponent inputComponent = new InputComponent();
for (WSPort originalFromPort : originalFromPorts) {
InputNode inputNode = inputComponent.createNode(graph);
List<Port> originalToPorts = originalFromPort.getToPorts();
boolean first = true;
for (Port originalToPort : originalToPorts) {
String toPortID = originalToPort.getID();
Port toPort = graph.getPort(toPortID);
graph.addEdge(inputNode.getPort(), toPort);
if (first) {
first = false;
Point position = NodeController.getGUI(originalToPort).getPosition();
Point inputNodePosition = new Point(0, position.y);
inputNode.setPosition(inputNodePosition);
}
}
}
}
Aggregations