magoffin.matt.ma2.dao.hbm
Class HibernateMediaItemDao

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by magoffin.matt.dao.hbm.GenericHibernateDao<MediaItem,java.lang.Long>
              extended by magoffin.matt.ma2.dao.hbm.HibernateMediaItemDao
All Implemented Interfaces:
magoffin.matt.dao.BatchableDao<MediaItem>, magoffin.matt.dao.GenericDao<MediaItem,java.lang.Long>, MediaItemDao, org.springframework.beans.factory.InitializingBean

public class HibernateMediaItemDao
extends magoffin.matt.dao.hbm.GenericHibernateDao<MediaItem,java.lang.Long>
implements MediaItemDao

Hibernate implementation of MediaItemDao.

Version:
$Revision: 43 $ $Date: 2007-10-21 11:10:01 +1300 (Sun, 21 Oct 2007) $
Author:
matt.magoffin

Nested Class Summary
 
Nested classes/interfaces inherited from class magoffin.matt.dao.hbm.GenericHibernateDao
magoffin.matt.dao.hbm.GenericHibernateDao.UpdateMode
 
Nested classes/interfaces inherited from interface magoffin.matt.dao.BatchableDao
magoffin.matt.dao.BatchableDao.BatchCallback<T>, magoffin.matt.dao.BatchableDao.BatchCallbackResult, magoffin.matt.dao.BatchableDao.BatchMode, magoffin.matt.dao.BatchableDao.BatchOptions, magoffin.matt.dao.BatchableDao.BatchResult
 
Field Summary
static java.lang.String QUERY_MEDIA_ITEMS_FOR_ALBUM
          Find all MediaItems for a Album.
static java.lang.String QUERY_MEDIA_ITEMS_FOR_COLLECTION
          Find all MediaItems for a Collection.
static java.lang.String QUERY_MEDIA_ITEMS_FOR_IDS
          Find all MediaItems for a list of IDs.
static java.lang.String QUERY_MEDIA_ITEMS_FOR_PATH
          Find all MediaItems for a path.
static java.lang.String QUERY_MEDIA_ITEMS_OF_COLLECTION_FOR_ALBUM
          Find all MediaItems and Albums for a Collection.
 
Fields inherited from class magoffin.matt.dao.hbm.GenericHibernateDao
DEFAULT_BATCH_FLUSH_COUNT, log
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Fields inherited from interface magoffin.matt.ma2.dao.MediaItemDao
BATCH_NAME_INDEX, BATCH_NAME_PROCESS_MEDIA_IDS, BATCH_PROCESS_PARAM_MEDIA_IDS_LIST
 
Constructor Summary
HibernateMediaItemDao()
          Default constructor.
 
Method Summary
 magoffin.matt.dao.BatchableDao.BatchResult batchProcess(magoffin.matt.dao.BatchableDao.BatchCallback<MediaItem> callback, magoffin.matt.dao.BatchableDao.BatchOptions options)
           
 java.util.List<MediaItem> findItemsForAlbum(java.lang.Long albumId)
          Find all MediaItems for a specific album.
 java.util.List<MediaItem> findItemsForCollection(java.lang.Long collectionId)
          Find all MediaItems for a specific collection.
 MediaItem getItemForPath(java.lang.Long collectionId, java.lang.String path)
          Find a MediaItem by its path and a specific collection.
 MediaItem getMediaItemWithInfo(java.lang.Long itemId)
          Get a MediaItem fully populated (with metadata, etc).
protected  java.lang.Long getPrimaryKey(MediaItem domainObject)
           
 java.lang.String getRemoveItemsFromAlbumsQuery()
           
protected  java.lang.String getRemoveItemsFromCollectionsQuery()
           
 java.util.List<MediaItem> removeItemsFromAlbums(java.lang.Long[] itemIds)
          Remove a set of MediaItems from any albums they reside in.
 java.util.List<MediaItem> removeItemsFromCollections(java.lang.Long[] itemIds)
          Remove a set of media items from the collections they are in.
 java.util.List<MediaItem> removeItemsOfCollectionFromAlbums(java.lang.Long collectionId)
          Find all MediaItems for a specific collection and then remove them from any album they reside in.
 void setRemoveItemsFromAlbumsQuery(java.lang.String removeItemsFromAlbumsQuery)
           
protected  void setRemoveItemsFromCollectionsQuery(java.lang.String removeItemsFromCollectionsQuery)
           
 
Methods inherited from class magoffin.matt.dao.hbm.GenericHibernateDao
delete, executeLiveCriteriaBatchCallback, executeNamedQueryBatchCallback, executeStatelessCriteriaBatchCallback, findByNamedQuery, findByNamedQuery, findByNamedQuery, findByNamedQuery, findByNamedQuery, get, getBatchFlushCount, getType, getUpdateMode, save, setBatchFlushCount, setUpdateMode, store, update
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, closeSessionIfNecessary, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface magoffin.matt.dao.GenericDao
delete, get, store
 

Field Detail

QUERY_MEDIA_ITEMS_FOR_PATH

public static final java.lang.String QUERY_MEDIA_ITEMS_FOR_PATH
Find all MediaItems for a path.

