JPDBManagerAction Class Reference

Database Manager Action pack all data and settings to perform some database operation. More...

#import <JPDBManagerAction.h>

List of all members.

Properties

NSString * entity
 The entity to perform this action.
NSString * fetchTemplate
 The Fetch Template to perform this action.
NSMutableDictionary * variablesListAndValues
 Values to replace on the pre formatted Fetch Template.
NSMutableArray * sortDescriptors
 Array of Sort Descriptors (NSSortDescriptor) to sort the result of this acion.
JPDBManagermanager
 Instance of the Manager to perform this Database Action.
BOOL commitTransaction
 Set if the Manager should commit this transaction immediatelly or not.
BOOL returnObjectsAsFault
 Define if the Result objects of some query should be as Core Data Fault.
BOOL ascendingOrder
 Define if the order of the results of some query should be Ascending or Descending.
BOOL returnActionAsArray
 Set if the Result of this action should be an NSArray or an NSFetchedResultsController object.

Init Methods

(id) + initWithManager:
 Init with an Database Manager to process this Database Action.
(id) - initWithManager:
 Init with an Database Manager to process this Database Action.

Set Query Limits

int startFetchInLine
 Set the initial row result to return from Query Methods results.
int limitFetchResults
 Set the maximum rows to return from Query Methods results.
(void) - setStartFetchInLine:setLimitFetchResults:
 Convenient method to set the startFetchInLine and limitFetchResults properties at the same time.
(void) - resetFetchLimits
 Reset the default Fetch Limits values.
(void) - resetDefaultValues
 Reset this Action Settings to default values.

Action Data Methods

(id) - applyEntity:
 Set an Entity to perform this action.
(id) - applyFetchTemplate:
 Set an Fetch Template name to perform this action.
(id) - applyFetchReplaceWithDictionary:
 Set the Values to replace on the pre formatted Fetch Template.
(id) - applyFetchReplaceWithVariables:
 Set the Values to replace on the pre formatted Fetch Template.
(id) - applyPredicate:
(id) - runAction
 Run this action on the associated JPDBManager Database Manager.

Order Keys Methods

(id) - applyArrayOfSortDescriptors:
 Set the Key attributes to sort the result of this acion.
(id) - applyOrderKeys:
 Set the Key attributes to sort the result of this acion.
(id) - applyOrderKey:
 Set the Key attribute to sort the result of this acion.
(id) - addOrderKey:
 Add a new Key attribute to sort the result of this action.
(void) - removeOrderKey:
 Remove an Key attribute from the sorter list.

Query All Data Methods

(id) - queryAllDataFromEntity:
 Query all data of the specified Entity.
(id) - queryAllDataFromEntity:orderWithKey:
 Query all data of the specified Entity.
(id) - queryAllDataFromEntity:orderWithKeys:
 Query all data of the specified Entity.

Query Data With Fetch Templates Methods

(id) - queryEntity:withFetchTemplate:
 Query specified Entity using one specified Fetch Template name.
(id) - queryEntity:withFetchTemplate:orderWithKey:
 Query specified Entity using one specified Fetch Template name.
(id) - queryEntity:withFetchTemplate:orderWithKeys:
 Query specified Entity using one specified Fetch Template name.

Query Data With Fetch Templates and Fetch Parameters Methods

(id) - queryEntity:withFetchTemplate:withVariables:
 Query specified Entity using one specified Fetch Template name.
(id) - queryEntity:withFetchTemplate:orderWithKey:withVariables:
 Query specified Entity using one specified Fetch Template name.
(id) - queryEntity:withFetchTemplate:replaceFetchWithDictionary:
 Query specified Entity using one specified Fetch Template name.
(id) - queryEntity:withFetchTemplate:replaceFetchWithDictionary:orderWithKey:
 Query specified Entity using one specified Fetch Template name.
(id) - queryEntity:withFetchTemplate:replaceFetchWithDictionary:orderWithKeys:
 Query specified Entity using one specified Fetch Template name.
(id) - queryEntity:withFetchTemplate:replaceFetchWithDictionary:arrayOfSortDescriptors:
 Query specified Entity using one specified Fetch Template name.
(id) - queryEntity:withFetchTemplate:replaceFetchWithDictionary:arrayOfSortDescriptors:customPredicate:

Query Data Methods With Custom Predicates

(id) - queryEntity:withPredicate:
 Query specified Entity using one custom NSPredicate Object.
(id) - queryEntity:withPredicate:orderWithKey:
 Query specified Entity using one custom NSPredicate Object.
(id) - queryEntity:withPredicate:orderWithKeys:
 Query specified Entity using one custom NSPredicate Object.
(id) - queryEntity:withPredicate:arrayOfSortDescriptors:
 Query specified Entity using one custom NSPredicate Object.

Remove Data Methods

(void) - deleteRecord:
 Delete specified Record from his Entity on the Database.
(void) - deleteRecord:andCommit:
 Delete specified Record from his Entity on the Database.
(void) - deleteRecordsFromEntity:withFetchTemplate:
 Delete all records queried by the specified Fetch Template.
(void) - deleteAllRecordsFromEntity:
 Delete all Records from specified Entity.

Write Data Methods

(id) - createNewRecordForEntity:
 Create and return a new record for specified Entity.

Detailed Description

Database Manager Action pack all data and settings to perform some database operation.

Database operations isn't called directy to the manager. Instead we create one instance of the JPDBManagerAction class, configure the data and settings to perform some CRUD operation and finally run this action. Yes, looks like a lot of work, but actually is not. Let's see some examples:

 id newRecord = [JPDatabaseManager createNewRecordForEntity:@"MyEntity"];

This is was really simple, isn't? Let's see this same operation on a more custom fashion:

 JPDBManagerAction *anAction = [[JPDBManagerSingleton sharedInstance] getDatabaseAction];
 [anAction setCommitTransaction:YES];
 id newRecord = [anAction createNewRecordForEntity:@"MyEntity"];

Well this looks a litle bit more complicated. Let's understand this two processes: The first one uses the JPDatabaseManager convenient macro shortcut that returns an JPDBManagerAction instance and perform this method in only one pass, is pure convenience. This macro is declared in the JPDBManagerDefinitions.h file.

The second way needs more steps, but you should use that way when you need more control of the all process, for example, you can configure if you want to automatically commit the operation or create some more dinamically code on your database operations.


Member Function Documentation

+ (id) initWithManager: (JPDBManager*)  anManager

Init with an Database Manager to process this Database Action.

Parameters:
anManagerAn Database Manager An autoreleseable instance.

Here is the caller graph for this function:

- (id) initWithManager: (JPDBManager *)  anManager

Init with an Database Manager to process this Database Action.

Parameters:
anManagerAn Database Manager An retained instance.
- (id) applyEntity: (NSString*)  anEntity

Set an Entity to perform this action.

Parameters:
anEntityNameThe Entity Name.
Returns:
Return itself.

Here is the caller graph for this function:

- (id) applyFetchTemplate: (NSString*)  anFetchTemplate

Set an Fetch Template name to perform this action.

Parameters:
anFetchRequestAn Fetch Template to perform the query.
Returns:
Return itself.
- (id) applyFetchReplaceWithDictionary: (NSDictionary*)  anDictionary

Set the Values to replace on the pre formatted Fetch Template.

Parameters:
anDictionaryAn Dictionary with Keys and Values to replace on the pre formatted Fetch Template
Returns:
Return itself.

Here is the caller graph for this function:

- (id) applyFetchReplaceWithVariables: (id)  variableList
,   NS_REQUIRES_NIL_TERMINATION 

Set the Values to replace on the pre formatted Fetch Template.

Parameters:
variableListKeys and Values to replace on the pre formatted Fetch Template.
Example:

 [anAction applyFetchReplaceWithVariables:@"value1", @"key1", @"value2", @"key2", nil];
Returns:
Return itself.

Here is the call graph for this function:

- (id) applyArrayOfSortDescriptors: (NSArray*)  anArray

Set the Key attributes to sort the result of this acion.

Parameters:
anArrayOfSortDescriptorsAn Array with defined NSSortDescriptors to sort the result.
Exceptions:
AnJPDBManagerActionException exception if the array contains an objects that doesn't is an NSSortDescriptors. See Handling Errors for more informations.
Returns:
Return itself.

Here is the caller graph for this function:

- (id) applyOrderKeys: (id)  listOfKeys
,   NS_REQUIRES_NIL_TERMINATION 

Set the Key attributes to sort the result of this acion.

Parameters:
listOfKeysAccept one or more Key Attributes to sort the result. Doesn't forget to terminate the list with an 'nil' token.
Returns:
Return itself.
Exceptions:
AnJPDBManagerActionException exception if the entity property isn't defined. See Handling Errors for more informations.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) applyOrderKey: (id)  anKey

Set the Key attribute to sort the result of this acion.

Parameters:
anKeyAn Key Attribute to sort the result.
Returns:
Return itself.
Exceptions:
AnJPDBManagerActionException exception if the entity property isn't defined. See Handling Errors for more informations.

Here is the call graph for this function:

- (id) addOrderKey: (id)  anKey

Add a new Key attribute to sort the result of this action.

Parameters:
anKeyAn Key Attribute to sort the result.
Returns:
Return itself.
Exceptions:
AnJPDBManagerActionException exception if the entity property isn't defined. See Handling Errors for more informations.
- (void) removeOrderKey: (id)  anKey

Remove an Key attribute from the sorter list.

Parameters:
anKeyAn Key Attribute to remove.
- (id) queryAllDataFromEntity: (NSString*)  anEntityName

Query all data of the specified Entity.

Parameters:
anEntityNameThe Entity Name.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

- (id) queryAllDataFromEntity: (NSString*)  anEntityName
orderWithKey: (id)  anKey 

Query all data of the specified Entity.

The #defaultOrderIsAscending property determines if is an Ascending or Descending order.

Parameters:
anEntityNameThe Entity Name.
anKeyOne Key attribute to sort the result.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

- (id) queryAllDataFromEntity: (NSString*)  anEntityName
orderWithKeys: (id)  listOfKeys
,   NS_REQUIRES_NIL_TERMINATION 

Query all data of the specified Entity.

Parameters:
anEntityNameThe Entity Name.
listOfKeysAccept one or more Key Attributes to sort the result. Doesn't forget to terminate the list with an 'nil' token.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName
orderWithKey: (id)  anKey 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
anKeyOne Key attribute to sort the result.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName
orderWithKeys: (id)  listOfKeys
,   NS_REQUIRES_NIL_TERMINATION 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
listOfKeysAccept one or more Key Attributes to sort the result. Doesn't forget to terminate the list with an 'nil' token.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName
withVariables: (id)  variableList
,   NS_REQUIRES_NIL_TERMINATION 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
variableListKeys and Values to replace on the pre formatted Fetch Template.
Example:

 [manager queryEntity:@"Entity" 
   withFetchTemplate:@"FetchAll"
       withVariables:@"value1", @"key1", @"value2", @"key2", nil];
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName
orderWithKey: (id)  anKey
withVariables: (id)  variableList
,   NS_REQUIRES_NIL_TERMINATION 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
anKeyOne Key attribute to sort the result.
variableListKeys and Values to replace on the pre formatted Fetch Template.
Example:

 [manager queryEntity:@"Entity" 
   withFetchTemplate:@"FetchAll"
        orderWithKey:@"id" 
       withVariables:@"value1", @"key1", @"value2", @"key2", nil];
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName
replaceFetchWithDictionary: (NSDictionary*)  variablesListAndValues 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
variablesListAndValuesAn Dictionary with Keys and Values to replace on the pre formatted Fetch Template.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName
replaceFetchWithDictionary: (NSDictionary*)  variablesListAndValues
orderWithKey: (id)  anKey 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
variablesListAndValuesAn Dictionary with Keys and Values to replace on the pre formatted Fetch Template.
anKeyOne Key attribute to sort the result.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName
replaceFetchWithDictionary: (NSDictionary*)  variablesListAndValues
orderWithKeys: (id)  listOfKeys
,   NS_REQUIRES_NIL_TERMINATION 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
variablesListAndValuesAn Dictionary with Keys and Values to replace on the pre formatted Fetch Template.
listOfKeysAccept one or more Key Attributes to sort the result. Doesn't forget to terminate the list with an 'nil' token.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName
replaceFetchWithDictionary: (NSDictionary*)  variablesListAndValues
arrayOfSortDescriptors: (NSArray*)  anArrayOfSortDescriptors 

