com.sap.ip.me.api.persist.query
Class JQueryFactory

java.lang.Object
  extended bycom.sap.ip.me.api.persist.query.JQueryFactory

public abstract class JQueryFactory
extends java.lang.Object

Query factory interface. The queries are reusable, read-only objects that allow filtering the data in a container. Usually, you create the query on first use, store it into a static field and then re-use it later. A JQuery only selects the specified attributes and not whole instances of PersistableEntities. The intention is to display screens very fast using JQueries.

The query interface supports sorting and grouping. To enable sorting, simply add attribute terms on which you wish to sort when creating the query.

Conditions should be added from left to right with decreasing selectivity.

The query can be parameterized using JQueryParameters. Parameters can be set during runtime. This makes a query reusable for differnet parameters without the need to create a new JQuery instance. Simply pass new parameter values to the executeQuery method on the PersistenceManager.

Author:
SAP
See Also:
JQuery, JQueryAttribute, JQueryParameter, JQueryCondition, JQuerySortOrder, JQueryGroupBy, JQueryFactory, JQueryResult

Constructor Summary
JQueryFactory()
           
 
Method Summary
abstract  JQueryAttribute createAggregate(JQueryAttribute attr, AggregationOperatorType aggreg)
          Create an aggregate on the query attribute.
abstract  JQueryAttribute createAttribute(ClassDescriptor candidateClass, AttributeDescriptor fieldName)
          Create a query attribute.
abstract  JQueryAttribute createAttribute(ClassDescriptor candidateClass, AttributeDescriptor fieldName, java.lang.Object tag)
          Create a query attribute.
abstract  JQueryLinkAttribute createAttribute(ClassDescriptor candidateClass, LinkDescriptor fieldName)
          Create a query attribute for links between tables.
abstract  JQueryCondition createCondition(JQueryAttribute left, java.lang.Object[] right)
          Deprecated.  
abstract  JQueryCondition createCondition(JQueryAttribute left, java.lang.Object[] right, java.lang.Object tag)
          Deprecated.  
abstract  JQueryCondition createCondition(JQueryAttribute left, RelationalOperatorType operator, JQueryAttribute right)
          Create simple condition between two attributes.
abstract  JQueryCondition createCondition(JQueryAttribute left, RelationalOperatorType operator, JQueryParameter right)
          Create simple condition with parameterized right operand.
abstract  JQueryCondition createCondition(JQueryAttribute left, RelationalOperatorType operator, java.lang.Object right)
          Deprecated.  
abstract  JQueryCondition createCondition(JQueryAttribute left, RelationalOperatorType operator, java.lang.Object right, java.lang.Object tag)
          Deprecated.  
abstract  JQueryCondition createCondition(JQueryCondition[] conditions, LogicalOperatorType operator)
          Construct n-ary logical operator.
abstract  JQueryCondition createCondition(JQueryCondition left, LogicalOperatorType operator, JQueryCondition right)
          Construct binary logical operator.
abstract  JQueryCondition createCondition(LogicalOperatorType operator, JQueryCondition right)
          Construct unary logical operator.
abstract  JQueryGroupBy createGroupBy(JQueryAttribute[] groupBy)
          Create group by for the specified attributes in the same order as the delivered JQueryAttribute[]
abstract  JQueryCondition createLinkCondition(JQueryLinkAttribute link)
          Create link condition to join two tables over link table.
abstract  JQueryParameter createParameter(java.lang.Object defaultValue)
          Create unnamed query parameter.
abstract  JQueryParameter createParameter(java.lang.Object defaultValue, java.lang.Object tag)
          Create named query parameter.
abstract  JQuery createQuery(JQueryAttribute[] attributes, JQueryCondition cond)
          Create query based on specified attributes and condition.
abstract  JQuery createQuery(JQueryAttribute[] attributes, JQueryCondition cond, boolean distinct)
          Create query based on specified attributes and condition.
abstract  JQuery createQuery(JQueryAttribute[] attributes, JQueryCondition cond, boolean distinct, JQuerySortOrder sortOrder)
          Create sorted query based on specified attributes and condition.
abstract  JQuery createQuery(JQueryAttribute[] attributes, JQueryCondition cond, boolean distinct, JQuerySortOrder[] sortOrders)
          Create sorted query based on specified attributes and condition.
abstract  JQuery createQuery(JQueryAttribute[] attributes, JQueryCondition cond, boolean distinct, JQuerySortOrder[] sortOrders, JQueryGroupBy groupBy)
          Create sorted and grouped query based on specified attributes and condition.
