use of org.teiid.query.metadata.MetadataValidator in project teiid by teiid.
the class TestMongoDBQueryExecution method setUp.
@Before
public void setUp() throws Exception {
this.translator = new MongoDBExecutionFactory();
this.translator.setDatabaseVersion("2.6");
this.translator.start();
MetadataFactory mf = TestDDLParser.helpParse(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.ddl")), "northwind");
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "sakila", new FunctionTree("mongo", new UDFSource(translator.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
this.utility = new TranslationUtility(metadata);
}
use of org.teiid.query.metadata.MetadataValidator in project teiid by teiid.
the class TestDataEntitySchemaBuilder method getNorthwindMetadataFromODataXML.
static TransformationMetadata getNorthwindMetadataFromODataXML() throws Exception {
ModelMetaData model = new ModelMetaData();
model.setName("nw");
model.setModelType(Type.PHYSICAL);
MetadataFactory mf = new MetadataFactory("northwind", 1, SystemMetadata.getInstance().getRuntimeTypeMap(), model);
EdmDataServices edm = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new FileReader(UnitTestUtil.getTestDataFile("northwind.xml"))));
ODataMetadataProcessor metadataProcessor = new ODataMetadataProcessor();
// $NON-NLS-1$
PropertiesUtils.setBeanProperties(metadataProcessor, mf.getModelProperties(), "importer");
metadataProcessor.getMetadata(mf, edm);
String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
TransformationMetadata metadata = RealMetadataFactory.fromDDL(ddl, "northwind", "nw");
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
return metadata;
}
use of org.teiid.query.metadata.MetadataValidator in project teiid by teiid.
the class TestODataMetadataProcessor method testSchema.
@Test
public void testSchema() throws Exception {
translator = new ODataExecutionFactory();
translator.start();
String csdl = ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.xml"));
ODataMetadataProcessor processor = new ODataMetadataProcessor();
Properties props = new Properties();
props.setProperty("schemaNamespace", "ODataWeb.Northwind.Model");
props.setProperty("entityContainer", "NorthwindEntities");
MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
processor.getMetadata(mf, new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new InputStreamReader(new ByteArrayInputStream(csdl.getBytes())))));
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "northwind", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
MetadataFactory mf2 = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
QueryParser.getQueryParser().parseDDL(mf2, ddl);
Procedure p = mf.getSchema().getProcedure("executeVoid");
assertNotNull(p);
assertEquals(1, p.getParameters().size());
}
use of org.teiid.query.metadata.MetadataValidator in project teiid by teiid.
the class TestODataSQLVistor method setUp.
@Before
public void setUp() throws Exception {
translator = new ODataExecutionFactory();
translator.start();
String csdl = ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.xml"));
EdmDataServices eds = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new InputStreamReader(new ByteArrayInputStream(csdl.getBytes()))));
ODataMetadataProcessor processor = new ODataMetadataProcessor();
Properties props = new Properties();
props.setProperty("schemaNamespace", "ODataWeb.Northwind.Model");
props.setProperty("entityContainer", "NorthwindEntities");
MetadataFactory mf = new MetadataFactory("vdb", 1, "nw", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
processor.getMetadata(mf, eds);
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "northwind", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
// TransformationMetadata metadata = RealMetadataFactory.fromDDL(ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.ddl")), "northwind", "nw");
utility = new TranslationUtility(metadata);
}
use of org.teiid.query.metadata.MetadataValidator in project teiid by teiid.
the class TestSAPODataMetadataProcessor method testSchema.
@Test
public void testSchema() throws Exception {
translator = new SAPODataExecutionFactory();
translator.start();
String csdl = ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("sap-metadata.xml"));
SAPMetadataProcessor processor = new SAPMetadataProcessor();
Properties props = new Properties();
MetadataFactory mf = new MetadataFactory("vdb", 1, "flight", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null);
processor.getMetadata(mf, new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new InputStreamReader(new ByteArrayInputStream(csdl.getBytes())))));
TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "flight", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions())));
ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
// String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
//
// MetadataFactory mf2 = new MetadataFactory(null, 1, "flight", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
// QueryParser.getQueryParser().parseDDL(mf2, ddl);
TranslationUtility utility = new TranslationUtility(metadata);
RuntimeMetadata rm = utility.createRuntimeMetadata();
Table t = rm.getTable("flight", "SubscriptionCollection");
assertNotNull(t);
// check the label name
assertNotNull(t.getColumnByName("persistNotifications"));
assertTrue(!t.getColumnByName("ID").isUpdatable());
assertEquals("Persist Notification", t.getColumnByName("persistNotifications").getAnnotation());
// check filterable
assertEquals(SearchType.Unsearchable, t.getColumnByName("persistNotifications").getSearchType());
// check sortable
assertEquals(SearchType.Unsearchable, t.getColumnByName("filter").getSearchType());
// check visible
assertEquals(false, t.getColumnByName("filter").isSelectable());
// check required-in-filter
assertEquals(1, t.getAccessPatterns().size());
assertEquals(2, t.getAccessPatterns().get(0).getColumns().size());
}
Aggregations