magoffin.matt.ma2.dao.hbm
Class HibernateAlbumDao

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<T,PK>
              extended by magoffin.matt.dao.hbm.GenericIndexableHibernateDao<Album,java.lang.Long>
                  extended by magoffin.matt.ma2.dao.hbm.HibernateAlbumDao
All Implemented Interfaces:
magoffin.matt.dao.GenericDao<Album,java.lang.Long>, magoffin.matt.dao.IndexableDao<java.lang.Long>, AlbumDao, org.springframework.beans.factory.InitializingBean

public class HibernateAlbumDao
extends magoffin.matt.dao.hbm.GenericIndexableHibernateDao<Album,java.lang.Long>
implements AlbumDao

Hibernate implementation of AlbumDao.

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
 
Field Summary
static java.lang.String QUERY_ALBUM_FOR_KEY
          Find an Album based on its anonymous key.
static java.lang.String QUERY_ALBUMS_FOR_THEME_ID
          Find an Album based on a theme ID.
static java.lang.String QUERY_ALBUMS_FOR_USER_ID
          Find all Albums for a User ID.
static java.lang.String QUERY_ALBUMS_FOR_USER_ID_AND_NAME
          Find all Albums for a User ID and name.
static java.lang.String QUERY_ALBUMS_FOR_USER_ID_BY_DATE
          Find all Albums for a User ID, sorted by date in descending order.
static java.lang.String QUERY_ALBUMS_FOR_USER_ID_BY_DATE_SINCE
          Find all Albums for a User ID, sorted by date in descending order, newer than a given date.
static java.lang.String QUERY_ALBUMS_FOR_USER_ID_FOR_ANONYMOUS_BY_DATE
          Find all Albums for a User ID with 'allowAnonymous' = TRUE, sorted by date in descending order.
static java.lang.String QUERY_ALBUMS_FOR_USER_ID_FOR_BROWSE_BY_DATE
          Find all Albums for a User ID with 'allowBrowse' = TRUE, sorted by date in descending order.
static java.lang.String QUERY_ALBUMS_FOR_USER_ID_FOR_FEED_BY_DATE
          Find all Albums for a User ID with 'allowFeed' = TRUE, sorted by date in descending order.
static java.lang.String QUERY_PARAM_ITEM_ID
          The HQL parameter name for a MediaItem ID.
static java.lang.String QUERY_PARAM_SINCE_DATE
          The HQL parameter name for the "since" date.
static java.lang.String QUERY_PARAM_USER_ID
          The HQL parameter name for a user ID.
static java.lang.String QUERY_PARENT_ALBUM_FOR_ALBUM
          Find the parent Album for a given Album.
static java.lang.String QUERY_SHARED_ALBUMS_FOR_MEDIA_ITEM
          Find all Albums that are shared and contain a MediaItem.
static java.lang.String SEARCH_ALBUMS_FOR_USER_ID_FOR_FEED_BY_DATE
          Find album search results for a User ID with 'allowFeed' = TRUE, sorted by date in descending order.
 
Fields inherited from class magoffin.matt.dao.hbm.GenericIndexableHibernateDao
DEFAULT_INDEX_BATCH_SIZE
 
Fields inherited from class magoffin.matt.dao.hbm.GenericHibernateDao
DEFAULT_BATCH_FLUSH_COUNT, log
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
HibernateAlbumDao()
          Default constructor.
 
Method Summary
 void delete(Album domainObject)
           
 java.util.List<Album> findAlbumsForUser(java.lang.Long userId)
          Find all top-level albums owned by a given user.
 java.util.List<Album> findAlbumsForUserAndName(java.lang.Long userId, java.lang.String name)
          Find top-level albums owned by a given user named a particular name.
 java.util.List<Album> findAlbumsForUserByDate(java.lang.Long userId, java.util.Calendar since, boolean anonymousOnly, boolean browseOnly, boolean feedOnly)
          Find top-level albums owned by a given user, ordered in descending order by date, for all albums created on or since a given date.
 java.util.List<Album> findAlbumsForUserByDate(java.lang.Long userId, int max, boolean anonymousOnly, boolean browseOnly, boolean feedOnly)
          Find top-level albums owned by a given user, ordered in descending order by date, with an optional maximum number of albums to return.
 java.util.List<Album> findSharedAlbumsContainingItem(MediaItem item)
          Get a list of all Albums that contain a given MediaItem and are shared.
 Album getAlbumForKey(java.lang.String anonymousKey)
          Get an Album for an anonymous key.
 Album getAlbumWithItems(java.lang.Long albumId)
          Get an Album with it's items fully populated.
 Album getParentAlbum(java.lang.Long childAlbumId)
          Get the parent album for another album.
