org.eobjects.metamodel
Class MetaModelHelper

java.lang.Object
  extended by org.eobjects.metamodel.MetaModelHelper

public final class MetaModelHelper
extends Object

This class contains various helper functionality to common tasks in MetaModel, eg.:

The class is mainly intended for internal use within the framework operations, but is kept stable, so it can also be used by framework users.


Method Summary
static SelectItem[] createSelectItems(Column... columns)
           
static Row executeSingleRowQuery(DataContext dataContext, Query query)
          Executes a single row query, like "SELECT COUNT(*), MAX(SOME_COLUMN) FROM MY_TABLE" or similar.
static DataSet getAggregated(List<SelectItem> workSelectItems, DataSet dataSet)
          Applies aggregate values to a dataset.
static DataSet getCarthesianProduct(DataSet... fromDataSets)
           
static DataSet getCarthesianProduct(DataSet[] fromDataSets, FilterItem... filterItems)
           
static DataSet getCarthesianProduct(DataSet[] fromDataSets, Iterable<FilterItem> whereItems)
           
static Column[] getColumnsBySuperType(Column[] columns, SuperColumnType superColumnType)
           
static Column[] getColumnsByType(Column[] columns, ColumnType columnType)
           
static DataSet getDistinct(DataSet dataSet)
           
static DataSet getFiltered(DataSet dataSet, FilterItem... filterItems)
           
static DataSet getFiltered(DataSet dataSet, Iterable<FilterItem> filterItems)
           
static List<SelectItem> getFunctionSelectItems(Iterable<SelectItem> selectItems)
           
static DataSet getGrouped(List<SelectItem> selectItems, DataSet dataSet, Collection<GroupByItem> groupByItems)
           
static DataSet getGrouped(List<SelectItem> selectItems, DataSet dataSet, GroupByItem[] groupByItems)
           
static DataSet getLeftJoin(DataSet ds1, DataSet ds2, FilterItem[] onConditions)
          Performs a left join (aka left outer join) operation on two datasets.
static DataSet getOrdered(DataSet dataSet, List<OrderByItem> orderByItems)
           
static DataSet getOrdered(DataSet dataSet, OrderByItem... orderByItems)
           
static DataSet getRightJoin(DataSet ds1, DataSet ds2, FilterItem[] onConditions)
          Performs a right join (aka right outer join) operation on two datasets.
static DataSet getSelection(List<SelectItem> selectItems, DataSet dataSet)
           
static DataSet getSelection(SelectItem[] selectItems, DataSet dataSet)
           
static Column[] getTableColumns(Table table, Column[] columns)
          Creates a subset array of columns, where only columns that are contained within the specified table are included.
static Column[] getTableColumns(Table table, Iterable<Column> columns)
          Creates a subset array of columns, where only columns that are contained within the specified table are included.
static List<FromItem> getTableFromItems(FromItem item)
           
static FromItem[] getTableFromItems(Query q)
          Examines a query and extracts an array of FromItem's that refer (directly) to tables (hence Joined FromItems and SubQuery FromItems are traversed but not included).
static Table[] getTables(Collection<Table> tableList, Iterable<Column> columnList)
          Creates an array of tables where all occurences of tables in the provided list of tables and columns are included
static Table[] getTables(Column[] columns)
           
static Table[] getTables(Iterable<Column> columns)
          Converts a list of columns to a corresponding array of tables
static boolean isInformationSchema(Schema schema)
          Determines if a schema is an information schema
static boolean isInformationSchema(String name)
          Determines if a schema name is the name of an information schema
static Query parseQuery(DataContext dc, String queryString)
           
