Package eu.admire.dispel.graph

Examples of eu.admire.dispel.graph.RequestNode


       
        DispelEngineResult result = engine.processDispel(dispel);
        Collection<Graph> graphs = result.getExecutionGraphs();
        assertEquals("Expect a single execution graph", 1, graphs.size());
        Graph graph = graphs.iterator().next();
        RequestNode echo = null;
        for (RequestNode node : graph.getNodes())
        {
            if (node.getName().equals("uk.org.ogsadai.Echo"))
            {
                echo = node;
            }
        }
        assertNotNull(echo);
       
        // test that the converter has been inserted correctly
        Connection echoInput = echo.getInput("input", 0);
        RequestNode converter = echoInput.getSource();
        assertNotNull(converter);
        assertEquals(SimpleTupleTypeConverter.TUPLE_CONVERT, converter.getName());
        RequestNode node = converter.getInput("expressions", 0).getSource();
        assertTrue(node instanceof LiteralValuesNode);
        List<Object> values = ((LiteralValuesNode)node).getValues();
        assertEquals(3, values.size());
        assertEquals(ListMarker.BEGIN, values.get(0));
        assertEquals("min+273.15", values.get(1));
        assertEquals(ListMarker.END, values.get(2));
        node = converter.getInput("columnNames", 0).getSource();
        assertTrue(node instanceof LiteralValuesNode);
        values = ((LiteralValuesNode)node).getValues();
        assertEquals(3, values.size());
        assertEquals(ListMarker.BEGIN, values.get(0));
        assertEquals("min", values.get(1));
        assertEquals(ListMarker.END, values.get(2));
        RequestNode sequence = converter.getInput("data", 0).getSource();
        assertTrue(sequence instanceof LiteralValuesNode);
        values = ((LiteralValuesNode)sequence).getValues();
        assertEquals(3, values.size());
        assertEquals(ListMarker.BEGIN, values.get(0));
        assertTrue(values.get(1) instanceof Map<?,?>);
View Full Code Here


            String gatewayName = (String)node.getAnnotation(AnnotationKeys.GATEWAY);
            for (Entry<String, Map<Integer, Connection>> inputs : node.getAllInputs().entrySet())
            {
                for (Entry<Integer, Connection> input : inputs.getValue().entrySet())
                {
                    RequestNode source = input.getValue().getSource();
                    if (source.isProcessingElement() &&
                            !gatewayName.equals(source.getAnnotation(AnnotationKeys.GATEWAY)))
                    {
                        insertDataTransfer(newNodes, input.getValue(), node, inputs.getKey(), input.getKey());
                    }
                }
            }
View Full Code Here

    private void insertDataTransfer(
            List<RequestNode> graph,
            Connection connection,
            RequestNode target, String name, int index)
    {
        RequestNode source = connection.getSource();
        Object sourceGateway = source.getAnnotation(AnnotationKeys.GATEWAY);
        Object targetGateway = target.getAnnotation(AnnotationKeys.GATEWAY);
        String transferName = mTransferPrefix + (mDTCounter++);
       
        // insert a new external output node with an auto-generated name
        ExternalOutputNode externalOutput =
View Full Code Here

        Map<String, Map<Integer, Connection>> allOutputs = node.getAllOutputs();
        Connection out = allOutputs.get(DATA_EXCHANGE_OUTPUT_NAME).get(0);
       
        graph.getNodes().remove(node);
       
        RequestNode sourceNode = in.getSource();
        sourceNode.replaceOutput(
            in.getSourceOutputName(),
            in.getSourceOutputIndex(),
            out);
    }
