org.archiviststoolkit.mydomain
Class DomainAccessObjectImpl

java.lang.Object
  extended by org.archiviststoolkit.mydomain.DomainAccessObjectImpl
All Implemented Interfaces:
java.util.EventListener, DomainAccessListener, DomainAccessObject
Direct Known Subclasses:
AccessionsDAO, ArchDescriptionAnalogInstancesDAO, ArchDescriptionRepeatingDataDAO, DatabaseTablesDAO, DigitalObjectDAO, LookupListsDAO, NamesDAO, RepositoriesDAO, ResourcesComponentsDAO, ResourcesDAO, SubjectsDAO

public class DomainAccessObjectImpl
extends java.lang.Object
implements DomainAccessObject, DomainAccessListener

Default implementation of a DomainAccessObject specific to hibernate version 2.


Constructor Summary
DomainAccessObjectImpl(java.lang.Class clazz)
          Constructor which builds a DAO for this class.
 
Method Summary
 void add(DomainObject domainObject)
          Add an instance to this DAO.
 void addGroup(java.util.Collection collection, java.awt.Component parent)
          Add a group of instances.
 void addListener(DomainAccessListener listener)
          Add a listener for this DAO.
 void closeLongSession()
           
 void closeLongSessionRollback()
           
 void delete(DomainObject domainObject)
          Delete this object from the data store.
 void deleteById(java.lang.Long identifier)
          Delete this object from the data store.
 void deleteGroup(java.util.Collection collection)
          Delete these objects from the data store.
 void deleteLongSession(DomainObject domainObject)
           
 void deleteLongSession(DomainObject domainObject, boolean closeSession)
           
 void domainChanged(DomainAccessEvent event)
          Called to notify the listener that an event has occurred.
 java.util.Collection findAll(org.hibernate.LockMode lockmode, java.lang.String... sortFields)
          Get a collection of all objects under the control of this domain access object.
 java.util.Collection findAll(java.lang.String... sortFields)
          Return a collection with everything in this DAO.
 java.util.Collection findAllLongSession(java.lang.Boolean alwaysApplyFilters, java.lang.String... sortFields)
           
 java.util.Collection findAllLongSession(java.lang.String... sortFields)
          Get a collection of all objects under the control of this domain access object.
 java.util.Collection findByExample(java.lang.Object instance)
          Find a collection of domain objects by example.
 java.util.Collection findByNamedQuery(java.lang.String queryName)
          Return a collection which conforms to the named query.
 java.util.Collection findByNamedQuery(java.lang.String queryName, java.lang.Object propertyObject)
          Return a collection which conforms to the named query.
 DomainObject findByPrimaryKey(java.lang.Long identifier)
          Find an instance by its identifier.
 DomainObject findByPrimaryKeyLongSession(java.lang.Long identifier)
          Find an instance by its identifier.
 DomainObject findByPrimaryKeyLongSessionForPrinting(java.lang.Long identifier)
          Find an instance by its identifier.
 java.util.Collection findByPropertyValue(java.lang.String propertyName, java.lang.Object value)
          Find instances through a named query without parameters.
 java.util.Collection findByPropertyValues(java.lang.String propertyName, java.lang.Object[] values)
          Find instances through a named query without parameters.
 java.util.Collection findByPropertyValuesLongSession(java.lang.String propertyName, java.lang.Object[] values)
          Find instances through a named query without parameters.
 java.util.Collection findByQuery(java.lang.String queryString)
          Find a collection of domain objects by direct hql query.
 java.util.Collection findByQueryEditor(QueryEditor editor, InfiniteProgressPanel progressPanel)
          Find a collection of domain objects by direct hql query.
 DomainObject findByUniquePropertyValue(java.lang.String propertyName, java.lang.Object value)
          Find instances through a named query without parameters.
 DomainObject findByUniquePropertyValueLongSession(java.lang.String propertyName, java.lang.Object value)
          Find instances through a named query without parameters.
 java.lang.Integer getCountBasedOnPropertyValue(java.lang.String propertyName, java.lang.Object value)
           
 java.lang.String getHumanReadableSearchString()
           
 org.hibernate.Session getLongSession()
           
