use of org.teiid.cdk.api.TranslationUtility 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"));
}
Aggregations