com.sap.ip.me.api.smartsync
Interface SmartSyncQueryFactory


public interface SmartSyncQueryFactory

QueryFactory provides functionality to create Query, Condition and SortOrder instances.

Creating a condition

A Condition can be created using the createCondition method of this factory.
Examples:
Creating a SingleCondition
  //SYNC_KEY > '10000000001'
  Condition singleCondition = queryFactory.createCondition(syncKeyFieldDescriptor,RelationalOperatorType.GREATER_THAN,"10000000001");
 
Creating a CompositeCondition
  //SYNC_KEY > '10000000001'
  Condition greaterCondition = queryFactory.createCondition(syncKeyFieldDescriptor,RelationalOperatorType.GREATER_THAN,"10000000001");
  //SYNC_KEY < '10000000020'
  Condition lesserCondition = queryFactory.createCondition(syncKeyFieldDescriptor,RelationalOperatorType.LOWER_THAN,"10000000020");
  //'10000000001'  <  SYNC_KEY < '10000000020'
  Condition[] multipleCondition = new Condition[]{ greaterCondition, lesserCondition };
  Condition compositeCondition = queryFactory.createCondition(multipleCondition,LogicalOperatorType.AND);
 
You can pass 'null' for a condition to query for all data. This is especially usefull when it is combined with startIndex and maxCount for displaying a limited amount of data.

Creating a SortOrder

A SortOrder can be created using the createSortOrder method of this factory.
Examples:
Creating a SingleSortOrder
  //sort in SYNC_KEY field in ASC order
  Condition singleSortOrder = queryFactory.createSortOrder(syncKeyFieldDescriptor,true);
 
Creating a MultipleSortOrder
  //sort in NAME field in ASC order
  SortOrder nameAscSortOrder = queryFactory.createSortOrder(nameFieldDescriptor,true);
  //sort in SYNC_KEY field in DESC order
  SortOrder syncKeyDescSortOrder = queryFactory.createSortOrder(syncKeyFieldDescriptor,false);
  //sort in NAME field first then in SYNC_KEY field
  SortOrder[] multipleSortOrder = new SortOrder[]{ nameAscSortOrder, syncKeyDescSortOrder };
  Condition compositeSortOrder = queryFactory.createSortOrder(multipleSortOrder);
 

Creating a query

A Query can be created using the createQuery method of this factory. This method is heavily overloaded for different types of arguments. Only two types of query are supported: the Row query and SyncBo query.
To create a query on the Row entities in the repository, a RowDescriptor is required. On the other hand, a SyncBoDescriptor is required to conduct a query against the SyncBo entities in the repository.
Examples:
Creating a Row query
  //Query for 010 ChildRows with SYNC_KEY > '10000000001'
  Condition singleCondition = queryFactory.createCondition(syncKeyFieldDescriptor,RelationalOperatorType.GREATER_THAN,"10000000001");
  Query rowQuery = queryFactory.createQuery(child101RowDescriptor,singleCondition);
 
Creating a SyncBo query
  //Query for SyncBos with SYNC_KEY > '10000000001'
  Condition singleCondition = queryFactory.createCondition(syncKeyFieldDescriptor,RelationalOperatorType.GREATER_THAN,"10000000001");
  Query syncBoQuery = queryFactory.createQuery(syncBoDescriptor,singleCondition);
 
When JDBC Persistence is used, you should consider using SmartSyncJQueryFactory instead.

Version:
2.1
Author:
SAP
See Also:
SmartSyncJQueryFactory

