Package eu.admire.dispel.parser.types

Examples of eu.admire.dispel.parser.types.Variable


        registerSemanticDType("NationalPopulation",
                new SimpleSemanticType("dispel", "NationalPopulation", "dispel"));
        DISPELGraphBuilder builder =
            runDISPELFromFile(PATH + "modifiers.dispel");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("SQLQuery");
        assertTrue(var.getType() instanceof ProcessingElementTypeType);
        Object value = var.getValue();
        assertTrue(value instanceof ProcessingElementType);
        ProcessingElementDescriptor descriptor =
            ((ProcessingElementType)value).getDescriptor();
        List<ProcessingElementModifier> modifiers =
            descriptor.getInput("expression").getModifiers();
        assertEquals(1, modifiers.size());
        assertEquals("terminator", modifiers.get(0).getName());
        modifiers = descriptor.getInput("resource").getModifiers();
        assertEquals(1, modifiers.size());
        assertEquals("locator", modifiers.get(0).getName());
        assertTrue(descriptor.getInput("resource").getIsDataSourceInput());
       
        var = builder.getDispelExecutionState().getVariables().get("LockedSQLQuery");
        assertTrue(var.getType() instanceof ProcessingElementTypeType);
        value = var.getValue();
        assertTrue(value instanceof ProcessingElementType);
        descriptor = ((ProcessingElementType)value).getDescriptor();
        modifiers = descriptor.getInput("resource").getModifiers();
        assertEquals(2, modifiers.size());
        List<String> mods = Arrays.asList("locator", "initiator");
        assertTrue(mods.contains(modifiers.get(0).getName()));
        assertTrue(mods.contains(modifiers.get(1).getName()));

        var = builder.getDispelExecutionState().getVariables().get("StrictSQLQuery");
        assertTrue(var.getType() instanceof ProcessingElementTypeType);
        value = var.getValue();
        assertTrue(value instanceof ProcessingElementType);
        descriptor = ((ProcessingElementType)value).getDescriptor();
        modifiers = descriptor.getOutput("data").getModifiers();
        assertEquals(1, modifiers.size());
        assertEquals("requiresStype", modifiers.get(0).getName());

        var = builder.getDispelExecutionState().getVariables().get("query");
        assertTrue(var.getType() instanceof ProcessingElementType);
        value = var.getValue();
        assertTrue(value instanceof ProcessingElementNode);
        descriptor = ((ProcessingElementNode)value).getProcessingElementDescriptor();
        modifiers = descriptor.getOutput("data").getModifiers();
        assertEquals(1, modifiers.size());
        ProcessingElementModifier modifier = modifiers.get(0);
        assertEquals("preserved", modifier.getName());
        assertEquals(1, modifier.getArguments().size());
        assertEquals("localhost:8080/QueryOutput", modifier.getArguments().get(0));
       
        var = builder.getDispelExecutionState().getVariables().get("lockedQuery");
        assertTrue(var.getType() instanceof ProcessingElementType);
        value = var.getValue();
        assertTrue(value instanceof ProcessingElementNode);
        descriptor = ((ProcessingElementNode)value).getProcessingElementDescriptor();
        modifiers = descriptor.getOutput("data").getModifiers();
        assertEquals(2, modifiers.size());
        mods = Arrays.asList("requiresStype", "preserved");
        assertTrue(mods.contains(modifiers.get(0).getName()));
        assertTrue(mods.contains(modifiers.get(1).getName()));
        SType stype = descriptor.getOutput("data").getSType();
        assertTrue(stype instanceof ListSType);
        assertTrue(((ListSType)stype).getChildType() instanceof TupleSType);
       
        var = builder.getDispelExecutionState().getVariables().get("compressedQuery");
        assertTrue(var.getType() instanceof ProcessingElementType);
        value = var.getValue();
        assertTrue(value instanceof ProcessingElementNode);
        descriptor = ((ProcessingElementNode)value).getProcessingElementDescriptor();
        modifiers = descriptor.getOutput("data").getModifiers();
        assertEquals(1, modifiers.size());
        modifier = modifiers.get(0);
        assertEquals("compressed", modifier.getName());
        assertEquals(1, modifier.getArguments().size());
        assertEquals("eu.admire.madup.compression", modifier.getArguments().get(0));
       
        var = builder.getDispelExecutionState().getVariables().get("combine2");
        assertTrue(var.getType() instanceof ProcessingElementType);
        value = var.getValue();
        assertTrue(value instanceof ProcessingElementNode);
        descriptor = ((ProcessingElementNode)value).getProcessingElementDescriptor();
        System.out.println(descriptor);
        modifiers = descriptor.getInput("inputs").getModifiers();
        assertEquals(1, modifiers.size());