protected  java.lang.Long getPrimaryKey(Album domainObject)
           
 void init()
          Initialize after properties configured.
 int reassignAlbumsUsingTheme(Theme oldTheme, Theme newTheme)
          Reassign all Albums using a particular Theme to a new Theme.
 
Methods inherited from class magoffin.matt.dao.hbm.GenericIndexableHibernateDao
getIndexBatchSize, getIndexObjectIdColumnName, getIndexObjectTableAlias, getIndexRowMapper, getIndexTimeZone, getJdbcTemplate, getSqlIndexAll, getSqlIndexDateRange, getSqlParamIdxWithDateRange, index, populateIndexRow, setIndexBatchSize, setIndexObjectIdColumnName, setIndexObjectTableAlias, setIndexRowMapper, setIndexTimeZone, setJdbcTemplate, setSqlIndexAll, setSqlIndexDateRange, setSqlParamIdxWithDateRange
 
Methods inherited from class magoffin.matt.dao.hbm.GenericHibernateDao
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
get, store
 

Field Detail

QUERY_ALBUMS_FOR_USER_ID

public static final java.lang.String QUERY_ALBUMS_FOR_USER_ID
Find all Albums for a User ID.

See Also:
Constant Field Values

QUERY_ALBUMS_FOR_USER_ID_AND_NAME

public static final java.lang.String QUERY_ALBUMS_FOR_USER_ID_AND_NAME
Find all Albums for a User ID and name.

See Also:
Constant Field Values

QUERY_ALBUMS_FOR_USER_ID_BY_DATE

public static final java.lang.String QUERY_ALBUMS_FOR_USER_ID_BY_DATE
Find all Albums for a User ID, sorted by date in descending order.

See Also:
Constant Field Values

QUERY_ALBUMS_FOR_USER_ID_FOR_ANONYMOUS_BY_DATE

public static final java.lang.String QUERY_ALBUMS_FOR_USER_ID_FOR_ANONYMOUS_BY_DATE
Find all Albums for a User ID with 'allowAnonymous' = TRUE, sorted by date in descending order.

See Also:
Constant Field Values

QUERY_ALBUMS_FOR_USER_ID_FOR_BROWSE_BY_DATE

public static final java.lang.String QUERY_ALBUMS_FOR_USER_ID_FOR_BROWSE_BY_DATE
Find all Albums for a User ID with 'allowBrowse' = TRUE, sorted by date in descending order.

See Also:
Constant Field Values

QUERY_ALBUMS_FOR_USER_ID_FOR_FEED_BY_DATE

public static final java.lang.String QUERY_ALBUMS_FOR_USER_ID_FOR_FEED_BY_DATE
Find all Albums for a User ID with 'allowFeed' = TRUE, sorted by date in descending order.

See Also:
Constant Field Values

SEARCH_ALBUMS_FOR_USER_ID_FOR_FEED_BY_DATE

public static final java.lang.String SEARCH_ALBUMS_FOR_USER_ID_FOR_FEED_BY_DATE
Find album search results for a User ID with 'allowFeed' = TRUE, sorted by date in descending order.

See Also:
Constant Field Values

QUERY_ALBUMS_FOR_USER_ID_BY_DATE_SINCE

public static final java.lang.String QUERY_ALBUMS_FOR_USER_ID_BY_DATE_SINCE
Find all Albums for a User ID, sorted by date in descending order, newer than a given date.

See Also:
Constant Field Values

QUERY_ALBUM_FOR_KEY

public static final java.lang.String QUERY_ALBUM_FOR_KEY
Find an Album based on its anonymous key.

See Also:
Constant Field Values

QUERY_ALBUMS_FOR_THEME_ID

public static final java.lang.String QUERY_ALBUMS_FOR_THEME_ID
Find an Album based on a theme ID.

See Also:
Constant Field Values

QUERY_SHARED_ALBUMS_FOR_MEDIA_ITEM

public static final java.lang.String QUERY_SHARED_ALBUMS_FOR_MEDIA_ITEM
Find all Albums that are shared and contain a MediaItem.

See Also:
Constant Field Values

QUERY_PARENT_ALBUM_FOR_ALBUM

public static final java.lang.String QUERY_PARENT_ALBUM_FOR_ALBUM
Find the parent Album for a given Album.

See Also:
Constant Field Values

QUERY_PARAM_USER_ID

public static final java.lang.String QUERY_PARAM_USER_ID
The HQL parameter name for a user ID.

See Also:
Constant Field Values

QUERY_PARAM_ITEM_ID

public static final java.lang.String QUERY_PARAM_ITEM_ID
The HQL parameter name for a MediaItem ID.

See Also:
Constant Field Values

