Search in sources :

Example 1 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class XBayaUtil 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 2 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class WorkflowHarvester method removeUnnecessaryNodes.

/**
 * @param pair
 * @param clone
 */
private void removeUnnecessaryNodes(Node node, Port candidatePort, Workflow workflow) {
    if (candidatePort.getFromPort().getEdges().size() == 1) {
        Node fromNode = candidatePort.getFromNode();
        try {
            List<DataPort> inputPorts = fromNode.getInputPorts();
            for (DataPort dataPort : inputPorts) {
                removeUnnecessaryNodes(fromNode, dataPort, workflow);
            }
            workflow.removeNode(fromNode);
        } catch (GraphException e) {
            throw new WorkflowRuntimeException(e);
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Node(org.apache.airavata.workflow.model.graph.Node) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 3 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class GraphUtil method propagateTypes.

/**
 * @param graph
 * @throws GraphException
 */
public static void propagateTypes(Graph graph) throws GraphException {
    List<WSPort> wsPorts = getPorts(graph, WSPort.class);
    for (WSPort wsPort : wsPorts) {
        List<DataEdge> edges = wsPort.getEdges();
        for (DataEdge edge : edges) {
            DataPort fromPort = edge.getFromPort();
            DataPort toPort = edge.getToPort();
            if (fromPort == wsPort) {
                toPort.copyType(wsPort);
            } else if (toPort == wsPort) {
                fromPort.copyType(wsPort);
            } else {
                throw new WorkflowRuntimeException();
            }
        }
    }
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) DataPort(org.apache.airavata.workflow.model.graph.DataPort) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 4 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class JythonClassLoader method getBaseURL.

private URL getBaseURL(Class klass) {
    // /d/e/f.class
    String path = klass.getName().replace('.', '/').concat(".class");
    URL classURL = this.parent.getResource(path);
    String jarURLString;
    if ("jar".equals(classURL.getProtocol())) {
        // classURL = jar:file/a/b/c.jar!/d/e/f.class
        // or jar:http://example.org/a/b/c.jar!/d/e/f.class
        String file = classURL.getFile();
        // file = file:/a/b/c.jar!d/e/f.class
        // or http://example.org/a/b/c.jar!d/e/f.class
        logger.debug("file: " + file);
        jarURLString = file.substring(0, file.lastIndexOf('!'));
    // jarURLString = file:/a/b/c.jar
    // or http://example.org/a/b/c.jar
    } else {
        // file:/a/b/c/d/e/f.class
        // /a/b/c/d/e/f.class
        String file = classURL.getFile();
        int index = file.lastIndexOf(path);
        // /a/b/c/
        jarURLString = "file:" + file.substring(0, index);
    }
    try {
        URL jarURL = new URL(jarURLString);
        return jarURL;
    } catch (MalformedURLException e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) URL(java.net.URL)

Example 5 with WorkflowRuntimeException

use of org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException in project airavata by apache.

the class JythonClassLoader method maybeGetJarFile.

private JarFile maybeGetJarFile(URL url) {
    String path;
    try {
        path = URLDecoder.decode(url.getPath(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new WorkflowRuntimeException(e);
    }
    logger.debug("path: " + path);
    if (path.endsWith("/")) {
        // It's a local directory
        return null;
    } else if ("file".equals(url.getProtocol())) {
        // Jar file
        try {
            JarFile jarFile = new JarFile(path);
            return jarFile;
        } catch (IOException e) {
            throw new WorkflowRuntimeException(e);
        }
    } else {
        // A Jar file
        try {
            if (this.tmpJarDirectory == null) {
                Date date = new Date();
                SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd-HHmmss-S");
                String time = format.format(date);
                String fileName = ".xbaya-jars-" + time;
                String tmpdir = System.getProperty("java.io.tmpdir");
                this.tmpJarDirectory = new File(tmpdir, fileName);
                this.tmpJarDirectory.mkdir();
            }
            int i = path.lastIndexOf('/');
            File file = new File(this.tmpJarDirectory, path.substring(i + 1));
            logger.debug("file: " + file);
            InputStream stream = url.openStream();
            IOUtil.writeToFile(stream, file);
            JarFile jarFile = new JarFile(file);
            return jarFile;
        } catch (IOException e) {
            throw new WorkflowRuntimeException(e);
        }
    }
}
Also used : InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) SimpleDateFormat(java.text.SimpleDateFormat) JarFile(java.util.jar.JarFile) File(java.io.File) Date(java.util.Date)

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