View Full Code Here


     * @throws Exception
     */
    public void addAnnotationToRequestNode() throws Exception
    {
        Object value;
        Variable variable =
            mExecutionState.getVariables().get(mPEVariableName);
        if (variable == null)
        {
            throw new UnresolvedVariableException(mPEVariableName);
        }
        if (mPEVariableArrayIndices == null)
        {
            value = variable.getValue();
        }
        else
        {
            value = variable.getValue(mPEVariableArrayIndices);
        }
        if (value instanceof RequestNode)
        {
            RequestNode node = (RequestNode)value;
            node.addAnnotation(mAnnotationKey, mAnnotationValue);
View Full Code Here

        {
            Object value =
                arguments.get(i).evaluate(executionState.getVariables());
            String paramName = indices.get(i);
            Type type = parameters.get(paramName);
            Variable variable = new Variable(type, value);
            result.put(paramName, variable);
            // add the parameter name to the used types
            // if its type is a processing element type
            if (type instanceof ProcessingElementTypeType
                    && arrayDimensions.get(paramName) == 0)
View Full Code Here

          try
            {
              String[] parts = name.split("\\.");
              executionState.getVariables().put(
                        parts[parts.length-1], // simple name
                        new Variable(
                                new ProcessingElementTypeType(((ProcessingElementType)pe).getDescriptor()),
                                pe));
            }
            catch (TypeMismatchException e)
            {
View Full Code Here

        // Write the used processing elements to the mappers
        executionState.getUsedProcessingElements().addAll(
                builder.getDispelExecutionState().getUsedProcessingElements());
       
        // Add a variable if the used object is an instance
        Variable var = builder.getDispelExecutionState().getVariables().get(object.getName());
        if (var != null)
        {
            executionState.getVariables().put(name, var);
            LOG.debug("Added new variable " + name + " = " + var);
        }
View Full Code Here

    }
   
    public void setConnection(String name) throws TypeMismatchException
    {
        Connection connection = new TeeConnection();
        Variable var = new Variable(new ConnectionType(), connection);
        mExecutionState.getVariables().put(name, var);
    }
View Full Code Here

                reg = new RegisteredObject(qName, function);
            }
            else
            {
                // see if it's a variable, so we're registering an object
                Variable value = mExecutionState.getVariables().get(name);
                if (value != null)
                {
                    reg = new RegisteredObject(qName, value);
                }
            }
View Full Code Here

                "Connection c;\n" +
                "s => c;\n" +
                "A p = new A;\n" +
                "s => p.input;");
        assertNull(mError);
        Variable a = builder.getDispelExecutionState().getVariables().get("a");
        assertNotNull(a);
        assertEquals(Arrays.asList(0l), a.getArray().get(0));
        assertEquals(Arrays.asList(1l), a.getArray().get(1));
        Variable s = builder.getDispelExecutionState().getVariables().get("s");
        assertNotNull(s);
        Object value = s.getValue();
        assertTrue(value instanceof List<?>);
        assertEquals(Arrays.<Object>asList(10l, 15l, 20l, 0l, 1l, -17l), value);
    }
View Full Code Here

                "Connection c; Connection d;" +
                "|- 0 -| => c; |- 1 -| => c; |- 2 -| => c; " +
                    "|- [ 0 ] -| => d; |- [ 1 ] -| => d; " +
                    "A a = new A; |- 0 -| => a.in; |- 1 -| => a.in; ");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("c");
        assertTrue(var.getValue() instanceof Connection);
        RequestNode source = ((Connection)var.getValue()).getSource();
        assertTrue(source instanceof LiteralValuesNode);
        List<Object> values = ((LiteralValuesNode)source).getValues();
        assertEquals(Arrays.asList(0l, 1l, 2l), values);
       
        var = builder.getDispelExecutionState().getVariables().get("d");
        assertTrue(var.getValue() instanceof Connection);
        source = ((Connection)var.getValue()).getSource();
        assertTrue(source instanceof LiteralValuesNode);
        values = ((LiteralValuesNode)source).getValues();
        assertEquals(
                Arrays.<Object>asList(
                    ListMarker.BEGIN, 0l, ListMarker.END,
                    ListMarker.BEGIN, 1l, ListMarker.END),
                values);

        var = builder.getDispelExecutionState().getVariables().get("a");
        assertTrue(var.getValue() instanceof RequestNode);
        source = ((RequestNode)var.getValue()).getInput("in", 0).getSource();
        assertTrue(source instanceof LiteralValuesNode);
        values = ((LiteralValuesNode)source).getValues();
        assertEquals(Arrays.asList(0l, 1l), values);
    }
View Full Code Here

            runDISPEL("use a.A; A a1 = new A; A a2 = new A;\n" +
            "a1.output => a2.input with @bli=\"bla\"; " +
            "Connection c;" +
            "a1.other => c with @joe=\"eoj\";");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("a1");
        assertTrue(var.getValue() instanceof ProcessingElementNode);
        ProcessingElementNode a1 = (ProcessingElementNode)var.getValue();
        Connection output = a1.getOutput("output", 0);
        assertEquals("bla", output.getAnnotation("bli"));
        Connection other = a1.getOutput("other", 0);
        assertEquals("eoj", other.getAnnotation("joe"));
    }
View Full Code Here

TOP

Related Classes of eu.admire.dispel.parser.types.Variable

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.