QUERY_PARAM_SINCE_DATE

public static final java.lang.String QUERY_PARAM_SINCE_DATE
The HQL parameter name for the "since" date.

See Also:
Constant Field Values
Constructor Detail

HibernateAlbumDao

public HibernateAlbumDao()
Default constructor.

Method Detail

init

public void init()
Initialize after properties configured.


getPrimaryKey

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

findAlbumsForUser

public java.util.List<Album> findAlbumsForUser(java.lang.Long userId)
Description copied from interface: AlbumDao
Find all top-level albums owned by a given user.

Specified by:
findAlbumsForUser in interface AlbumDao
Parameters:
userId - the ID of the user to find the albums for
Returns:
list of found albums, or empty List if none found

findAlbumsForUserAndName

public java.util.List<Album> findAlbumsForUserAndName(java.lang.Long userId,
                                                      java.lang.String name)
Description copied from interface: AlbumDao
Find top-level albums owned by a given user named a particular name.

Specified by:
findAlbumsForUserAndName in interface AlbumDao
Parameters:
userId - the ID of the user to find the albums for
name - the name of the album to find
Returns:
list of found albums, or empty list if none found

getParentAlbum

public Album getParentAlbum(java.lang.Long childAlbumId)
Description copied from interface: AlbumDao
Get the parent album for another album.

Specified by:
getParentAlbum in interface AlbumDao
Parameters:
childAlbumId - the child album ID
Returns:
the parent Album, or null if the album has no parent

delete

public void delete(Album domainObject)
Specified by:
delete in interface magoffin.matt.dao.GenericDao<Album,java.lang.Long>
Overrides:
delete in class magoffin.matt.dao.hbm.GenericHibernateDao<Album,java.lang.Long>

findSharedAlbumsContainingItem

public java.util.List<Album> findSharedAlbumsContainingItem(MediaItem item)
Description copied from interface: AlbumDao
Get a list of all Albums that contain a given MediaItem and are shared.

Specified by:
findSharedAlbumsContainingItem in interface AlbumDao
Parameters:
item - the item
Returns:
list of albums, or empty list if none found

findAlbumsForUserByDate

public java.util.List<Album> findAlbumsForUserByDate(java.lang.Long userId,
                                                     java.util.Calendar since,
                                                     boolean anonymousOnly,
                                                     boolean browseOnly,
                                                     boolean feedOnly)
Description copied from interface: AlbumDao
Find top-level albums owned by a given user, ordered in descending order by date, for all albums created on or since a given date.

Specified by:
findAlbumsForUserByDate in interface AlbumDao
Parameters:
userId - the ID of the user to find the albums for
since - the date to get albums since
anonymousOnly - if true then only get albums which allow anonymous access
browseOnly - if true then only get albums which allow browse access
feedOnly - if true then only get albums which allow feed access
Returns:
list of found albums, or empty list if none found

findAlbumsForUserByDate

public java.util.List<Album> findAlbumsForUserByDate(java.lang.Long userId,
                                                     int max,
                                                     boolean anonymousOnly,
                                                     boolean browseOnly,
                                                     boolean feedOnly)
Description copied from interface: AlbumDao
Find top-level albums owned by a given user, ordered in descending order by date, with an optional maximum number of albums to return.

Specified by:
findAlbumsForUserByDate in interface AlbumDao
Parameters:
userId - the ID of the user to find the albums for
max - the maximum number of albums to return, if greater than zero (otherwise return all albums)
anonymousOnly - if true then only get albums which allow anonymous access
browseOnly - if true then only get albums which allow browse access
feedOnly - if true then only get albums which allow feed access
Returns:
list of found albums, or empty list if none found

getAlbumForKey

public Album getAlbumForKey(java.lang.String anonymousKey)
Description copied from interface: AlbumDao
Get an Album for an anonymous key.

Specified by:
getAlbumForKey in interface AlbumDao
Parameters:
anonymousKey - the anonymous key
Returns:
the found Album, or null if not found

getAlbumWithItems

public Album getAlbumWithItems(java.lang.Long albumId)
Description copied from interface: AlbumDao
Get an Album with it's items fully populated.

Specified by:
getAlbumWithItems in interface AlbumDao
Parameters:
albumId - the ID of the album
Returns:
the Album, or null if not found

reassignAlbumsUsingTheme

public int reassignAlbumsUsingTheme(Theme oldTheme,
                                    Theme newTheme)
Description copied from interface: AlbumDao
Reassign all Albums using a particular Theme to a new Theme.

Specified by:
reassignAlbumsUsingTheme in interface AlbumDao
Parameters:
oldTheme - the Theme to search for
newTheme - the new Theme to replace the old Theme with
Returns:
the number of Albums updated