protected  java.lang.Class getPersistentClass()
           
 int merge(java.util.Collection<DomainObject> mergeFrom, DomainObject mergeTo, InfiniteProgressPanel progressPanel)
           
 void notifyListeners(DomainAccessEvent event)
          Notify all the listeners of an event.
 void removeListener(DomainAccessListener listener)
          Remove a listener from this DAO.
 void setHumanReadableSearchString(java.lang.String humanReadableSearchString)
           
 void update(DomainObject domainObject)
          Update the instance within this DAO.
 void updateLongSession(DomainObject domainObject)
          Update the instance within this DAO.
 void updateLongSession(DomainObject domainObject, boolean closeSession)
          Update the instance within this DAO.
 int updateTextField(java.lang.String propertyName, java.lang.String oldValue, java.lang.String newValue, InfiniteProgressPanel progressPanel)
          Find instances through a named query without parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomainAccessObjectImpl

public DomainAccessObjectImpl(java.lang.Class clazz)
Constructor which builds a DAO for this class.

Parameters:
clazz - the class to build to
Method Detail

addListener

public final void addListener(DomainAccessListener listener)
Add a listener for this DAO.

Specified by:
addListener in interface DomainAccessObject
Parameters:
listener - the listener to add

removeListener

public final void removeListener(DomainAccessListener listener)
Remove a listener from this DAO.

Specified by:
removeListener in interface DomainAccessObject
Parameters:
listener - the listener to remove

notifyListeners

public final void notifyListeners(DomainAccessEvent event)
Notify all the listeners of an event.

Parameters:
event - the event which should be sent to all listeners

add

public final void add(DomainObject domainObject)
               throws PersistenceException
Add an instance to this DAO.

Specified by:
add in interface DomainAccessObject
Parameters:
domainObject - the object to add
Throws:
PersistenceException - fails if we cannot persist the instance

addGroup

public final void addGroup(java.util.Collection collection,
                           java.awt.Component parent)
                    throws PersistenceException
Add a group of instances.

Specified by:
addGroup in interface DomainAccessObject
Parameters:
collection - the objects to add
Throws:
PersistenceException - fails if we cannot persist the instance

update

public final void update(DomainObject domainObject)
                  throws PersistenceException
Update the instance within this DAO.

Specified by:
update in interface DomainAccessObject
Parameters:
domainObject - the instance to update
Throws:
PersistenceException - fails if we cannot update the instance

updateLongSession

public final void updateLongSession(DomainObject domainObject)
                             throws PersistenceException
Update the instance within this DAO.

Specified by:
updateLongSession in interface DomainAccessObject
Parameters:
domainObject - the instance to update
Throws:
PersistenceException - fails if we cannot update the instance

updateLongSession

public final void updateLongSession(DomainObject domainObject,
                                    boolean closeSession)
                             throws PersistenceException
Update the instance within this DAO.

Specified by:
updateLongSession in interface DomainAccessObject
Parameters:
domainObject - the instance to update
Throws:
PersistenceException - fails if we cannot update the instance

deleteGroup

public void deleteGroup(java.util.Collection collection)
                 throws PersistenceException
Delete these objects from the data store.

Specified by:
deleteGroup in interface DomainAccessObject
Parameters:
collection - the object to delete
Throws:
PersistenceException - fails if we cannot delete the instance

delete

public void delete(DomainObject domainObject)
            throws DeleteException
Delete this object from the data store.

Specified by:
delete in interface DomainAccessObject
Parameters:
domainObject - the object to delete
Throws:
DeleteException - fails if we cannot delete the instance

deleteLongSession

public final void deleteLongSession(DomainObject domainObject)
                             throws DeleteException
Specified by:
deleteLongSession in interface DomainAccessObject
Throws:
DeleteException

deleteLongSession

public final void deleteLongSession(DomainObject domainObject,
                                    boolean closeSession)
                             throws DeleteException
Specified by:
deleteLongSession in interface DomainAccessObject
Throws:
DeleteException

deleteById

public final void deleteById(java.lang.Long identifier)
                      throws DeleteException
Delete this object from the data store.

Parameters:
identifier - the id of the object to delete
Throws:
DeleteException - fails if we cannot delete the instance

findByPrimaryKey

public final DomainObject findByPrimaryKey(java.lang.Long identifier)
                                    throws LookupException
Find an instance by its identifier.

