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