use of org.apache.airavata.model.application.io.DataType in project airavata by apache.
the class EndDoWhileNode method portTypeChanged.
/**
* @see org.apache.airavata.workflow.model.graph.system.SystemNode#portTypeChanged(org.apache.airavata.workflow.model.graph.system.SystemDataPort)
*/
@Override
protected void portTypeChanged(SystemDataPort port) throws GraphException {
super.portTypeChanged(port);
List<DataPort> inputPorts = getInputPorts();
List<DataPort> outputPorts = getOutputPorts();
Kind kind = port.getKind();
int index;
if (kind == Kind.DATA_IN) {
index = inputPorts.indexOf(port);
} else if (kind == Kind.DATA_OUT) {
index = outputPorts.indexOf(port);
} else {
throw new WorkflowRuntimeException();
}
SystemDataPort inputPort = (SystemDataPort) inputPorts.get(index);
SystemDataPort outputPort = (SystemDataPort) outputPorts.get(index);
DataType inputType = inputPort.getType();
DataType outputType = outputPort.getType();
DataType portType = port.getType();
if (portType == null || portType.equals(WSConstants.XSD_ANY_TYPE)) {
// Do nothing
return;
}
if (port == inputPort) {
// input -> output
if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
outputPort.copyType(port, 1);
} else if (outputType.equals(portType)) {
// Do nothing.
} else {
// XXX cannot parse array from WSDL.
// String message = "The type of input " + index + " ("
// + inputType + ") of " + getID()
// + " must be same as the type of output " + index + " ("
// + outputType + ").";
// throw new GraphException(message);
}
} else if (port == outputPort) {
// output -> input1
if (inputType.equals(WSConstants.XSD_ANY_TYPE)) {
inputPort.copyType(port, -1);
} else if (inputType.equals(portType)) {
// Do nothing.
} else {
// XXX cannot parse array from WSDL.
// String message = "The type of input " + index + " ("
// + inputType + ") of " + getID()
// + " must be same as the type of output " + index + " ("
// + outputType + ").";
// throw new GraphException(message);
}
} else {
throw new WorkflowRuntimeException();
}
}
use of org.apache.airavata.model.application.io.DataType 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.model.application.io.DataType 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());
}
}
}
use of org.apache.airavata.model.application.io.DataType in project airavata by apache.
the class DifferedInputNode method edgeWasRemoved.
/**
* Called whan an Edge was removed from the parameter port. Change the name
* of the node.
*
* @see edu.indiana.extreme.xbaya.graph.impl.NodeImpl#edgeWasRemoved(edu.indiana.extreme.xbaya.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);
}
}
}
use of org.apache.airavata.model.application.io.DataType in project airavata by apache.
the class SystemNode 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 {
super.edgeWasAdded(edge);
GraphUtil.validateConnection(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) {
// setType() propagates the change to the whole workflow.
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();
}
}
}
Aggregations