Package org.teiid.metadata

Examples of org.teiid.metadata.Table


    @Test public void testDuplicatException() throws Exception {
      FakeServer server = new FakeServer();
      MetadataFactory mf = createMetadataFactory("x", new Properties());
      MetadataFactory mf1 = createMetadataFactory("y", new Properties());
     
      Table dup = mf.addTable("dup");
      Table dup1 = mf1.addTable("dup");
     
      mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
      mf1.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup1);
     
      MetadataStore ms = mf.getMetadataStore();
View Full Code Here


  public static Command createView(String sql, TransformationMetadata md, String vGroup)
      throws QueryParserException, QueryResolverException,
      TeiidComponentException {
    QueryNode vm1g1n1 = new QueryNode(sql);
    Table vm1g1 = RealMetadataFactory.createUpdatableVirtualGroup(vGroup, md.getMetadataStore().getSchema("VM1"), vm1g1n1);

    Command command = QueryParser.getQueryParser().parseCommand(sql);
    QueryResolver.resolveCommand(command, md);
   
    List<SingleElementSymbol> symbols = command.getProjectedSymbols();
View Full Code Here

     // Create models
    Schema pm1 = RealMetadataFactory.createPhysicalModel("pm1", metadataStore); //$NON-NLS-1$
    Schema vm1 = RealMetadataFactory.createVirtualModel("vm1", metadataStore);   //$NON-NLS-1$

    // Create physical groups
    Table pm1g1 = RealMetadataFactory.createPhysicalGroup("g1", pm1); //$NON-NLS-1$
    Table pm1g2 = RealMetadataFactory.createPhysicalGroup("g2", pm1); //$NON-NLS-1$
    Table pm1g3 = RealMetadataFactory.createPhysicalGroup("g3", pm1); //$NON-NLS-1$
       
    // Create physical elements
    List<Column> pm1g1e = RealMetadataFactory.createElements(pm1g1,
      new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
      new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
    if (!allUpdatable) {
      pm1g1e.get(0).setUpdatable(false);
    }
   
    KeyRecord pk = RealMetadataFactory.createKey(Type.Primary, "pk", pm1g1, pm1g1e.subList(0, 1));
   
    List<Column> pm1g2e = RealMetadataFactory.createElements(pm1g2,
      new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
      new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });

    RealMetadataFactory.createKey(Type.Primary, "pk", pm1g2, pm1g1e.subList(1, 2));
    RealMetadataFactory.createForeignKey("fk", pm1g2, pm1g2e.subList(0, 1), pk);
   
        List<Column> pm1g3e = RealMetadataFactory.createElements(pm1g3,
            new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
        pm1g3e.get(0).setNullType(NullType.No_Nulls);
        pm1g3e.get(0).setDefaultValue(null);
       
        pm1g3e.get(1).setNullType(NullType.No_Nulls);
        pm1g3e.get(1).setAutoIncremented(true);
        pm1g3e.get(1).setDefaultValue(null);
       
        pm1g3e.get(2).setNullType(NullType.No_Nulls);
        pm1g3e.get(2).setDefaultValue("xyz"); //$NON-NLS-1$

    // Create virtual groups
    QueryNode vm1g1n1 = new QueryNode("SELECT e1 as a, e2 FROM pm1.g1 WHERE e3 > 5"); //$NON-NLS-1$ //$NON-NLS-2$
    Table vm1g1 = RealMetadataFactory.createUpdatableVirtualGroup("g1", vm1, vm1g1n1); //$NON-NLS-1$
    QueryNode vm1g2n1 = new QueryNode("SELECT e1, e2, e3, e4 FROM pm1.g2 WHERE e3 > 5"); //$NON-NLS-1$ //$NON-NLS-2$
    Table vm1g2 = RealMetadataFactory.createUpdatableVirtualGroup("g2", vm1, vm1g2n1); //$NON-NLS-1$
        QueryNode vm1g3n1 = new QueryNode("SELECT e1, e3 FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
        Table vm1g3 = RealMetadataFactory.createUpdatableVirtualGroup("g3", vm1, vm1g3n1); //$NON-NLS-1$
        QueryNode vm1g4n1 = new QueryNode("SELECT e1, e2 FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
        Table vm1g4 = RealMetadataFactory.createUpdatableVirtualGroup("g4", vm1, vm1g4n1); //$NON-NLS-1$
        QueryNode vm1g5n1 = new QueryNode("SELECT e2, e3 FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
        Table vm1g5 = RealMetadataFactory.createVirtualGroup("g5", vm1, vm1g5n1); //$NON-NLS-1$

    // Create virtual elements
    RealMetadataFactory.createElements(vm1g1,
      new String[] { "a", "e2"}, //$NON-NLS-1$ //$NON-NLS-2$
      new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER});
View Full Code Here

  private static final String VM1 = "VM1";

  @Test public void testInsert() throws Exception {
    TransformationMetadata metadata = TestUpdateValidator.example1();
    TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, GX);
    Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
    t.setDeletePlan("");
    t.setUpdatePlan("");
    t.setInsertPlan("FOR EACH ROW BEGIN insert into pm1.g1 (e1) values (new.x); END");
   
    String sql = "insert into gx (x, y) values (1, 2)";
   
    FakeDataManager dm = new FakeDataManager();
    FakeDataStore.addTable("pm1.g1", dm, metadata);
View Full Code Here

  }
 
  @Test public void testInsertWithQueryExpression() throws Exception {
    TransformationMetadata metadata = TestUpdateValidator.example1();
    TestUpdateValidator.createView("select '1' as x, 2 as y", metadata, GX);
    Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
    t.setDeletePlan("");
    t.setUpdatePlan("");
    t.setInsertPlan("FOR EACH ROW BEGIN insert into pm1.g1 (e1) values (new.x); END");
   
    String sql = "insert into gx (x, y) select e1, e2 from pm1.g1";
   
    FakeDataManager dm = new FakeDataManager();
    FakeDataStore.addTable("pm1.g1", dm, metadata);
View Full Code Here

  }
 
  @Test public void testDelete() throws Exception {
    TransformationMetadata metadata = TestUpdateValidator.example1();
    TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, GX);
    Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
    t.setDeletePlan("FOR EACH ROW BEGIN delete from pm1.g1 where e2 = old.x; END");
    t.setUpdatePlan("");
    t.setInsertPlan("");
   
    String sql = "delete from gx where y = 2";
   
    FakeDataManager dm = new FakeDataManager();
    FakeDataStore.addTable("pm1.g1", dm, metadata);
View Full Code Here

  }
 
  @Test public void testUpdate() throws Exception {
    TransformationMetadata metadata = TestUpdateValidator.example1();
    TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, GX);
    Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
    t.setDeletePlan("");
    t.setUpdatePlan("FOR EACH ROW BEGIN update pm1.g1 set e2 = new.y where e2 = old.y; END");
    t.setInsertPlan("");
   
    String sql = "update gx set y = 5";
   
    FakeDataManager dm = new FakeDataManager();
    FakeDataStore.addTable("pm1.g1", dm, metadata);
View Full Code Here

  }
 
  @Test public void testUpdateWithNonConstant() throws Exception {
    TransformationMetadata metadata = TestUpdateValidator.example1();
    TestUpdateValidator.createView("select 1 as x, 2 as y", metadata, GX);
    Table t = metadata.getMetadataStore().getSchemas().get(VM1).getTables().get(GX);
    t.setDeletePlan("");
    t.setUpdatePlan("FOR EACH ROW BEGIN update pm1.g1 set e2 = new.y where e2 = old.y; END");
    t.setInsertPlan("");
   
    String sql = "update gx set y = x";
   
    FakeDataManager dm = new FakeDataManager();
    FakeDataStore.addTable("pm1.g1", dm, metadata);
View Full Code Here

TOP

Related Classes of org.teiid.metadata.Table

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.