Search in sources :

Example 56 with MetadataStore

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

the class TestValidator method exampleMetadata1.

public TransformationMetadata exampleMetadata1() {
    MetadataStore metadataStore = new MetadataStore();
    // Create metadata objects
    // $NON-NLS-1$
    Schema modelObj = RealMetadataFactory.createPhysicalModel("test", metadataStore);
    // $NON-NLS-1$
    Table groupObj = RealMetadataFactory.createPhysicalGroup("group", modelObj);
    // $NON-NLS-1$
    Column elemObj0 = RealMetadataFactory.createElement("e0", groupObj, DataTypeManager.DefaultDataTypes.INTEGER);
    // $NON-NLS-1$
    Column elemObj1 = RealMetadataFactory.createElement("e1", groupObj, DataTypeManager.DefaultDataTypes.STRING);
    // $NON-NLS-1$
    Column elemObj2 = RealMetadataFactory.createElement("e2", groupObj, DataTypeManager.DefaultDataTypes.STRING);
    // $NON-NLS-1$
    RealMetadataFactory.createElement("e3", groupObj, DataTypeManager.DefaultDataTypes.STRING);
    elemObj0.setNullType(NullType.No_Nulls);
    elemObj1.setNullType(NullType.Nullable);
    elemObj1.setDefaultValue(Boolean.TRUE.toString());
    elemObj2.setNullType(NullType.Nullable);
    elemObj2.setDefaultValue(Boolean.FALSE.toString());
    return RealMetadataFactory.createTransformationMetadata(metadataStore, "example1");
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) Schema(org.teiid.metadata.Schema)

Example 57 with MetadataStore

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

the class TestValidator method exampleMetadata2.

/**
 * Group has element with type object
 * @return QueryMetadataInterface
 */
public static TransformationMetadata exampleMetadata2() {
    MetadataStore metadataStore = new MetadataStore();
    // Create metadata objects
    // $NON-NLS-1$
    Schema modelObj = RealMetadataFactory.createPhysicalModel("test", metadataStore);
    // $NON-NLS-1$
    Table groupObj = RealMetadataFactory.createPhysicalGroup("group", modelObj);
    RealMetadataFactory.createElements(groupObj, new String[] { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "e0", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "e1", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "e2", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "e3", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "e4", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
    "e5" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.OBJECT, DataTypeManager.DefaultDataTypes.BLOB, DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.XML });
    return RealMetadataFactory.createTransformationMetadata(metadataStore, "example2");
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) Table(org.teiid.metadata.Table) Schema(org.teiid.metadata.Schema)

Example 58 with MetadataStore

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

the class TestResteasyEnabler method testOtherModels.

@Test
public void testOtherModels() throws VirtualDatabaseException {
    RestWarGenerator generator = Mockito.mock(RestWarGenerator.class);
    ResteasyEnabler resteasyEnabler = new ResteasyEnabler(generator) {

        Admin getAdmin() {
            return Mockito.mock(Admin.class);
        }

        Executor getExecutor() {
            return ExecutorUtils.getDirectExecutor();
        }
    };
    MetadataStore ms = new MetadataStore();
    CompositeVDB vdb = TestCompositeVDB.createCompositeVDB(ms, "x");
    vdb.getVDB().addProperty("{http://teiid.org/rest}auto-generate", "true");
    ModelMetaData model = new ModelMetaData();
    model.setName("other");
    model.setModelType(Type.OTHER);
    vdb.getVDB().addModel(model);
    resteasyEnabler.finishedDeployment("x", vdb);
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TestCompositeVDB(org.teiid.deployers.TestCompositeVDB) CompositeVDB(org.teiid.deployers.CompositeVDB) RestWarGenerator(org.teiid.deployers.RestWarGenerator) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 59 with MetadataStore

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

the class FakeTranslationFactory method getYahooTranslationUtility.

public TranslationUtility getYahooTranslationUtility() {
    MetadataStore metadataStore = new MetadataStore();
    // Create models
    // $NON-NLS-1$
    Schema yahoo = RealMetadataFactory.createPhysicalModel("Yahoo", metadataStore);
    // Create physical groups
    // $NON-NLS-1$
    Table quotes = RealMetadataFactory.createPhysicalGroup("Yahoo.QuoteServer", yahoo);
    // Create physical elements
    String[] elemNames = new String[] { // $NON-NLS-1$ //$NON-NLS-2$
    "TickerSymbol", // $NON-NLS-1$ //$NON-NLS-2$
    "LastTrade", // $NON-NLS-1$ //$NON-NLS-2$
    "LastTradeDate", // $NON-NLS-1$ //$NON-NLS-2$
    "LastTradeTime", // $NON-NLS-1$ //$NON-NLS-2$
    "PercentageChange", // $NON-NLS-1$ //$NON-NLS-2$
    "TickerSymbol2", // $NON-NLS-1$ //$NON-NLS-2$
    "DaysHigh", // $NON-NLS-1$ //$NON-NLS-2$
    "DaysLow", // $NON-NLS-1$
    "TotalVolume" };
    String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BIG_INTEGER };
    List<Column> cols = RealMetadataFactory.createElements(quotes, elemNames, elemTypes);
    // Set name in source on each column
    String[] nameInSource = new String[] { "Symbol", "Last", "Date", "Time", "Change", "Symbol2", "High", "Low", "Volume" };
    for (int i = 0; i < nameInSource.length; i++) {
        cols.get(i).setNameInSource(nameInSource[i]);
    }
    // Set column-specific properties
    cols.get(0).setSelectable(false);
    cols.get(0).setSearchType(SearchType.Unsearchable);
    return new TranslationUtility(RealMetadataFactory.createTransformationMetadata(metadataStore, "yahoo"));
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) Schema(org.teiid.metadata.Schema) TranslationUtility(org.teiid.cdk.api.TranslationUtility)

