Package org.apache.airavata.workflow.model.graph

Examples of org.apache.airavata.workflow.model.graph.GraphException


    try {
      WSGraph graph = createWSGraph();
      graph.parse(graphElement);
      return graph;
    } catch (RuntimeException e) {
      throw new GraphException(MessageConstants.XML_ERROR, e);
    }
  }
View Full Code Here


             * check if there is already more than instance node connecting to destination node
             */
            if (!(toNode instanceof InstanceNode)) {
                for (Node node : toNode.getControlInPort().getFromNodes()) {
                    if ((node instanceof InstanceNode) && this != node) {
                        throw new GraphException("Cannot connect more than one instance node to another node.");
                    }
                }
            }
        }
    }
View Full Code Here

     * @throws GraphException
     */
    protected void indexToPointer() throws GraphException {
        this.node = this.graph.getNode(this.nodeID);
        if (this.node == null) {
            throw new GraphException("Cannot find a node with the ID, " + this.nodeID + ".");
        }
    }
View Full Code Here

            }
        }
        if (edgeSet.isEmpty()) {
            return sortedOrder;
        } else {
            throw new GraphException("Graph Topological sorting failed, Graph has at least one cycle");
        }
    }
View Full Code Here

            } else if (inputType2.equals(portType)) {
                // Do nothing.
            } else {
                String message = "The type of input " + index + " (" + inputType1 + ") of " + getID()
                        + " must be same as the type of input " + (index + size) + " (" + inputType2 + ").";
                throw new GraphException(message);
            }
            // input1 -> output
            if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
                outputPort.copyType(port);
            } else if (outputType.equals(portType)) {
                // Do nothing.
            } else {
                String message = "The type of input " + index + " (" + inputType1 + ") of " + getID()
                        + " must be same as the type of output " + index + " (" + outputType + ").";
                throw new GraphException(message);
            }

        } else if (port == inputPort2) {
            // input2 -> input1
            if (inputType1.equals(WSConstants.XSD_ANY_TYPE)) {
                inputPort1.copyType(port);
            } else if (inputType1.equals(portType)) {
                // Do nothing.
            } else {
                String message = "The type of input " + index + " (" + inputType1 + ") of " + getID()
                        + " must be same as the type of input " + (index + size) + " (" + inputType2 + ").";
                throw new GraphException(message);
            }
            // input2 -> output
            if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
                outputPort.copyType(port);
            } else if (outputType.equals(portType)) {
                // Do nothing.
            } else {
                String message = "The type of input " + (index + size) + " (" + inputType2 + ") of " + getID()
                        + " must be same as the type of output " + index + " (" + outputType + ").";
                throw new GraphException(message);
            }
        } else if (port == outputPort) {
            // output -> input1
            if (inputType1.equals(WSConstants.XSD_ANY_TYPE)) {
                inputPort1.copyType(port);
            } else if (inputType1.equals(portType)) {
                // Do nothing.
            } else {
                String message = "The type of input " + index + " (" + inputType1 + ") of " + getID()
                        + " must be same as the type of output " + index + " (" + outputType + ").";
                throw new GraphException(message);
            }
            // output -> input2
            if (inputType2.equals(WSConstants.XSD_ANY_TYPE)) {
                inputPort2.copyType(port);
            } else if (inputType2.equals(portType)) {
                // Do nothing.
            } else {
                String message = "The type of input " + (index + size) + " (" + inputType2 + ") of " + getID()
                        + " must be same as the type of input " + index + " (" + outputType + ").";
                throw new GraphException(message);
            }
        } else {
            throw new WorkflowRuntimeException();
        }
    }