Specified by:
findByPrimaryKey in interface DomainAccessObject
Parameters:
identifier - the identifier we are looking for
Returns:
the domain object with the required identifier
Throws:
LookupException - fails if we cannot execute the lookup

findByPrimaryKeyLongSession

public final DomainObject findByPrimaryKeyLongSession(java.lang.Long identifier)
                                               throws LookupException
Find an instance by its identifier.

Specified by:
findByPrimaryKeyLongSession in interface DomainAccessObject
Parameters:
identifier - the identifier we are looking for
Returns:
the domain object with the required identifier
Throws:
LookupException - fails if we cannot execute the lookup

findByPrimaryKeyLongSessionForPrinting

public final DomainObject findByPrimaryKeyLongSessionForPrinting(java.lang.Long identifier)
                                                          throws LookupException
Find an instance by its identifier.

Specified by:
findByPrimaryKeyLongSessionForPrinting in interface DomainAccessObject
Parameters:
identifier - the identifier we are looking for
Returns:
the domain object with the required identifier
Throws:
LookupException - fails if we cannot execute the lookup

closeLongSession

public void closeLongSession()
                      throws java.sql.SQLException
Specified by:
closeLongSession in interface DomainAccessObject
Throws:
java.sql.SQLException

closeLongSessionRollback

public void closeLongSessionRollback()
                              throws java.sql.SQLException
Specified by:
closeLongSessionRollback in interface DomainAccessObject
Throws:
java.sql.SQLException

getLongSession

public org.hibernate.Session getLongSession()
Specified by:
getLongSession in interface DomainAccessObject

findAll

public java.util.Collection findAll(java.lang.String... sortFields)
                             throws LookupException
Return a collection with everything in this DAO.

Specified by:
findAll in interface DomainAccessObject
Returns:
a collection of everything of this class
Throws:
LookupException - fails if we cannot execute the lookup

findAll

public java.util.Collection findAll(org.hibernate.LockMode lockmode,
                                    java.lang.String... sortFields)
                             throws LookupException
Description copied from interface: DomainAccessObject
Get a collection of all objects under the control of this domain access object.

Specified by:
findAll in interface DomainAccessObject
Returns:
the collection of all instances
Throws:
LookupException - if we failed to execute the lookup

findAllLongSession

public java.util.Collection findAllLongSession(java.lang.String... sortFields)
                                        throws LookupException
Description copied from interface: DomainAccessObject
Get a collection of all objects under the control of this domain access object.

Specified by:
findAllLongSession in interface DomainAccessObject
Returns:
the collection of all instances
Throws:
LookupException - if we failed to execute the lookup

findAllLongSession

public java.util.Collection findAllLongSession(java.lang.Boolean alwaysApplyFilters,
                                               java.lang.String... sortFields)
                                        throws LookupException
Specified by:
findAllLongSession in interface DomainAccessObject
Throws:
LookupException

findByQuery

public final java.util.Collection findByQuery(java.lang.String queryString)
                                       throws LookupException
Find a collection of domain objects by direct hql query.

Specified by:
findByQuery in interface DomainAccessObject
Parameters:
queryString - the hql statement
Returns:
the collection of domain objects
Throws:
LookupException - if we failed to find the objects.

findByQueryEditor

public final java.util.Collection findByQueryEditor(QueryEditor editor,
                                                    InfiniteProgressPanel progressPanel)
Find a collection of domain objects by direct hql query.

Specified by:
findByQueryEditor in interface DomainAccessObject
Parameters:
editor - an AT query editor
Returns:
the collection of domain objects

findByExample

public final java.util.Collection findByExample(java.lang.Object instance)
                                         throws LookupException
Find a collection of domain objects by example.

Specified by:
findByExample in interface DomainAccessObject
Parameters:
instance - the example object
Returns:
the collection of domain objects
Throws:
LookupException - if we failed to find the objects.

findByPropertyValue

public java.util.Collection findByPropertyValue(java.lang.String propertyName,
                                                java.lang.Object value)
                                         throws LookupException
Find instances through a named query without parameters.

Specified by:
findByPropertyValue in interface DomainAccessObject
Parameters:
propertyName - the name of the property
value - the value of the property
Returns:
the collection of instances
Throws:
LookupException - if we failed to execute the query

