org.teiid.metadata.Table.getColumns()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(263)

本文整理了Java中org.teiid.metadata.Table.getColumns()方法的一些代码示例,展示了Table.getColumns()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getColumns()方法的具体详情如下:
包路径:org.teiid.metadata.Table
类名称:Table
方法名:getColumns

Table.getColumns介绍

暂无

代码示例

代码示例来源:origin: org.jboss.teiid/teiid-engine

  1. public static void determineDependencies(AbstractMetadataRecord p, Command command) {
  2. LinkedHashSet<AbstractMetadataRecord> values = new LinkedHashSet<AbstractMetadataRecord>();
  3. collectDependencies(command, values);
  4. p.setIncomingObjects(new ArrayList<AbstractMetadataRecord>(values));
  5. if (p instanceof Table) {
  6. Table t = (Table)p;
  7. for (int i = 0; i < t.getColumns().size(); i++) {
  8. LinkedHashSet<AbstractMetadataRecord> columnValues = new LinkedHashSet<AbstractMetadataRecord>();
  9. Column c = t.getColumns().get(i);
  10. c.setIncomingObjects(columnValues);
  11. determineDependencies(command, c, i, columnValues);
  12. }
  13. }
  14. }

代码示例来源:origin: teiid/teiid

  1. public void setTableMetadata(Table tableMetadata) {
  2. if (tableMetadata != null) {
  3. this.columns = tableMetadata.getColumns();
  4. this.table = new GroupSymbol(tableMetadata.getName());
  5. }
  6. this.tableMetadata = tableMetadata;
  7. }

代码示例来源:origin: org.jboss.teiid/teiid-engine

  1. public void setTableMetadata(Table tableMetadata) {
  2. if (tableMetadata != null) {
  3. this.columns = tableMetadata.getColumns();
  4. this.table = new GroupSymbol(tableMetadata.getName());
  5. }
  6. this.tableMetadata = tableMetadata;
  7. }

代码示例来源:origin: org.teiid/teiid-engine

  1. public void setTableMetadata(Table tableMetadata) {
  2. if (tableMetadata != null) {
  3. this.columns = tableMetadata.getColumns();
  4. this.table = new GroupSymbol(tableMetadata.getName());
  5. }
  6. this.tableMetadata = tableMetadata;
  7. }

代码示例来源:origin: org.teiid/teiid-engine

  1. public List<Column> getElementIDsInGroupID(final Object groupID) throws TeiidComponentException, QueryMetadataException {
  2. List<Column> columns = ((Table)groupID).getColumns();
  3. if (columns == null || columns.isEmpty()) {
  4. throw new QueryMetadataException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31071, ((Table)groupID).getName()));
  5. }
  6. return columns;
  7. }

代码示例来源:origin: org.jboss.teiid/teiid-engine

  1. public List<Column> getElementIDsInGroupID(final Object groupID) throws TeiidComponentException, QueryMetadataException {
  2. List<Column> columns = ((Table)groupID).getColumns();
  3. if (columns == null || columns.isEmpty()) {
  4. throw new QueryMetadataException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31071, ((Table)groupID).getName()));
  5. }
  6. return columns;
  7. }

代码示例来源:origin: teiid/teiid

  1. public List<Column> getElementIDsInGroupID(final Object groupID) throws TeiidComponentException, QueryMetadataException {
  2. List<Column> columns = ((Table)groupID).getColumns();
  3. if (columns == null || columns.isEmpty()) {
  4. throw new QueryMetadataException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31071, ((Table)groupID).getName()));
  5. }
  6. return columns;
  7. }

代码示例来源:origin: org.teiid.connectors/translator-odata4

  1. static Table getComplexTableParentTable(RuntimeMetadata metadata, Table table) throws TranslatorException {
  2. for (Column c : table.getColumns()) {
  3. if (ODataMetadataProcessor.isPseudo(c)) {
  4. ForeignKey fk = table.getForeignKeys().get(0);
  5. String tableName = fk.getReferenceTableName();
  6. if (tableName.indexOf('.') == -1) {
  7. tableName = fk.getReferenceKey().getParent().getFullName();
  8. }
  9. return (Table)metadata.getTable(tableName);
  10. }
  11. }
  12. return table;
  13. }

