本文整理了Java中org.teiid.metadata.Table.getPrimaryKey()
方法的一些代码示例,展示了Table.getPrimaryKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getPrimaryKey()
方法的具体详情如下:
包路径:org.teiid.metadata.Table
类名称:Table
方法名:getPrimaryKey
暂无
代码示例来源:origin: teiid/teiid
@Override
public Object getPrimaryKey(Object metadataID) {
Table table = (Table)metadataID;
return table.getPrimaryKey();
}
代码示例来源:origin: org.teiid/teiid-engine
@Override
public Object getPrimaryKey(Object metadataID) {
Table table = (Table)metadataID;
return table.getPrimaryKey();
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
@Override
public Object getPrimaryKey(Object metadataID) {
Table table = (Table)metadataID;
return table.getPrimaryKey();
}
代码示例来源: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-mongodb
boolean hasCompositePrimaryKey(Table table) {
KeyRecord pk = table.getPrimaryKey();
return pk.getColumns().size() > 1;
}
代码示例来源: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: 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: org.teiid.connectors/translator-odata4
KeyRecord getPKorUnique(Table table) {
KeyRecord pk = table.getPrimaryKey();
if (pk == null && !table.getUniqueKeys().isEmpty()) {
pk = table.getUniqueKeys().get(0);
}
return pk;
}
代码示例来源:origin: org.teiid.connectors/translator-mongodb
static boolean isPartOfPrimaryKey(Table table, String columnName) {
KeyRecord pk = table.getPrimaryKey();
if (pk != null) {
for (Column column:pk.getColumns()) {
if (getRecordName(column).equals(columnName)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: org.teiid.connectors/translator-mongodb
public boolean isPartOfPrimaryKey(String columnName) {
KeyRecord pk = this.table.getPrimaryKey();
if (pk != null) {
for (Column column:pk.getColumns()) {
if (column.getName().equals(columnName)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: org.teiid.connectors/translator-odata
private boolean matchesWithPkOrUnique(List<String> names, Table table) {
if (keyMatches(names, table.getPrimaryKey())) {
return true;
}
for (KeyRecord record:table.getUniqueKeys()) {
if (keyMatches(names, record)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.teiid.connectors/translator-odata
static boolean isPartOfPrimaryKey(Table table, String columnName) {
KeyRecord pk = table.getPrimaryKey();
if (hasColumn(pk, columnName)) {
return true;
}
for (KeyRecord key:table.getUniqueKeys()) {
if (hasColumn(key, columnName)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.teiid.connectors/translator-odata
private boolean isJoinOrPkColumn(Column column) {
boolean joinColumn = Boolean.valueOf(column.getProperty(ODataMetadataProcessor.JOIN_COLUMN, false));
if (!joinColumn) {
Table table = (Table)column.getParent();
return (table.getPrimaryKey().getColumnByName(column.getName()) != null);
}
return false;
}
代码示例来源:origin: org.teiid/teiid-olingo
static boolean isPartOfPrimaryKey(Table table, String columnName) {
KeyRecord pk = table.getPrimaryKey();
if (hasColumn(pk, columnName)) {
return true;
}
for (KeyRecord key:table.getUniqueKeys()) {
if (hasColumn(key, columnName)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.teiid/teiid-engine
final public AbstractMetadataRecord primaryKey(MetadataFactory factory, Table table, String name) throws ParseException {
List<String> columnNames = null;
Column column = null;
KeyRecord key = null;
jj_consume_token(PRIMARY);
jj_consume_token(KEY);
columnNames = columnList(true, false);
if (table.getPrimaryKey() != null){
{if (true) throw new MetadataException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));}
}
{if (true) return factory.addPrimaryKey(name!=null?name:"PK", columnNames, table);}
throw new Error("Missing return statement in function");
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
final public AbstractMetadataRecord primaryKey(MetadataFactory factory, Table table, String name) throws ParseException {
List<String> columnNames = null;
Column column = null;
KeyRecord key = null;
jj_consume_token(PRIMARY);
jj_consume_token(KEY);
columnNames = columnList(true, false);
if (table.getPrimaryKey() != null){
{if (true) throw new MetadataException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));}
}
{if (true) return factory.addPrimaryKey(name!=null?name:"PK", columnNames, table);}
throw new Error("Missing return statement in function");
}
代码示例来源:origin: org.teiid.connectors/translator-odata4
private boolean isJoinOrPkColumn(Column column) {
Table table = (Table)column.getParent();
boolean isKey = (table.getPrimaryKey().getColumnByName(column.getName()) != null);
if (!isKey) {
for(ForeignKey fk:table.getForeignKeys()) {
if (fk.getColumnByName(column.getName()) != null) {
isKey = true;
}
}
}
return isKey;
}
}
代码示例来源:origin: teiid/teiid
@Test
public void testAlterAddPK() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date); ALTER TABLE G1 ADD 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: 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: teiid/teiid
@Test
public void testEmptyKey() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));";
buildModel("pm1", true, this.vdb, this.store, ddl);
buildTransformationMetadata();
this.store.getSchema("pm1").getTable("G1").getPrimaryKey().getColumns().clear();
ValidatorReport report = new ValidatorReport();
report = new MetadataValidator().validate(this.vdb, this.store);
assertTrue(printError(report), report.hasItems());
}
内容来源于网络,如有侵权,请联系作者删除!