Search in sources :

Example 76 with TranslationUtility

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

Aggregations

TranslationUtility (org.teiid.cdk.api.TranslationUtility)76 Command (org.teiid.language.Command)52 Test (org.junit.Test)45 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)35 ExecutionContext (org.teiid.translator.ExecutionContext)33 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)26 SimpleDBSQLVisitor (org.teiid.translator.simpledb.SimpleDBSQLVisitor)14 MetadataFactory (org.teiid.metadata.MetadataFactory)13 FunctionTree (org.teiid.query.function.FunctionTree)11 UDFSource (org.teiid.query.function.UDFSource)11 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)11 Before (org.junit.Before)10 LdapContext (javax.naming.ldap.LdapContext)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 SimpleDBExecutionFactory (org.teiid.translator.simpledb.SimpleDBExecutionFactory)8 List (java.util.List)7 ResultSetExecution (org.teiid.translator.ResultSetExecution)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 DataSource (javax.activation.DataSource)6 WSConnection (org.teiid.translator.WSConnection)6