代码示例来源:origin: teiid/teiid

  1. @Test public void testArrayType() throws Exception {
  2. String ddl = "CREATE VIEW V (col string[]) as select ('a','b');";
  3. Schema s = helpParse(ddl, "model").getSchema();
  4. Table t = s.getTable("V");
  5. assertEquals(1, t.getColumns().size());
  6. assertEquals("string[]", t.getColumns().get(0).getRuntimeType());
  7. assertEquals(String[].class, t.getColumns().get(0).getJavaType());
  8. }

代码示例来源:origin: teiid/teiid

  1. @Test
  2. public void testUDT() throws Exception {
  3. String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar OPTIONS (UDT 'NMTOKENS(12,13,11)'))";
  4. Schema s = helpParse(ddl, "model").getSchema();
  5. Map<String, Table> tableMap = s.getTables();
  6. assertTrue("Table not found", tableMap.containsKey("G1"));
  7. Table table = tableMap.get("G1");
  8. assertEquals("NMTOKENS", table.getColumns().get(1).getDatatype().getName());
  9. assertEquals(12, table.getColumns().get(1).getLength());
  10. assertEquals(13, table.getColumns().get(1).getPrecision());
  11. assertEquals(11, table.getColumns().get(1).getScale());
  12. }

代码示例来源:origin: teiid/teiid

  1. @Test
  2. public void testConstraints2() throws Exception {
  3. String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date, " +
  4. "ACCESSPATTERN(e1), UNIQUE(e1), ACCESSPATTERN(e2, e3))";
  5. Schema s = helpParse(ddl, "model").getSchema();
  6. Map<String, Table> tableMap = s.getTables();
  7. assertTrue("Table not found", tableMap.containsKey("G1"));
  8. Table table = tableMap.get("G1");
  9. assertEquals(table.getColumns().subList(0, 1), table.getUniqueKeys().get(0).getColumns());
  10. assertEquals(2, table.getAccessPatterns().size());
  11. assertEquals(table.getColumns().subList(0, 1), table.getAccessPatterns().get(0).getColumns());
  12. assertEquals(table.getColumns().subList(1, 3), table.getAccessPatterns().get(1).getColumns());
  13. }

代码示例来源:origin: org.teiid/teiid-engine

  1. private void verifyTableColumns(ModelMetaData model, ValidatorReport report,
  2. MetadataValidator metadataValidator, Table view, Table matView, String ignoreColumnOnMatView) {
  3. List<Column> columns = view.getColumns();
  4. for(int i = 0 ; i < columns.size() ; i ++) {
  5. Column column = columns.get(i);
  6. Column matViewColumn = matView.getColumnByName(column.getName());
  7. if (matViewColumn == null) {
  8. metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31193, column.getName(), matView.getFullName(), view.getFullName()));
  9. } else if(!column.getDatatypeUUID().equals(matViewColumn.getDatatypeUUID())){
  10. metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31194, matViewColumn.getName(), matView.getFullName(), column.getName(), view.getFullName()));
  11. }
  12. }
  13. }
  14. }

代码示例来源:origin: teiid/teiid

  1. @Test
  2. public void testConstraints() throws Exception {
  3. String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date, " +
  4. " PRIMARY KEY (e1, e2), INDEX(e2, e3), ACCESSPATTERN(e1), UNIQUE(e1)," +
  5. " ACCESSPATTERN(e2, e3))";
  6. Schema s = helpParse(ddl, "model").getSchema();
  7. Map<String, Table> tableMap = s.getTables();
  8. assertTrue("Table not found", tableMap.containsKey("G1"));
  9. Table table = tableMap.get("G1");
  10. assertEquals(table.getColumns().subList(0, 2), table.getPrimaryKey().getColumns());
  11. assertEquals(table.getColumns().subList(1, 3), table.getIndexes().get(0).getColumns());
  12. assertEquals(table.getColumns().subList(0, 1), table.getUniqueKeys().get(0).getColumns());
  13. assertEquals(2, table.getAccessPatterns().size());
  14. assertEquals(table.getColumns().subList(0, 1), table.getAccessPatterns().get(0).getColumns());
  15. assertEquals(table.getColumns().subList(1, 3), table.getAccessPatterns().get(1).getColumns());
  16. }

