org.teiid.metadata.Table类的使用及代码示例

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

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

Table介绍

暂无

代码示例

代码示例来源: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: teiid/teiid

  1. public Collection<KeyRecord> getAllKeys() {
  2. Collection<KeyRecord> keys = new LinkedList<KeyRecord>();
  3. if (getPrimaryKey() != null) {
  4. keys.add(getPrimaryKey());
  5. }
  6. keys.addAll(getForeignKeys());
  7. keys.addAll(getAccessPatterns());
  8. keys.addAll(getIndexes());
  9. keys.addAll(getUniqueKeys());
  10. return keys;
  11. }

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

  1. private static void removeTableOption(String key, Table table) {
  2. if (table.getProperty(key, false) != null) {
  3. table.setProperty(key, null);
  4. }
  5. removeCommonProperty(key, table);
  6. if (key.equals(DDLConstants.MATERIALIZED)) {
  7. table.setMaterialized(false);
  8. }
  9. if (key.equals(DDLConstants.MATERIALIZED_TABLE)) {
  10. table.setMaterializedTable(null);
  11. }
  12. if (key.equals(DDLConstants.UPDATABLE)) {
  13. table.setSupportsUpdate(false);
  14. }
  15. if (key.equals(DDLConstants.CARDINALITY)) {
  16. table.setCardinality(-1);
  17. }
  18. }

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

  1. static KeyRecord getIdentifier(Table table) {
  2. if (table.getPrimaryKey() != null) {
  3. return table.getPrimaryKey();
  4. }
  5. for (KeyRecord key:table.getUniqueKeys()) {
  6. return key;
  7. }
  8. return null;
  9. }

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

  1. private static String getEntityTypeName(Table t, boolean preserveEntityTypeName) {
  2. String entityTypeName = t.getName();
  3. if (preserveEntityTypeName && t.getProperty(ODataMetadataProcessor.ENTITY_TYPE, false) != null) {
  4. entityTypeName = t.getProperty(ODataMetadataProcessor.ENTITY_TYPE, false);
  5. }
  6. return entityTypeName;
  7. }

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

  1. private Table createView(String name) {
  2. Table t = addTable(name);
  3. t.setSystem(true);
  4. t.setSupportsUpdate(false);
  5. t.setVirtual(true);
  6. t.setTableType(Type.Table);
  7. return t;
  8. }

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

  1. private static void setTableOptions(Table table) {
  2. Map<String, String> props = table.getProperties();
  3. setCommonProperties(table, props);
  4. String value = props.remove(DDLConstants.MATERIALIZED);
  5. if (value != null) {
  6. table.setMaterialized(isTrue(value));
  7. }
  8. value = props.remove(DDLConstants.MATERIALIZED_TABLE);
  9. if (value != null) {
  10. Table mattable = new Table();
  11. mattable.setName(value);
  12. table.setMaterializedTable(mattable);
  13. }
  14. value = props.remove(DDLConstants.UPDATABLE);
  15. if (value != null) {
  16. table.setSupportsUpdate(isTrue(value));
  17. }
  18. value = props.remove(DDLConstants.CARDINALITY);
  19. if (value != null) {
  20. table.setCardinality(Long.valueOf(value));
  21. }
  22. }

代码示例来源: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.teiid/teiid-engine

  1. public Collection<KeyRecord> getUniqueKeysInGroup(final Object groupID)
  2. throws TeiidComponentException, QueryMetadataException {
  3. Table tableRecordImpl = (Table)groupID;
  4. ArrayList<KeyRecord> result = new ArrayList<KeyRecord>(tableRecordImpl.getUniqueKeys());
  5. if (tableRecordImpl.getPrimaryKey() != null) {
  6. result.add(tableRecordImpl.getPrimaryKey());
  7. }
  8. for (KeyRecord key : tableRecordImpl.getIndexes()) {
  9. if (key.getType() == KeyRecord.Type.Unique) {
  10. result.add(key);
  11. }
  12. }
  13. return result;
  14. }

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

  1. Column getColumn(String columnName, Table table) throws MetadataException {
  2. Column c = table.getColumnByName(columnName);
  3. if (c != null) {
  4. return c;
  5. }
  6. throw new MetadataException(QueryPlugin.Util.getString("SQLParser.no_column", columnName, table.getName())); //$NON-NLS-1$
  7. }

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

  1. /**
  2. * Create a physical group with default settings.
  3. * @param name Name of physical group, must match model name
  4. * @param model Associated model
  5. * @return FakeMetadataObject Metadata object for group
  6. */
  7. public static Table createPhysicalGroup(String name, Schema model, boolean fullyQualify) {
  8. Table table = new Table();
  9. table.setName(name);
  10. model.addTable(table);
  11. table.setSupportsUpdate(true);
  12. table.setNameInSource((fullyQualify || name.lastIndexOf(".") == -1)? name : name.substring(name.lastIndexOf(".") + 1)); //$NON-NLS-1$ //$NON-NLS-2$
  13. table.setTableType(org.teiid.metadata.Table.Type.Table);
  14. return table;
  15. }

