com.businessobjects.query
Interface SubQuery

All Superinterfaces:
ConditionBase

public interface SubQuery
extends ConditionBase

The SubQuery interface is used to provide a set of results to the main query.

Example: Applying SubQuery to the Query.

        QuerySpecification boQuerySpec = QuerySpecification.Factory.newInstance();
        // Create a Query array. We are only using a single query in this example, so the array is of size 1.
        Query boQuery1 = Query.Factory.newInstance();
        // The query will contain three result objects (these objects represent the fields that are contained in the query result). Create an array of QueryObject objects to store the result objects. You can use Detail, Dimension, or Measure objects as result objects.
        QueryObject[] boQueryResultObjects = new QueryObject[2];
        boQueryResultObjects[0] = QueryObject.Factory.newInstance();
        boQueryResultObjects[1] = QueryObject.Factory.newInstance();
        boQueryResultObjects[0].setKey((String)dimensionKeys.get(0));
        boQueryResultObjects[1].setKey((String)measureKeys.get(0));
        QueryObject boBasedOnObject = QueryObject.Factory.newInstance();
        boBasedOnObject.setKey((String)dimensionKeys.get(0));
        QueryObject boFilteredObject  = QueryObject.Factory.newInstance();
        boFilteredObject.setKey((String)dimensionKeys.get(0));

        SubQuery subquery = SubQuery.Factory.newInstance();
        subquery.setConditionOperator(ConditionOperator.LESS);
        subquery.setComparisonOperator(ComparisonOperator.ANY);
        subquery.setFilteredObjectArray(0,boFilteredObject);
        subquery.setResultObjectArray(1,boBasedOnObject);

        ConditionBase[] boConditionBase = new ConditionBase[1];
        boConditionBase[0] = subquery;
        QueryCondition boQueryCondition = QueryCondition.Factory.newInstance();
        boQueryCondition.setItemArray(boConditionBase);

        boQuery1.setQueryCondition(boQueryCondition);
        // Add the array of result objects to the Query.
        boQuery1.setQueryResultArray(boQueryResultObjects);
        // Add the Query to the QuerySpecification
        boQuerySpec.setQueryBase(boQuery1);
 
For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Note: The subquery can contain one or more filtered objects, one or more result objects and one or more query conditions.


Nested Class Summary
static class SubQuery.Factory
          A class with methods for creating instances of the SubQuery type.
 
Field Summary
static org.apache.xmlbeans.SchemaType type
          Internal Use Only.
 