abstract  JQuery createQuery(JQueryAttribute[] attributes, JQueryCondition cond, JQuerySortOrder sortOrder)
          Create sorted query based on specified attributes and condition.
abstract  JQuery createQuery(JQueryAttribute[] attributes, JQueryCondition cond, JQuerySortOrder[] sortOrders)
          Create sorted query based on specified attributes and condition.
abstract  JQuery createQuery(JQueryAttribute[] attributes, JQueryCondition cond, JQuerySortOrder[] sortOrders, JQueryGroupBy groupBy)
          Create sorted and grouped query based on specified attributes and condition.
abstract  JQuerySortOrder createSortOrder(JQueryAttribute attribute)
          Create ascending sort order on given attribute.
abstract  JQuerySortOrder createSortOrder(JQueryAttribute attribute, boolean ascending)
          Create sort order on given attribute.
abstract  JQuerySortOrder createSortOrder(JQuerySortOrder[] sortOrders)
          Deprecated.  
static JQueryFactory getInstance()
          Get instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JQueryFactory

public JQueryFactory()
Method Detail

createQuery

public abstract JQuery createQuery(JQueryAttribute[] attributes,
                                   JQueryCondition cond)
                            throws java.lang.IllegalArgumentException
Create query based on specified attributes and condition.

Parameters:
attributes - attributes used in this query.
cond - condition to use to filter results.
Throws:
java.lang.IllegalArgumentException - if condition uses attributes not mentioned in attributes parameter.

createQuery

public abstract JQuery createQuery(JQueryAttribute[] attributes,
                                   JQueryCondition cond,
                                   JQuerySortOrder[] sortOrders)
                            throws java.lang.IllegalArgumentException
Create sorted query based on specified attributes and condition.

Parameters:
attributes - attributes used in this query.
cond - condition to use to filter results.
sortOrders - sort orders to use for this query or null to use default sorting.
Throws:
java.lang.IllegalArgumentException - if condition or sort orders use attributes not mentioned in attributes parameter.

createQuery

public abstract JQuery createQuery(JQueryAttribute[] attributes,
                                   JQueryCondition cond,
                                   JQuerySortOrder sortOrder)
                            throws java.lang.IllegalArgumentException
Create sorted query based on specified attributes and condition.

Parameters:
attributes - attributes used in this query.
cond - condition to use to filter results.
sortOrder - sort order to use for this query or null to use default sorting.
Throws:
java.lang.IllegalArgumentException - if condition or sort orders use attributes not mentioned in attributes parameter.

createQuery

public abstract JQuery createQuery(JQueryAttribute[] attributes,
                                   JQueryCondition cond,
                                   JQuerySortOrder[] sortOrders,
                                   JQueryGroupBy groupBy)
                            throws java.lang.IllegalArgumentException
Create sorted and grouped query based on specified attributes and condition. The groupBy consists of the attributes to group by.

Parameters:
attributes - attributes used in this query.
cond - condition to use to filter results.
groupBy - grouping to use for this query or null to use no grouping
Throws:
java.lang.IllegalArgumentException - if condition or sort orders use attributes not mentioned in attributes parameter.

createQuery

public abstract JQuery createQuery(JQueryAttribute[] attributes,
                                   JQueryCondition cond,
                                   boolean distinct)
                            throws java.lang.IllegalArgumentException
Create query based on specified attributes and condition.

Parameters:
attributes - attributes used in this query.
cond - condition to use to filter results.
distinct - if true, select unique (no row duplicates).
Throws:
java.lang.IllegalArgumentException - if condition uses attributes not mentioned in attributes parameter.

createQuery

public abstract JQuery createQuery(JQueryAttribute[] attributes,
                                   JQueryCondition cond,
                                   boolean distinct,
                                   JQuerySortOrder[] sortOrders)
                            throws java.lang.IllegalArgumentException
Create sorted query based on specified attributes and condition.

Parameters:
attributes - attributes used in this query.
cond - condition to use to filter results.
distinct - if true, select unique (no row duplicates).
sortOrders - sort orders to use for this query or null to use default sorting.
Throws:
java.lang.IllegalArgumentException - if condition or sort orders use attributes not mentioned in attributes parameter.

createQuery

public abstract JQuery createQuery(JQueryAttribute[] attributes,
                                   JQueryCondition cond,
                                   boolean distinct,
                                   JQuerySortOrder sortOrder)
                            throws java.lang.IllegalArgumentException