Query specified Entity using one specified Fetch Template name.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.
variablesListAndValuesAn Dictionary with Keys and Values to replace on the pre formatted Fetch Template.
anArrayOfSortDescriptorsAn Array of Key attributes to sort the result.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withPredicate: (NSPredicate*)  anPredicate 

Query specified Entity using one custom NSPredicate Object.

Parameters:
anEntityNameThe Entity Name. @
anPredicateAn NSPredicate object defining the query.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withPredicate: (NSPredicate*)  anPredicate
orderWithKey: (id)  anKey 

Query specified Entity using one custom NSPredicate Object.

Parameters:
anEntityNameThe Entity Name.
anPredicateAn NSPredicate object defining the query.
anKeyOne Key attribute to sort the result.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withPredicate: (NSPredicate*)  anPredicate
orderWithKeys: (id)  listOfKeys
,   NS_REQUIRES_NIL_TERMINATION 

Query specified Entity using one custom NSPredicate Object.

Parameters:
anEntityNameThe Entity Name.
anPredicateAn NSPredicate object defining the query.
listOfKeysAccept one or more Key Attributes to sort the result. Doesn't forget to terminate the list with an 'nil' token.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) queryEntity: (NSString*)  anEntityName
withPredicate: (NSPredicate*)  anPredicate
arrayOfSortDescriptors: (NSArray*)  anArrayOfSortDescriptors 

Query specified Entity using one custom NSPredicate Object.

Parameters:
anEntityNameThe Entity Name.
anPredicateAn NSPredicate object defining the query.
anArrayOfSortDescriptorsAn Array of Key attributes to sort the result.
Returns:
One unordered collection with queried data Objects. The Class of this collection is setted by #returnQueryAsArray property.

Here is the caller graph for this function:

- (void) deleteRecord: (id)  anObject

Delete specified Record from his Entity on the Database.

This method will use the commitTransaction property to decide if commit automatically this change.

Parameters:
anObjectRecord object to delete.

Here is the call graph for this function:

- (void) deleteRecord: (id)  anObject
andCommit: (BOOL)  commit 

Delete specified Record from his Entity on the Database.

Parameters:
anObjectRecord object to delete.
commitSpecify if you want to commit or not this operation immediattelly.

Here is the caller graph for this function:

- (void) deleteRecordsFromEntity: (NSString*)  anEntityName
withFetchTemplate: (NSString*)  anFetchName 

Delete all records queried by the specified Fetch Template.

This method will use the commitTransaction property to decide if commit automatically this change.

Parameters:
anEntityNameThe Entity Name.
anFetchNameAn Fetch Template to perform the query.

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) deleteAllRecordsFromEntity: (NSString*)  anEntityName

Delete all Records from specified Entity.

This could be a consuming operation on large databases.

Parameters:
anEntityNameThe Entity Name.

Here is the call graph for this function:

- (id) createNewRecordForEntity: (NSString*)  anEntityName

Create and return a new record for specified Entity.

Parameters:
anEntityNameThe Entity Name.
Returns:
New empty Record.

Here is the call graph for this function:


Property Documentation

- (BOOL) commitTransaction [read, write, assign]

Set if the Manager should commit this transaction immediatelly or not.


Default value is NO.

- (BOOL) returnObjectsAsFault [read, write, assign]

Define if the Result objects of some query should be as Core Data Fault.

Default value is NO.

- (BOOL) ascendingOrder [read, write, assign]

Define if the order of the results of some query should be Ascending or Descending.

Note that by performance you should set this value before apply any Key sort attribute. You can do it after, but the manager will recreate every sort key again. Default value is YES.

- (BOOL) returnActionAsArray [read, write, assign]

Set if the Result of this action should be an NSArray or an NSFetchedResultsController object.


Default value is YES.

- (int) startFetchInLine [read, write, assign]

Set the initial row result to return from Query Methods results.

Combine this set with the limitFetchResults property.
Default value is 0.

- (int) limitFetchResults [read, write, assign]

Set the maximum rows to return from Query Methods results.

Combine this set with the startFetchInLine property.
Default value is 0, it means that all rows in the Entity will be retrieved.


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