Package com.tagtraum.beatunes.analysis
Class HibernateTaskQueue
- java.lang.Object
-
- com.tagtraum.beatunes.analysis.HibernateTaskQueue
-
- All Implemented Interfaces:
TaskQueue,PageCacheDataSource<SongTask>,ApplicationComponent<BeaTunes>,ListModel
public class HibernateTaskQueue extends Object implements TaskQueue, PageCacheDataSource<SongTask>
Hibernate task queue.- Author:
- Hendrik Schreiber
-
-
Constructor Summary
Constructors Constructor Description HibernateTaskQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListDataListener(ListDataListener l)voidclear()org.hibernate.QuerycreatePageQuery(org.hibernate.Session session)Creates a query that selects persistent objects in the right order.BeaTunesgetApplication()Returns the main application component.TaskgetElementAt(int index)Return task with given index.HibernateUtilgetHibernateUtil()StringgetId()Unique id for each instance of this object.LonggetId(SongTask songTask)Needs to be implemented to get the persistent id of the objects that are cached in this cache.IndexedId[]getIds(org.hibernate.Session session)A complete list of sorted ids along with their natural indices.intgetSize()List<Long>getSongIdsForTasksUsingOnlineResources()Ids for tasks that use online resources.PlayList.SortDirectiongetSortDirection()StringgetSortProperty()SongTaskgetWithId(org.hibernate.Session session, Long id)List<SongTask>getWithIds(org.hibernate.Session session, Long... ids)Creates a query that selects persistent objects in the right order.intindexOf(long id)Returns the index of a given Task or-1if not found or not displayed.intindexOf(Object object)Returns the index of a given Task or-1if not found or not displayed.voidinit()Initializes this component and its sub-components.booleanisEmpty()voidobjectsAvailable(int index0, int index1)Notifies the data source, that the given index range has been loaded.List<Long>offer(List<Long> songIds, TaskFactory taskFactory, DiscreteProgressListener discreteProgressListener)Create tasks using the provided factory and list of song ids and add them to the queue.Taskpoll(long timeout, TimeUnit unit)booleanremove(Task task)voidremoveListDataListener(ListDataListener l)voidsetApplication(BeaTunes beaTunes)Sets the main application component.voidsetHibernateUtil(HibernateUtil hibernateUtil)voidsetSortDirection(PlayList.SortDirection sortDirection)voidsetSortProperty(String sortProperty)voidshutdown()Shuts down this component and its sub-components.
-
-
-
Method Detail
-
getHibernateUtil
public HibernateUtil getHibernateUtil()
- Specified by:
getHibernateUtilin interfacePageCacheDataSource<SongTask>- Returns:
- hibernate utilities
-
setHibernateUtil
public void setHibernateUtil(HibernateUtil hibernateUtil)
-
getId
public Long getId(SongTask songTask)
Description copied from interface:PageCacheDataSourceNeeds to be implemented to get the persistent id of the objects that are cached in this cache.- Specified by:
getIdin interfacePageCacheDataSource<SongTask>- Parameters:
songTask- some persistent object- Returns:
- persistent id
-
getWithId
public SongTask getWithId(org.hibernate.Session session, Long id)
- Specified by:
getWithIdin interfacePageCacheDataSource<SongTask>- Parameters:
session- sessionid- id of the object we are looking for- Returns:
- the persistent object or null, if not found
- See Also:
PageCacheDataSource.getWithIds(Session, Long...)
-
getWithIds
public List<SongTask> getWithIds(org.hibernate.Session session, Long... ids)
Description copied from interface:PageCacheDataSourceCreates a query that selects persistent objects in the right order. query.setMaxResults(..) and query.setFirstResult(..) are set by the caller.- Specified by:
getWithIdsin interfacePageCacheDataSource<SongTask>- Parameters:
session- sessionids- ids of the objects we are looking for- Returns:
- list of objects. not found objects are
null - See Also:
PageCacheDataSource.getWithId(Session, Long)
-
getIds
public IndexedId[] getIds(org.hibernate.Session session)
Description copied from interface:PageCacheDataSourceA complete list of sorted ids along with their natural indices. Indices of filtered out objects are flipped:-(index+1)- Specified by:
getIdsin interfacePageCacheDataSource<SongTask>- Parameters:
session- hibernate session- Returns:
- a complete list of persistent ids
-
createPageQuery
public org.hibernate.Query createPageQuery(org.hibernate.Session session)
Description copied from interface:PageCacheDataSourceCreates a query that selects persistent objects in the right order. query.setMaxResults(..) and query.setFirstResult(..) are set by the caller.- Specified by:
createPageQueryin interfacePageCacheDataSource<SongTask>- Parameters:
session- session- Returns:
- a query that returns objects in the right order or null, if such a query cannot be constructed
-
objectsAvailable
public void objectsAvailable(int index0, int index1)Description copied from interface:PageCacheDataSourceNotifies the data source, that the given index range has been loaded.- Specified by:
objectsAvailablein interfacePageCacheDataSource<SongTask>- Parameters:
index0- start indexindex1- end index (inclusive)
-
setApplication
public void setApplication(BeaTunes beaTunes)
Description copied from interface:ApplicationComponentSets the main application component.- Specified by:
setApplicationin interfaceApplicationComponent<BeaTunes>- Specified by:
setApplicationin interfaceTaskQueue- Parameters:
beaTunes- beaTunes instance
-
getApplication
public BeaTunes getApplication()
Description copied from interface:ApplicationComponentReturns the main application component.- Specified by:
getApplicationin interfaceApplicationComponent<BeaTunes>- Returns:
- application object
-
getId
public String getId()
Description copied from interface:ApplicationComponentUnique id for each instance of this object.- Specified by:
getIdin interfaceApplicationComponent<BeaTunes>- Returns:
- id
-
init
public void init()
Description copied from interface:ApplicationComponentInitializes this component and its sub-components.- Specified by:
initin interfaceApplicationComponent<BeaTunes>
-
shutdown
public void shutdown()
Description copied from interface:ApplicationComponentShuts down this component and its sub-components.- Specified by:
shutdownin interfaceApplicationComponent<BeaTunes>
-
getElementAt
public Task getElementAt(int index)
Description copied from interface:TaskQueueReturn task with given index.- Specified by:
getElementAtin interfaceListModel- Specified by:
getElementAtin interfaceTaskQueue- Parameters:
index- index- Returns:
- task or null, if there is no task with the given index.
-
indexOf
public int indexOf(Object object)
Description copied from interface:TaskQueueReturns the index of a given Task or-1if not found or not displayed.
-
indexOf
public int indexOf(long id)
Description copied from interface:TaskQueueReturns the index of a given Task or-1if not found or not displayed.
-
offer
public List<Long> offer(List<Long> songIds, TaskFactory taskFactory, DiscreteProgressListener discreteProgressListener)
Description copied from interface:TaskQueueCreate tasks using the provided factory and list of song ids and add them to the queue.
-
poll
public Task poll(long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
pollin interfaceTaskQueue- Throws:
InterruptedException- See Also:
BlockingQueue.poll(long, java.util.concurrent.TimeUnit)
-
getSongIdsForTasksUsingOnlineResources
public List<Long> getSongIdsForTasksUsingOnlineResources()
Description copied from interface:TaskQueueIds for tasks that use online resources.- Specified by:
getSongIdsForTasksUsingOnlineResourcesin interfaceTaskQueue- Returns:
- list of ids.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceTaskQueue- See Also:
Collection.isEmpty()
-
remove
public boolean remove(Task task)
- Specified by:
removein interfaceTaskQueue- See Also:
BlockingQueue.remove(Object)
-
clear
public void clear()
- Specified by:
clearin interfaceTaskQueue- See Also:
Collection.clear()
-
setSortProperty
public void setSortProperty(String sortProperty)
- Specified by:
setSortPropertyin interfaceTaskQueue
-
getSortProperty
public String getSortProperty()
- Specified by:
getSortPropertyin interfaceTaskQueue
-
setSortDirection
public void setSortDirection(PlayList.SortDirection sortDirection)
- Specified by:
setSortDirectionin interfaceTaskQueue
-
getSortDirection
public PlayList.SortDirection getSortDirection()
- Specified by:
getSortDirectionin interfaceTaskQueue
-
addListDataListener
public void addListDataListener(ListDataListener l)
- Specified by:
addListDataListenerin interfaceListModel
-
removeListDataListener
public void removeListDataListener(ListDataListener l)
- Specified by:
removeListDataListenerin interfaceListModel
-
-