use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException 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.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class DSCUtil method creatEPR.
// // /**
// // * For debugging
// // *
// // * @param args
// // */
// // public static void main(String[] args) {
// // WsdlDefinitions awsdl = WsdlResolver.getInstance().loadWsdl(DSCUtil.class, "wsdls/math/adder-awsdl.xml");
// // WsdlDefinitions cwsdl = convertToCWSDL(awsdl, URI.create("http://localhost"));
// // System.out.println(cwsdl.xmlStringPretty());
// // }
//
// /**
// * Creates CWSDLs for all WSDLs in a workflow.
// *
// * @param workflow
// * @param dscURL
// * @return The Map<partnerLinkName, CWSDL>.
// * @throws URISyntaxException
// */
// public static Map<String, WsdlDefinitions> createCWSDLs(Workflow workflow, String dscURL) throws URISyntaxException {
// return createCWSDLs(workflow, new URI(dscURL));
// }
//
// /**
// * @param workflow
// * @param dscURL
// * @return The Map<partnerLinkName, CWSDL>.
// */
// public static Map<String, WsdlDefinitions> createCWSDLs(Workflow workflow, URI dscURL) {
// Map<String, WsdlDefinitions> WSDLMap = new HashMap<String, WsdlDefinitions>();
// Graph graph = workflow.getGraph();
// // for (WSNode node : GraphUtil.getWSNodes(graph)) {
// // String partnerLinkName = BPELScript.createPartnerLinkName(node.getID());
// // WsdlDefinitions wsdl = node.getComponent().getWSDL();
// // if (WSDLUtil.isAWSDL(wsdl)) {
// // try {
// // wsdl = convertToCWSDL(WSDLUtil.deepClone(wsdl), dscURL);
// // } catch (UtilsException e) {
// // e.printStackTrace();
// // }
// // }
// // WSDLMap.put(partnerLinkName, wsdl);
// // }
// return WSDLMap;
// }
//
// /**
// * Converts a specified AWSDL to CWSDL using DSC URI.
// *
// * @param definitions
// * The specified AWSDL. This will be modified.
// * @param dscURI
// * @return The CWSDL converted.
// */
// public static WsdlDefinitions convertToCWSDL(WsdlDefinitions definitions, URI dscURI) {
// // Create a new List to avoid ConcurrentModificationException.
// List<WsdlPortType> portTypes = new ArrayList<WsdlPortType>();
// for (WsdlPortType portType : definitions.portTypes()) {
// portTypes.add(portType);
// }
//
// for (WsdlPortType portType : portTypes) {
// URI uri = creatEPR(dscURI, portType.getQName());
// WsdlUtil.createCWSDL(definitions, portType, uri);
// }
// return definitions;
// }
private static URI creatEPR(URI dscURI, QName portTypeQName) {
String encodedPortType;
try {
encodedPortType = URLEncoder.encode(portTypeQName.toString(), "UTF-8");
URI epr = dscURI.resolve("/" + encodedPortType);
return epr;
} catch (UnsupportedEncodingException e) {
// Should not happen
throw new WorkflowRuntimeException(e);
}
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class ForEachNode method portTypeChanged.
/**
* @param port
* @throws GraphException
*/
@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 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.exceptions.WorkflowRuntimeException in project airavata by apache.
the class OutputNode 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
List<DataEdge> edges = getEdges();
if (edges.size() == 0) {
setParameterType(null);
if (!isConfigured()) {
// Reset
setName(OutputComponent.NAME);
setDescription("");
setMetadata(null);
}
} else if (edges.size() == 1) {
// This happens when the second edges was wrongly added and removed.
} else {
// Should not happen
throw new WorkflowRuntimeException("edges.size(): " + edges.size());
}
}
Aggregations