Search in sources :

Example 81 with ModelMetaData

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);
}
Also used : ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 82 with ModelMetaData

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);
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 83 with ModelMetaData

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());
}
Also used : HashMap(java.util.HashMap) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 84 with ModelMetaData

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);
}
Also used : ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 85 with ModelMetaData

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());
}
Also used : HashMap(java.util.HashMap) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Aggregations

ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)191 Test (org.junit.Test)131 Properties (java.util.Properties)50 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)45 HardCodedExecutionFactory (org.teiid.runtime.HardCodedExecutionFactory)43 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)36 Connection (java.sql.Connection)23 MetadataFactory (org.teiid.metadata.MetadataFactory)21 Statement (java.sql.Statement)19 ResultSet (java.sql.ResultSet)18 CallableStatement (java.sql.CallableStatement)16 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)15 ArrayList (java.util.ArrayList)13 StringContentProvider (org.eclipse.jetty.client.util.StringContentProvider)11 SourceMappingMetadata (org.teiid.adminapi.impl.SourceMappingMetadata)11 Table (org.teiid.metadata.Table)11 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)11 List (java.util.List)9 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)9 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)9