Package org.teiid.metadata

Examples of org.teiid.metadata.Table


    }
   
    public static TransformationMetadata getMetadata() {
      MetadataStore store = new MetadataStore();
      Schema modeshape = RealMetadataFactory.createPhysicalModel("modeshape", store);
      Table nt_base = RealMetadataFactory.createPhysicalGroup("nt_base", modeshape);
      nt_base.setNameInSource("\"nt:base\"");
    List<Column> cols = RealMetadataFactory.createElements(nt_base, new String[] { "jcr_path",
        "mode_properties", "jcr_primaryType", "prop" }, new String[] {
        TypeFacility.RUNTIME_NAMES.STRING,
        TypeFacility.RUNTIME_NAMES.STRING,
        TypeFacility.RUNTIME_NAMES.STRING,
View Full Code Here


      MetadataStore store = new MetadataStore();
        // Create models
        Schema salesforceModel = RealMetadataFactory.createPhysicalModel("SalesforceModel", store); //$NON-NLS-1$
      
        // Create Account group
        Table accountTable = RealMetadataFactory.createPhysicalGroup("Account", salesforceModel); //$NON-NLS-1$
        accountTable.setNameInSource("Account"); //$NON-NLS-1$
        accountTable.setProperty("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
        accountTable.setProperty(Constants.SUPPORTS_RETRIEVE, Boolean.TRUE.toString());
        // Create Account Columns
        String[] acctNames = new String[] {
            "ID", "Name", "Stuff", "Industry"  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        };
        String[] acctTypes = new String[] { 
            DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING
        };
       
        List<Column> acctCols = RealMetadataFactory.createElements(accountTable, acctNames, acctTypes);
        acctCols.get(2).setNativeType("multipicklist"); //$NON-NLS-1$
        acctCols.get(2).setSearchType(SearchType.Like_Only);
        // Set name in source on each column
        String[] accountNameInSource = new String[] {
           "id", "AccountName", "Stuff", "Industry"             //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ 
        };
        for(int i=0; i<2; i++) {
            Column obj = acctCols.get(i);
            obj.setNameInSource(accountNameInSource[i]);
        }
       
        // Create Contact group
        Table contactTable = RealMetadataFactory.createPhysicalGroup("Contacts", salesforceModel); //$NON-NLS-1$
        contactTable.setNameInSource("Contact"); //$NON-NLS-1$
        contactTable.setProperty("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
        // Create Contact Columns
        String[] elemNames = new String[] {
            "ContactID", "Name", "AccountId", "InitialContact"  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        };
        String[] elemTypes = new String[] { 
View Full Code Here

      MetadataRepository repo = Mockito.mock(MetadataRepository.class);
      server.setMetadataRepository(repo);
      Mockito.stub(repo.getViewDefinition(Mockito.anyString(), Mockito.anyInt(), (Table)Mockito.anyObject())).toAnswer(new Answer<String>() {
        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
          Table t = (Table)invocation.getArguments()[2];
          if (t.getName().equals("vw")) {
            return "select '2011'";
          }
          return null;
        }
    });
      Mockito.stub(repo.getProcedureDefinition(Mockito.anyString(), Mockito.anyInt(), (Procedure)Mockito.anyObject())).toAnswer(new Answer<String>() {
        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
          Procedure t = (Procedure)invocation.getArguments()[2];
          if (t.getName().equals("proc")) {
            return "create virtual procedure begin select '2011'; end";
          }
          return null;
        }
    });
View Full Code Here

      Relationship relationship = iterator.next();
      if (!this.connectorEnv.isModelAuditFields() && isAuditField(relationship.getForeignKeyField())) {
                continue;
            }

      Table parent = tableMap.get(NameUtil.normalizeName(relationship.getParentTable()));
      KeyRecord pk = parent.getPrimaryKey();
      if (null == pk) {
                throw new RuntimeException("ERROR !!primary key column not found!!"); //$NON-NLS-1$
            }
      ArrayList<String> columnNames = new ArrayList<String>();
      columnNames.add(pk.getName());
     
     
      Table child = tableMap.get(NameUtil.normalizeName(relationship.getChildTable()));
     
      Column col = null;
      columns = child.getColumns();
      for (Iterator colIter = columns.iterator(); colIter.hasNext();) {
        Column column = (Column) colIter.next();
        if(column.getName().equals(relationship.getForeignKeyField())) {
          col = column;
        }
      }
      if (null == col) throw new RuntimeException(
                    "ERROR !!foreign key column not found!! " + child.getName() + relationship.getForeignKeyField()); //$NON-NLS-1$

     
      String columnName = "FK_" + parent.getName() + "_" + col.getName();//$NON-NLS-1$ //$NON-NLS-2$
      ArrayList<String> columnNames2 = new ArrayList<String>();
      columnNames2.add(col.getName())
View Full Code Here

    } catch (ResourceException e) {
      throw new TranslatorException(e);
    }
   
    String name = NameUtil.normalizeName(objectMetadata.getName());
    Table table = metadataFactory.addTable(name);
   
    table.setNameInSource(objectMetadata.getName());
    tableMap.put(name, table);
    getRelationships(objectMetadata);

    table.setProperty(TABLE_CUSTOM, String.valueOf(objectMetadata.isCustom()));
    table.setProperty(TABLE_SUPPORTS_CREATE, String.valueOf(objectMetadata.isCreateable()));
    table.setProperty(TABLE_SUPPORTS_DELETE, String.valueOf(objectMetadata.isDeletable()));
    table.setProperty(TABLE_SUPPORTS_MERGE, String.valueOf(objectMetadata.isMergeable()));
    table.setProperty(TABLE_SUPPORTS_QUERY, String.valueOf(objectMetadata.isQueryable()));
    table.setProperty(TABLE_SUPPORTS_REPLICATE, String.valueOf(objectMetadata.isReplicateable()));
    table.setProperty(TABLE_SUPPORTS_RETRIEVE, String.valueOf(objectMetadata.isRetrieveable()));
    table.setProperty(TABLE_SUPPORTS_SEARCH, String.valueOf(objectMetadata.isSearchable()));

    hasUpdateableColumn = false;
    addColumns(objectMetadata, table);
   
    // Some SF objects return true for isUpdateable() but have no updateable columns.
    if(hasUpdateableColumn && objectMetadata.isUpdateable()) {
      table.setSupportsUpdate(true);
    }
  }
View Full Code Here

   
    /** create fake BQT metadata to test this case, name in source is important */
    private QueryMetadataInterface getOracleSpecificMetadata() {
      MetadataStore metadataStore = new MetadataStore();
      Schema foo = RealMetadataFactory.createPhysicalModel("BQT1", metadataStore); //$NON-NLS-1$
        Table table = RealMetadataFactory.createPhysicalGroup("SmallA", foo); //$NON-NLS-1$
        Table dual = RealMetadataFactory.createPhysicalGroup("DUAL", foo); //$NON-NLS-1$
        table.setNameInSource("SmallishA");//$NON-NLS-1$
        String[] elemNames = new String[] {
            "DoubleNum"//$NON-NLS-1$
            "ID", //$NON-NLS-1$
            "timestampvalue", //$NON-NLS-1$
View Full Code Here

 
  @Test public void testSystemMatViewsWithRowRefresh() throws Exception {
    //TOOD: remove this. it's a workaround for TEIIDDES-549
    VDBMetaData vdb = server.getVDB(MATVIEWS);
    TransformationMetadata tm = vdb.getAttachment(TransformationMetadata.class);
    Table t = tm.getGroupID("TEST.RANDOMVIEW");
    t.setSelectTransformation("/*+ cache(updatable) */ " +  t.getSelectTransformation());
   
    Statement s = conn.createStatement();
    //prior to load refresh of a single row returns -1
    ResultSet rs = s.executeQuery("select * from (call refreshMatViewRow('TEST.RANDOMVIEW', 0)) p");
    assertTrue(rs.next());
View Full Code Here

    while (tables.next()) {
      String tableCatalog = tables.getString(1);
      String tableSchema = tables.getString(2);
      String tableName = tables.getString(3);
      String fullName = getFullyQualifiedName(tableCatalog, tableSchema, tableName);
      Table table = metadataFactory.addTable(useFullSchemaName?fullName:tableName);
      table.setNameInSource(getFullyQualifiedName(tableCatalog, tableSchema, tableName, true));
      table.setSupportsUpdate(true);
      String remarks = tables.getString(5);
      table.setAnnotation(remarks);
      tableMap.put(fullName, new TableInfo(tableCatalog, tableSchema, tableName, table));
      tableMap.put(tableName, new TableInfo(tableCatalog, tableSchema, tableName, table));
    }
    tables.close();
   
View Full Code Here

    }
   
    @Test public void testUniqueidentifier() throws Exception {
      MetadataStore metadataStore = new MetadataStore();
      Schema foo = RealMetadataFactory.createPhysicalModel("foo", metadataStore); //$NON-NLS-1$
        Table table = RealMetadataFactory.createPhysicalGroup("bar", foo); //$NON-NLS-1$
        String[] elemNames = new String[] {
            "x"  //$NON-NLS-1$
        };
        String[] elemTypes = new String[] { 
            DataTypeManager.DefaultDataTypes.STRING
View Full Code Here

   
    BufferManager bm = fbs.getBufferManager();
    CachedResults results = new CachedResults();
    ProcessorPlan plan = new FakeProcessorPlan(0);
    CommandContext cc = new CommandContext();
    Table t = RealMetadataFactory.exampleBQT().getGroupID("bqt1.smalla");
    cc.accessedDataObject(t);
    plan.setContext(cc);
    results.setResults(tb, plan);
    results.setCommand(new Query());
    Cache cache = new DefaultCache("dummy"); //$NON-NLS-1$
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.