use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class TestODBCSchema method testTypes.
@Test
public void testTypes() throws Exception {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("x");
mmd.setModelType(Type.VIRTUAL);
mmd.addSourceMetadata("ddl", "create view v as select null, cast(null as xml), cast(null as boolean), cast(null as byte), cast(null as short), cast(null as integer), cast(null as long)," + " cast(null as float), cast(null as double), cast(null as bigdecimal), cast(null as biginteger), cast(null as time), cast(null as date), cast(null as timestamp), cast(null as varbinary), " + " cast(null as char), cast(null as string), cast(null as clob), cast(null as blob), " + " cast(null as xml[]), cast(null as boolean[]), cast(null as byte[]), cast(null as short[]), cast(null as integer[]), cast(null as long[]), cast(null as bigdecimal[]), cast(null as biginteger[]), " + " cast(null as float[]), cast(null as double[]), cast(null as time[]), cast(null as date[]), cast(null as timestamp[]), cast(null as varbinary[]), " + " cast(null as char[]), cast(null as string[]), cast(null as clob[]), cast(null as blob[])");
server.deployVDB("x", mmd);
this.internalConnection.close();
// $NON-NLS-1$ //$NON-NLS-2$
this.internalConnection = server.createConnection("jdbc:teiid:x");
// $NON-NLS-1$
execute("select count(oid) = count(distinct oid) from pg_attribute");
this.internalResultSet.next();
assertTrue(this.internalResultSet.getBoolean(1));
// $NON-NLS-1$
execute("select oid from pg_class where relname = 'v'");
this.internalResultSet.next();
int val = this.internalResultSet.getInt(1);
String sql = "select n.nspname, c.relname, a.attname, a.atttypid, t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), case t.typtype when 'd' then t.typbasetype else 0 end, t.typtypmod, c.relhasoids " + "from (((pg_catalog.pg_class c inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace and " + "c.oid = ?) inner join pg_catalog.pg_attribute a on (not a.attisdropped) and a.attnum > 0 and a.attrelid = c.oid) inner join pg_catalog.pg_type t on t.oid = a.atttypid) left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum order by n.nspname, c.relname, attnum";
execute(sql, new Object[] { val });
TestMMDatabaseMetaData.compareResultSet(this.internalResultSet);
}
use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class TestReplication method deployTtlVDB.
private void deployTtlVDB(FakeServer server) throws ConnectorManagerException, VirtualDatabaseException, TranslatorException {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("mv");
mmd.setModelType(Type.VIRTUAL);
mmd.addSourceMetadata("ddl", "create view c options (materialized true) as /*+ cache(ttl:1000) */ select 'hello world'");
VDBMetaData vdb = new VDBMetaData();
vdb.setXmlDeployment(true);
vdb.setName("ttl");
vdb.setModels(Arrays.asList(mmd));
vdb.addProperty("lazy-invalidate", "true");
server.deployVDB(vdb);
}
use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class TestMetadataFactory method testDuplicateTables.
@Test
public void testDuplicateTables() {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("foo");
mmd.addProperty("importer.renameDuplicateTables", "true");
HashMap<String, Datatype> types = new HashMap<String, Datatype>();
Datatype value = new Datatype();
value.setName("string");
types.put("string", value);
MetadataFactory factory = new MetadataFactory("x", 1, types, mmd);
Table x = factory.addTable("x");
assertEquals("x", x.getName());
Table x1 = factory.addTable("X");
assertEquals("X_1", x1.getName());
Table x2 = factory.addTable("X");
assertEquals("X_2", x2.getName());
}
use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class TestMetadataFactory method testSchemaProperties.
@Test
public void testSchemaProperties() {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("foo");
mmd.addProperty("teiid_rel:data-ttl", "1");
MetadataFactory mf = new MetadataFactory("x", 1, Collections.EMPTY_MAP, mmd);
Schema s = mf.getSchema();
assertEquals("foo", s.getName());
String val = s.getProperty(DataModifiable.DATA_TTL, false);
assertEquals("1", val);
}
use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class TestMetadataFactory method testDuplicateProcedure.
@Test
public void testDuplicateProcedure() {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("foo");
mmd.addProperty("importer.renameAllDuplicates", "true");
HashMap<String, Datatype> types = new HashMap<String, Datatype>();
Datatype value = new Datatype();
value.setName("string");
types.put("string", value);
MetadataFactory factory = new MetadataFactory("x", 1, types, mmd);
Procedure x = factory.addProcedure("x");
assertEquals("x", x.getName());
Procedure x1 = factory.addProcedure("X");
assertEquals("X_1", x1.getName());
Procedure x2 = factory.addProcedure("X");
assertEquals("X_2", x2.getName());
}
Aggregations