Search in sources :

Example 31 with WorkflowRuntimeException

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;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 32 with WorkflowRuntimeException

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;
}
Also used : ComponentReference(org.apache.airavata.workflow.model.component.ComponentReference) ArrayList(java.util.ArrayList) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) File(java.io.File)

Example 33 with WorkflowRuntimeException

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");
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Example 34 with WorkflowRuntimeException

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;
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Workflow(org.apache.airavata.workflow.model.wf.Workflow) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) PortImpl(org.apache.airavata.workflow.model.graph.impl.PortImpl)

Example 35 with WorkflowRuntimeException

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();
    }
}
Also used : WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Aggregations

WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)41 DataPort (org.apache.airavata.workflow.model.graph.DataPort)25 GraphException (org.apache.airavata.workflow.model.graph.GraphException)13 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)12 Node (org.apache.airavata.workflow.model.graph.Node)11 DataType (org.apache.airavata.model.application.io.DataType)10 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)9 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)8 Port (org.apache.airavata.workflow.model.graph.Port)8 Kind (org.apache.airavata.workflow.model.graph.Port.Kind)7 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)7 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)6 LinkedList (java.util.LinkedList)4 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)4 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)4 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)4 Point (java.awt.Point)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)3