Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.list.engine
Class ComposedQuery

    java.lang.Object
      org.makumba.list.engine.ComposedQuery

Direct Known Subclasses:
  ComposedSubquery

    public class ComposedQuery

extends Object

An OQL query composed from various elements found in script pages. It can be enriched when a new element is found. It has a prepared Qyuery correspondent in a makumba database It may be based on a super query.

Version:
  $Id: ComposedQuery.java 3527 2009-01-02 16:13:26Z rosso_nero $
Author:
  Cristian Bogdan

Nested Class Summary
`static interface` | `ComposedQuery.Evaluator` Interface for an Evaluator which can evaluate expressions

Field Summary
`(package private) String[]` | `derivedSections` Derived section texts, made from the sections of this query and the sections of its superqueries
`(package private) static Vector<Vector<Integer>>` | `empty` A Vector containing an empty vector.
`static int` | `FROM` Standard index for the FROM query section
`(package private) String` | `fromAnalyzerOQL`
`static int` | `GROUPBY` Standard index for the GROUPBY query section
`(package private) Vector<Integer>` | `keyset` The keyset defining the primary key for this query.
`(package private) Vector<String>` | `keysetLabels` The labels of the keyset
`static int` | `ORDERBY` Standard index for the ORDERBY query section
`(package private) Vector<Vector<Integer>>` | `previousKeyset` The keyset of all the parent queries
`(package private) Hashtable<String,Integer>` | `projectionExpr` The expression associated to each projection
`(package private) Vector<String>` | `projections` The projections made in this query
`QueryAnalysisProvider` | `qep`
`(package private) String[]` | `sections` Section texts, encoded with the standard indexes
`(package private) int` | `subqueries` The subqueries of this query
`(package private) String` | `typeAnalyzerOQL`
`static int` | `VARFROM` Standard index for the VARFROM query section
`static int` | `WHERE` Standard index for the WHERE query section

Constructor Summary
`ComposedQuery(String[] sections, String queryLanguage)` Default constructor

Method Summary
`(package private) Integer` | `addProjection(String expr)` Adds a projection with the given expression
`void` | `addProjectionDirectly(String s)` allows to directly set a projection.
`protected void` | `addSubquery(ComposedSubquery q)` Adds a subquery to this query.
`void` | `analyze()`
`(package private) String` | `checkExpr(String str)` Checks the orderBy or groupBy expressions to see if they are already selected, if not adds a projection.
`Object` | `checkExprSetOrNullable(String expr)`
`(package private) String` | `checkProjection(String expr)` Checks if a projection exists, and if not, adds it.
`Integer` | `checkProjectionInteger(String expr)` Checks if a projection exists, and if not, adds it.
`static String` | `columnName(Integer n)` Gets the name of a column indicated by index
`protected String` | `computeQuery(String[] derivedSections, boolean typeAnalysisOnly)` Computes the query from its sections
`Grouper` | `execute(QueryProvider qep, Map args, ComposedQuery.Evaluator v, int offset, int limit)` Executes the contained query in the given database
`Map<String,DataDefinition>` | `getFromLabelTypes()` Gets the types of the labels in the FROM section
`String` | `getFromSection()` Gets the FROM section
`String` | `getGroupBySection()` Gets the GROUP BY section
`DataDefinition` | `getLabelType(String s)` Gets the type of a given label
`String` | `getProjectionAt(int n)` Gets a given projection
`Vector<String>` | `getProjections()` Gets the projections of this query
`DataDefinition` | `getProjectionTypes()` Gets the type of the fields between SELECT and FROM
`DataDefinition` | `getResultType()` Gets the type of the result
`String` | `getTypeAnalyzerQuery()` Gets the query string.
`void` | `init()` Initializes the object.
`protected void` | `initKeysets()` Initializes the keysets. previousKeyset is "empty"
`protected void` | `prependFromToKeyset()` Adds all keys from the FROM section to the keyset, and their labels to the keyLabels.
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### qep

    public QueryAnalysisProvider qep

### subqueries

    int subqueries

  The subqueries of this query

### projections

    Vector<String> projections

  The projections made in this query

### projectionExpr

    Hashtable<String,Integer> projectionExpr

  The expression associated to each projection

### FROM

    public static final int FROM

  Standard index for the FROM query section

  See Also:
    Constant Field Values

### WHERE

    public static final int WHERE

  Standard index for the WHERE query section

  See Also:
    Constant Field Values

### GROUPBY

    public static final int GROUPBY

  Standard index for the GROUPBY query section

  See Also:
    Constant Field Values

### ORDERBY

    public static final int ORDERBY

  Standard index for the ORDERBY query section

  See Also:
    Constant Field Values

### VARFROM

    public static final int VARFROM

  Standard index for the VARFROM query section

  See Also:
    Constant Field Values

### sections

    String[] sections

  Section texts, encoded with the standard indexes

### derivedSections

    String[] derivedSections

  Derived section texts, made from the sections of this query and the sections of its superqueries

### typeAnalyzerOQL

    String typeAnalyzerOQL