Method Summary
 Condition createCondition(Condition[] conditions, LogicalOperatorType logicalOperator)
          Returns a Condition instance having a multiple Condition entities related with a corresponding logical operator.
 Condition createCondition(FieldDescriptor fieldDescriptor, RelationalOperatorType relationalOperator, java.lang.Object value)
          Returns a Condition instance for the specified FieldDescriptor, RelationalOperatorType and value.
 Query createQuery(RowDescriptor rowDescriptor, Condition condition)
          Returns a Query instance for the specified RowDescriptor and Condition objects.
 Query createQuery(RowDescriptor rowDescriptor, Condition condition, int maxCount)
          Returns a Query instance for the specified RowDescriptor and Condition objects, with a maximum count limit.
 Query createQuery(RowDescriptor rowDescriptor, Condition condition, SortOrder sortOrder)
          Returns a Query instance for the specified RowDescriptor, Condition, and SortOrder objects.
 Query createQuery(RowDescriptor rowDescriptor, Condition condition, SortOrder sortOrder, int maxCount)
          Returns a Query instance for the specified RowDescriptor, SortOrder and Condition objects, with a maximum count limit.
 Query createQuery(RowDescriptor rowDescriptor, Condition condition, SortOrder sortOrder, int startIdx, int maxCount)
          Returns a Query instance for the specified RowDescriptor, SortOrder and Condition objects, with a start index and a maximum count limit.
 Query createQuery(SyncBoDescriptor syncBoDescriptor, Condition condition)
          Returns a Query instance for the specified SyncBoDescriptor and Condition objects.
 Query createQuery(SyncBoDescriptor syncBoDescriptor, Condition condition, int maxCount)
          Returns a Query instance for the specified SyncBoDescriptor and Condition objects with a maximum limit count.
 Query createQuery(SyncBoDescriptor syncBoDescriptor, Condition condition, SortOrder sortOrder)
          Returns a Query instance for the specified SyncBoDescriptor, Condition and SortOrder objects.
 Query createQuery(SyncBoDescriptor syncBoDescriptor, Condition condition, SortOrder sortOrder, int maxCount)
          Returns a Query instance for the specified SyncBoDescriptor, Condition and SortOrder objects with a max count limit
 Query createQuery(SyncBoDescriptor syncBoDescriptor, Condition condition, SortOrder sortOrder, int startIndex, int maxCount)
          Returns a Query instance for the specified SyncBoDescriptor, Condition and SortOrder objects with a starting index and max count limit
 Query createQuery(SyncBoDescriptor syncBoDescriptor, SortOrder sortOrder, int startIndex, int maxCount)
          Returns a Query instance for the specified SyncBoDescriptor and SortOrder objects with a starting index and max count limit
 SortOrder createSortOrder(FieldDescriptor fieldDescriptor, boolean isAscending)
          Returns a simple SortOrder instance for the specified FieldDescriptor and sort order flag.
 SortOrder createSortOrder(SortOrder[] sortOrders)
          Returns a multiple SortOrder instance.
 SortOrder createSortOrderForSyncBoKey(RowDescriptor rowDescriptor, boolean isAscending)
          Creates a sort order for the SyncBo key of the row.
 

Method Detail

createCondition

public Condition createCondition(FieldDescriptor fieldDescriptor,
                                 RelationalOperatorType relationalOperator,
                                 java.lang.Object value)
Returns a Condition instance for the specified FieldDescriptor, RelationalOperatorType and value.

Parameters:
fieldDescriptor - the FieldDescriptor of the field whose value is to be compared
relationalOperator - the RelationalOperator or the comparison operator
value - the reference value to which the field value is to be compared
Returns:
a Condition instance for the specified attributes

createCondition

public Condition createCondition(Condition[] conditions,
                                 LogicalOperatorType logicalOperator)
Returns a Condition instance having a multiple Condition entities related with a corresponding logical operator.

Parameters:
conditions - the array of Condition entities
logicalOperator - the logical operator to which the conditions will be correlated
Returns:
a composite Condition instance

createSortOrder

public SortOrder createSortOrder(FieldDescriptor fieldDescriptor,
                                 boolean isAscending)
Returns a simple SortOrder instance for the specified FieldDescriptor and sort order flag. Make sure that the FieldDescriptor is indexed for best performance!

Parameters:
fieldDescriptor - the FieldDescriptor of the sort field
isAscending - flag indicating whether to sort in ascending manner
Returns:
a SortOrder instance having the specified attributes

createSortOrderForSyncBoKey

public SortOrder createSortOrderForSyncBoKey(RowDescriptor rowDescriptor,
                                             boolean isAscending)
Creates a sort order for the SyncBo key of the row.

Parameters:
rowDescriptor - row descriptor of the child row
isAscending - flag indicating whether to sort in ascending manner
Returns:
a SortOrder instance

createSortOrder

public SortOrder createSortOrder(SortOrder[] sortOrders)
Returns a multiple SortOrder instance. Sorting is conducted according to the order of components in the array.

Parameters:
sortOrders - the SortOrder entities
Returns:
a SortOrder instance having a multiple components

createQuery

public Query createQuery(RowDescriptor rowDescriptor,
                         Condition condition)
                  throws PersistenceException
Returns a Query instance for the specified RowDescriptor and Condition objects.

Parameters:
rowDescriptor - the RowDescriptor of the Row to be searched
condition - a Condition instance; could be a single or composite condition
Returns:
a Row Query instance for the specified RowDescriptor and Condition
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(RowDescriptor rowDescriptor,
                         Condition condition,
                         SortOrder sortOrder)
                  throws PersistenceException
Returns a Query instance for the specified RowDescriptor, Condition, and SortOrder objects.

Parameters:
rowDescriptor - the RowDescriptor of the Row to be searched
condition - a Condition instance; could be a single or composite condition
sortOrder - the SortOrder instance; could be a single or multiple sort order fields
Returns:
a Row Query instance for the specified RowDescriptor, Condition and SortOrder objects
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(RowDescriptor rowDescriptor,
                         Condition condition,
                         int maxCount)
                  throws PersistenceException
Returns a Query instance for the specified RowDescriptor and Condition objects, with a maximum count limit.

Parameters:
rowDescriptor - the RowDescriptor of the Row to be searched
condition - a Condition instance; could be a single or composite condition
maxCount - the maximum number of Row entities to be returned
Returns:
a Row Query instance for the specified RowDescriptor and Condition attributes with a query limit set to maxCount
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(RowDescriptor rowDescriptor,
                         Condition condition,
                         SortOrder sortOrder,
                         int maxCount)
                  throws PersistenceException
