com.scooterframework.orm.activerecord
Class AssociatedRecordsInCategory

java.lang.Object
  extended by com.scooterframework.orm.activerecord.AssociatedRecordsInCategory

public class AssociatedRecordsInCategory
extends java.lang.Object

AssociatedRecordsInCategory class contains a list of ActiveRecord objects and its owner for a category.


Field Summary
protected  boolean latestRecordsLoaded
           
 
Constructor Summary
AssociatedRecordsInCategory(ActiveRecord owner, java.lang.String category, java.lang.String type, boolean refresh)
          Owner record is the owner of the category association.
 
Method Summary
 AssociatedRecordsInCategory add(ActiveRecord record)
          Adds target record to the association.
 AssociatedRecordsInCategory add(ActiveRecord record, java.util.Map<java.lang.String,java.lang.Object> joinInput)
          Adds target record to the association.
 AssociatedRecordsInCategory add(java.util.List<? extends ActiveRecord> targets)
          Adds a list of target records to the association.
 AssociatedRecordsInCategory add(java.util.List<? extends ActiveRecord> targets, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> joinInputs)
          Adds a list of target records to the association.
 AssociatedRecordsInCategory delete(ActiveRecord target)
          Deletes target record from the association.
 AssociatedRecordsInCategory delete(java.util.List<? extends ActiveRecord> targets)
          Deletes a list of target records from the association.
 AssociatedRecordsInCategory detach(ActiveRecord target)
          Detaches target record from the association.
 AssociatedRecordsInCategory detach(ActiveRecord target, boolean keepJoinRecord)
          Detaches target record from the association.
 AssociatedRecordsInCategory detach(java.util.List<? extends ActiveRecord> targets)
          Detaches a list of target records from the association.
 AssociatedRecordsInCategory detach(java.util.List<? extends ActiveRecord> targets, boolean keepJoinRecord)
          Detaches a list of target records from the association.
 AssociatedRecords getAssociatedRecordsByType(java.lang.String type)
          Returns AssociatedRecords of a type.
 java.lang.String getCategory()
          Returns category.
 Category getCategoryInstance()
          Returns category instance.
 ActiveRecord getOwner()
          Returns owner of the association.
 ActiveRecord getRecord(java.lang.String type, int index)
          Returns a specific associated record at index from the list for a specific type.
 java.util.List<ActiveRecord> getRecords()
          Returns the associated records for all types.
 java.util.List<ActiveRecord> getRecords(boolean refresh)
          Returns the associated records of all types.
 java.util.List<ActiveRecord> getRecords(java.lang.String type)
          Returns the associated records of a particular type.
 java.util.List<ActiveRecord> getRecords(java.lang.String type, boolean refresh)
          Returns the associated records of a particular type.
 boolean isEmpty()
          Return true if this list contains no elements.
 int size()
          Returns the number of associated objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

latestRecordsLoaded

protected boolean latestRecordsLoaded
Constructor Detail

AssociatedRecordsInCategory

public AssociatedRecordsInCategory(ActiveRecord owner,
                                   java.lang.String category,
                                   java.lang.String type,
                                   boolean refresh)
Owner record is the owner of the category association. For example, Tag is owner of the taggable category, the center class of the category may be Tagging.class.

Parameters:
owner - owner record of the category
category - name of the category
type - specific record type in the category
refresh - true if retrieving data from database
Method Detail

getAssociatedRecordsByType

public AssociatedRecords getAssociatedRecordsByType(java.lang.String type)
Returns AssociatedRecords of a type.

Parameters:
type - type name in the category
Returns:
AssociatedRecords instance for the specific type

getRecord

public ActiveRecord getRecord(java.lang.String type,
                              int index)
Returns a specific associated record at index from the list for a specific type.

Parameters:
type - type name in the category
index - index position of the record
Returns:
an ActiveRecord instance at the index

getRecords

public java.util.List<ActiveRecord> getRecords()
Returns the associated records for all types.

Returns:
a list of ActiveRecord instances for all types

getRecords

public java.util.List<ActiveRecord> getRecords(boolean refresh)
Returns the associated records of all types.

Parameters:
refresh - true if database records are to be relaoded.
Returns:
a list of ActiveRecord instances for all types