Create sorted query based on specified attributes and condition.

Parameters:
attributes - attributes used in this query.
cond - condition to use to filter results.
distinct - if true, select unique (no row duplicates).
sortOrder - sort order to use for this query or null to use default sorting.
Throws:
java.lang.IllegalArgumentException - if condition or sort orders use attributes not mentioned in attributes parameter.

createQuery

public abstract JQuery createQuery(JQueryAttribute[] attributes,
                                   JQueryCondition cond,
                                   boolean distinct,
                                   JQuerySortOrder[] sortOrders,
                                   JQueryGroupBy groupBy)
                            throws java.lang.IllegalArgumentException
Create sorted and grouped query based on specified attributes and condition.

Parameters:
attributes - attributes used in this query.
cond - condition to use to filter results.
distinct - if true, select unique (no row duplicates).
groupBy - attributes to group by or null for no grouping
Throws:
java.lang.IllegalArgumentException - if condition or sort orders use attributes not mentioned in attributes parameter.

createAttribute

public abstract JQueryAttribute createAttribute(ClassDescriptor candidateClass,
                                                AttributeDescriptor fieldName)
                                         throws java.lang.IllegalArgumentException
Create a query attribute.

Parameters:
candidateClass - candidate class.
fieldName - field name in candidate class to bind to this term.
Returns:
new term representing given class attribute.
Throws:
java.lang.IllegalArgumentException

createAttribute

public abstract JQueryAttribute createAttribute(ClassDescriptor candidateClass,
                                                AttributeDescriptor fieldName,
                                                java.lang.Object tag)
                                         throws java.lang.IllegalArgumentException
Create a query attribute.

Parameters:
candidateClass - candidate class.
fieldName - field name in candidate class to bind to this term.
tag - identificator tag that can be later used to identify this attribute.
Returns:
new term representing given class attribute.
Throws:
java.lang.IllegalArgumentException

createAggregate

public abstract JQueryAttribute createAggregate(JQueryAttribute attr,
                                                AggregationOperatorType aggreg)
Create an aggregate on the query attribute. A new query aggregate attribute is returned by this method. Please note that all attributes belonging to a candidate class have to be either aggregate or simple attributes.

Parameters:
attr - attribute to change to aggregate.
aggreg - aggregation function to use.
Returns:
aggregation attribute.

createAttribute

public abstract JQueryLinkAttribute createAttribute(ClassDescriptor candidateClass,
                                                    LinkDescriptor fieldName)
                                             throws java.lang.IllegalArgumentException
Create a query attribute for links between tables.

Parameters:
candidateClass - candidate class.
fieldName - field name in candidate class to bind to this term.
Returns:
new term representing given class attribute.
Throws:
java.lang.IllegalArgumentException

createParameter

public abstract JQueryParameter createParameter(java.lang.Object defaultValue)
Create unnamed query parameter.

Parameters:
defaultValue - default value for this parameter.
Returns:
new term representing query parameter.

createParameter

public abstract JQueryParameter createParameter(java.lang.Object defaultValue,
                                                java.lang.Object tag)
Create named query parameter.

Parameters:
defaultValue - default value for this parameter.
tag - parameter identification tag.
Returns:
new term representing query parameter.

createSortOrder

public abstract JQuerySortOrder createSortOrder(JQueryAttribute attribute)
Create ascending sort order on given attribute.

Make sure you haven marked the AttributeDescriptor as index for best performance!

Parameters:
attribute - attribute to sort by (should be indexed!).
Returns:
sort order for the attribute.

createSortOrder

public abstract JQuerySortOrder createSortOrder(JQueryAttribute attribute,
                                                boolean ascending)
Create sort order on given attribute.

Make sure you haven marked the AttributeDescriptor as index for best performance!

Parameters:
attribute - attribute to sort.
ascending - if true, sort ascending.
Returns:
sort order for the attribute.

createSortOrder

public abstract JQuerySortOrder createSortOrder(JQuerySortOrder[] sortOrders)
Deprecated.  

Create composite sort order.

Parameters:
sortOrders - sort orders.
Returns:
composite sort order.

createGroupBy

public abstract JQueryGroupBy createGroupBy(JQueryAttribute[] groupBy)
Create group by for the specified attributes in the same order as the delivered JQueryAttribute[]

Parameters:
groupBy - attributes to group by
Returns:
a group by for the given attributes

createCondition

public abstract JQueryCondition createCondition(JQueryAttribute left,
                                                RelationalOperatorType operator,
                                                JQueryParameter right)
                                         throws java.lang.IllegalArgumentException
