Search in sources :

Example 36 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataMetadataProcessor method testNorthwind.

@Test
public void testNorthwind() throws Exception {
    String file = "northwind_v4.xml";
    String schema = "northwind";
    String schemaNamespace = "ODataWebExperimental.Northwind.Model";
    MetadataFactory mf = createMetadata(file, schema, schemaNamespace);
    String metadataDDL = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
    assertEquals(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind_v4.ddl")), metadataDDL);
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Test(org.junit.Test)

Example 37 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataMetadataProcessor method functionMetadata.

static MetadataFactory functionMetadata(String name, CsdlReturnType returnType, Object other) throws TranslatorException {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    CsdlFunction func = function(name, returnType);
    CsdlFunctionImport funcImport = new CsdlFunctionImport();
    funcImport.setFunction(new FullQualifiedName("namespace." + name));
    funcImport.setName(name);
    XMLMetadata metadata = buildXmlMetadata(funcImport, func, other);
    processor.getMetadata(mf, metadata);
    return mf;
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) FullQualifiedName(org.apache.olingo.commons.api.edm.FullQualifiedName) XMLMetadata(org.apache.olingo.client.api.edm.xml.XMLMetadata) ClientCsdlXMLMetadata(org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata) Properties(java.util.Properties)

Example 38 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataQueryExecution method testGeometry.

@Test
public void testGeometry() throws Exception {
    String query = "SELECT * FROM Airports_Location";
    String expectedURL = "Airports?$select=IcaoCode,Location";
    FileReader reader = new FileReader(UnitTestUtil.getTestDataFile("airport-locations.json"));
    MetadataFactory mf = TestODataMetadataProcessor.tripPinMetadata();
    ResultSetExecution execution = helpExecute(TestODataMetadataProcessor.tripPinMetadata(), query, ObjectConverterUtil.convertToString(reader), expectedURL);
    List<?> row = execution.next();
    assertEquals("187 Suffolk Ln.", row.get(2));
    assertEquals("xyz", row.get(0));
    GeometryInputSource gis = (GeometryInputSource) row.get(1);
    assertEquals("<gml:Point><gml:pos>-48.23456 20.12345</gml:pos></gml:Point>", ObjectConverterUtil.convertToString(gis.getGml()));
    assertEquals(4326, gis.getSrid().intValue());
    row = execution.next();
    assertEquals("gso", row.get(0));
    gis = (GeometryInputSource) row.get(1);
    assertEquals("<gml:Point><gml:pos>1.0 2.0</gml:pos></gml:Point>", ObjectConverterUtil.convertToString(gis.getGml()));
    assertNull(execution.next());
    reader.close();
}
Also used : ResultSetExecution(org.teiid.translator.ResultSetExecution) MetadataFactory(org.teiid.metadata.MetadataFactory) GeometryInputSource(org.teiid.GeometryInputSource) FileReader(java.io.FileReader) Test(org.junit.Test)

Example 39 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestODataQueryExecution method testActionReturnsComplexCollection.

@Test
public void testActionReturnsComplexCollection() throws Exception {
    String query = "exec invoke(1, 'foo')";
    String expectedURL = "invoke";
    String response = "{\"value\":[{\n" + "            \"street\":\"United States\",\n" + "            \"city\":\"Boise\",\n" + "            \"state\":\"ID\"\n" + "           }," + "           {" + "            \"street\":\"China\",\n" + "            \"city\":\"Newyork\",\n" + "            \"state\":\"NY\"\n" + "         }]}";
    CsdlComplexType complex = TestODataMetadataProcessor.complexType("Address");
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("namespace.Address");
    MetadataFactory mf = TestODataMetadataProcessor.actionMetadata("invoke", returnType, complex);
    ProcedureExecution excution = helpProcedureExecute(mf, query, response, expectedURL, 200);
    assertArrayEquals(new Object[] { "United States", "Boise", "ID" }, excution.next().toArray(new Object[3]));
    assertArrayEquals(new Object[] { "China", "Newyork", "NY" }, excution.next().toArray(new Object[3]));
    assertNull(excution.next());
}
Also used : MetadataFactory(org.teiid.metadata.MetadataFactory) ProcedureExecution(org.teiid.translator.ProcedureExecution) CsdlComplexType(org.apache.olingo.commons.api.edm.provider.CsdlComplexType) CsdlReturnType(org.apache.olingo.commons.api.edm.provider.CsdlReturnType) Test(org.junit.Test)

Example 40 with MetadataFactory

use of org.teiid.metadata.MetadataFactory in project teiid by teiid.

the class TestMetadataValidator method buildModel.

public static ModelMetaData buildModel(String modelName, boolean physical, VDBMetaData vdb, MetadataStore store, String ddl) throws Exception {
    ModelMetaData model = new ModelMetaData();
    model.setName(modelName);
    model.setModelType(physical ? Model.Type.PHYSICAL : Model.Type.VIRTUAL);
    vdb.addModel(model);
    DDLMetadataRepository repo = new DDLMetadataRepository();
    MetadataFactory mf = new MetadataFactory("myVDB", 1, modelName, TestDDLParser.getDataTypes(), new Properties(), ddl);
    mf.setParser(QueryParser.getQueryParser());
    mf.getSchema().setPhysical(physical);
    repo.loadMetadata(mf, null, null, ddl);
    mf.mergeInto(store);
    model.addAttchment(MetadataFactory.class, mf);
    return model;
}
Also used : MetadataFactory(org.teiid.metadata.MetadataFactory) Properties(java.util.Properties) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Aggregations

MetadataFactory (org.teiid.metadata.MetadataFactory)159 Test (org.junit.Test)116 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)91 Properties (java.util.Properties)74 Table (org.teiid.metadata.Table)59 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)35 Procedure (org.teiid.metadata.Procedure)30 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)21 Column (org.teiid.metadata.Column)20 Connection (java.sql.Connection)18 FunctionTree (org.teiid.query.function.FunctionTree)15 UDFSource (org.teiid.query.function.UDFSource)14 CouchbaseMetadataProcessor (org.teiid.translator.couchbase.CouchbaseMetadataProcessor)14 Dimension (org.teiid.translator.couchbase.CouchbaseMetadataProcessor.Dimension)14 CouchbaseProperties (org.teiid.translator.couchbase.CouchbaseProperties)14 TranslationUtility (org.teiid.cdk.api.TranslationUtility)13 ValidatorReport (org.teiid.query.validator.ValidatorReport)13 XMLMetadata (org.apache.olingo.client.api.edm.xml.XMLMetadata)12 ClientCsdlXMLMetadata (org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata)12 ForeignKey (org.teiid.metadata.ForeignKey)12