ERXRestFetchSpecification< T extends EOEnterpriseObject > Class Reference

Collaboration diagram for ERXRestFetchSpecification< T extends EOEnterpriseObject >:

Collaboration graph
[legend]

List of all members.

Classes

class  Results< T >

Public Member Functions

int batchNumber (NSKeyValueCoding options)
int batchSize (NSKeyValueCoding options)
int defaultBatchSize ()
void enableRequestQualifiers (EOQualifier baseQualifier, ERXKeyFilter qualifierFilter)
String entityName ()
 ERXRestFetchSpecification (String entityName, EOQualifier defaultQualifier, EOQualifier baseQualifier, ERXKeyFilter qualifierFilter, NSArray< EOSortOrdering > defaultSortOrderings, int defaultBatchSize)
 ERXRestFetchSpecification (String entityName, EOQualifier defaultQualifier, NSArray< EOSortOrdering > defaultSortOrderings, int defaultBatchSize)
 ERXRestFetchSpecification (String entityName, EOQualifier defaultQualifier, NSArray< EOSortOrdering > defaultSortOrderings)
int maxBatchSize ()
NSArray< T > objects (NSArray< T > objects, EOEditingContext editingContext, WORequest request)
NSArray< T > objects (EOEditingContext editingContext, WORequest request)
NSArray< T > objects (NSArray< T > objects, EOEditingContext editingContext, NSKeyValueCoding options)
NSArray< T > objects (EOEditingContext editingContext, NSKeyValueCoding options)
EOQualifier qualifier (EOEditingContext editingContext, NSKeyValueCoding options)
NSRange range (NSKeyValueCoding options)
Results< T > results (EOEditingContext editingContext, NSKeyValueCoding options)
void setDefaultBatchSize (int defaultBatchSize)
void setMaxBatchSize (int maxBatchSize)
NSArray< EOSortOrdering > sortOrderings (EOEditingContext editingContext, NSKeyValueCoding options)

Private Attributes

EOQualifier _baseQualifier
int _defaultBatchSize
EOQualifier _defaultQualifier
NSArray< EOSortOrdering > _defaultSortOrderings
String _entityName
int _maxBatchSize
ERXKeyFilter _qualifierFilter
boolean _requestQualifiersEnabled

Static Private Attributes

static final Pattern _rangePattern = Pattern.compile("items=(.*)-(.*)")


Detailed Description

ERXRestFetchSpecification provides a wrapper around fetching objects with batching, sort orderings, and (optionally) qualifiers configured in the WORequest.

Example query string parameters:

Because request EOQualifiers could possibly pose a security risk, you must explicitly enable request qualifiers by calling enableRequestQualifiers(baseQualifier) or by using the longer constructor that takes an optional base qualifier. A base qualifier is prepended (AND'd) to whatever qualifier is passed on the query string to restrict the results of the user's query.

An example use:

 public WOActionResults indexAction() throws Throwable {
 	ERXRestFetchSpecification<Task> fetchSpec = new ERXRestFetchSpecification<Task>(Task.ENTITY_NAME, null, null, queryFilter(), Task.CREATION_DATE.descs(), 25);
 	NSArray<Task> tasks = fetchSpec.objects(editingContext(), options());
 	return response(editingContext(), Task.ENTITY_NAME, tasks, showFilter());
 }
 

In this example, we are fetching the "Task" entity, sorted by creation date, with a default batch size of 25, and with request qualifiers enable (meaning, we allow users to pass in a qualifier in the query string), filtering the qualifier with the ERXKeyFilter returned by the queryFilter() method. We then fetch the resulting tasks and return the response to the user.

Author:
mschrag
Parameters:
<T> the type of the objects being returned

Constructor & Destructor Documentation

ERXRestFetchSpecification ( String  entityName,
EOQualifier  defaultQualifier,
NSArray< EOSortOrdering >  defaultSortOrderings 
)

Creates a new ERXRestFetchSpecification with a maximum batch size of 100, but with batching turned off by default.

Parameters:
entityName the name of the entity being fetched
defaultQualifier the default qualifiers (if none are specified in the request)
defaultSortOrderings the default sort orderings (if none are specified in the request)

ERXRestFetchSpecification ( String  entityName,
EOQualifier  defaultQualifier,
NSArray< EOSortOrdering >  defaultSortOrderings,
int  defaultBatchSize 
)

Creates a new ERXRestFetchSpecification with a maximum batch size of 100. default.

Parameters:
entityName the name of the entity being fetched
defaultQualifier the default qualifiers (if none are specified in the request)
defaultSortOrderings the default sort orderings (if none are specified in the request)
defaultBatchSize the default batch size (-1 to disable)

ERXRestFetchSpecification ( String  entityName,
EOQualifier  defaultQualifier,
EOQualifier  baseQualifier,
ERXKeyFilter  qualifierFilter,
NSArray< EOSortOrdering >  defaultSortOrderings,
int  defaultBatchSize 
)

Creates a new ERXRestFetchSpecification with a maximum batch size of 100 and with request qualifiers enabled. default.

Parameters:
entityName the name of the entity being fetched
defaultQualifier the default qualifiers (if none are specified in the request)
baseQualifier the base qualifier (see enableRequestQualifiers)
qualifierFilter the key filter to apply against the query qualifier
defaultSortOrderings the default sort orderings (if none are specified in the request)
defaultBatchSize the default batch size (-1 to disable)


Member Function Documentation

int batchNumber ( NSKeyValueCoding  options  ) 

Returns the effective batch number.

Parameters:
options the current options
Returns:
the effective batch number

int batchSize ( NSKeyValueCoding  options  ) 

Returns the effective batch size.

Parameters:
options the current options
Returns:
the effective batch size

int defaultBatchSize (  ) 

Returns the default batch size (defaults to -1 = off).

Returns:
the default batch size

void enableRequestQualifiers ( EOQualifier  baseQualifier,
ERXKeyFilter  qualifierFilter 
)

Enables qualifiers in the request, but will be AND'd to the given base qualifier (in case you need to perform security restrictions)

Parameters:
baseQualifier the base qualifier to and with
qualifierFilter the key filter to apply against the query qualifier

String entityName (  ) 

Returns the name of the entity used in this fetch.

Returns:
the name of the entity used in this fetch

int maxBatchSize (  ) 

Returns the maximum batch size (defaults to 100).

Returns:
the maximum batch size

NSArray<T> objects ( NSArray< T >  objects,
EOEditingContext  editingContext,
WORequest  request 
)

Applies the effective attributes of this fetch specification to the given array, filtering, sorting, and cutting into batches accordingly.

Parameters:
objects the objects to filter
editingContext the editing context to evaluate the qualifer filter with
request the current request
Returns:
the filtered objects

NSArray<T> objects ( EOEditingContext  editingContext,
WORequest  request 
)

Fetches the objects into the given editing context with the effective attributes of this fetch specification.

Parameters:
editingContext the editing context to fetch into
request the current request
Returns:
the fetch objects

NSArray<T> objects ( NSArray< T >  objects,
EOEditingContext  editingContext,
NSKeyValueCoding  options 
)

Applies the effective attributes of this fetch specification to the given array, filtering, sorting, and cutting into batches accordingly.

Parameters:
objects the objects to filter
editingContext the editing context to evaluate the qualifer filter with
options the current options
Returns:
the filtered objects

NSArray<T> objects ( EOEditingContext  editingContext,
NSKeyValueCoding  options 
)

Fetches the objects into the given editing context with the effective attributes of this fetch specification.

Parameters:
editingContext the editing context to fetch into
options the current options
Returns:
the fetch objects

EOQualifier qualifier ( EOEditingContext  editingContext,
NSKeyValueCoding  options 
)

Returns the effective qualifier.

Parameters:
options the current options
Returns:
the effective qualifier

NSRange range ( NSKeyValueCoding  options  ) 

Returns the range of this fetch.

Parameters:
options the current options
Returns:
the effective batch number

Results<T> results ( EOEditingContext  editingContext,
NSKeyValueCoding  options 
)

Fetches the objects into the given editing context with the effective attributes of this fetch specification.

Parameters:
editingContext the editing context to fetch into
options the current options
Returns:
the fetch objects

void setDefaultBatchSize ( int  defaultBatchSize  ) 

Sets the default batch size

Parameters:
defaultBatchSize the default batch size

void setMaxBatchSize ( int  maxBatchSize  ) 

Sets the maximum batch size.

Parameters:
maxBatchSize the maximum batch size

NSArray<EOSortOrdering> sortOrderings ( EOEditingContext  editingContext,
NSKeyValueCoding  options 
)

Returns the effective sort orderings.

Parameters:
options the current options
Returns:
the effective sort orderings


Member Data Documentation

EOQualifier _baseQualifier [private]

int _defaultBatchSize [private]

EOQualifier _defaultQualifier [private]

NSArray<EOSortOrdering> _defaultSortOrderings [private]

String _entityName [private]

int _maxBatchSize [private]

final Pattern _rangePattern = Pattern.compile("items=(.*)-(.*)") [static, private]

boolean _requestQualifiersEnabled [private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:27 2012 for Project Wonder by  doxygen 1.5.8