代码示例来源:origin: org.jboss.teiid/teiid-engine

  1. private void verifyTableColumns(ModelMetaData model, ValidatorReport report,
  2. MetadataValidator metadataValidator, Table view, Table matView, String ignoreColumnOnMatView) {
  3. List<Column> columns = view.getColumns();
  4. for(int i = 0 ; i < columns.size() ; i ++) {
  5. Column column = columns.get(i);
  6. Column matViewColumn = matView.getColumnByName(column.getName());
  7. if (matViewColumn == null) {
  8. metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31193, column.getName(), matView.getFullName(), view.getFullName()));
  9. } else if(!column.getDatatypeUUID().equals(matViewColumn.getDatatypeUUID())){
  10. metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31194, matViewColumn.getName(), matView.getFullName(), column.getName(), view.getFullName()));
  11. }
  12. }
  13. }
  14. }

代码示例来源:origin: teiid/teiid

  1. private void verifyTableColumns(ModelMetaData model, ValidatorReport report,
  2. MetadataValidator metadataValidator, Table view, Table matView, String ignoreColumnOnMatView) {
  3. List<Column> columns = view.getColumns();
  4. for(int i = 0 ; i < columns.size() ; i ++) {
  5. Column column = columns.get(i);
  6. Column matViewColumn = matView.getColumnByName(column.getName());
  7. if (matViewColumn == null) {
  8. metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31193, column.getName(), matView.getFullName(), view.getFullName()));
  9. } else if(!column.getDatatypeUUID().equals(matViewColumn.getDatatypeUUID())){
  10. metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31194, matViewColumn.getName(), matView.getFullName(), column.getName(), view.getFullName()));
  11. }
  12. }
  13. }
  14. }

代码示例来源:origin: teiid/teiid

  1. @Test public void testMultiple() throws Exception {
  2. TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/ZZZ.vdb");
  3. Collection<String> names = tm.getGroupsForPartialName("PRODUCTDATA");
  4. assertEquals(1, names.size());
  5. names = tm.getGroupsForPartialName("PARTS");
  6. assertEquals(1, names.size());
  7. //ensure that datatypes are set
  8. Table t = tm.getGroupID(names.iterator().next());
  9. assertNotNull(t.getColumns().get(0).getDatatype());
  10. }

代码示例来源:origin: teiid/teiid

  1. @Test
  2. public void testGlobalTemp() throws Exception {
  3. String ddl = "CREATE GLOBAL TEMPORARY TABLE T (col string);";
  4. Schema s = helpParse(ddl, "model").getSchema();
  5. Table t = s.getTable("T");
  6. assertEquals(1, t.getColumns().size());
  7. }

代码示例来源:origin: teiid/teiid

  1. @Test
  2. public void testMultiKeyPK() throws Exception {
  3. String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date, PRIMARY KEY (e1, e2))";
  4. Schema s = helpParse(ddl, "model").getSchema();
  5. Map<String, Table> tableMap = s.getTables();
  6. assertTrue("Table not found", tableMap.containsKey("G1"));
  7. Table table = tableMap.get("G1");
  8. assertEquals(table.getColumns().subList(0, 2), table.getPrimaryKey().getColumns());
  9. }

代码示例来源:origin: teiid/teiid

  1. @Test
  2. public void testAlterAddPK() throws Exception {
  3. String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date); ALTER TABLE G1 ADD PRIMARY KEY (e1, e2);";
  4. Schema s = helpParse(ddl, "model").getSchema();
  5. Map<String, Table> tableMap = s.getTables();
  6. assertTrue("Table not found", tableMap.containsKey("G1"));
  7. Table table = tableMap.get("G1");
  8. assertEquals(table.getColumns().subList(0, 2), table.getPrimaryKey().getColumns());
  9. }

代码示例来源:origin: teiid/teiid

  1. @Test
  2. public void testFK() throws Exception {
  3. String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));\n" +
  4. "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, " +
  5. "FOREIGN KEY (g2e1, g2e2) REFERENCES G1 (g1e1, g1e2) options (\"teiid_rel:allow-join\" true))";
  6. Schema s = helpParse(ddl, "model").getSchema();
  7. Map<String, Table> tableMap = s.getTables();
  8. assertEquals(2, tableMap.size());
  9. assertTrue("Table not found", tableMap.containsKey("G1"));
  10. assertTrue("Table not found", tableMap.containsKey("G2"));
  11. Table table = tableMap.get("G2");
  12. ForeignKey fk = table.getForeignKeys().get(0);
  13. assertEquals(Boolean.TRUE.toString(), fk.getProperty(ForeignKey.ALLOW_JOIN, false));
  14. assertEquals(fk.getColumns(), table.getColumns());
  15. assertEquals("G1", fk.getReferenceTableName());
  16. }

相关文章