Method Summary
 QueryObject addNewFilteredObject()
          Appends and returns a new empty value (as xml) as the last FilteredObject element
 QueryCondition addNewQueryCondition()
          Appends and returns a new empty QueryCondition element
 QueryObject addNewResultObject()
          Appends and returns a new empty value (as xml) as the last ResultObject element
 ComparisonOperator.Enum getComparisonOperator()
          Gets the ComparisonOperator attribute
 ConditionOperator.Enum getConditionOperator()
           Gets the operator used between the filtered objects and the result objects in the subquery.
 QueryObject[] getFilteredObjectArray()
           Gets the objects in the main query that the subquery is returning filtered results for.
 QueryObject getFilteredObjectArray(int i)
           Gets the object in the main query that the subquery is returning filtered results for.
 QueryCondition getQueryCondition()
           Gets the query condition to use in the subquery to filter results returned by the subquery.
 QueryObject[] getResultObjectArray()
           Gets the fields returned by the subquery to the main query.
 QueryObject getResultObjectArray(int i)
           Gets the fields returned by the subquery to the main query.
 QueryObject insertNewFilteredObject(int i)
          Inserts and returns a new empty value (as xml) of the "FilteredObject" element at the specified index position.
 QueryObject insertNewResultObject(int i)
          Inserts and returns a new empty value (as xml) of the ResultObject element as the specified index position.
 boolean isSetComparisonOperator()
          Checks if the ComparisonOperator attribute has been set.
 boolean isSetQueryCondition()
          Checks if the QueryCondition element has been set.
 void removeFilteredObject(int i)
          Removes the "FilteredObject" element at the specified index position.
 void removeResultObject(int i)
          Removes the "ResultObject" element as the specified index position.
 void setComparisonOperator(ComparisonOperator.Enum comparisonOperator)
          Sets the ComparisonOperator attribute.
 void setConditionOperator(ConditionOperator.Enum conditionOperator)
           Sets the operator used between the filtered objects and the result objects in the subquery.
 void setFilteredObjectArray(int i, QueryObject filteredObject)
           Sets the object in the main query that the subquery is returning filtered results for.
 void setFilteredObjectArray(QueryObject[] filteredObjectArray)
           Sets the objects in the main query that the subquery is returning filtered results for.
 void setQueryCondition(QueryCondition queryCondition)
           Sets the query condition to use in the subquery to filter results returned by the subquery.
 void setResultObjectArray(int i, QueryObject resultObject)
           Sets the fields returned by the subquery to the main query.
 void setResultObjectArray(QueryObject[] resultObjectArray)
           Sets the fields returned by the subquery to the main query.
 int sizeOfFilteredObjectArray()
          Returns the size of the FilteredObject array.
 int sizeOfResultObjectArray()
          Returns the size of the ResultObject array.
 void unsetComparisonOperator()
          Deletes or unsets the ComparisonOperator attribute
 void unsetQueryCondition()
          Deletes or unsets the "QueryCondition" element
 ComparisonOperator xgetComparisonOperator()
          Internal Use Only.
 ConditionOperator xgetConditionOperator()
          Internal Use Only.
 void xsetComparisonOperator(ComparisonOperator comparisonOperator)
          Internal Use Only.
 void xsetConditionOperator(ConditionOperator conditionOperator)
          Internal Use Only.
 
Methods inherited from interface com.businessobjects.query.ConditionBase
getID, isSetID, setID, unsetID, xgetID, xsetID
 

Field Detail

type

static final org.apache.xmlbeans.SchemaType type

Internal Use Only.

Method Detail

getFilteredObjectArray

QueryObject[] getFilteredObjectArray()

Gets the objects in the main query that the subquery is returning filtered results for.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Returns:
the objects in the main query that the subquery is returning filtered results for

getFilteredObjectArray

QueryObject getFilteredObjectArray(int i)

Gets the object in the main query that the subquery is returning filtered results for.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Parameters:
i - the index in the array that contains the requested filtered object
Returns:
the object at array index i

sizeOfFilteredObjectArray

int sizeOfFilteredObjectArray()
Returns the size of the FilteredObject array.

Returns:
the size of the FilteredObject array.

setFilteredObjectArray

void setFilteredObjectArray(QueryObject[] filteredObjectArray)

Sets the objects in the main query that the subquery is returning filtered results for.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Parameters:
filteredObject - the objects in the main query that the subquery is returning filtered results for

setFilteredObjectArray

void setFilteredObjectArray(int i,
                            QueryObject filteredObject)

Sets the object in the main query that the subquery is returning filtered results for.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Parameters:
i - the index in the array at which to store the filtered object
value - the filtered object to store in the array

insertNewFilteredObject

QueryObject insertNewFilteredObject(int i)
Inserts and returns a new empty value (as xml) of the "FilteredObject" element at the specified index position.

Parameters:
i - the index of the FilterObject element
Returns:
a new empty value (as xml) of the "FilteredObject" element at the specified index position.

addNewFilteredObject

QueryObject addNewFilteredObject()
Appends and returns a new empty value (as xml) as the last FilteredObject element

Returns:
a new empty value (as xml) as the last FilteredObject element

removeFilteredObject

void removeFilteredObject(int i)
Removes the "FilteredObject" element at the specified index position.

Parameters:
i - the index of the FilteredObject element

getResultObjectArray

QueryObject[] getResultObjectArray()

Gets the fields returned by the subquery to the main query.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Returns:
the fields returned by the subquery to the main query

getResultObjectArray

QueryObject getResultObjectArray(int i)

Gets the fields returned by the subquery to the main query.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Parameters:
i - the index in the array where the result object is stored
Returns:
the requested result object

