Search in sources :

Example 66 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestTransformationMetadata method testAmbiguousTableWithPrivateModel.

@Test
public void testAmbiguousTableWithPrivateModel() throws Exception {
    Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
    Datatype dt = new Datatype();
    dt.setName(DataTypeManager.DefaultDataTypes.STRING);
    dt.setJavaClassName(String.class.getCanonicalName());
    datatypes.put(DataTypeManager.DefaultDataTypes.STRING, dt);
    // $NON-NLS-1$
    MetadataFactory mf = new MetadataFactory(null, 1, "x", datatypes, new Properties(), null);
    // $NON-NLS-1$
    mf.addTable("y");
    // $NON-NLS-1$
    MetadataFactory mf1 = new MetadataFactory(null, 1, "x1", datatypes, new Properties(), null);
    // $NON-NLS-1$
    mf1.addTable("y");
    CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.asMetadataStore(), mf1.asMetadataStore()));
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("foo");
    vdb.setVersion(1);
    ModelMetaData model = new ModelMetaData();
    model.setName("x1");
    vdb.addModel(model);
    ModelMetaData model2 = new ModelMetaData();
    model2.setName("x");
    model2.setVisible(true);
    vdb.addModel(model2);
    TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, RealMetadataFactory.SFM.getSystemFunctions(), null);
    // $NON-NLS-1$
    Collection result = tm.getGroupsForPartialName("y");
    assertEquals(2, result.size());
    RealMetadataFactory.buildWorkContext(tm, vdb);
    model.setVisible(false);
    tm = new TransformationMetadata(vdb, cms, null, RealMetadataFactory.SFM.getSystemFunctions(), null);
    // $NON-NLS-1$
    result = tm.getGroupsForPartialName("y");
    assertEquals(1, result.size());
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) HashMap(java.util.HashMap) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Collection(java.util.Collection) Properties(java.util.Properties) Datatype(org.teiid.metadata.Datatype) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 67 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestTransformationMetadata method exampleTransformationMetadata.

private TransformationMetadata exampleTransformationMetadata() throws TranslatorException {
    Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
    Datatype dt = new Datatype();
    dt.setName(DataTypeManager.DefaultDataTypes.STRING);
    dt.setJavaClassName(String.class.getCanonicalName());
    datatypes.put(DataTypeManager.DefaultDataTypes.STRING, dt);
    // $NON-NLS-1$
    MetadataFactory mf = new MetadataFactory(null, 1, "x", datatypes, new Properties(), null);
    // $NON-NLS-1$
    mf.addProcedure("y");
    Table t = mf.addTable("foo");
    mf.addColumn("col", DataTypeManager.DefaultDataTypes.STRING, t);
    // $NON-NLS-1$
    MetadataFactory mf1 = new MetadataFactory(null, 1, "x1", datatypes, new Properties(), null);
    // $NON-NLS-1$
    mf1.addProcedure("y");
    Table table = mf1.addTable("doc");
    table.setSchemaPaths(Arrays.asList("../../x.xsd"));
    table.setResourcePath("/a/b/doc.xmi");
    HashMap<String, VDBResources.Resource> resources = new HashMap<String, VDBResources.Resource>();
    resources.put("/x.xsd", new VDBResources.Resource(VFS.getRootVirtualFile()));
    CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.asMetadataStore(), mf1.asMetadataStore()));
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("vdb");
    vdb.setVersion(1);
    vdb.addModel(buildModel("x"));
    vdb.addModel(buildModel("x1"));
    vdb.addModel(buildModel("y"));
    return new TransformationMetadata(vdb, cms, resources, RealMetadataFactory.SFM.getSystemFunctions(), null);
}
Also used : Table(org.teiid.metadata.Table) HashMap(java.util.HashMap) Properties(java.util.Properties) Datatype(org.teiid.metadata.Datatype) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData)

Example 68 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class EvaluatorIterator method createTransformationMetadata.

public static TransformationMetadata createTransformationMetadata(String ddl) {
    MetadataStore mds = new MetadataStore();
    MetadataFactory mf = new MetadataFactory("vdb", 1, IMPLICIT_MODEL_NAME, SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    QueryParser.getQueryParser().parseDDL(mf, ddl);
    mf.mergeInto(mds);
    CompositeMetadataStore store = new CompositeMetadataStore(mds);
    VDBMetaData vdbMetaData = new VDBMetaData();
    // $NON-NLS-1$
    vdbMetaData.setName("vdb");
    vdbMetaData.setVersion(1);
    List<FunctionTree> udfs = new ArrayList<FunctionTree>();
    for (Schema schema : store.getSchemas().values()) {
        vdbMetaData.addModel(createModel(schema.getName(), schema.isPhysical()));
    }
    TransformationMetadata metadata = new TransformationMetadata(vdbMetaData, store, null, SFM.getSystemFunctions(), udfs);
    vdbMetaData.addAttchment(TransformationMetadata.class, metadata);
    vdbMetaData.addAttchment(QueryMetadataInterface.class, metadata);
    return metadata;
}
Also used : CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) FunctionTree(org.teiid.query.function.FunctionTree) MetadataFactory(org.teiid.metadata.MetadataFactory) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Schema(org.teiid.metadata.Schema) ArrayList(java.util.ArrayList) Properties(java.util.Properties)

Example 69 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class RealMetadataFactory method exampleBQTVDB.

public static VDBMetaData exampleBQTVDB() {
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("example1");
    vdb.setVersion(1);
    vdb.addModel(RealMetadataFactory.createModel("BQT1", true));
    vdb.addModel(RealMetadataFactory.createModel("BQT2", true));
    vdb.addModel(RealMetadataFactory.createModel("BQT3", true));
    vdb.addModel(RealMetadataFactory.createModel("LOB", true));
    vdb.addModel(RealMetadataFactory.createModel("VQT", false));
    vdb.addModel(RealMetadataFactory.createModel("pm1", true));
    vdb.addModel(RealMetadataFactory.createModel("pm2", true));
    vdb.addModel(RealMetadataFactory.createModel("pm3", true));
    vdb.addModel(RealMetadataFactory.createModel("pm4", true));
    return vdb;
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData)

Example 70 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class RealMetadataFactory method example1VDB.

public static VDBMetaData example1VDB() {
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("example1");
    vdb.setVersion(1);
    vdb.addModel(RealMetadataFactory.createModel("pm1", true));
    vdb.addModel(RealMetadataFactory.createModel("pm2", true));
    vdb.addModel(RealMetadataFactory.createModel("pm3", true));
    vdb.addModel(RealMetadataFactory.createModel("pm4", true));
    vdb.addModel(RealMetadataFactory.createModel("pm5", true));
    vdb.addModel(RealMetadataFactory.createModel("pm6", true));
    vdb.addModel(RealMetadataFactory.createModel("vm1", false));
    vdb.addModel(RealMetadataFactory.createModel("vm2", false));
    vdb.addModel(RealMetadataFactory.createModel("tm1", false));
    return vdb;
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData)

Aggregations

VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)121 Test (org.junit.Test)48 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)36 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 MetadataStore (org.teiid.metadata.MetadataStore)15 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)14 VDBRepository (org.teiid.deployers.VDBRepository)12 ArrayList (java.util.ArrayList)10 IOException (java.io.IOException)9 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)9 Properties (java.util.Properties)8 XMLStreamException (javax.xml.stream.XMLStreamException)8 VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)8 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)7 TeiidComponentException (org.teiid.core.TeiidComponentException)7 VDBKey (org.teiid.vdb.runtime.VDBKey)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)6 Schema (org.teiid.metadata.Schema)6 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)5