Search in sources :

Example 11 with WorkflowRuntimeException

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();
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) Kind(org.apache.airavata.workflow.model.graph.Port.Kind) DataType(org.apache.airavata.model.application.io.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 12 with 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);
    }
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) URI(java.net.URI)

Example 13 with WorkflowRuntimeException

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();
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) Kind(org.apache.airavata.workflow.model.graph.Port.Kind) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 14 with 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());
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) DataType(org.apache.airavata.model.application.io.DataType) List(java.util.List) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 15 with WorkflowRuntimeException

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