Package eu.admire.dispel.engine

Examples of eu.admire.dispel.engine.DispelObject


       
        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())
View Full Code Here


                "|- 1, 2, 3 -|:MySType::Set([MyDType[]]) => c; " +
                "|- repeat 15 of x -| => c; " +
                "|- repeat enough of x -| => c; " +
                "}";
        mRegistry.register("MyDType",
                new DispelObject(
                        "MyDType",
                        DispelObjectType.DOMAIN_TYPE,
                        new DomainType(new SimpleDType())));
        mRegistry.register("MySType",
                new DispelObject(
                        "MySType",
                        DispelObjectType.STRUCTURAL_TYPE,
                        new StructuralType(new PrimitiveSType("Integer"))));
        DISPELGraphBuilder builder = runDISPEL(new StringReader(function));
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("A"));
View Full Code Here

    }

    @Test
    public void testFunctionCall() throws Exception
    {
        DispelObject reg = new DispelObject();
        reg.name = "fun.f";
        reg.dispel = "package fun { Real f(Integer i, String s) { return 1; } }";
        reg.type = DispelObjectType.FUNCTION;
        mRegistry.register("fun.f", reg);
        String function = "use fun.f; void g() { Real r = f(1, \"s\"); f(2, \"x\"); }";
View Full Code Here

        DISPELGraphBuilder builder = runDISPEL(
                new FileReader("test/unit/eu/admire/dispel/parser/v4/converter/RegisterCrossValidationFunctions.dispel"));
        for (Entry<String, RegisteredObject> reg : builder.getRegistered().entrySet())
        {
            System.out.println("Registering " + reg.getKey());
            DispelObject object = new DispelObject(reg.getKey(), reg.getValue().getObject());
            mRegistry.register(reg.getKey(), object);
        }
        String dispel = FunctionToDISPEL.convert(builder.getFunctions().get("eu.admire.CrossValidationTest"));
        runDISPEL(new StringReader(dispel));
        TestCase.assertFalse("Function DISPEL cannot be parsed.", mHasError);
View Full Code Here

          DispelExecutionState executionState,
          AdmireRegistry registry,
          DispelOptimiser optimiser)
      throws UnregisteredUsedObjectException, CompilationException
  {
      DispelObject object;
      Map<String, Set<DispelObject>> candidates;
      try
      {
          candidates = registry.lookup(Collections.singleton(name));
      }
      catch (LookupFailedException e)
      {
          throw new UnregisteredUsedObjectException(name, e);
      }
     
      object = optimiser.chooseCandidate(candidates).get(name);
      if (object == null)
      {
          throw new UnregisteredUsedObjectException(name);
      }
      if (object.getType() == DispelObjectType.PROCESSING_ELEMENT_TYPE)
      {
          ProcessingElementType pe = new ProcessingElementType(name);
          pe.setDescriptor((ProcessingElementDescriptor)object.metadata);
          executionState.getUsedProcessingElements().registerType(name, pe);
          // processing element implementations are parsed later
View Full Code Here

        }
     
      Map<String, DispelObject> chosen =
          optimiser.chooseCandidate(candidates);
     
      DispelObject details = chosen.get(functionName);
      if (details == null || details.getType() != DispelObjectType.FUNCTION)
      {
          return null;
      }
     
      compile(functionName, details, executionState, registry, optimiser);
View Full Code Here

        }
    }
   
    public void testConnectionWithSType() throws Exception
    {
        DispelObject object = new DispelObject(
                "MySType",
                DispelObjectType.STRUCTURAL_TYPE,
                new StructuralType(new ListSType(new PrimitiveSType("Integer"))));
        mRegistry.register("MySType", object);
        runDISPEL("use MySType; Connection c; |- [1] -|::[MySType] => c; ");
View Full Code Here

        assertNull(mError);
    }
   
    public void testConnectionWithAnnotation() throws Exception
    {
        DispelObject object = new DispelObject(
                "MySType",
                DispelObjectType.STRUCTURAL_TYPE,
                new StructuralType(new ListSType(new PrimitiveSType("Integer"))));
        mRegistry.register("MySType", object);
        DISPELGraphBuilder builder =
View Full Code Here

            runDISPEL("String s = \"abcde\"; Integer i = 123; register s, i;");
        assertNull(mError);
        RegisteredObject object = builder.getRegistered().get("s");
        assertNotNull(object);
        assertTrue(object.getObject() instanceof Variable);
        DispelObject reg = new DispelObject("s", ((Variable)object.getObject()).getValue());
        mRegistry.register(reg.name, reg);
        object = builder.getRegistered().get("i");
        assertNotNull(object);
        assertTrue(object.getObject() instanceof Variable);
        reg = new DispelObject("i", ((Variable)object.getObject()).getValue());
        mRegistry.register(reg.name, reg);
        builder = runDISPEL("use s; use i; String a = s; Integer b = i;");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("s");
        assertNotNull(var);
View Full Code Here

                new SimpleSemanticType("dispel", "RDBuri", "dispel"));
        DISPELGraphBuilder builder = runDISPELFromFile(PATH + "ExampleFunctionWrappingConstantAsStream.dispel");
        assertTrue(!builder.getRegistered().isEmpty());
        RegisteredObject reg = builder.getRegistered().values().iterator().next();
        assertTrue(reg.getObject() instanceof Function);
        DispelObject function = new DispelObject(((Function)reg.getObject()).getName(), (Function)reg.getObject());
        mRegistry.register(function.getName(), function);
        System.out.println(function.getDispel());
        assertNull(mError);
        builder = runDISPELFromFile(PATH + "FreezingSQLdataSourceV2.dispel");
        assertNull(mError);
    }
View Full Code Here

TOP

Related Classes of eu.admire.dispel.engine.DispelObject

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.