Project Wonder 5.0

er.rest
Class ERXRestFetchSpecification<T extends com.webobjects.eocontrol.EOEnterpriseObject>

java.lang.Object
  extended by er.rest.ERXRestFetchSpecification<T>
Type Parameters:
T - the type of the objects being returned

public class ERXRestFetchSpecification<T extends com.webobjects.eocontrol.EOEnterpriseObject>
extends java.lang.Object

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

Nested Class Summary
static class ERXRestFetchSpecification.Results<T>
          Encapsulates the results of a fetch along with some fetch metadata.
 
Constructor Summary
ERXRestFetchSpecification(java.lang.String entityName, com.webobjects.eocontrol.EOQualifier defaultQualifier, com.webobjects.eocontrol.EOQualifier baseQualifier, ERXKeyFilter qualifierFilter, com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> defaultSortOrderings, int defaultBatchSize)
          Creates a new ERXRestFetchSpecification with a maximum batch size of 100 and with request qualifiers enabled.
ERXRestFetchSpecification(java.lang.String entityName, com.webobjects.eocontrol.EOQualifier defaultQualifier, com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> defaultSortOrderings)
          Creates a new ERXRestFetchSpecification with a maximum batch size of 100, but with batching turned off by default.
ERXRestFetchSpecification(java.lang.String entityName, com.webobjects.eocontrol.EOQualifier defaultQualifier, com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> defaultSortOrderings, int defaultBatchSize)
          Creates a new ERXRestFetchSpecification with a maximum batch size of 100.
 
Method Summary
 int batchNumber(com.webobjects.foundation.NSKeyValueCoding options)
          Returns the effective batch number.
 int batchSize(com.webobjects.foundation.NSKeyValueCoding options)
          Returns the effective batch size.
 int defaultBatchSize()
          Returns the default batch size (defaults to -1 = off).
 void enableRequestQualifiers(com.webobjects.eocontrol.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)
 java.lang.String entityName()
          Returns the name of the entity used in this fetch.
 int maxBatchSize()
          Returns the maximum batch size (defaults to 100).
 com.webobjects.foundation.NSArray<T> objects(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSKeyValueCoding options)
          Fetches the objects into the given editing context with the effective attributes of this fetch specification.
 com.webobjects.foundation.NSArray<T> objects(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.appserver.WORequest request)
          Fetches the objects into the given editing context with the effective attributes of this fetch specification.
 com.webobjects.foundation.NSArray<T> objects(com.webobjects.foundation.NSArray<T> objects, com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSKeyValueCoding options)
          Applies the effective attributes of this fetch specification to the given array, filtering, sorting, and cutting into batches accordingly.
 com.webobjects.foundation.NSArray<T> objects(com.webobjects.foundation.NSArray<T> objects, com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.appserver.WORequest request)
          Applies the effective attributes of this fetch specification to the given array, filtering, sorting, and cutting into batches accordingly.
 com.webobjects.eocontrol.EOQualifier qualifier(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSKeyValueCoding options)
          Returns the effective qualifier.
 com.webobjects.foundation.NSRange range(com.webobjects.foundation.NSKeyValueCoding options)
          Returns the range of this fetch.
 ERXRestFetchSpecification.Results<T> results(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSKeyValueCoding options)
          Fetches the objects into the given editing context with the effective attributes of this fetch specification.
 void setDefaultBatchSize(int defaultBatchSize)
          Sets the default batch size
 void setMaxBatchSize(int maxBatchSize)
          Sets the maximum batch size.
 com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSKeyValueCoding options)
          Returns the effective sort orderings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXRestFetchSpecification

public ERXRestFetchSpecification(java.lang.String entityName,
                                 com.webobjects.eocontrol.EOQualifier defaultQualifier,
                                 com.webobjects.foundation.NSArray<com.webobjects.eocontrol.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

public ERXRestFetchSpecification(java.lang.String entityName,
                                 com.webobjects.eocontrol.EOQualifier defaultQualifier,
                                 com.webobjects.foundation.NSArray<com.webobjects.eocontrol.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

public ERXRestFetchSpecification(java.lang.String entityName,
                                 com.webobjects.eocontrol.EOQualifier defaultQualifier,
                                 com.webobjects.eocontrol.EOQualifier baseQualifier,
                                 ERXKeyFilter qualifierFilter,
                                 com.webobjects.foundation.NSArray<com.webobjects.eocontrol.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)
Method Detail

entityName

public java.lang.String entityName()
Returns the name of the entity used in this fetch.

Returns:
the name of the entity used in this fetch

maxBatchSize

public int maxBatchSize()
Returns the maximum batch size (defaults to 100).

Returns:
the maximum batch size

setMaxBatchSize

public void setMaxBatchSize(int maxBatchSize)
Sets the maximum batch size.

Parameters:
maxBatchSize - the maximum batch size

defaultBatchSize

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

Returns:
the default batch size

setDefaultBatchSize

public void setDefaultBatchSize(int defaultBatchSize)
Sets the default batch size

Parameters:
defaultBatchSize - the default batch size

enableRequestQualifiers

public void enableRequestQualifiers(com.webobjects.eocontrol.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

sortOrderings

public com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                                                com.webobjects.foundation.NSKeyValueCoding options)
Returns the effective sort orderings.

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

qualifier

public com.webobjects.eocontrol.EOQualifier qualifier(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                      com.webobjects.foundation.NSKeyValueCoding options)
Returns the effective qualifier.

Parameters:
options - the current options
Returns:
the effective qualifier

batchNumber

public int batchNumber(com.webobjects.foundation.NSKeyValueCoding options)
Returns the effective batch number.

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

range

public com.webobjects.foundation.NSRange range(com.webobjects.foundation.NSKeyValueCoding options)
Returns the range of this fetch.

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

batchSize

public int batchSize(com.webobjects.foundation.NSKeyValueCoding options)
Returns the effective batch size.

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

results

public ERXRestFetchSpecification.Results<T> results(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                    com.webobjects.foundation.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

objects

public com.webobjects.foundation.NSArray<T> objects(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                    com.webobjects.foundation.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

objects

public com.webobjects.foundation.NSArray<T> objects(com.webobjects.foundation.NSArray<T> objects,
                                                    com.webobjects.eocontrol.EOEditingContext editingContext,
                                                    com.webobjects.foundation.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

objects

public com.webobjects.foundation.NSArray<T> objects(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                    com.webobjects.appserver.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

objects

public com.webobjects.foundation.NSArray<T> objects(com.webobjects.foundation.NSArray<T> objects,
                                                    com.webobjects.eocontrol.EOEditingContext editingContext,
                                                    com.webobjects.appserver.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

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.