org.jlf.dataMap
Class CRUDDataMapper

java.lang.Object
  |
  +--org.jlf.dataMap.DataMapper
        |
        +--org.jlf.dataMap.CRUDDataMapper
Direct Known Subclasses:
JDBCDataMapper

public abstract class CRUDDataMapper
extends DataMapper

This class is used as the base of all data mapping mechanisms that can do full CRUD (Create, Read, Update, Delete) in the data mapping framework. Some mechanisms (like XML to a file) don't support update/delete, just create/write, and this won't need this class.

See Also:
DataLocation, DataMappedObject, DataMapper

Field Summary
protected  java.util.Vector postCommitUpdateObjects
          Holds a collection of objects used to do post-commit updates.
 
Fields inherited from class org.jlf.dataMap.DataMapper
dataArray, dataLocation
 
Constructor Summary
CRUDDataMapper()
          Allow the default constructor, please use a parameterized constructor!
CRUDDataMapper(DataLocation dataLocation)
          Constructs a new data mapper which references back to the DataLocation who created it.
 
Method Summary
protected  void addPostCommitUpdate(DataMappedObject dmo)
          Adds a data mapped object to a collection of objects to be updated after a successful commit to the data sink.
 void commitWrites()
          Updates objects in the postCommitUpdateObjects collection after a successful commit.
abstract  void create(DataMappedObject dmo, Relationship relationship)
          This method is an abstract method that must be overridden to support object creation in the data location.
abstract  void delete(DataMappedObject dmo, Relationship relationship)
          This method is an abstract method that must be overridden to support deletions of an object already created in the data location.
abstract  void update(DataMappedObject dmo, Relationship relationship)
          This method is an abstract method that must be overridden to support updates to objects already existing in the data location.
 void write(DataMappedObject dmo, Relationship relationship)
          This method is an abstract method for the purpose of writing a data mapped object, potentially in the context of a relationship, to a data store.
 void writeWithoutCascade(DataMappedObject dmo, Relationship relationship)
          Helper method to split up the write of an object to the correct create, update, or delete method.
 
Methods inherited from class org.jlf.dataMap.DataMapper
close, findBySearchCriteria, findDataAttributeForReplacementString, getCascadedRelationships, getDataLocation, replaceAttributeParameters, rollbackWrites, setDataLocation, stringForDataAttributeReplacement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

postCommitUpdateObjects

protected java.util.Vector postCommitUpdateObjects
Holds a collection of objects used to do post-commit updates. When an object is written/committed to the data store, we need to reset its object attributes to reflect that fact, so the same object update doesn't get written to two different transaction updates.

Constructor Detail

CRUDDataMapper

public CRUDDataMapper()
Allow the default constructor, please use a parameterized constructor!


CRUDDataMapper

public CRUDDataMapper(DataLocation dataLocation)
Constructs a new data mapper which references back to the DataLocation who created it.

Method Detail

addPostCommitUpdate

protected void addPostCommitUpdate(DataMappedObject dmo)
Adds a data mapped object to a collection of objects to be updated after a successful commit to the data sink.


commitWrites

public void commitWrites()
Updates objects in the postCommitUpdateObjects collection after a successful commit. This method should be called as a super call from subclasses after everything goes well in a commit to the specific data sink.

Specified by:
commitWrites in class DataMapper

write

public void write(DataMappedObject dmo,
                  Relationship relationship)
This method is an abstract method for the purpose of writing a data mapped object, potentially in the context of a relationship, to a data store.

This method cascades relationships if identified by the mapping properties file.

The relationship can be null if not in context of a relationship.

Specified by:
write in class DataMapper

writeWithoutCascade

public void writeWithoutCascade(DataMappedObject dmo,
                                Relationship relationship)
Helper method to split up the write of an object to the correct create, update, or delete method.

The relationship can be null if not in context of a relationship.


create

public abstract void create(DataMappedObject dmo,
                            Relationship relationship)
This method is an abstract method that must be overridden to support object creation in the data location.


update

public abstract void update(DataMappedObject dmo,
                            Relationship relationship)
This method is an abstract method that must be overridden to support updates to objects already existing in the data location.


delete

public abstract void delete(DataMappedObject dmo,
                            Relationship relationship)
This method is an abstract method that must be overridden to support deletions of an object already created in the data location.