Search in sources :

Example 81 with VDBMetaData

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

the class VDBStatusChecker method resourceAdded.

void resourceAdded(String resourceName) {
    List<Runnable> runnables = new ArrayList<Runnable>();
    for (CompositeVDB cvdb : getVDBRepository().getCompositeVDBs()) {
        VDBMetaData vdb = cvdb.getVDB();
        if (vdb.getStatus() == Status.FAILED) {
            continue;
        }
        resourceAdded(resourceName, runnables, vdb);
    }
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ArrayList(java.util.ArrayList)

Example 82 with VDBMetaData

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

the class VDBStatusChecker method dataSourceAdded.

public void dataSourceAdded(String dataSourceName, VDBKey vdbKey) {
    dataSourceName = stripContext(dataSourceName);
    if (vdbKey == null) {
        // scan all
        resourceAdded(dataSourceName);
    } else {
        CompositeVDB cvdb = getVDBRepository().getCompositeVDB(vdbKey);
        if (cvdb == null) {
            return;
        }
        VDBMetaData vdb = cvdb.getVDB();
        resourceAdded(dataSourceName, new LinkedList<Runnable>(), vdb);
    }
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData)

Example 83 with VDBMetaData

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

the class TestRestWebArchiveBuilder method getTestVDBMetaData.

private VDBMetaData getTestVDBMetaData() throws FileNotFoundException, XMLStreamException {
    VDBMetaData vdb = VDBMetadataParser.unmarshell(new FileInputStream(UnitTestUtil.getTestDataFile("sample-vdb.xml")));
    MetadataStore ms = new MetadataStore();
    for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
        MetadataFactory mf = TestDDLParser.helpParse(model.getSchemaText(), model.getName());
        ms.addSchema(mf.getSchema());
    }
    TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(ms, "Rest");
    vdb.addAttchment(QueryMetadataInterface.class, metadata);
    vdb.addAttchment(TransformationMetadata.class, metadata);
    vdb.addAttchment(MetadataStore.class, ms);
    return vdb;
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) FileInputStream(java.io.FileInputStream) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 84 with VDBMetaData

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

the class TestRestWebArchiveBuilder method testBuildArchiveSwagger.

@Test
public void testBuildArchiveSwagger() throws Exception {
    VDBMetaData vdb = getTestVDBMetaData();
    RestASMBasedWebArchiveBuilder builder = new RestASMBasedWebArchiveBuilder();
    MetadataStore metadataStore = vdb.getAttachment(TransformationMetadata.class).getMetadataStore();
    for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
        Schema schema = metadataStore.getSchema(model.getName());
        byte[] viewContents = builder.getViewClass(vdb.getName(), vdb.getVersion(), model.getName(), schema, false);
        if (viewContents != null) {
            Class<?> cls = ASMUtilities.defineClass("org.teiid.jboss.rest.View", viewContents);
            Set<Annotation> annotationSet = new HashSet<Annotation>();
            for (Annotation annotation : cls.getAnnotations()) {
                annotationSet.add(annotation);
            }
            assertEquals(2, annotationSet.size());
            for (Method m : cls.getMethods()) {
                if (m.getName().equals("g1Tableapplication_xml")) {
                    ApiOperation annotation = m.getAnnotation(ApiOperation.class);
                    assertEquals("g1Table", annotation.value());
                } else if (m.getName().equals("sqlQueryxml")) {
                    ApiOperation annotation = m.getAnnotation(ApiOperation.class);
                    assertEquals("xml", annotation.value());
                } else if (m.getName().equals("sqlQueryjson")) {
                    ApiOperation annotation = m.getAnnotation(ApiOperation.class);
                    assertEquals("json", annotation.value());
                }
            }
        }
    }
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Schema(org.teiid.metadata.Schema) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) MetadataStore(org.teiid.metadata.MetadataStore) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ApiOperation(io.swagger.annotations.ApiOperation) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 85 with VDBMetaData

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

the class TestRestWebArchiveBuilder method testBuildArchive.

@Test
public void testBuildArchive() throws Exception {
    VDBMetaData vdb = getTestVDBMetaData();
    RestASMBasedWebArchiveBuilder builder = new RestASMBasedWebArchiveBuilder();
    byte[] contents = builder.getContent(vdb);
    ArrayList<String> files = new ArrayList<String>();
    files.add("WEB-INF/web.xml");
    files.add("WEB-INF/jboss-web.xml");
    files.add("WEB-INF/classes/org/teiid/jboss/rest/View.class");
    files.add("WEB-INF/classes/org/teiid/jboss/rest/TeiidRestApplication.class");
    files.add("WEB-INF/classes/org/teiid/jboss/rest/Bootstrap.class");
    files.add("META-INF/MANIFEST.MF");
    files.add("api.html");
    files.add("images/teiid_logo_450px.png");
    files.add("swagger/swagger-ui.js");
    files.add("swagger/css/print.css");
    files.add("swagger/css/reset.css");
    files.add("swagger/css/screen.css");
    files.add("swagger/css/style.css");
    files.add("swagger/css/typography.css");
    files.add("swagger/images/favicon-16x16.png");
    files.add("swagger/images/favicon-32x32.png");
    files.add("swagger/lang/en.js");
    files.add("swagger/lang/es.js");
    files.add("swagger/lang/pt.js");
    files.add("swagger/lang/ru.js");
    files.add("swagger/lang/translator.js");
    files.add("swagger/lib/backbone-min.js");
    files.add("swagger/lib/handlebars-2.0.0.js");
    files.add("swagger/lib/highlight.7.3.pack.js");
    files.add("swagger/lib/jquery-1.8.0.min.js");
    files.add("swagger/lib/jquery.ba-bbq.min.js");
    files.add("swagger/lib/jquery.slideto.min.js");
    files.add("swagger/lib/jquery.wiggle.min.js");
    files.add("swagger/lib/marked.js");
    files.add("swagger/lib/swagger-oauth.js");
    files.add("swagger/lib/underscore-min.js");
    files.add("swagger/lib/underscore-min.map");
    ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(contents));
    ZipEntry ze;
    while ((ze = zipIn.getNextEntry()) != null) {
        assertTrue(files.contains(ze.getName()));
        zipIn.closeEntry();
    }
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ZipEntry(java.util.zip.ZipEntry) ArrayList(java.util.ArrayList) Test(org.junit.Test)

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