Package org.teiid.cdk.api

Examples of org.teiid.cdk.api.TranslationUtility


    public static Command helpTranslate(String vdbFileName, String sql) {
      return helpTranslate(vdbFileName, null, null, sql);
    }
   
    public static TranslationUtility getTranslationUtility(String vdbFileName, String udf) {
      TranslationUtility util = null;
      if (PARTS_VDB.equals(vdbFileName)) {
        util = new TranslationUtility(TranslationHelper.class.getResource(vdbFileName));
      } else if (BQT_VDB.equals(vdbFileName)){
        util = FakeTranslationFactory.getInstance().getBQTTranslationUtility();
      } else {
        Assert.fail("unknown vdb"); //$NON-NLS-1$
      }
View Full Code Here


      throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
    }
  }
   
    public static Command helpTranslate(String vdbFileName, String udf, List<FunctionMethod> pushdowns, String sql) {
      TranslationUtility util =  getTranslationUtility(vdbFileName, null);  
     
      Collection <FunctionMethod> methods = new ArrayList<FunctionMethod>();
      if (udf != null) {
        try {
        methods.addAll(FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream()));
      } catch (JAXBException e) {
        throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
      } catch (IOException e) {
        throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
      }
      }
      if (pushdowns != null) {
        methods.addAll(pushdowns);
      }
      util.setUDF(methods);
      return util.parseCommand(sql);
    }   
View Full Code Here

    @BeforeClass
    public static void setUp() throws TranslatorException {
        TRANSLATOR = new ModeShapeExecutionFactory();
        TRANSLATOR.setUseBindVariables(false);
        TRANSLATOR.start();
        UTIL = new TranslationUtility(getMetadata());
        TranslationHelper.loadUDFs(UDF, UTIL);
    }
View Full Code Here

        helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, correctNaming);
    }

    private void helpTestVisitor(String vdb, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws TranslatorException {
        // Convert from sql to objects
        TranslationUtility util = new TranslationUtility(vdb);
        Command obj =  util.parseCommand(input, correctNaming, true);       
    this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
    }
View Full Code Here

    public String getTestVDB() {
        return UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb"; //$NON-NLS-1$
    }
   
    public void helpTestTranslate(String sql, String expectedOutput) {
        TranslationUtility util = new TranslationUtility(getTestVDB());
        Command query = util.parseCommand(sql);        
        assertEquals(expectedOutput, query.toString());       
    }
View Full Code Here

            "delete from partssupplier.parts where part_color = 'Red'", //$NON-NLS-1$
            "DELETE FROM PARTS WHERE PARTS.PART_COLOR = 'Red'"); //$NON-NLS-1$
    }

    public void testGetRMD() throws Exception {
        TranslationUtility util = new TranslationUtility(getTestVDB());
       
        // Translate command to get some ids
        Select query = (Select) util.parseCommand("select * from partssupplier.parts"); //$NON-NLS-1$
        NamedTable group = (NamedTable) query.getFrom().get(0);
        AbstractMetadataRecord mid = group.getMetadataObject();
        assertEquals("PartsSupplier.PARTSSUPPLIER.PARTS", mid.getFullName()); //$NON-NLS-1$
       
        // Use RMD to get stuff
View Full Code Here

        obj.setNativeType("uniqueidentifier"); //$NON-NLS-1$
       
        CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
        QueryMetadataInterface metadata = new TransformationMetadata(null, store, null, FakeMetadataFactory.SFM.getSystemFunctions(), null);
       
        TranslationUtility tu = new TranslationUtility(metadata);
        Command command = tu.parseCommand("select max(x) from bar"); //$NON-NLS-1$
        TranslationHelper.helpTestVisitor("SELECT MAX(cast(bar.x as char(36))) FROM bar", trans, command); //$NON-NLS-1$
       
        command = tu.parseCommand("select * from (select max(x) as max from bar) x"); //$NON-NLS-1$
        TranslationHelper.helpTestVisitor("SELECT x.max FROM (SELECT MAX(cast(bar.x as char(36))) AS max FROM bar) x", trans, command); //$NON-NLS-1$
    }
View Full Code Here

  public static FakeTranslationFactory getInstance() {
    return instance;
  }

  public TranslationUtility getBQTTranslationUtility() {
    return new TranslationUtility(FakeMetadataFactory.exampleBQTCached());
  }
View Full Code Here

  public TranslationUtility getBQTTranslationUtility() {
    return new TranslationUtility(FakeMetadataFactory.exampleBQTCached());
  }
 
  public TranslationUtility getYahooTranslationUtility() {
    return new TranslationUtility(FakeMetadataFactory.exampleYahoo());
  }
View Full Code Here

  public TranslationUtility getYahooTranslationUtility() {
    return new TranslationUtility(FakeMetadataFactory.exampleYahoo());
  }
 
  public TranslationUtility getExampleTranslationUtility() {
    return new TranslationUtility(FakeMetadataFactory.example1Cached());
  }
View Full Code Here

TOP

Related Classes of org.teiid.cdk.api.TranslationUtility

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.