Examples of DISPELGraphBuilder


Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    private AdmireRegistry mRegistry;
   
    public void process(String dispel) throws IOException
    {
        DISPELCompiler compiler = new DISPELCompiler();
        DISPELGraphBuilder builder = new DISPELGraphBuilder(
                mRegistry,
                new SimpleDispelOptimiser());
        compiler.setRequestBuilder(builder);
        compiler.addErrorListener(this);
        compiler.parse(dispel);

        Map<String, RegisteredObject> registered = builder.getRegistered();
        Map<String, Variable> variables = builder.getDispelExecutionState().getVariables();
       
        for (Entry<String, RegisteredObject> entry : registered.entrySet())
        {
            LOG.debug("Processing registered object " + entry.getKey());
           
            DispelObject reg = null;
            try
            {
                if (entry.getValue().getObject() instanceof Variable)
                {
                    Variable var = (Variable)entry.getValue().getObject();
                    if (var.getValue() != null)
                    {
                        reg = new DispelObject(entry.getKey(), var.getValue());
                    }
                    else
                    {
                        error(0, 0, new VariableNotInitialisedException(entry.getKey()));
                        return;
                    }
                }
                else
                {
                    reg = new DispelObject(entry.getKey(), entry.getValue());
                }
            }
            catch(IllegalArgumentException e)
            {
              error(0, 0, e);
              return;
            }

            if (reg.getType() == DispelObjectType.PROCESSING_ELEMENT_TYPE)
            {
                ProcessingElementType peType = (ProcessingElementType)entry.getValue().getObject();
                if (peType.getImplementation() != null)
                {
                    LOG.debug("Writing registered composite processing element " + entry.getKey());
                    Graph component = GraphUtilities.getConnectedComponent(
                            peType.getImplementation());
                    String image =
                        convertToImage(component, variables);
                    mRegistered.put(reg.name, image);
                }
                else
                {
                    LOG.debug("Registering processing element type " + entry.getKey());
                    StringBuilder pe = new StringBuilder();
                    pe.append("Type ");
                    pe.append(reg.name);
                    if (peType.getDescriptor().getSuperType() != null
                            && !peType.getDescriptor().getSuperType().isEmpty())
                    {
                        pe.append(" is PE<");
                        pe.append(peType.getDescriptor().getSuperType().iterator().next());
                        pe.append(">;");
                    }
                    else
                    {
                        pe.append(" is PE(<");
                        for (ProcessingElementInputDescriptor input : peType.getDescriptor().getInputs())
                        {
                            pe.append("Connection ");
                            if (input.getIsDataSourceInput())
                            {
                                pe.append("locator ");
                            }
                            pe.append(input.getName());
                            pe.append("; ");
                        }
                        if (!peType.getDescriptor().getInputs().isEmpty())
                        {
                            pe.delete(pe.length()-2, pe.length());
                        }
                        pe.append("> => <");
                        for (ProcessingElementOutputDescriptor output : peType.getDescriptor().getOutputs())
                        {
                            pe.append("Connection ");
                            pe.append(output.getName());
                            pe.append("; ");
                        }
                        if (!peType.getDescriptor().getOutputs().isEmpty())
                        {
                            pe.delete(pe.length()-2, pe.length());
                        }
                        pe.append(">);");
                    }
                    mRegistered.put(reg.name, pe.toString());
                }
            }
            else
            {
                mRegistered.put(reg.getName(), reg.getDispel());
            }
        }
       
        LOG.debug("Writing submitted graphs.");
        for (Graph graph : builder.getSubmittedGraphs())
        {
            String image = convertToImage(graph, variables);
            mSubmitted.add(image);
        }
       
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

   
    @Test
    public void testEmpty() throws Exception
    {
        String function = "Integer A(String a, Real b) {}";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
        System.out.println(dispel);
    }
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    @Test
    public void testSimple() throws Exception
    {
        String function = "Integer A() { String a = \"xxx\"; Integer x = 1+2*3/5; }";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
        System.out.println(dispel);
    }
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    @Test
    public void testParameterArray() throws Exception
    {
        String function = "Integer[] A(String[] a) { Integer[][] i = new Integer[2][10]; return i[0]; }";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
        System.out.println(dispel);
    }
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    @Test
    public void testForLoop() throws Exception
    {
        String function = "void f() { for (Integer i=0; i<2; i++) { } Integer i; for (i=0; i<5; i++) {} }";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("f"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
        System.out.println(dispel);
    }
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    @Test
    public void testPackage() throws Exception
    {
        String function = "package eu.admire { " +
            "Integer A() { String a = \"xxx\"; } }";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("eu.admire.A"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
        System.out.println(dispel);
    }
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    @Test
    public void testReturnPEInstance() throws Exception
    {
        mRegistry.registerProcessingElement("SQLQuery");
        String function = "use SQLQuery; SQLQuery A() { return new SQLQuery; }";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
        System.out.println(dispel);
    }
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    {
        mRegistry.registerProcessingElement("X");
        String function = "use X; Integer A() { " +
            "X a = new X; X[] b = new X[2]; " +
            "a.out => b[0].in[0]; Connection c; c => b[1].in; a.out => c; }";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
        runDISPEL(new StringReader(dispel));
        System.out.println(dispel);
    }
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    @Test
    public void testReturnConnection() throws Exception
    {
        String function = "Connection A() { " +
                "Connection c; return c; }";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
//        System.out.println(dispel);
    }
View Full Code Here

Examples of eu.admire.dispel.parser.v4.builder.DISPELGraphBuilder

    @Test
    public void testReturnConnectionArray() throws Exception
    {
        String function = "Connection[] A() { " +
                "Connection[] c = new Connection[2]; return c; }";
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse(mHasError);
//        System.out.println(dispel);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.