Search in sources :

Example 1 with MetadataValidator

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);
}
Also used : UDFSource(org.teiid.query.function.UDFSource) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FunctionTree(org.teiid.query.function.FunctionTree) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) TranslationUtility(org.teiid.cdk.api.TranslationUtility) MetadataValidator(org.teiid.query.metadata.MetadataValidator) ValidatorReport(org.teiid.query.validator.ValidatorReport) Before(org.junit.Before)

Example 2 with MetadataValidator

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;
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) EdmxFormatParser(org.odata4j.format.xml.EdmxFormatParser) FileReader(java.io.FileReader) MetadataValidator(org.teiid.query.metadata.MetadataValidator) ValidatorReport(org.teiid.query.validator.ValidatorReport) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 3 with MetadataValidator

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());
}
Also used : UDFSource(org.teiid.query.function.UDFSource) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FunctionTree(org.teiid.query.function.FunctionTree) InputStreamReader(java.io.InputStreamReader) EdmxFormatParser(org.odata4j.format.xml.EdmxFormatParser) Properties(java.util.Properties) ValidatorReport(org.teiid.query.validator.ValidatorReport) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) Procedure(org.teiid.metadata.Procedure) MetadataValidator(org.teiid.query.metadata.MetadataValidator) Test(org.junit.Test)

Example 4 with MetadataValidator

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);
}
Also used : UDFSource(org.teiid.query.function.UDFSource) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FunctionTree(org.teiid.query.function.FunctionTree) InputStreamReader(java.io.InputStreamReader) TranslationUtility(org.teiid.cdk.api.TranslationUtility) EdmxFormatParser(org.odata4j.format.xml.EdmxFormatParser) Properties(java.util.Properties) ValidatorReport(org.teiid.query.validator.ValidatorReport) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) EdmDataServices(org.odata4j.edm.EdmDataServices) MetadataValidator(org.teiid.query.metadata.MetadataValidator) Before(org.junit.Before)

Example 5 with MetadataValidator

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());
}
Also used : UDFSource(org.teiid.query.function.UDFSource) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FunctionTree(org.teiid.query.function.FunctionTree) Table(org.teiid.metadata.Table) InputStreamReader(java.io.InputStreamReader) TranslationUtility(org.teiid.cdk.api.TranslationUtility) EdmxFormatParser(org.odata4j.format.xml.EdmxFormatParser) Properties(java.util.Properties) RuntimeMetadata(org.teiid.metadata.RuntimeMetadata) ValidatorReport(org.teiid.query.validator.ValidatorReport) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) MetadataValidator(org.teiid.query.metadata.MetadataValidator) Test(org.junit.Test)

Aggregations

MetadataValidator (org.teiid.query.metadata.MetadataValidator)20 ValidatorReport (org.teiid.query.validator.ValidatorReport)20 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 MetadataFactory (org.teiid.metadata.MetadataFactory)12 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)12 FunctionTree (org.teiid.query.function.FunctionTree)10 UDFSource (org.teiid.query.function.UDFSource)10 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)8 Test (org.junit.Test)5 FileReader (java.io.FileReader)4 EdmxFormatParser (org.odata4j.format.xml.EdmxFormatParser)4 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)4 TranslationUtility (org.teiid.cdk.api.TranslationUtility)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStreamReader (java.io.InputStreamReader)3 Properties (java.util.Properties)3 Before (org.junit.Before)3 MetadataException (org.teiid.metadata.MetadataException)3 Table (org.teiid.metadata.Table)3 QueryParser (org.teiid.query.parser.QueryParser)3