sizeOfResultObjectArray

int sizeOfResultObjectArray()
Returns the size of the ResultObject array.

Returns:
the size of the ResultObject array.

setResultObjectArray

void setResultObjectArray(QueryObject[] resultObjectArray)

Sets the fields returned by the subquery to the main query.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Parameters:
resultObject - the fields returned by the subquery to the main query

setResultObjectArray

void setResultObjectArray(int i,
                          QueryObject resultObject)

Sets the fields returned by the subquery to the main query.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Parameters:
i - the index in the array in which to store the result object
value - the result object to store in the array

insertNewResultObject

QueryObject insertNewResultObject(int i)
Inserts and returns a new empty value (as xml) of the ResultObject element as the specified index position.

Parameters:
i - the index of the ResultObject element
Returns:
a new empty value (as xml) of the ResultObject element as the specified index position.

addNewResultObject

QueryObject addNewResultObject()
Appends and returns a new empty value (as xml) as the last ResultObject element

Returns:
a new empty value (as xml) as the last ResultObject element

removeResultObject

void removeResultObject(int i)
Removes the "ResultObject" element as the specified index position.

Parameters:
i - the index of the ResultObject element

getQueryCondition

QueryCondition getQueryCondition()

Gets the query condition to use in the subquery to filter results returned by the subquery.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Returns:
the query condition to use in the subquery to filter results returned by the subquery

isSetQueryCondition

boolean isSetQueryCondition()
Checks if the QueryCondition element has been set.

Returns:
true if the QueryCondition element is set, otherwise false

setQueryCondition

void setQueryCondition(QueryCondition queryCondition)

Sets the query condition to use in the subquery to filter results returned by the subquery.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Parameters:
queryCondition - the query condition to use in the subquery to filter results returned by the subquery

addNewQueryCondition

QueryCondition addNewQueryCondition()
Appends and returns a new empty QueryCondition element

Returns:
a new empty QueryCondition element

unsetQueryCondition

void unsetQueryCondition()
Deletes or unsets the "QueryCondition" element


getConditionOperator

ConditionOperator.Enum getConditionOperator()

Gets the operator used between the filtered objects and the result objects in the subquery.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Returns:
operator used between the filtered objects and the result objects in the subquery

xgetConditionOperator

ConditionOperator xgetConditionOperator()

Internal Use Only.


setConditionOperator

void setConditionOperator(ConditionOperator.Enum conditionOperator)

Sets the operator used between the filtered objects and the result objects in the subquery.

Example:

For example, if you want to list all of the stores in states that have a total sales revenue greater than two million dollars, you can create a subquery that returns the states which have total sales greater than two million dollars; your main query would then list only stores in those states.

In this case, the field "State" would be the filtered object. The condition operator would be set to "InList". The result object (the fields returned to the main query) would also be "State". Furthermore, the subquery would contain a query condition specifying that we only want states where the total revenue is greater than two million dollars.

Parameters:
conditionOperator - the operator used between the filtered objects and the result objects in the subquery

xsetConditionOperator

void xsetConditionOperator(ConditionOperator conditionOperator)

Internal Use Only.


getComparisonOperator

ComparisonOperator.Enum getComparisonOperator()
Gets the ComparisonOperator attribute

Returns:
the ComparisonOperator instance

xgetComparisonOperator

ComparisonOperator xgetComparisonOperator()

Internal Use Only.


isSetComparisonOperator

boolean isSetComparisonOperator()
Checks if the ComparisonOperator attribute has been set.

Returns:
true if the ComparisonOperator element is set, otherwise false

setComparisonOperator

void setComparisonOperator(ComparisonOperator.Enum comparisonOperator)
Sets the ComparisonOperator attribute.

Parameters:
comparisonOperator - the operator used to compare objects.

xsetComparisonOperator

void xsetComparisonOperator(ComparisonOperator comparisonOperator)

Internal Use Only.


unsetComparisonOperator

void unsetComparisonOperator()
Deletes or unsets the ComparisonOperator attribute