com.sap.caf.rt.bol.util

Class QueryFilterFactory

java.lang.Object
  extended by com.sap.caf.rt.bol.util.QueryFilterFactory

public class QueryFilterFactory
extends Object

This class is a factory for creating instances of QueryFilter.


Field Summary
static String BO_NODE_REFERENCE_PATH_SEPARATOR
          A separator for attributes that are from an associated BO Node.
static String NESTED_STRUCTURE_PATH_SEPARATOR
          A separator for attributes that are part of a complex structure.
 
Constructor Summary
QueryFilterFactory()
           
 
Method Summary
static QueryFilter createBoolOperator(String type)
          Deprecated. 
static QueryFilter createBracket(String type)
          Deprecated. 
static QueryFilter createDateFilter(Condition condition, Date value, String name)
          Deprecated. 
static QueryFilter createFilter(Condition condition, Object value)
          Creates a QueryFilter with a given condition.
static QueryFilter createFilter(Object value)
          Creates a QueryFilter for a given search value.
static QueryFilter createFilter(Object value, Condition condition)
          Deprecated. 
static QueryFilter createFilter(String attributeSpec, Condition condition, Object value)
          Creates a QueryFilter suitable for the findByMultipleParameters operation.
static QueryFilter createFilterForBetween(Object valueLow, Object valueHigh)
          Creates a QueryFilter for searching in a range.
static QueryFilter createFilterForBetween(String attributeSpec, Object valueLow, Object valueHigh)
          Creates a QueryFilter for searching in a range.
static QueryFilter createFreetextFilter(String action, String value)
          Deprecated. 
static QueryFilter createNumericFilter(Condition condition, int value, String name, boolean bAttribute)
          Deprecated. 
static QueryFilter createQueryFilter()
          Creates an empty query filter.
static QueryFilter createStringFilter(String action, String value, String name, boolean bAttribute)
          Deprecated. 
static QueryFilter getQueryFilter(Object value)
          Deprecated. 
static Object nullToWildcard(Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BO_NODE_REFERENCE_PATH_SEPARATOR

public static final String BO_NODE_REFERENCE_PATH_SEPARATOR
A separator for attributes that are from an associated BO Node.

See Also:
Constant Field Values

NESTED_STRUCTURE_PATH_SEPARATOR

public static final String NESTED_STRUCTURE_PATH_SEPARATOR
A separator for attributes that are part of a complex structure.

See Also:
Constant Field Values
Constructor Detail

QueryFilterFactory

public QueryFilterFactory()
Method Detail

createQueryFilter

public static QueryFilter createQueryFilter()
Creates an empty query filter.

Returns:
an empty query filter

getQueryFilter

@Deprecated
public static QueryFilter getQueryFilter(Object value)
Deprecated. 

Creates a QueryFilter for a given search value. The condition for the returned instance is Condition.EQ. This method is suitable for creating query filters for defined by the application developer "findByXXX" methods but not for the findByMultipleParameters method. For the latter you can use #createFilter(String attributePath, String condition, Object value) or createFilterForBetween(String attributeSpec, Object valueLow, Object valueHigh). This method is deprecated, use createFilter(Object) instead.

Parameters:
value - the following values have some special semantics:
  • null - the search clause will be "IS NULL"
  • String - the '*' char is treated as a wildcard chararacter. If an empty string is supplied then the return filter will be a fake filter (no constraints will be imposed by it).
Returns:
a QueryFilter instance to represent an equality constraint for the given value
See Also:
Condition

createFilterForBetween

public static QueryFilter createFilterForBetween(Object valueLow,
                                                 Object valueHigh)
Creates a QueryFilter for searching in a range.

Parameters:
valueLow - the start of the search range
valueHigh - the end of the search range
Returns:
a QueryFilter instance for the given parameters

createFilter

@Deprecated
public static QueryFilter createFilter(Object value,
                                                  Condition condition)
Deprecated. 

Creates a QueryFilter with a given condition. This method is deprecated because of inconsistent order of parameters with createFilter(String, Condition, Object), use createFilter(Condition, Object) instead.

Parameters:
value - the search value
condition - a value from the Condition enumeration
Returns:
a QueryFilter instance for the given parameters

createFilter

public static QueryFilter createFilter(Condition condition,
                                       Object value)
Creates a QueryFilter with a given condition.

Parameters:
condition - a value from the Condition enumeration
value - the search value
Returns:
a QueryFilter instance for the given parameters

createFilter

public static QueryFilter createFilter(Object value)
Creates a QueryFilter for a given search value. The condition for the returned instance is Condition.EQ. This method is suitable for creating query filters for defined by the application developer "findByXXX" methods but not for the findByMultipleParameters method. For the latter you can use #createFilter(String attributePath, String condition, Object value) or createFilterForBetween(String attributeSpec, Object valueLow, Object valueHigh).

Parameters:
value - the following values have some special semantics:
  • null - the search clause will be "IS NULL"
  • StringThe '*' char is treated as a wildcard chararacter. If an empty string is supplied then the return filter will be a fake filter (no constraints will be imposed by it).
Returns:
a QueryFilter instance to represent an equality constraint for the given value
See Also:
Condition}

createNumericFilter

@Deprecated
public static QueryFilter createNumericFilter(Condition condition,
                                                         int value,
                                                         String name,
                                                         boolean bAttribute)