Example 60 with MetadataStore

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

the class VDBRepository method finishDeployment.

public void finishDeployment(String name, String version) {
    VDBKey key = new VDBKey(name, version);
    CompositeVDB v = this.vdbRepo.get(key);
    if (v == null) {
        return;
    }
    VDBMetaData metadataAwareVDB = v.getVDB();
    if (v.getOriginalVDB().getStatus() == Status.FAILED) {
        if (v.getOriginalVDB() != metadataAwareVDB && metadataAwareVDB.getStatus() == Status.LOADING) {
            metadataAwareVDB.setStatus(Status.FAILED);
        }
        return;
    }
    synchronized (metadataAwareVDB) {
        try {
            try {
                v.metadataLoadFinished(allowEnv);
            } catch (MetadataException e) {
                // $NON-NLS-1$
                LogManager.logWarning(LogConstants.CTX_RUNTIME, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version, e.getMessage()));
                if (!metadataAwareVDB.isPreview()) {
                    ValidatorReport report = new ValidatorReport();
                    report.addItem(new ValidatorFailure(e.getMessage()));
                    if (!processMetadataValidatorReport(key, report)) {
                        metadataAwareVDB.setStatus(Status.FAILED);
                        notifyFinished(name, version, v);
                        return;
                    }
                }
            }
            MetadataStore store = metadataAwareVDB.removeAttachment(MetadataStore.class);
            ValidatorReport report = new MetadataValidator(store.getDatatypes(), QueryParser.getQueryParser()).validate(metadataAwareVDB, store);
            if (report.hasItems()) {
                LogManager.logWarning(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version, report.getItems().iterator().next()));
                if (!metadataAwareVDB.isPreview() && !processMetadataValidatorReport(key, report)) {
                    metadataAwareVDB.setStatus(Status.FAILED);
                    notifyFinished(name, version, v);
                    return;
                }
            }
            validateDataSources(metadataAwareVDB);
            metadataAwareVDB.setStatus(Status.ACTIVE);
            // for  replication of events, temp tables and mat views
            GlobalTableStore gts = CompositeGlobalTableStore.createInstance(v, this.bufferManager, this.objectReplictor);
            metadataAwareVDB.addAttchment(GlobalTableStore.class, gts);
            if (this.databaseStore != null) {
                metadataAwareVDB.addAttchment(DatabaseStore.class, this.databaseStore);
            }
            notifyFinished(name, version, v);
        } finally {
            if (metadataAwareVDB.getStatus() != Status.ACTIVE && metadataAwareVDB.getStatus() != Status.FAILED) {
                // guard against an unexpected exception - probably bad validation logic
                metadataAwareVDB.setStatus(Status.FAILED);
                notifyFinished(name, version, v);
            }
        }
    }
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) VDBKey(org.teiid.vdb.runtime.VDBKey) ValidatorFailure(org.teiid.query.validator.ValidatorFailure) GlobalTableStore(org.teiid.query.tempdata.GlobalTableStore) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) FunctionMetadataValidator(org.teiid.query.function.metadata.FunctionMetadataValidator) MetadataValidator(org.teiid.query.metadata.MetadataValidator) MetadataException(org.teiid.metadata.MetadataException) ValidatorReport(org.teiid.query.validator.ValidatorReport)

Aggregations

MetadataStore (org.teiid.metadata.MetadataStore)73 Schema (org.teiid.metadata.Schema)47 Test (org.junit.Test)38 Table (org.teiid.metadata.Table)37 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)22 QueryNode (org.teiid.query.mapping.relational.QueryNode)19 Column (org.teiid.metadata.Column)17 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)15 Properties (java.util.Properties)12 MetadataFactory (org.teiid.metadata.MetadataFactory)12 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)12 Procedure (org.teiid.metadata.Procedure)11 List (java.util.List)9 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)9 Connection (java.sql.Connection)8 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)8 ArrayList (java.util.ArrayList)7 ProcedureParameter (org.teiid.metadata.ProcedureParameter)7 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)7 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)6