View Full Code Here

            } else if (edges.size() > 1) {
                // Not the first edge.
                QName parameterType = getParameterType();
                if (!toType.equals(WSConstants.XSD_ANY_TYPE)
                        && !parameterType.equals(toType)) {
                    throw new GraphException(
                            "Cannot connect ports with different types.");
                }

            } else {
                // Should not happen.
View Full Code Here

  public static void validateConnection(Edge edge) throws GraphException {
    Port fromPort = edge.getFromPort();
    Port toPort = edge.getToPort();
    if (edge instanceof ControlEdge) {
      if (!(fromPort instanceof ControlPort && toPort instanceof ControlPort)) {
        throw new GraphException(MessageConstants.UNEXPECTED_ERROR);
      }
    } else if (edge instanceof DataEdge) {
      if (fromPort instanceof EPRPort) {
        // TODO
        return;
      }
      if (!(fromPort instanceof DataPort || fromPort instanceof EPRPort)
          || !(toPort instanceof DataPort)) {
        throw new GraphException(MessageConstants.UNEXPECTED_ERROR);
      }

      DataPort fromDataPort = (DataPort) fromPort;
      DataPort toDataPort = (DataPort) toPort;

      QName fromType = fromDataPort.getType();
      QName toType = toDataPort.getType();

      if (toDataPort.getEdges().size() > 1) {
        throw new GraphException(
            MessageConstants.MORE_THAN_ONE_CONNECTIONS);
      }

      // if connection came from the CEP register component it should be
      // ok
      if (fromPort.getNode() instanceof WSNode) {
        if ("registerStream".equals(((WSNode) fromPort.getNode())
            .getOperationName())) {
          return;
        }
      }

      if (!(fromType == null
          || fromType.equals(WSConstants.XSD_ANY_TYPE)
          || fromType.equals(new QName(WSConstants.XSD_NS_URI,
              "anyType"))
          || toType == null
          || toType.equals(WSConstants.XSD_ANY_TYPE)
          || toType.equals(new QName(WSConstants.XSD_NS_URI,
              "anyType")) || fromType.equals(toType)) && (fromType == null
          || fromType.equals(WSConstants.LEAD_ANY_TYPE)
          || fromType.equals(new QName(WSConstants.LEAD_NS_URI,
              "anyType"))
          || toType == null
          || toType.equals(WSConstants.LEAD_ANY_TYPE)
          || toType.equals(new QName(WSConstants.LEAD_NS_URI,
              "anyType")) || fromType.equals(toType))) {
        throw new GraphException(
            "Cannot connect ports with different types:"
                + " \nfrom=\t" + fromType + " \nto=\t" + toType
                + "");
      }
    }
View Full Code Here

    protected void indexToPointer() throws GraphException {
        for (String portID : this.inputPortIDs) {
            PortImpl port = this.graph.getPort(portID);
            if (port == null) {
                throw new GraphException("Port, " + portID + ", does not exist.");
            }
            port.setKind(PortImpl.Kind.DATA_IN);
            port.setNode(this);
            this.inputPorts.add((DataPort) port);
        }

        for (String portID : this.outputPortIDs) {
            PortImpl port = this.graph.getPort(portID);
            if (port == null) {
                throw new GraphException("Port, " + portID + ", does not exist.");
            }
            port.setKind(PortImpl.Kind.DATA_OUT);
            port.setNode(this);
            this.outputPorts.add((DataPort) port);
        }

        if (this.controlInPortID != null) {
            PortImpl port = this.graph.getPort(this.controlInPortID);
            if (port == null) {
                throw new GraphException("Port, " + this.controlInPortID + ", does not exist.");
            }
            port.setKind(PortImpl.Kind.CONTROL_IN);
            port.setNode(this);
            this.controlInPort = (ControlPort) port;
        }

        for (String portID : this.controlOutPortIDs) {
            PortImpl port = this.graph.getPort(portID);
            if (port == null) {
                throw new GraphException("Port, " + portID + ", does not exist.");
            }
            port.setKind(PortImpl.Kind.CONTROL_OUT);
            port.setNode(this);
            this.controlOutPorts.add((ControlPort) port);
        }

        if (this.eprPortID != null) {
            PortImpl port = this.graph.getPort(this.eprPortID);
            if (port == null) {
                throw new GraphException("Port, " + this.eprPortID + ", does not exist.");
            }
            port.setKind(PortImpl.Kind.EPR);
            port.setNode(this);
            this.eprPort = port;
        }
View Full Code Here

    protected void edgeWasAdded(Edge edge) throws GraphException {
        super.edgeWasAdded(edge);
        if (edge instanceof ControlEdge) {
            List<ControlEdge> edges = getEdges();
            if (edges.size() > 1) {
                throw new GraphException("Cannot connect more than one Control Ports to the Exit node.");
            }
        }
    }
View Full Code Here

            } else if (edges.size() > 1) {
                // Not the first edge.
                QName parameterType = getParameterType();
                if (!toType.equals(WSConstants.XSD_ANY_TYPE)
                        && !parameterType.equals(toType)) {
                    throw new GraphException(
                            "Cannot connect ports with different types.");
                }

            } else {
                // Should not happen.
View Full Code Here

TOP

Related Classes of org.apache.airavata.workflow.model.graph.GraphException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.