Deprecated. 

Creates a QueryFilter for searching in a TREX system. It cannot be used for local persistency queries.

Parameters:
condition - the condition for this filter; see the constants QueryFilter.CONDITION_* for the possible values
value - the search value
name - the name of the attribute or category; complex attributes have to be named like "name_of_comlex_attribute.name_of_attribute"
bAttribute - true if name is an attribute, false if it is a category
Returns:
a QueryFilter instance for the given parameters

createStringFilter

@Deprecated
public static QueryFilter createStringFilter(String action,
                                                        String value,
                                                        String name,
                                                        boolean bAttribute)
Deprecated. 

Creates a QueryFilter for searching in a TREX system. It cannot be used for local persistency queries. There are several opportunities for the type of the search: an exact search, a wilcard search or a fuzzy search.

Parameters:
action - the type of the search that should be performed; see the constants QueryFilter.ACTION_* for the possible values
value - the search value; may contain wildcards (for all the possible values, please check the TREX documentation)
name - the name of the attribute or category; complex attributes have to be named like "name_of_comlex_attribute.name_of_attribute"
bAttribute - true if name is an attribute, false if it is a category
Returns:
a QueryFilter instance for the given parameters

createFreetextFilter

@Deprecated
public static QueryFilter createFreetextFilter(String action,
                                                          String value)
Deprecated. 

Creates a QueryFilter for searching in a TREX system. It cannot be used for local persistency queries. The created query filter will be used to perform a freetext search over all of the attributes of a BO Node.

Parameters:
action - the type of the search that should be performed; see the constants QueryFilter.ACTION_* for the possible values
value - the search value; may contain wildcards (for all the possible values, please check the TREX documentation)
Returns:
a QueryFilter instance for the given parameters

createDateFilter

@Deprecated
public static QueryFilter createDateFilter(Condition condition,
                                                      Date value,
                                                      String name)
Deprecated. 

Creates a QueryFilter for searching in a TREX system. It cannot be used for local persistency queries. This method is used to create a filter on a numeric attribute or a category of a BO Node. For expressions on date attributes you have to keep in mind that a java.util.Date represents a timestamp which is a time measured in milliseconds. So, for example, if you want to search for objects that have been created at a specific day, you have to define a query which contains two date filters that are combined by an AND-operator. The first timestamp points to the day you want to search for at 0:00 AM. The second timestamp represents 0:00 AM at the next day.

Parameters:
condition - a value from the Condition enumeration
value - the search date value
name - the name of the attribute or category
Returns:
a QueryFilter instance for the given parameters

createBracket

@Deprecated
public static QueryFilter createBracket(String type)
Deprecated. 

Creates a bracket which can be part of a query. This method is used in order to prepare a search clause for the findByMultipleParameters method. You may use QueryFilter.OPEN_BRACKET and QueryFilter.CLOSE_BRACKET instead of this method.

Parameters:
type - the type of the bracket; see the constants QueryFilter.OPERATION_BRACKET_* for the possible values
Returns:
a QueryFilter instance for the given parameters

createBoolOperator

@Deprecated
public static QueryFilter createBoolOperator(String type)
Deprecated. 

Creates a boolean operator which can be used to combine expressions. You may use QueryFilter.AND, QueryFilter.OR and QueryFilter.NOT instead of this method.

Parameters:
type - the type of the operator; see the constants QueryFilter.OPERATION_* for the possible values
Returns:
a QueryFilter instance for the given parameters

createFilter

public static QueryFilter createFilter(String attributeSpec,
                                       Condition condition,
                                       Object value)
Creates a QueryFilter suitable for the findByMultipleParameters operation.

Parameters:
attributeSpec - This is the full path of the queried attribute. The attribute path is a sequence of attribute names of BO Nodes or complex structures, separated by BO_NODE_REFERENCE_PATH_SEPARATOR or NESTED_STRUCTURE_PATH_SEPARATOR.
Example: given the domain model:
  Complex structure "Address" with fields:
      "country" : STRING
      "streetName" : STRING 
         
  BO Nodes:
      BO: Department with field: 
         "name" : STRING
      BO: Employee with fields:
         "firstName" : STRING
         "lastName" : STRING
         "address" : Address    
  Associations:
         "employees" - unidirectional one-to-many association from Department to Employee
 
The following attribute paths can be formed for the BO Node Department (meaning that the query will search for Departments while satisfying the search conditions):
"name" - refers to the name of the Department
"employees.firstName" - refers to the "firstName" attribute of any employee in this department (only departments that have at least one Employee with given first name
"employees.address#streetName" - refers to the "streetName" attribute of any employee that works in the department
condition - a value from the Condition enumeration
value - the search value
Returns:
a QueryFilter instance for the given parameters

createFilterForBetween

public static QueryFilter createFilterForBetween(String attributeSpec,
                                                 Object valueLow,
                                                 Object valueHigh)
Creates a QueryFilter for searching in a range.

Parameters:
attributeSpec - see createFilter(String, Condition, Object) for more information
valueLow - the start of the search range
valueHigh - the end of the search range
Returns:
a QueryFilter instance for the given parameters
See Also:
createFilter(String, Condition, Object)

nullToWildcard

public static Object nullToWildcard(Object value)


Copyright 2009 SAP AG Complete Copyright Notice