本文整理了Java中org.teiid.metadata.Table
类的一些代码示例,展示了Table
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table
类的具体详情如下:
包路径:org.teiid.metadata.Table
类名称:Table
暂无
代码示例来源:origin: teiid/teiid
public void setTableMetadata(Table tableMetadata) {
if (tableMetadata != null) {
this.columns = tableMetadata.getColumns();
this.table = new GroupSymbol(tableMetadata.getName());
}
this.tableMetadata = tableMetadata;
}
代码示例来源:origin: teiid/teiid
public Collection<KeyRecord> getAllKeys() {
Collection<KeyRecord> keys = new LinkedList<KeyRecord>();
if (getPrimaryKey() != null) {
keys.add(getPrimaryKey());
}
keys.addAll(getForeignKeys());
keys.addAll(getAccessPatterns());
keys.addAll(getIndexes());
keys.addAll(getUniqueKeys());
return keys;
}
代码示例来源:origin: teiid/teiid
private static void removeTableOption(String key, Table table) {
if (table.getProperty(key, false) != null) {
table.setProperty(key, null);
}
removeCommonProperty(key, table);
if (key.equals(DDLConstants.MATERIALIZED)) {
table.setMaterialized(false);
}
if (key.equals(DDLConstants.MATERIALIZED_TABLE)) {
table.setMaterializedTable(null);
}
if (key.equals(DDLConstants.UPDATABLE)) {
table.setSupportsUpdate(false);
}
if (key.equals(DDLConstants.CARDINALITY)) {
table.setCardinality(-1);
}
}
代码示例来源:origin: org.teiid/teiid-olingo
static KeyRecord getIdentifier(Table table) {
if (table.getPrimaryKey() != null) {
return table.getPrimaryKey();
}
for (KeyRecord key:table.getUniqueKeys()) {
return key;
}
return null;
}
代码示例来源:origin: org.teiid.connectors/translator-odata
private static String getEntityTypeName(Table t, boolean preserveEntityTypeName) {
String entityTypeName = t.getName();
if (preserveEntityTypeName && t.getProperty(ODataMetadataProcessor.ENTITY_TYPE, false) != null) {
entityTypeName = t.getProperty(ODataMetadataProcessor.ENTITY_TYPE, false);
}
return entityTypeName;
}
代码示例来源:origin: org.teiid/teiid-runtime
private Table createView(String name) {
Table t = addTable(name);
t.setSystem(true);
t.setSupportsUpdate(false);
t.setVirtual(true);
t.setTableType(Type.Table);
return t;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
private static void setTableOptions(Table table) {
Map<String, String> props = table.getProperties();
setCommonProperties(table, props);
String value = props.remove(DDLConstants.MATERIALIZED);
if (value != null) {
table.setMaterialized(isTrue(value));
}
value = props.remove(DDLConstants.MATERIALIZED_TABLE);
if (value != null) {
Table mattable = new Table();
mattable.setName(value);
table.setMaterializedTable(mattable);
}
value = props.remove(DDLConstants.UPDATABLE);
if (value != null) {
table.setSupportsUpdate(isTrue(value));
}
value = props.remove(DDLConstants.CARDINALITY);
if (value != null) {
table.setCardinality(Long.valueOf(value));
}
}
代码示例来源:origin: teiid/teiid
@Test
public void testConstraints() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date, " +
" PRIMARY KEY (e1, e2), INDEX(e2, e3), ACCESSPATTERN(e1), UNIQUE(e1)," +
" ACCESSPATTERN(e2, e3))";
Schema s = helpParse(ddl, "model").getSchema();
Map<String, Table> tableMap = s.getTables();
assertTrue("Table not found", tableMap.containsKey("G1"));
Table table = tableMap.get("G1");
assertEquals(table.getColumns().subList(0, 2), table.getPrimaryKey().getColumns());
assertEquals(table.getColumns().subList(1, 3), table.getIndexes().get(0).getColumns());
assertEquals(table.getColumns().subList(0, 1), table.getUniqueKeys().get(0).getColumns());
assertEquals(2, table.getAccessPatterns().size());
assertEquals(table.getColumns().subList(0, 1), table.getAccessPatterns().get(0).getColumns());
assertEquals(table.getColumns().subList(1, 3), table.getAccessPatterns().get(1).getColumns());
}
代码示例来源:origin: org.teiid/teiid-engine
public Collection<KeyRecord> getUniqueKeysInGroup(final Object groupID)
throws TeiidComponentException, QueryMetadataException {
Table tableRecordImpl = (Table)groupID;
ArrayList<KeyRecord> result = new ArrayList<KeyRecord>(tableRecordImpl.getUniqueKeys());
if (tableRecordImpl.getPrimaryKey() != null) {
result.add(tableRecordImpl.getPrimaryKey());
}
for (KeyRecord key : tableRecordImpl.getIndexes()) {
if (key.getType() == KeyRecord.Type.Unique) {
result.add(key);
}
}
return result;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
Column getColumn(String columnName, Table table) throws MetadataException {
Column c = table.getColumnByName(columnName);
if (c != null) {
return c;
}
throw new MetadataException(QueryPlugin.Util.getString("SQLParser.no_column", columnName, table.getName())); //$NON-NLS-1$
}
代码示例来源:origin: teiid/teiid
/**
* Create a physical group with default settings.
* @param name Name of physical group, must match model name
* @param model Associated model
* @return FakeMetadataObject Metadata object for group
*/
public static Table createPhysicalGroup(String name, Schema model, boolean fullyQualify) {
Table table = new Table();
table.setName(name);
model.addTable(table);
table.setSupportsUpdate(true);
table.setNameInSource((fullyQualify || name.lastIndexOf(".") == -1)? name : name.substring(name.lastIndexOf(".") + 1)); //$NON-NLS-1$ //$NON-NLS-2$
table.setTableType(org.teiid.metadata.Table.Type.Table);
return table;
}
代码示例来源:origin: teiid/teiid
@Test
public void testMultiKeyPK() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date, PRIMARY KEY (e1, e2))";
Schema s = helpParse(ddl, "model").getSchema();
Map<String, Table> tableMap = s.getTables();
assertTrue("Table not found", tableMap.containsKey("G1"));
Table table = tableMap.get("G1");
assertEquals(table.getColumns().subList(0, 2), table.getPrimaryKey().getColumns());
}
代码示例来源:origin: org.teiid.connectors/translator-odata4
static Table getComplexTableParentTable(RuntimeMetadata metadata, Table table) throws TranslatorException {
for (Column c : table.getColumns()) {
if (ODataMetadataProcessor.isPseudo(c)) {
ForeignKey fk = table.getForeignKeys().get(0);
String tableName = fk.getReferenceTableName();
if (tableName.indexOf('.') == -1) {
tableName = fk.getReferenceKey().getParent().getFullName();
}
return (Table)metadata.getTable(tableName);
}
}
return table;
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
/**
*
* @param metadataFactory
* @param tableCatalog
* @param tableSchema
* @param tableName
* @param remarks
* @param fullName
* @return
*/
protected Table addTable(MetadataFactory metadataFactory,
String tableCatalog, String tableSchema, String tableName,
String remarks, String fullName) {
Table table = metadataFactory.addTable(useFullSchemaName?fullName:tableName);
table.setNameInSource(getFullyQualifiedName(tableCatalog, tableSchema, tableName, true));
//create a fqn for the table
FullyQualifiedName fqn = new FullyQualifiedName();
if (tableCatalog != null && !tableCatalog.isEmpty()) {
fqn.append(getCatalogTerm(), tableCatalog);
}
if (tableSchema != null && !tableSchema.isEmpty()) {
fqn.append(getSchemaTerm(), tableSchema);
}
fqn.append(getTableTerm(), tableName);
table.setProperty(FQN, fqn.toString());
table.setSupportsUpdate(true);
table.setAnnotation(remarks);
return table;
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
@Override
public Object getPrimaryKey(Object metadataID) {
Table table = (Table)metadataID;
return table.getPrimaryKey();
}
代码示例来源:origin: org.teiid.connectors/translator-google
/**
* Adds new table to metadata.
*
* @param spreadsheet Name of the spreadsheet
* @param worksheet Name of the worksheet
* @throws TranslatorException
*/
private void addTable(MetadataFactory mf, Worksheet worksheet) {
if (worksheet.getColumnCount() == 0){
return;
}
Table table = mf.addTable(worksheet.getName());
table.setProperty(FQN, new FullyQualifiedName("worksheet", worksheet.getName()).toString()); //$NON-NLS-1$
table.setNameInSource(worksheet.getName());
if (worksheet.isHeaderEnabled()) {
table.setSupportsUpdate(true);
}
addColumnsToTable(mf, table, worksheet);
}
代码示例来源:origin: org.teiid.connectors/translator-mongodb
static boolean isPartOfForeignKey(Table table, String columnName) {
for (ForeignKey fk : table.getForeignKeys()) {
for (Column column : fk.getColumns()) {
if (column.getName().equals(columnName)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: teiid/teiid
@Test
public void testConstraints2() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date, " +
"ACCESSPATTERN(e1), UNIQUE(e1), ACCESSPATTERN(e2, e3))";
Schema s = helpParse(ddl, "model").getSchema();
Map<String, Table> tableMap = s.getTables();
assertTrue("Table not found", tableMap.containsKey("G1"));
Table table = tableMap.get("G1");
assertEquals(table.getColumns().subList(0, 1), table.getUniqueKeys().get(0).getColumns());
assertEquals(2, table.getAccessPatterns().size());
assertEquals(table.getColumns().subList(0, 1), table.getAccessPatterns().get(0).getColumns());
assertEquals(table.getColumns().subList(1, 3), table.getAccessPatterns().get(1).getColumns());
}
代码示例来源:origin: org.teiid.connectors/translator-odata
private boolean hasColumns(List<String> columnNames, Table table) {
for (String columnName:columnNames) {
if (table.getColumnByName(columnName) == null) {
return false;
}
}
return true;
}
代码示例来源:origin: org.teiid/teiid-engine
public Collection<Table> getXMLTempGroups(Table tableRecord) {
ArrayList<Table> results = new ArrayList<Table>();
String namePrefix = tableRecord.getName() + TransformationMetadata.DELIMITER_STRING;
for (Table table : tableRecord.getParent().getTables().values()) {
if (table.getTableType() == Type.XmlStagingTable && table.getName().startsWith(namePrefix)) {
results.add(table);
}
}
return results;
}
内容来源于网络,如有侵权,请联系作者删除!