Returns a Query instance for the specified RowDescriptor, SortOrder and Condition objects, with a maximum count limit.

Parameters:
rowDescriptor - the RowDescriptor of the Row to be searched
condition - a Condition instance; could be a single or composite condition
sortOrder - the SortOrder instance; could be a single or multiple sort order fields
maxCount - the maximum number of Row entities to be returned
Returns:
a Row Query instance for the specified RowDescriptor, Condition and SortOrder attributes with a query limit set to maxCount
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(RowDescriptor rowDescriptor,
                         Condition condition,
                         SortOrder sortOrder,
                         int startIdx,
                         int maxCount)
                  throws PersistenceException
Returns a Query instance for the specified RowDescriptor, SortOrder and Condition objects, with a start index and a maximum count limit.

Parameters:
rowDescriptor - the RowDescriptor of the Row to be searched
condition - a Condition instance; could be a single or composite condition
sortOrder - the SortOrder instance; could be a single or multiple sort order fields
maxCount - the maximum number of Row entities to be returned
Returns:
a Row Query instance for the specified RowDescriptor, Condition and SortOrder attributes with a query limit set to maxCount
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(SyncBoDescriptor syncBoDescriptor,
                         Condition condition)
                  throws PersistenceException
Returns a Query instance for the specified SyncBoDescriptor and Condition objects.

Parameters:
syncBoDescriptor - the SyncBoDescriptor of the SyncBos to be searched
condition - a Condition instance; could be a single or composite condition
Returns:
a SyncBo Query instance for the specified SyncBoDescriptor and Condition
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(SyncBoDescriptor syncBoDescriptor,
                         Condition condition,
                         SortOrder sortOrder)
                  throws PersistenceException
Returns a Query instance for the specified SyncBoDescriptor, Condition and SortOrder objects.

Parameters:
syncBoDescriptor - the SyncBoDescriptor of the SyncBos to be searched
condition - a Condition instance; could be a single or composite condition
sortOrder - the SortOrder instance; could be a single or multiple sort order fields
Returns:
a SyncBo Query instance for the specified SyncBoDescriptor,Condition and SortOrder attributes
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(SyncBoDescriptor syncBoDescriptor,
                         Condition condition,
                         int maxCount)
                  throws PersistenceException
Returns a Query instance for the specified SyncBoDescriptor and Condition objects with a maximum limit count.

Parameters:
syncBoDescriptor - the SyncBoDescriptor of the SyncBos to be searched
condition - a Condition instance; could be a single or composite condition
maxCount - the maximum number of SyncBo entities to be returned
Returns:
a SyncBo Query instance for the specified SyncBoDescriptor and Condition with a max
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(SyncBoDescriptor syncBoDescriptor,
                         SortOrder sortOrder,
                         int startIndex,
                         int maxCount)
                  throws PersistenceException
Returns a Query instance for the specified SyncBoDescriptor and SortOrder objects with a starting index and max count limit

Parameters:
syncBoDescriptor - the SyncBoDescriptor of the SyncBos to be searched
sortOrder - the SortOrder instance; could be a single or multiple sort order fields
startIndex - the starting index number of the SyncBo object in the list; should be either 0 or any integer greater than 0
maxCount - the maximum number of SyncBo entities from the starting index to be retrieved
Returns:
a SyncBo Query instance for the specified SyncBoDescriptor and SortOrder attributes with a starting index and maximum count limit
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(SyncBoDescriptor syncBoDescriptor,
                         Condition condition,
                         SortOrder sortOrder,
                         int startIndex,
                         int maxCount)
                  throws PersistenceException
Returns a Query instance for the specified SyncBoDescriptor, Condition and SortOrder objects with a starting index and max count limit

Parameters:
syncBoDescriptor - the SyncBoDescriptor of the SyncBos to be searched
sortOrder - the SortOrder instance; could be a single or multiple sort order fields
startIndex - the starting index number of the SyncBo object in the list; should 0 or greater
maxCount - the maximum number of SyncBo entities from the starting index to be retrieved
Returns:
a SyncBo Query instance for the specified SyncBoDescriptor, Condition and SortOrder attributes with a starting index and maximum count limit
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation

createQuery

public Query createQuery(SyncBoDescriptor syncBoDescriptor,
                         Condition condition,
                         SortOrder sortOrder,
                         int maxCount)
                  throws PersistenceException
Returns a Query instance for the specified SyncBoDescriptor, Condition and SortOrder objects with a max count limit

Parameters:
syncBoDescriptor - the SyncBoDescriptor of the SyncBos to be searched
sortOrder - the SortOrder instance; could be a single or multiple sort order fields
maxCount - the maximum number of SyncBo entities from the starting index to be retrieved
Returns:
a SyncBo Query instance for the specified SyncBoDescriptor, Condition and SortOrder attributes with a maximum count limit
Throws:
PersistenceException - is thrown if a persistent related error occured during the creation


Copyright © 2005 SAP AG. All Rights Reserved.