Create simple condition with parameterized right operand. This parameter can be set before execution.

Parameters:
left - left operand.
operator - comparison operator.
right - right operand as parameter.
Throws:
java.lang.IllegalArgumentException - if the operator is invalid, one of terms is null or the term types do not match.

createCondition

public abstract JQueryCondition createCondition(JQueryAttribute left,
                                                RelationalOperatorType operator,
                                                JQueryAttribute right)
                                         throws java.lang.IllegalArgumentException
Create simple condition between two attributes.

Parameters:
left - left operand.
operator - comparison operator.
right - right operand as parameter.
Throws:
java.lang.IllegalArgumentException - if the operator is invalid, one of terms is null or the term types do not match.

createCondition

public abstract JQueryCondition createCondition(JQueryAttribute left,
                                                RelationalOperatorType operator,
                                                java.lang.Object right)
                                         throws java.lang.IllegalArgumentException
Deprecated.  

Create simple condition with parameterized right operand. This method creates internally a new parameter and passes identifier of the attribute on the left side to this parameter as parameter identifier.

Parameters:
left - left operand.
operator - comparison operator.
right - right operand as parameter (can be an array for IN operator).
Throws:
java.lang.IllegalArgumentException - if the operator is invalid, one of terms is null or the term types do not match.

createCondition

public abstract JQueryCondition createCondition(JQueryAttribute left,
                                                RelationalOperatorType operator,
                                                java.lang.Object right,
                                                java.lang.Object tag)
                                         throws java.lang.IllegalArgumentException
Deprecated.  

Create named simple condition with parameterized right operand. This method creates internally a new parameter with given identifier tag.

Parameters:
left - left operand.
operator - comparison operator.
right - right operand as parameter (can be an array for IN operator).
tag - identifier tag to use for the parameter.
Throws:
java.lang.IllegalArgumentException - if the operator is invalid, one of terms is null or the term types do not match.

createCondition

public abstract JQueryCondition createCondition(JQueryAttribute left,
                                                java.lang.Object[] right)
                                         throws java.lang.IllegalArgumentException
Deprecated.  

Create simple IN condition with parameterized right operand. This method creates internally a new parameter and passes identifier of the attribute on the left side to this parameter as parameter identifier.

Parameters:
left - left operand.
right - array of values for right operand.
Throws:
java.lang.IllegalArgumentException - if the attribute is null or the types don't match.

createCondition

public abstract JQueryCondition createCondition(JQueryAttribute left,
                                                java.lang.Object[] right,
                                                java.lang.Object tag)
                                         throws java.lang.IllegalArgumentException
Deprecated.  

Create named simple IN condition with parameterized right operand. This method creates internally a new parameter with given identifier tag.

Parameters:
left - left operand.
right - array of values for right operand.
tag - identifier tag to use for the parameter.
Throws:
java.lang.IllegalArgumentException - if the attribute is null or the types don't match.

createLinkCondition

public abstract JQueryCondition createLinkCondition(JQueryLinkAttribute link)
Create link condition to join two tables over link table.

Parameters:
link - link attribute.

createCondition

public abstract JQueryCondition createCondition(JQueryCondition left,
                                                LogicalOperatorType operator,
                                                JQueryCondition right)
                                         throws java.lang.IllegalArgumentException
Construct binary logical operator.

Parameters:
left - left operand.
operator - logical operator.
right - right operand.
Throws:
java.lang.IllegalArgumentException - if an invalid operator is specified or one of operands is null.

createCondition

public abstract JQueryCondition createCondition(JQueryCondition[] conditions,
                                                LogicalOperatorType operator)
                                         throws java.lang.IllegalArgumentException
Construct n-ary logical operator.

Parameters:
conditions - operands.
operator - logical operator.
Throws:
java.lang.IllegalArgumentException - if an invalid operator is specified or one of operands is null.

createCondition

public abstract JQueryCondition createCondition(LogicalOperatorType operator,
                                                JQueryCondition right)
                                         throws java.lang.IllegalArgumentException
Construct unary logical operator.

Parameters:
operator - logical operator (only NOT supported).
right - right operand.
Throws:
java.lang.IllegalArgumentException - if an invalid operator is specified or the operand is null.

getInstance

public static JQueryFactory getInstance()
Get instance. Throws a RuntimeException when then current PersistenceImplementation does not support JQuery.

Returns:
factory instance.


Copyright © 2005 SAP AG. All Rights Reserved.