See Also:
Constant Field Values

QUERY_MEDIA_ITEMS_FOR_COLLECTION

public static final java.lang.String QUERY_MEDIA_ITEMS_FOR_COLLECTION
Find all MediaItems for a Collection.

See Also:
Constant Field Values

QUERY_MEDIA_ITEMS_FOR_ALBUM

public static final java.lang.String QUERY_MEDIA_ITEMS_FOR_ALBUM
Find all MediaItems for a Album.

See Also:
Constant Field Values

QUERY_MEDIA_ITEMS_FOR_IDS

public static final java.lang.String QUERY_MEDIA_ITEMS_FOR_IDS
Find all MediaItems for a list of IDs.

See Also:
Constant Field Values

QUERY_MEDIA_ITEMS_OF_COLLECTION_FOR_ALBUM

public static final java.lang.String QUERY_MEDIA_ITEMS_OF_COLLECTION_FOR_ALBUM
Find all MediaItems and Albums for a Collection.

See Also:
Constant Field Values
Constructor Detail

HibernateMediaItemDao

public HibernateMediaItemDao()
Default constructor.

Method Detail

getPrimaryKey

protected java.lang.Long getPrimaryKey(MediaItem domainObject)
Specified by:
getPrimaryKey in class magoffin.matt.dao.hbm.GenericHibernateDao<MediaItem,java.lang.Long>

findItemsForAlbum

public java.util.List<MediaItem> findItemsForAlbum(java.lang.Long albumId)
Description copied from interface: MediaItemDao
Find all MediaItems for a specific album.

Specified by:
findItemsForAlbum in interface MediaItemDao
Parameters:
albumId - the ID of the album
Returns:
the MediaItems of the album

findItemsForCollection

public java.util.List<MediaItem> findItemsForCollection(java.lang.Long collectionId)
Description copied from interface: MediaItemDao
Find all MediaItems for a specific collection.

Specified by:
findItemsForCollection in interface MediaItemDao
Parameters:
collectionId - the ID of the collection
Returns:
the MediaItems of the collection

getItemForPath

public MediaItem getItemForPath(java.lang.Long collectionId,
                                java.lang.String path)
Description copied from interface: MediaItemDao
Find a MediaItem by its path and a specific collection.

Specified by:
getItemForPath in interface MediaItemDao
Parameters:
collectionId - the ID of the collection the item is in
path - the item's path
Returns:
the found item, or null if not found

getMediaItemWithInfo

public MediaItem getMediaItemWithInfo(java.lang.Long itemId)
Description copied from interface: MediaItemDao
Get a MediaItem fully populated (with metadata, etc).

Specified by:
getMediaItemWithInfo in interface MediaItemDao
Parameters:
itemId - the ID of the item to get
Returns:
the media item

removeItemsFromAlbums

public java.util.List<MediaItem> removeItemsFromAlbums(java.lang.Long[] itemIds)
Description copied from interface: MediaItemDao
Remove a set of MediaItems from any albums they reside in.

Specified by:
removeItemsFromAlbums in interface MediaItemDao
Parameters:
itemIds - the IDs of the items to remove from albums
Returns:
the media items removed

removeItemsFromCollections

public java.util.List<MediaItem> removeItemsFromCollections(java.lang.Long[] itemIds)
Description copied from interface: MediaItemDao
Remove a set of media items from the collections they are in.

Specified by:
removeItemsFromCollections in interface MediaItemDao
Parameters:
itemIds - the IDs of the items to remove from collections
Returns:
the media items removed

removeItemsOfCollectionFromAlbums

public java.util.List<MediaItem> removeItemsOfCollectionFromAlbums(java.lang.Long collectionId)
Description copied from interface: MediaItemDao
Find all MediaItems for a specific collection and then remove them from any album they reside in.

Specified by:
removeItemsOfCollectionFromAlbums in interface MediaItemDao
Parameters:
collectionId - the ID of the collection
Returns:
the media items removed

batchProcess

public magoffin.matt.dao.BatchableDao.BatchResult batchProcess(magoffin.matt.dao.BatchableDao.BatchCallback<MediaItem> callback,
                                                               magoffin.matt.dao.BatchableDao.BatchOptions options)
Specified by:
batchProcess in interface magoffin.matt.dao.BatchableDao<MediaItem>

getRemoveItemsFromAlbumsQuery

public java.lang.String getRemoveItemsFromAlbumsQuery()
Returns:
Returns the removeItemsFromAlbumsQuery.

setRemoveItemsFromAlbumsQuery

public void setRemoveItemsFromAlbumsQuery(java.lang.String removeItemsFromAlbumsQuery)
Parameters:
removeItemsFromAlbumsQuery - The removeItemsFromAlbumsQuery to set.

getRemoveItemsFromCollectionsQuery

protected java.lang.String getRemoveItemsFromCollectionsQuery()
Returns:
the removeItemsFromCollectionsQuery

setRemoveItemsFromCollectionsQuery

protected void setRemoveItemsFromCollectionsQuery(java.lang.String removeItemsFromCollectionsQuery)
Parameters:
removeItemsFromCollectionsQuery - the removeItemsFromCollectionsQuery to set