use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class EndForEachNode 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.exceptions.WorkflowRuntimeException in project airavata by apache.
the class EndForEachNode 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.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class EndifNode 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();
int size = outputPorts.size();
Kind kind = port.getKind();
int index;
if (kind == Kind.DATA_IN) {
index = inputPorts.indexOf(port) % size;
} else if (kind == Kind.DATA_OUT) {
index = outputPorts.indexOf(port);
} else {
throw new WorkflowRuntimeException();
}
DataPort inputPort1 = inputPorts.get(index);
DataPort inputPort2 = inputPorts.get(size + index);
DataPort outputPort = outputPorts.get(index);
DataType inputType1 = inputPort1.getType();
DataType inputType2 = inputPort2.getType();
DataType outputType = outputPort.getType();
DataType portType = port.getType();
if (portType == null || portType.equals(WSConstants.XSD_ANY_TYPE)) {
// Do nothing
return;
}
if (port == inputPort1) {
// input1 -> input2
if (inputType2.equals(WSConstants.XSD_ANY_TYPE)) {
inputPort2.copyType(port);
} else if (inputType2.equals(portType)) {
// Do nothing.
} else {
String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of input " + (index + size) + " (" + inputType2 + ").";
throw new GraphException(message);
}
// input1 -> output
if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
outputPort.copyType(port);
} else if (outputType.equals(portType)) {
// Do nothing.
} else {
String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
throw new GraphException(message);
}
} else if (port == inputPort2) {
// input2 -> input1
if (inputType1.equals(WSConstants.XSD_ANY_TYPE)) {
inputPort1.copyType(port);
} else if (inputType1.equals(portType)) {
// Do nothing.
} else {
String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of input " + (index + size) + " (" + inputType2 + ").";
throw new GraphException(message);
}
// input2 -> output
if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
outputPort.copyType(port);
} else if (outputType.equals(portType)) {
// Do nothing.
} else {
String message = "The type of input " + (index + size) + " (" + inputType2 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
throw new GraphException(message);
}
} else if (port == outputPort) {
// output -> input1
if (inputType1.equals(WSConstants.XSD_ANY_TYPE)) {
inputPort1.copyType(port);
} else if (inputType1.equals(portType)) {
// Do nothing.
} else {
String message = "The type of input " + index + " (" + inputType1 + ") of " + getID() + " must be same as the type of output " + index + " (" + outputType + ").";
throw new GraphException(message);
}
// output -> input2
if (inputType2.equals(WSConstants.XSD_ANY_TYPE)) {
inputPort2.copyType(port);
} else if (inputType2.equals(portType)) {
// Do nothing.
} else {
String message = "The type of input " + (index + size) + " (" + inputType2 + ") of " + getID() + " must be same as the type of input " + index + " (" + outputType + ").";
throw new GraphException(message);
}
} else {
throw new WorkflowRuntimeException();
}
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class ForEachNode method edgeWasAdded.
/**
* @param edge
* @throws GraphException
*/
@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.exceptions.WorkflowRuntimeException 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();
}
}
}
}
Aggregations