findByPropertyValues

public java.util.Collection findByPropertyValues(java.lang.String propertyName,
                                                 java.lang.Object[] values)
                                          throws LookupException
Find instances through a named query without parameters.

Specified by:
findByPropertyValues in interface DomainAccessObject
Parameters:
propertyName - the name of the property
values - the value of the property
Returns:
the collection of instances
Throws:
LookupException - if we failed to execute the query

findByPropertyValuesLongSession

public java.util.Collection findByPropertyValuesLongSession(java.lang.String propertyName,
                                                            java.lang.Object[] values)
                                                     throws LookupException
Find instances through a named query without parameters.

Specified by:
findByPropertyValuesLongSession in interface DomainAccessObject
Parameters:
propertyName - the name of the property
values - the value of the property
Returns:
the collection of instances
Throws:
LookupException - if we failed to execute the query

findByUniquePropertyValue

public DomainObject findByUniquePropertyValue(java.lang.String propertyName,
                                              java.lang.Object value)
                                       throws LookupException
Find instances through a named query without parameters.

Specified by:
findByUniquePropertyValue in interface DomainAccessObject
Parameters:
propertyName - the name of the property
value - the value of the property
Returns:
the collection of instances
Throws:
LookupException - if we failed to execute the query

findByUniquePropertyValueLongSession

public DomainObject findByUniquePropertyValueLongSession(java.lang.String propertyName,
                                                         java.lang.Object value)
                                                  throws LookupException
Find instances through a named query without parameters.

Specified by:
findByUniquePropertyValueLongSession in interface DomainAccessObject
Parameters:
propertyName - the name of the property
value - the value of the property
Returns:
the collection of instances
Throws:
LookupException - if we failed to execute the query

updateTextField

public int updateTextField(java.lang.String propertyName,
                           java.lang.String oldValue,
                           java.lang.String newValue,
                           InfiniteProgressPanel progressPanel)
                    throws LookupException,
                           java.lang.IllegalAccessException,
                           java.lang.reflect.InvocationTargetException,
                           ValidationException
Find instances through a named query without parameters.

Specified by:
updateTextField in interface DomainAccessObject
Parameters:
propertyName - the name of the property
oldValue - the old value of the property
newValue - the new value of the property
Returns:
the number of records updated
Throws:
LookupException - if we failed to execute the query
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
ValidationException

getCountBasedOnPropertyValue

public java.lang.Integer getCountBasedOnPropertyValue(java.lang.String propertyName,
                                                      java.lang.Object value)
Specified by:
getCountBasedOnPropertyValue in interface DomainAccessObject

merge

public int merge(java.util.Collection<DomainObject> mergeFrom,
                 DomainObject mergeTo,
                 InfiniteProgressPanel progressPanel)
          throws MergeException
Specified by:
merge in interface DomainAccessObject
Throws:
MergeException

findByNamedQuery

public final java.util.Collection findByNamedQuery(java.lang.String queryName,
                                                   java.lang.Object propertyObject)
                                            throws LookupException
Return a collection which conforms to the named query. TODO: check the bean interface to queries

Specified by:
findByNamedQuery in interface DomainAccessObject
Parameters:
queryName - the name of the query
propertyObject - the bean which is used to pass properties to the query
Returns:
the collection generated by the query
Throws:
LookupException - fails if we cannot execute the named query

findByNamedQuery

public final java.util.Collection findByNamedQuery(java.lang.String queryName)
                                            throws LookupException
Return a collection which conforms to the named query.

Specified by:
findByNamedQuery in interface DomainAccessObject
Parameters:
queryName - the name of the query
Returns:
the collection provided by the query
Throws:
LookupException - fails if we cannot execute the query

domainChanged

public final void domainChanged(DomainAccessEvent event)
Called to notify the listener that an event has occurred.

Specified by:
domainChanged in interface DomainAccessListener
Parameters:
event - denotes that a domainobject has changed.

getPersistentClass

protected java.lang.Class getPersistentClass()

getHumanReadableSearchString

public java.lang.String getHumanReadableSearchString()
Specified by:
getHumanReadableSearchString in interface DomainAccessObject

setHumanReadableSearchString

public void setHumanReadableSearchString(java.lang.String humanReadableSearchString)