atg.process.filter
Class Filter

java.lang.Object
  extended by atg.process.filter.Filter
Direct Known Subclasses:
ExpressionFilter

public abstract class Filter
extends java.lang.Object

An abstract base class for all process filters.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static Filter FALSE
          Filter which represents false
static Filter TRUE
          Filter which represents true
 
Constructor Summary
Filter()
          Construct a new Filter.
 
Method Summary
static Filter andFilters(Filter[] pFilters)
          Returns a filter which is obtained by ANDing the filters in the given array.
static Filter andFilters(Filter pFilter1, Filter pFilter2)
          Returns a filter which is obtained by ANDing the two given filters.
 Filter assumeFalse(Filter pFalseFilter)
          Assumes that the given filter evaluates to FALSE, and tries to simplify this filter.
 Filter assumeTrue(Filter pTrueFilter)
          Assumes that the given filter evaluates to TRUE, and tries to simplify this filter.
 Query createProcessInstanceQuery(QueryBuilder pSubjectQueryBuilder, QueryBuilder pProcessInstanceQueryBuilder)
          Creates a repository query which can be used to find all the individual process instances that satisfy the filter.
 Query createSubjectQuery(QueryBuilder pSubjectQueryBuilder)
          Creates a repository query which can be used to find all the subjects that satisfy the filter.
protected abstract  Filter evaluate(ProcessExecutionContext pContext)
          Evaluates this filter in the given process execution context.
protected static java.util.ResourceBundle getResourceBundle()
          Returns our resource bundle.
 java.lang.String getSubjectType()
          If this filter has subject-related conditions any of which assume a particular subject type, returns that type.
 int hashCode()
          Returns the hash code.
 boolean implies(Filter pFilter)
          Returns true if this filter implies the given filter - that is, if this filter evaluates to TRUE, the given filter must also evaluate to TRUE.
 boolean isCacheable()
          Returns true if the result of evaluating this filter should be cached, false otherwise.
 Filter negate()
          Returns a filter which is obtained by negating this filter.
static Filter orFilters(Filter[] pFilters)
          Returns a filter which is obtained by ORing the filters in the given array.
static Filter orFilters(Filter pFilter1, Filter pFilter2)
          Returns a filter which is obtained by ORing the two given filters.
 void setCacheable(boolean pCacheable)
          Sets the flag indicating whether the result of evaluating this filter should be cached.
 Filter test(ProcessExecutionContext pContext)
          Calls evaluate on this filter, and returns one of the following values: Filter.TRUE - if evaluate returned Filter.TRUE Filter.FALSE - if evaluate returned Filter.FALSE or null this or another, simplified, Filter - in all other cases
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


TRUE

public static final Filter TRUE
Filter which represents true


FALSE

public static final Filter FALSE
Filter which represents false

Constructor Detail

Filter

public Filter()
Construct a new Filter.

Method Detail

getResourceBundle

protected static java.util.ResourceBundle getResourceBundle()
Returns our resource bundle.


isCacheable

public boolean isCacheable()
Returns true if the result of evaluating this filter should be cached, false otherwise.


setCacheable

public void setCacheable(boolean pCacheable)
Sets the flag indicating whether the result of evaluating this filter should be cached. The default is false.


evaluate

protected abstract Filter evaluate(ProcessExecutionContext pContext)
                            throws ProcessException
Evaluates this filter in the given process execution context. The context may not yet contain all of the information necessary to evaluate the filter - specifically, it may be missing the particular process instance and/or subject that the process is being executed on. If that is the case, the filter is evaluated as much as possible, and the simplified filter is returned.

The possible return values of this method are as follows:

Throws:
ProcessException - if there is a problem evaluating the filter (other than information missing from the context)

test

public Filter test(ProcessExecutionContext pContext)
            throws ProcessException
Calls evaluate on this filter, and returns one of the following values:

In other words, this method is different from evaluate only in that null values are treated instead as Filter.FALSE.

Throws:
ProcessException - if there is a problem evaluating the filter (other than information missing from the context)

getSubjectType

public java.lang.String getSubjectType()
                                throws ProcessException
If this filter has subject-related conditions any of which assume a particular subject type, returns that type. If the filter has no subject-related conditions, or if all such conditions apply to the base subject type, returns null.

The default implementation returns null.

Throws:
ProcessException - if there is a problem determining the subject type

createSubjectQuery

public Query createSubjectQuery(QueryBuilder pSubjectQueryBuilder)
                         throws RepositoryException,
                                ProcessException
Creates a repository query which can be used to find all the subjects that satisfy the filter. Returns null if no subjects can satisfy this filter.

This method will only be called on filters which have already been evaluated (by calling evaluate). Thus, the only subclasses which need to override this method are those which have conditions that contribute to the repository query (i.e., subject-related conditions). The default implementation throws a ProcessException.

Throws:
RepositoryException - if there is a repository problem constructing the query
ProcessException - if there is any other problem creating the query

createProcessInstanceQuery

public Query createProcessInstanceQuery(QueryBuilder pSubjectQueryBuilder,
                                        QueryBuilder pProcessInstanceQueryBuilder)
                                 throws RepositoryException,
                                        ProcessException
Creates a repository query which can be used to find all the individual process instances that satisfy the filter. Returns null if no process instances can satisfy this filter.

This method will only be called on filters which have already been evaluated (by calling evaluate). Thus, the only subclasses which need to override this method are those which have conditions that contribute to the repository query (i.e., subject- or process instance-related conditions). The default implementation throws a ProcessException.

Throws:
RepositoryException - if there is a repository problem constructing the query
ProcessException - if there is any other problem creating the query

andFilters

public static Filter andFilters(Filter pFilter1,
                                Filter pFilter2)
Returns a filter which is obtained by ANDing the two given filters.


andFilters

public static Filter andFilters(Filter[] pFilters)
Returns a filter which is obtained by ANDing the filters in the given array.


orFilters

public static Filter orFilters(Filter pFilter1,
                               Filter pFilter2)
Returns a filter which is obtained by ORing the two given filters.


orFilters

public static Filter orFilters(Filter[] pFilters)
Returns a filter which is obtained by ORing the filters in the given array.


negate

public Filter negate()
Returns a filter which is obtained by negating this filter.


assumeTrue

public Filter assumeTrue(Filter pTrueFilter)
Assumes that the given filter evaluates to TRUE, and tries to simplify this filter.


assumeFalse

public Filter assumeFalse(Filter pFalseFilter)
Assumes that the given filter evaluates to FALSE, and tries to simplify this filter.


implies

public boolean implies(Filter pFilter)
Returns true if this filter implies the given filter - that is, if this filter evaluates to TRUE, the given filter must also evaluate to TRUE. For example, this returns true if this filter is "(gender=Male)&(age=Young)" and the given filter is "age=Young."


hashCode

public int hashCode()
Returns the hash code.

Overrides:
hashCode in class java.lang.Object