代码示例来源: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: 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: org.teiid.connectors/translator-jdbc

  1. /**
  2. *
  3. * @param metadataFactory
  4. * @param tableCatalog
  5. * @param tableSchema
  6. * @param tableName
  7. * @param remarks
  8. * @param fullName
  9. * @return
  10. */
  11. protected Table addTable(MetadataFactory metadataFactory,
  12. String tableCatalog, String tableSchema, String tableName,
  13. String remarks, String fullName) {
  14. Table table = metadataFactory.addTable(useFullSchemaName?fullName:tableName);
  15. table.setNameInSource(getFullyQualifiedName(tableCatalog, tableSchema, tableName, true));
  16. //create a fqn for the table
  17. FullyQualifiedName fqn = new FullyQualifiedName();
  18. if (tableCatalog != null && !tableCatalog.isEmpty()) {
  19. fqn.append(getCatalogTerm(), tableCatalog);
  20. }
  21. if (tableSchema != null && !tableSchema.isEmpty()) {
  22. fqn.append(getSchemaTerm(), tableSchema);
  23. }
  24. fqn.append(getTableTerm(), tableName);
  25. table.setProperty(FQN, fqn.toString());
  26. table.setSupportsUpdate(true);
  27. table.setAnnotation(remarks);
  28. return table;
  29. }

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

  1. @Override
  2. public Object getPrimaryKey(Object metadataID) {
  3. Table table = (Table)metadataID;
  4. return table.getPrimaryKey();
  5. }

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

  1. /**
  2. * Adds new table to metadata.
  3. *
  4. * @param spreadsheet Name of the spreadsheet
  5. * @param worksheet Name of the worksheet
  6. * @throws TranslatorException
  7. */
  8. private void addTable(MetadataFactory mf, Worksheet worksheet) {
  9. if (worksheet.getColumnCount() == 0){
  10. return;
  11. }
  12. Table table = mf.addTable(worksheet.getName());
  13. table.setProperty(FQN, new FullyQualifiedName("worksheet", worksheet.getName()).toString()); //$NON-NLS-1$
  14. table.setNameInSource(worksheet.getName());
  15. if (worksheet.isHeaderEnabled()) {
  16. table.setSupportsUpdate(true);
  17. }
  18. addColumnsToTable(mf, table, worksheet);
  19. }

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

  1. static boolean isPartOfForeignKey(Table table, String columnName) {
  2. for (ForeignKey fk : table.getForeignKeys()) {
  3. for (Column column : fk.getColumns()) {
  4. if (column.getName().equals(columnName)) {
  5. return true;
  6. }
  7. }
  8. }
  9. return false;
  10. }

代码示例来源: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.connectors/translator-odata

  1. private boolean hasColumns(List<String> columnNames, Table table) {
  2. for (String columnName:columnNames) {
  3. if (table.getColumnByName(columnName) == null) {
  4. return false;
  5. }
  6. }
  7. return true;
  8. }

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

  1. public Collection<Table> getXMLTempGroups(Table tableRecord) {
  2. ArrayList<Table> results = new ArrayList<Table>();
  3. String namePrefix = tableRecord.getName() + TransformationMetadata.DELIMITER_STRING;
  4. for (Table table : tableRecord.getParent().getTables().values()) {
  5. if (table.getTableType() == Type.XmlStagingTable && table.getName().startsWith(namePrefix)) {
  6. results.add(table);
  7. }
  8. }
  9. return results;
  10. }

相关文章