### fromAnalyzerOQL

    String fromAnalyzerOQL

### keyset

    Vector<Integer> keyset

  The keyset defining the primary key for this query. Normally the primary key is made of the keys declared in FROM, in this query and all the parent queries. Keys are kept as integers (indexes)

### previousKeyset

    Vector<Vector<Integer>> previousKeyset

  The keyset of all the parent queries

### keysetLabels

    Vector<String> keysetLabels

  The labels of the keyset

### empty

    static Vector<Vector<Integer>> empty

  A Vector containing an empty vector. Used for empty keysets

Constructor Detail

### ComposedQuery

    public ComposedQuery(String[] sections,
                         String queryLanguage)

  Default constructor

  Parameters:
    `sections` -
    `usesHQL` -

Method Detail

### getResultType

    public DataDefinition getResultType()

  Gets the type of the result

  Returns:
    The DataDefinition corresponding to the type of the result

### getLabelType

    public DataDefinition getLabelType(String s)

  Gets the type of a given label

  Parameters:
    `s` - the name of the label
  Returns:
    A DataDefinition corresponding to the type of the label

### init

    public void init()

  Initializes the object. This is a template method

### getFromSection

    public String getFromSection()

  Gets the FROM section

  Returns:
    A String containing the FROM section of the query

### getGroupBySection

    public String getGroupBySection()

  Gets the GROUP BY section

  Returns:
    A String containing the GROUP BY section of the query

### initKeysets

    protected void initKeysets()

  Initializes the keysets. previousKeyset is "empty"

### addSubquery

    protected void addSubquery(ComposedSubquery q)

  Adds a subquery to this query. Makes it aware that it has subqueries at all.

  Parameters:
    `q` - the subquery

### prependFromToKeyset

    protected void prependFromToKeyset()

  Adds all keys from the FROM section to the keyset, and their labels to the keyLabels. They are all added as projections (this has to change)

### getProjectionAt

    public String getProjectionAt(int n)

  Gets a given projection

  Parameters:
    `n` - the index of the projection
  Returns:
    A String containing the projection

### addProjection

    Integer addProjection(String expr)

  Adds a projection with the given expression

  Parameters:
    `expr` - the expression to add
  Returns:
    The index at which the expression was added

### checkProjectionInteger

    public Integer checkProjectionInteger(String expr)

  Checks if a projection exists, and if not, adds it.

  Parameters:
    `expr` - the expression to add
  Returns:
    The index of the added projection

### checkProjection

    String checkProjection(String expr)

  Checks if a projection exists, and if not, adds it.

  Parameters:
    `expr` - the expression to add
  Returns:
    The column name of the projection

### columnName

    public static String columnName(Integer n)

  Gets the name of a column indicated by index

  Parameters:
    `n` - the index of the column
  Returns:
    A String containing the name of the column, of the kind "colN"

### checkExpr

    String checkExpr(String str)

  Checks the orderBy or groupBy expressions to see if they are already selected, if not adds a projection. Only group by and order by labels.

  Parameters:
    `str` - an orderBy or groupBy expression
  Returns:
    The checked expression, transformed according to the projections

### computeQuery

    protected String computeQuery(String[] derivedSections,
                                  boolean typeAnalysisOnly)

  Computes the query from its sections

  Parameters:
    `derivedSections` - the sections of this query
    `typeAnalysisOnly` - indicates whether this is only a type analysis
  Returns:
    The computed OQL query

### execute

    public Grouper execute(QueryProvider qep,
                           Map args,
                           ComposedQuery.Evaluator v,
                           int offset,
                           int limit)
                    throws LogicException

  Executes the contained query in the given database

  Parameters:
    `qep` - the database where the query should be ran
    `args` - the arguments we may need during the execution
    `v` - the evaluator evaluating the expressions
    `offset` - at which iteration this query should start
    `limit` - how many times should this query be ran
  Throws:
    `LogicException`

### analyze

    public void analyze()

### addProjectionDirectly

    public void addProjectionDirectly(String s)

  allows to directly set a projection. Used for totalCount in `QueryTag.doAnalyzedStartTag(org.makumba.analyser.PageCache)` to compose a query with 'count(*)' as the only projection.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### getTypeAnalyzerQuery

    public String getTypeAnalyzerQuery()

  Gets the query string.

  Returns:
    the query string in a form that can be used by a type analyser, in the query language of the ComposedQuery

### getProjections

    public Vector<String> getProjections()

  Gets the projections of this query

  Returns:
    a `Vector` containing the projections of this ComposedQuery

### getProjectionTypes

    public DataDefinition getProjectionTypes()

  Gets the type of the fields between SELECT and FROM

  Returns:
    A DataDefinition containing as fields the type and name of the query projections

### getFromLabelTypes

    public Map<String,DataDefinition> getFromLabelTypes()

  Gets the types of the labels in the FROM section

  Returns:
    a Map containing the labels and their type

### checkExprSetOrNullable

    public Object checkExprSetOrNullable(String expr)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20