use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class GraphUtil method isSameLabeledInput.
/**
* @param node
* @return null if not the same
*/
public static String isSameLabeledInput(Node node) {
if (!isAllInputsConnected(node)) {
throw new WorkflowRuntimeException("Node inputs not connected" + node);
}
if (!isAllInputsLabeled(node)) {
throw new WorkflowRuntimeException("Some or all of the node inputs not labeled" + node);
}
List<DataPort> inputPorts = node.getInputPorts();
String label = inputPorts.get(0).getEdge(0).getLabel();
for (DataPort dataPort : inputPorts) {
// 0 because its got only one
if (!label.equals(dataPort.getEdge(0).getLabel())) {
return null;
}
}
return label;
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class LocalComponentRegistry method getComponentTree.
private List<ComponentReference> getComponentTree(File dir) {
if (!dir.isDirectory()) {
throw new WorkflowRuntimeException(dir + "is not a directory.");
}
boolean found = false;
List<ComponentReference> tree = new ArrayList<ComponentReference>();
for (File file : dir.listFiles()) {
String fileName = file.getName();
if (file.isDirectory()) {
List<ComponentReference> subTree = getComponentTree(file);
if (subTree != null) {
found = true;
LocalComponentReference componentRef = new LocalComponentReference(file.getName(), file, this);
componentRef.getChildComponentReferences().addAll(subTree);
tree.add(componentRef);
}
} else if (fileName.endsWith(FileConstants.XML_SUFFIX) || fileName.endsWith(FileConstants.WSDL_SUFFIX) || fileName.endsWith(FileConstants.WSDL_SUFFIX2)) {
found = true;
LocalComponentReference componentReference = new LocalComponentReference(file.getName(), file, this);
tree.add(componentReference);
}
}
if (!found) {
// Doesn't show a directory that doesn't have any components.
tree = null;
}
return tree;
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class InterpreterUtil method findEndForEachFor.
/**
* @param node
* @return
*/
public static Node findEndForEachFor(ForEachNode node) {
Collection<Node> toNodes = node.getOutputPort(0).getToNodes();
if (toNodes.size() != 1) {
throw new WorkflowRuntimeException("ForEach output does not contain single out-edge");
}
Node middleNode = toNodes.iterator().next();
List<DataPort> outputPorts = middleNode.getOutputPorts();
for (DataPort dataPort : outputPorts) {
if (dataPort.getToNodes().size() == 1) {
Node possibleEndForEachNode = dataPort.getToNodes().get(0);
if (possibleEndForEachNode instanceof EndForEachNode) {
return possibleEndForEachNode;
}
}
}
throw new WorkflowRuntimeException("EndForEachNode not found");
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class WorkflowModifier method createDifference.
/**
* @return The workflow that needs to be executed.
* @throws GraphException
* @throws MonitorException
*/
public Workflow createDifference() throws GraphException, MonitorException {
WSGraph originalGraph = this.modifiedWorkflow.getGraph();
Workflow workflow = this.modifiedWorkflow.clone();
String name = workflow.getName();
name += " (diff)";
workflow.setName(name);
WSGraph graph = workflow.getGraph();
// Remove the finished node.
removeFinishedNodes(originalGraph, graph);
Set<WSPort> originalFromPorts = getFinalOutputPorts(originalGraph, graph);
// Create input nodes for unconnected input ports.
createInputNodes(graph, originalFromPorts);
// Set default values.
for (WSPort originalFromPort : originalFromPorts) {
// TODO handle the case that node is not WSNode.
Node originalFromNode = originalFromPort.getNode();
String fromNodeID = originalFromNode.getID();
String output;
if (originalFromNode instanceof InputNode) {
// notification that includes the input of the workflow.
output = getWorkflowInput(fromNodeID);
} else if (originalFromNode instanceof WSNode) {
// Retrieve input value from notification.
WSComponent component = ((WSNode) originalFromNode).getComponent();
String messageName = component.getOutputTypeName();
String parameterName = originalFromPort.getComponentPort().getName();
output = getOutput(fromNodeID, messageName, parameterName);
} else {
// This should not happen.
throw new WorkflowRuntimeException(originalFromNode.getClass().getName());
}
Port originalToPort = originalFromPort.getToPorts().get(0);
PortImpl toPort = graph.getPort(originalToPort.getID());
InputNode inputNode = (InputNode) toPort.getFromNode();
inputNode.setDefaultValue(output);
}
return workflow;
}
use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.
the class JythonRunner method run.
/**
* @param script
* @param arguments
* @throws WorkflowException
*/
public void run(final String script, final String[] arguments) throws WorkflowException {
try {
Class<?> runnerClass = this.loader.loadClass(JythonOneTimeRunnerImpl.class.getName(), true);
JythonOneTimeRunner runner = (JythonOneTimeRunner) runnerClass.newInstance();
runner.run(script, arguments);
} catch (ClassNotFoundException e) {
throw new WorkflowRuntimeException(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (InstantiationException e) {
throw new WorkflowRuntimeException(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (IllegalAccessException e) {
throw new WorkflowRuntimeException(ErrorMessages.UNEXPECTED_ERROR, e);
} finally {
loader.cleanUp();
}
}
Aggregations