bill.util.persist
Class EntityDataConfig

java.lang.Object
  |
  +--bill.util.persist.EntityData
        |
        +--bill.util.persist.EntityDataConfig

public abstract class EntityDataConfig
extends EntityData

This class is used to define an entity and to manipulate the entity in the persistent store. This class uses a PersistConfiguration object as it's persistent store.


Fields inherited from class bill.util.persist.EntityData
_collectionInfo, _collections, _elements, _entityName, _keys, _state, ET_BOOLEAN, ET_DOUBLE, ET_INTEGER, ET_LONG, ET_OID, ET_REAL, ET_STRING
 
Constructor Summary
EntityDataConfig()
          Creator based on the name of the entity.
EntityDataConfig(String entityName)
          Creator based on the name of the entity.
EntityDataConfig(String entityName, Hashtable keyValues)
          Creator based on the name of the entity and the key elements' values.
 
Method Summary
protected  void deleteConfigEntry()
          Deletes an existing configuration entry in the configuration file.
protected  void deleteConfigEntry(boolean nullFileNameOK)
          Deletes an existing configuration entry in the configuration file.
 String getCollectionClassName()
          Returns the class name of the EntityCollection class associated with this class.
protected  void insertConfigEntry()
          Inserts a new configuration entry into the configuration file.
protected  void insertConfigEntry(boolean nullFileNameOK)
          Inserts a new configuration entry into the configuration file.
 void retrieve(Hashtable keyValues)
          Retrieves an entity from the database that is keyed by the given key values.
 int save()
          Controls the updating of the persistent store with the entity's information.
 int save(boolean nullFileNameOK)
          Controls the updating of the persistent store with the entity's information.
 void setValues(ConfigurationSection entitySection)
          Populates the entity's element values from a configuration section.
protected  void updateConfigEntry()
          Updates an existing configuration entry in the configuration file.
protected  void updateConfigEntry(boolean nullFileNameOK)
          Updates an existing configuration entry in the configuration file.
 
Methods inherited from class bill.util.persist.EntityData
addElement, containsElement, getCollection, getElement, getElements, getElementValue, getEntityName, getKey, identifyElements, identifyKeyElement, identifyRequiredElement, instantiateCollection, isDeleted, isModified, isNew, registerOneToManyCollection, setClean, setDeleted, setElementValue, setElementValues, setEntityName, setModified, setNew, toString, userValidate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntityDataConfig

public EntityDataConfig()
Creator based on the name of the entity. Populates and defaults class instance variables. The user must call setEntityName before being able to do much with an object created with this creator.

EntityDataConfig

public EntityDataConfig(String entityName)
Creator based on the name of the entity. Populates and defaults class instance variables.
Parameters:
entityName - The name of the entity.

EntityDataConfig

public EntityDataConfig(String entityName,
                        Hashtable keyValues)
                 throws PersistException
Creator based on the name of the entity and the key elements' values. Populates and defaults class instance variables, the populates the entity's element values from the persistent data store.
Parameters:
entityName - The name of the entity.
keyValues - The key element's values. Keyed by the element's logical name, result is the element's value.
Throws:
PersistException - If a fatal error occurs that causes us to not be able to perform the retrieval. In our case this would be a ConfigurationException of some sort.
Method Detail

setValues

public void setValues(ConfigurationSection entitySection)
               throws PersistException
Populates the entity's element values from a configuration section.
Parameters:
entitySection - The configuration section to use in populating the entity.
Throws:
PersistException - If a fatal error occurs that causes us to not be able to extract the configuration section's data.

insertConfigEntry

protected void insertConfigEntry()
                          throws PersistException
Inserts a new configuration entry into the configuration file. This is done by looping through all the registered elements and their values and adding them to the file.
Throws:
PersistException - Thrown when the section to be inserted already exists.

insertConfigEntry

protected void insertConfigEntry(boolean nullFileNameOK)
                          throws PersistException
Inserts a new configuration entry into the configuration file. This is done by looping through all the registered elements and their values and adding them to the file.
Parameters:
nullFileNameOK - Indicates if we should throw an exception when the configuration file has no file name associated with it. A value of true indicates we should not throw an exception, false indicates we should.
Throws:
PersistException - Thrown when the section to be inserted already exists.

updateConfigEntry

protected void updateConfigEntry()
                          throws PersistException
Updates an existing configuration entry in the configuration file. This is done by looping through all the registered elements and their values and building the SQL string using these values.
Throws:
PersistException - Thrown when the section to be updated does not exist.

updateConfigEntry

protected void updateConfigEntry(boolean nullFileNameOK)
                          throws PersistException
Updates an existing configuration entry in the configuration file. This is done by looping through all the registered elements and their values and building the SQL string using these values.
Parameters:
nullFileNameOK - Indicates if we should throw an exception when the configuration file has no file name associated with it. A value of true indicates we should not throw an exception, false indicates we should.
Throws:
PersistException - Thrown when the section to be updated does not exist.

deleteConfigEntry

protected void deleteConfigEntry()
                          throws PersistException
Deletes an existing configuration entry in the configuration file. This is done by looping through the key elements and building the section name of the section to be deleted.
Throws:
PersistException - Thrown when the section to be deleted does not exist.

deleteConfigEntry

protected void deleteConfigEntry(boolean nullFileNameOK)
                          throws PersistException
Deletes an existing configuration entry in the configuration file. This is done by looping through the key elements and building the section name of the section to be deleted.
Parameters:
nullFileNameOK - Indicates if we should throw an exception when the configuration file has no file name associated with it. A value of true indicates we should not throw an exception, false indicates we should.
Throws:
PersistException - Thrown when the section to be deleted does not exist.

save

public int save()
         throws PersistException
Controls the updating of the persistent store with the entity's information. Determines the type of action to perform against the store (insert, update, or delete) and calls the appropriate method to perform the action.
Overrides:
save in class EntityData
Returns:
The number of rows affected by the persistent store update.
Throws:
PersistException - If a fatal error occurs that causes us to not be able to perform the action, such as a failed validation.

save

public int save(boolean nullFileNameOK)
         throws PersistException
Controls the updating of the persistent store with the entity's information. Determines the type of action to perform against the store (insert, update, or delete) and calls the appropriate method to perform the action.
Parameters:
nullFileNameOK - Indicates if we should throw an exception when the configuration file has no file name associated with it. A value of true indicates we should not throw an exception, false indicates we should.
Returns:
The number of rows affected by the persistent store update.
Throws:
PersistException - If a fatal error occurs that causes us to not be able to perform the action, such as a failed validation.

retrieve

public void retrieve(Hashtable keyValues)
              throws PersistException
Retrieves an entity from the database that is keyed by the given key values.
Overrides:
retrieve in class EntityData
Parameters:
keyValues - The key element's values. Keyed by the element's logical name, result is the element's value.
Throws:
PersistException - If a fatal error occurs that causes us to not be able to perform the retrieval. In our case this would be a missing configuration section, which implies the key values passed in do not match any of our persisted entities.

getCollectionClassName

public String getCollectionClassName()
Returns the class name of the EntityCollection class associated with this class.
Overrides:
getCollectionClassName in class EntityData
Returns:
The full package name of the collection class, in this case bill.util.EntityCollectionConfig.