View Full Code Here

        if (nameInputs != null)
        {
            Connection input = nameInputs.get(0);
            if (input != null)
            {
                RequestNode source = input.getSource();
                remove.add(source);
                if (source instanceof LiteralValuesNode)
                {
                    name = (String)((LiteralValuesNode) source).getValues().get(0);
                }
View Full Code Here

  @Override
  public Graph transform(RequestContext context, Graph graph)
      throws TransformationException {

    RequestNode gathererNode = new ProcessingElementNode("eu.admire.Gatherer");
    List<RequestNode> list = new ArrayList<RequestNode>();

    int i = 0; // number of created Observers

    for (RequestNode node : graph.getNodes()) {

      Map<String, Map<Integer, Connection>> outputs = node
          .getAllOutputs();

      for (String keyName : outputs.keySet()) {
        for (Integer keyIndex : outputs.get(keyName).keySet()) {
          Connection conn = outputs.get(keyName).get(keyIndex);

              int targetCount = 0;
              for(RequestNodeInput target : conn.getTargets()) {
         
                       
                        RequestNode observerNode = new ProcessingElementNode("eu.admire.Observer");
                       
                        Connection output = observerNode.getOutput("out", 0);
                        target.getRequestNode().replaceInput(target.getName(), target.getIndex(), output);
                       
                        Connection input = observerNode.getInput("in", 0);
                       
                        if (targetCount == 0)
                        {
                            node.replaceOutput(keyName, keyIndex, input);
                        }
                        else
                        {
                            observerNode.connectInput("in", 0, node.getOutput(keyName, keyIndex));
                        }
                        targetCount++;

                        Connection gathConn = observerNode.getOutput("observed", 0);
                        gathererNode.connectInput("input", i++, gathConn);


                       
                        list.add(observerNode);
View Full Code Here

        d.setRepresents(new SimpleSemanticType("", "tempInCelsius"));
        tupleOut.addElement("min", d);
        tupleOut.addElement("max", d);
        ProcessingElementOutputDescriptor output = new ProcessingElementOutputDescriptor("output");
        output.setDType(new CollectionDType(tupleOut, CollectionDType.LIST));
        RequestNode result = converter.checkCompatibility(output, input);

        TestCase.assertTrue(result instanceof CompositeProcessingElement);
        CompositeProcessingElement composite = (CompositeProcessingElement)result;
        List<RequestNodeInput> targets = composite.getInput("input", 0).getTargets();
        TestCase.assertEquals(1, targets.size());
View Full Code Here

        if (nameInputs != null)
        {
            Connection input = nameInputs.get(0);
            if (input != null)
            {
                RequestNode source = input.getSource();
                remove.add(source);
                if (source instanceof LiteralValuesNode)
                {
                    result = (String)((LiteralValuesNode) source).getValues().get(0);
                }
View Full Code Here

                       
                        // It is connected to a literal?
                        Connection conn =
                            peNode.getInput(inputDesc.getName(), 0);
                       
                        RequestNode source = conn.getSource();
                        if (source instanceof LiteralValuesNode)
                        {
                            List<Object> values =
                                ((LiteralValuesNode) source).getValues();
                            if (!values.isEmpty())
View Full Code Here

            final RequestNodeInput target,
            Map<RequestNode, ProcessingElement> peToActivity,
            Map<Location, PipelineWorkflow> workflows)
    throws RepeatEnoughMissingControlInputException
    {
        RequestNode node = target.getRequestNode();
        Connection connection = null;
        for (Entry<String, Map<Integer, Connection>> entry: node.getAllInputs().entrySet())
        {
            for (Entry<Integer, Connection> input : entry.getValue().entrySet())
            {
                // ignore the literal output
                if (input.getValue() == literal.getOutput())
                {
                    continue;
                }
                else
                {
                    // use the first connection we come across
                    // except other infinite repeaters
                    connection = input.getValue();
                    if (connection.getSource() instanceof LiteralValuesNode)
                    {
                        LiteralValuesNode lit = (LiteralValuesNode) connection.getSource();
                        // we can't use an infinite repeater as a control
                        if (isInfiniteRepeater(lit.getValues()))
                        {
                            connection = null;
                            continue;
                        }
                    }
                    if (connection != null)
                    {
                        break;
                    }
                }
            }
            if (connection != null)
            {
                break;
            }
        }
        if (connection == null)
        {
            throw new RepeatEnoughMissingControlInputException(node);
        }
       
        ProcessingElement controlledRepeat =
            new ProcessingElement(ControlledRepeat.DEFAULT_ACTIVITY_NAME);
        controlledRepeat.createInput(ControlledRepeat.INPUT_CONTROL);
        controlledRepeat.createInput(ControlledRepeat.INPUT_REPEATED);
        controlledRepeat.createOutput(ControlledRepeat.OUTPUT_CONTROL);
        controlledRepeat.createOutput(ControlledRepeat.OUTPUT_REPEATED);
        Location location = (Location)node.getAnnotation(AnnotationKeys.LOCATION);
        workflows.get(location).add(controlledRepeat);
        ProcessingElement targetActivity = peToActivity.get(node);
       
        Repeater repeater = (Repeater)literal.getValues().get(0);
        Object value = repeater.getValue();
View Full Code Here

TOP

Related Classes of eu.admire.dispel.graph.RequestNode

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.