use of org.teiid.metadata.Table in project teiid by teiid.
the class TestODataMetadataProcessor method testMultikeyPK.
@Test
public void testMultikeyPK() throws Exception {
MetadataFactory mf = multiplePKMetadata();
Table g1 = mf.getSchema().getTable("G1");
assertNotNull(g1.getPrimaryKey().getColumnByName("e1"));
assertNotNull(g1.getPrimaryKey().getColumnByName("e2"));
assertNull(g1.getPrimaryKey().getColumnByName("e3"));
}
use of org.teiid.metadata.Table in project teiid by teiid.
the class TestODataMetadataProcessor method testMultipleNavigationProperties.
@Test
public void testMultipleNavigationProperties() throws Exception {
MetadataFactory mf = multipleNavigationProperties();
String metadataDDL = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
Table g1 = mf.getSchema().getTable("G1");
Table g2 = mf.getSchema().getTable("G2");
ForeignKey fk = g2.getForeignKeys().get(0);
assertEquals("G1_one_2_many", fk.getName());
assertNotNull(fk.getColumnByName("e1"));
}
use of org.teiid.metadata.Table in project teiid by teiid.
the class TestODataMetadataProcessor method testMultipleEnititySetWithSameComplexType.
@Test
public void testMultipleEnititySetWithSameComplexType() throws Exception {
ODataMetadataProcessor processor = new ODataMetadataProcessor();
MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
CsdlComplexType address = complexType("Address");
XMLMetadata metadata = buildXmlMetadata(createES("Persons", "namespace.Person"), buildPersonEntity(address), address, createES("Corporate", "namespace.Business"), buildBusinessEntity(address));
processor.getMetadata(mf, metadata);
assertEquals(5, mf.getSchema().getTables().size());
assertNotNull(mf.getSchema().getTable("Persons"));
assertNotNull(mf.getSchema().getTable("Corporate"));
assertNotNull(mf.getSchema().getTable("Persons_address"));
assertNotNull(mf.getSchema().getTable("Corporate_address"));
Table personTable = mf.getSchema().getTable("Persons");
assertEquals(2, personTable.getColumns().size());
Table personAddress = mf.getSchema().getTable("Persons_address");
assertEquals(4, personAddress.getColumns().size());
ForeignKey fk = personAddress.getForeignKeys().get(0);
assertNotNull(fk.getColumnByName("Persons_ssn"));
Table businessTable = mf.getSchema().getTable("Corporate");
assertEquals(1, businessTable.getColumns().size());
Table corporateAddress = mf.getSchema().getTable("Corporate_address");
assertEquals(4, corporateAddress.getColumns().size());
fk = corporateAddress.getForeignKeys().get(0);
assertNotNull(fk.getColumnByName("Corporate_name"));
}
use of org.teiid.metadata.Table in project teiid by teiid.
the class ODataUpdateExecution method addAutoGeneretedKeys.
private void addAutoGeneretedKeys() {
OEntity entity = this.response.getResultsIter().next().getEntity();
Table table = this.visitor.getEnityTable();
int cols = table.getPrimaryKey().getColumns().size();
Class<?>[] columnDataTypes = new Class<?>[cols];
String[] columnNames = new String[cols];
// this is typically expected to be an int/long, but we'll be general here. we may eventual need the type logic off of the metadata importer
for (int i = 0; i < cols; i++) {
columnDataTypes[i] = table.getPrimaryKey().getColumns().get(i).getJavaType();
columnNames[i] = table.getPrimaryKey().getColumns().get(i).getName();
}
GeneratedKeys generatedKeys = this.executionContext.getCommandContext().returnGeneratedKeys(columnNames, columnDataTypes);
List<Object> vals = new ArrayList<Object>(columnDataTypes.length);
for (int i = 0; i < columnDataTypes.length; i++) {
OProperty<?> prop = entity.getProperty(columnNames[i]);
Object value = this.translator.retrieveValue(prop.getValue(), columnDataTypes[i]);
vals.add(value);
}
generatedKeys.addKey(vals);
}
use of org.teiid.metadata.Table in project teiid by teiid.
the class SAPMetadataProcessor method addEntitySetAsTable.
@Override
protected Table addEntitySetAsTable(MetadataFactory mf, EdmEntitySet entitySet) throws TranslatorException {
Table table = super.addEntitySetAsTable(mf, entitySet);
KeyRecord accessPattern = this.accessPatterns.get(table);
if (accessPattern != null) {
table.getAccessPatterns().add(accessPattern);
}
return table;
}
Aggregations