static List<Row> readDataSetFull(DataSet dataSet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTables

public static Table[] getTables(Collection<Table> tableList,
                                Iterable<Column> columnList)
Creates an array of tables where all occurences of tables in the provided list of tables and columns are included


isInformationSchema

public static boolean isInformationSchema(Schema schema)
Determines if a schema is an information schema

Parameters:
schema -
Returns:

isInformationSchema

public static boolean isInformationSchema(String name)
Determines if a schema name is the name of an information schema

Parameters:
name -
Returns:

getTables

public static Table[] getTables(Iterable<Column> columns)
Converts a list of columns to a corresponding array of tables

Parameters:
columns - the columns that the tables will be extracted from
Returns:
an array containing the tables of the provided columns.

getTableColumns

public static Column[] getTableColumns(Table table,
                                       Iterable<Column> columns)
Creates a subset array of columns, where only columns that are contained within the specified table are included.

Parameters:
table -
columns -
Returns:
an array containing the columns that exist in the table

getTableColumns

public static Column[] getTableColumns(Table table,
                                       Column[] columns)
Creates a subset array of columns, where only columns that are contained within the specified table are included.

Parameters:
table -
columns -
Returns:
an array containing the columns that exist in the table

getCarthesianProduct

public static DataSet getCarthesianProduct(DataSet... fromDataSets)

getCarthesianProduct

public static DataSet getCarthesianProduct(DataSet[] fromDataSets,
                                           Iterable<FilterItem> whereItems)

getCarthesianProduct

public static DataSet getCarthesianProduct(DataSet[] fromDataSets,
                                           FilterItem... filterItems)

getFiltered

public static DataSet getFiltered(DataSet dataSet,
                                  Iterable<FilterItem> filterItems)

getFiltered

public static DataSet getFiltered(DataSet dataSet,
                                  FilterItem... filterItems)

getSelection

public static DataSet getSelection(List<SelectItem> selectItems,
                                   DataSet dataSet)

getSelection

public static DataSet getSelection(SelectItem[] selectItems,
                                   DataSet dataSet)

getGrouped

public static DataSet getGrouped(List<SelectItem> selectItems,
                                 DataSet dataSet,
                                 Collection<GroupByItem> groupByItems)

getGrouped

public static DataSet getGrouped(List<SelectItem> selectItems,
                                 DataSet dataSet,
                                 GroupByItem[] groupByItems)

getAggregated

public static DataSet getAggregated(List<SelectItem> workSelectItems,
                                    DataSet dataSet)
Applies aggregate values to a dataset. This method is to be invoked AFTER any filters have been applied.

Parameters:
workSelectItems - all select items included in the processing of the query (including those originating from other clauses than the SELECT clause).
dataSet -
Returns:

getFunctionSelectItems

public static List<SelectItem> getFunctionSelectItems(Iterable<SelectItem> selectItems)

getOrdered

public static DataSet getOrdered(DataSet dataSet,
                                 List<OrderByItem> orderByItems)

getOrdered

public static DataSet getOrdered(DataSet dataSet,
                                 OrderByItem... orderByItems)

readDataSetFull

public static List<Row> readDataSetFull(DataSet dataSet)

getTableFromItems

public static FromItem[] getTableFromItems(Query q)
Examines a query and extracts an array of FromItem's that refer (directly) to tables (hence Joined FromItems and SubQuery FromItems are traversed but not included).

Parameters:
q - the query to examine
Returns:
an array of FromItem's that refer directly to tables

getTableFromItems

public static List<FromItem> getTableFromItems(FromItem item)

executeSingleRowQuery

public static Row executeSingleRowQuery(DataContext dataContext,
                                        Query query)
                                 throws MetaModelException
Executes a single row query, like "SELECT COUNT(*), MAX(SOME_COLUMN) FROM MY_TABLE" or similar.

Parameters:
dataContext - the DataContext object to use for executing the query
query - the query to execute
Returns:
a row object representing the single row returned from the query
Throws:
MetaModelException - if less or more than one Row is returned from the query

getLeftJoin

public static DataSet getLeftJoin(DataSet ds1,
                                  DataSet ds2,
                                  FilterItem[] onConditions)
Performs a left join (aka left outer join) operation on two datasets.

Parameters:
ds1 - the left dataset
ds2 - the right dataset
onConditions - the conditions to join by
Returns:
the left joined result dataset

getRightJoin

public static DataSet getRightJoin(DataSet ds1,
                                   DataSet ds2,
                                   FilterItem[] onConditions)
Performs a right join (aka right outer join) operation on two datasets.

Parameters:
ds1 - the left dataset
ds2 - the right dataset
onConditions - the conditions to join by
Returns:
the right joined result dataset

createSelectItems

public static SelectItem[] createSelectItems(Column... columns)

getDistinct

public static DataSet getDistinct(DataSet dataSet)

getTables

public static Table[] getTables(Column[] columns)

getColumnsByType

public static Column[] getColumnsByType(Column[] columns,
                                        ColumnType columnType)

getColumnsBySuperType

public static Column[] getColumnsBySuperType(Column[] columns,
                                             SuperColumnType superColumnType)

parseQuery

public static Query parseQuery(DataContext dc,
                               String queryString)


Copyright © 2007-2013. All Rights Reserved.