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);
}
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;
}
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();
}
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());
}
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;
}
Aggregations