getRecords

public java.util.List<ActiveRecord> getRecords(java.lang.String type)
Returns the associated records of a particular type.

Parameters:
type - type name in the category
Returns:
a list of ActiveRecord instances for the specific type

getRecords

public java.util.List<ActiveRecord> getRecords(java.lang.String type,
                                               boolean refresh)
Returns the associated records of a particular type.

Parameters:
type - type name in the category
Returns:
a list of ActiveRecord instances for the specific type

getOwner

public ActiveRecord getOwner()
Returns owner of the association.


getCategory

public java.lang.String getCategory()
Returns category.


getCategoryInstance

public Category getCategoryInstance()
Returns category instance.


isEmpty

public boolean isEmpty()
Return true if this list contains no elements.

Returns:
true if this list contains no elements.

size

public int size()
Returns the number of associated objects.

Returns:
the number of associated objects.

add

public AssociatedRecordsInCategory add(ActiveRecord record)
Adds target record to the association. This method simply delegates the request to a corresponding HMT association's add method.

Parameters:
record - a record to be added to the association.
Returns:
updated AssociatedRecordsInCategory

add

public AssociatedRecordsInCategory add(ActiveRecord record,
                                       java.util.Map<java.lang.String,java.lang.Object> joinInput)
Adds target record to the association. This method simply delegates the request to a corresponding HMT association's add method.

Parameters:
record - a record to be added to the association.
joinInput - A map of input data for the join record.
Returns:
updated AssociatedRecordsInCategory

add

public AssociatedRecordsInCategory add(java.util.List<? extends ActiveRecord> targets)
Adds a list of target records to the association. This method simply delegates the request to a corresponding HMT association's add method.

Parameters:
targets - a list of target record to be added to the association.
Returns:
updated AssociatedRecordsInCategory

add

public AssociatedRecordsInCategory add(java.util.List<? extends ActiveRecord> targets,
                                       java.util.List<java.util.Map<java.lang.String,java.lang.Object>> joinInputs)
Adds a list of target records to the association. This method simply delegates the request to a corresponding HMT association's add method.

Parameters:
targets - a list of target record to be added to the association.
joinInputs - a list of input data map for the through table.
Returns:
updated AssociatedRecordsInCategory

delete

public AssociatedRecordsInCategory delete(ActiveRecord target)
Deletes target record from the association. This method simply delegates the request to a corresponding HMT association's delete method.

Parameters:
target - a record to be deleted from the association.
Returns:
updated AssociatedRecordsInCategory

delete

public AssociatedRecordsInCategory delete(java.util.List<? extends ActiveRecord> targets)
Deletes a list of target records from the association. This method simply delegates the request to a corresponding HMT association's delete method.

Parameters:
targets - a list of target record to be deleted from the association.
Returns:
updated AssociatedRecordsInCategory

detach

public AssociatedRecordsInCategory detach(ActiveRecord target)
Detaches target record from the association. This method simply delegates the request to a corresponding HMT association's detach method.

Parameters:
target - a record to be detached from the association.
Returns:
updated AssociatedRecordsInCategory

detach

public AssociatedRecordsInCategory detach(ActiveRecord target,
                                          boolean keepJoinRecord)
Detaches target record from the association. This method simply delegates the request to a corresponding HMT association's detach method.

Parameters:
target - a record to be detached from the association.
keepJoinRecord - if true, keep the join record. Otherwise, delete it.
Returns:
updated AssociatedRecordsInCategory

detach

public AssociatedRecordsInCategory detach(java.util.List<? extends ActiveRecord> targets)
Detaches a list of target records from the association. This method simply delegates the request to a corresponding HMT association's detach method.

Parameters:
targets - a list of target record to be deleted from the association.
Returns:
updated AssociatedRecordsInCategory

detach

public AssociatedRecordsInCategory detach(java.util.List<? extends ActiveRecord> targets,
                                          boolean keepJoinRecord)
Detaches a list of target records from the association. This method simply delegates the request to a corresponding HMT association's detach method.

Parameters:
targets - a list of target record to be deleted from the association.
keepJoinRecord - if true, keep the join record. Otherwise, delete it.
Returns:
updated AssociatedRecordsInCategory