com.atlassian.confluence.pages.persistence.dao.hibernate
Class HibernateBlogPostDao

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate.support.HibernateDaoSupport
          extended by com.atlassian.hibernate.HibernateObjectDao
              extended by com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
                  extended by com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao
                      extended by com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateBlogPostDao
All Implemented Interfaces:
ObjectDao, VersionedObjectDao, BlogPostDao, org.springframework.beans.factory.InitializingBean

public class HibernateBlogPostDao
extends ConfluenceHibernateObjectDao
implements BlogPostDao

Hibernate implementation of the BlogPost DAO


Field Summary
 
Fields inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
cacheFactory, confluenceUserDao
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
HibernateBlogPostDao()
           
 
Method Summary
 BlogPost getBlogPost(java.lang.String spaceKey, java.lang.String title, java.util.Calendar day)
          Get the blog post by name and date.
 BlogPost getBlogPost(java.lang.String spaceKey, java.lang.String title, java.util.Calendar day, boolean eagerLoadComments)
          Get the blog post by name and date.
 BlogPost getBlogPostByTitle(java.lang.String spaceKey, java.lang.String title)
          Get a blog post by name.
 long getBlogPostCount(java.lang.String spaceKey, java.util.Calendar date, int period)
          Get total number of blogPost.
 java.util.List<java.util.Date> getBlogPostDates(java.lang.String spaceKey)
          Returns a list of creation dates for all the blog posts in a space.
 java.util.List<java.util.Date> getBlogPostDates(java.lang.String spaceKey, java.util.Calendar date, int period)
          Returns a list of creation dates for all the blog posts in a space for a particular period.
 java.util.List<BlogPost> getBlogPosts(Space space, boolean currentOnly)
          Return an iterator for the specified space.
 java.util.List getBlogPosts(java.lang.String spaceKey, java.util.Calendar date, int period)
          Get the blog posts in a space for a particular period.
 java.util.List getBlogPosts(java.lang.String spaceKey, java.util.Calendar date, int period, int startIndex, int maxResultCount)
          Get list of blogPost by Date.
protected  BlogPost getByClassId(long id)
          Retrieve the object with a particular id from the database.
 BlogPost getById(long id)
          Get a blog post by id.
 BlogPost getFirstPostAfter(BlogPost post)
          Used for finding the "previous" post to an existing post.
 BlogPost getFirstPostAfter(java.lang.String spaceKey, java.util.Date creationDate)
          Used for finding the "previous" post to an existing post
 BlogPost getFirstPostBefore(BlogPost post)
          Used for finding the "previous" post to an existing post.
 BlogPost getFirstPostBefore(java.lang.String spaceKey, java.util.Date creationDate)
          Used for finding the "previous" post to an existing post
 BlogPost getMostRecentBlogPost(java.lang.String spaceKey)
           
 java.lang.Class getPersistentClass()
           
 java.util.List getRecentlyAddedBlogPosts(int maxPosts, java.util.Date timeSince, java.lang.String spaceKey)
           
 java.util.List getRecentlyAddedBlogPosts(int maxCount, java.lang.String spaceKey)
          Get list of recently created blog posts.
 
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
findAllSorted, findLatestVersionsCount, findLatestVersionsIterator, findNamedQueryStringParams, save, setCacheFactory, setConfluenceUserDao, updateModificationData
 
Methods inherited from class com.atlassian.hibernate.HibernateObjectDao
findAll, findAllSorted, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getCountResult, index, refresh, reIndex, remove, replicate, save, saveRaw, setIndexer, unIndex, uniqueResult
 
Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
checkDaoConfig, 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 com.atlassian.confluence.core.persistence.VersionedObjectDao
findLatestVersionsCount, findLatestVersionsIterator, save
 
Methods inherited from interface bucket.core.persistence.ObjectDao
findAll, findAllSorted, findAllSorted, refresh, remove, replicate, save, saveRaw
 

Constructor Detail

HibernateBlogPostDao

public HibernateBlogPostDao()
Method Detail

getPersistentClass

public java.lang.Class getPersistentClass()
Specified by:
getPersistentClass in interface ObjectDao

getById

public BlogPost getById(long id)
Description copied from interface: BlogPostDao
Get a blog post by id. Will return null if the post does not exist

Specified by:
getById in interface BlogPostDao

getByClassId

protected BlogPost getByClassId(long id)
Description copied from class: HibernateObjectDao
Retrieve the object with a particular id from the database. The object must be of the same class as the DAO's getPersistentClass() method returns.

Overrides:
getByClassId in class HibernateObjectDao
Parameters:
id - the id of the object to look up
Returns:
the corresponding object, or null if the object does not exist with the appropriate class and id.

getBlogPostByTitle

public BlogPost getBlogPostByTitle(java.lang.String spaceKey,
                                   java.lang.String title)
Description copied from interface: BlogPostDao
Get a blog post by name. If there is no blog post by that name, or if the name is ambiguous (there are multiple blog posts by that name on different dates), the method will return null

Specified by:
getBlogPostByTitle in interface BlogPostDao
Parameters:
spaceKey - the space
title - the title
Returns:
the blog post in that key with that title, or null if there is no such post, or the title does not unambiguously refer to a single blog entry.

getBlogPost

public BlogPost getBlogPost(java.lang.String spaceKey,
                            java.lang.String title,
                            java.util.Calendar day)
Description copied from interface: BlogPostDao
Get the blog post by name and date. If there is no blog post by that name on that date, the method will return null

Specified by:
getBlogPost in interface BlogPostDao
Parameters:
spaceKey - the space to look for the post in
title - the title of the post we are looking for
day - the DAY the post was created on. Any part of the calendar more specific than a day will be ignored

getBlogPost

public BlogPost getBlogPost(java.lang.String spaceKey,
                            java.lang.String title,
                            java.util.Calendar day,
                            boolean eagerLoadComments)
Description copied from interface: BlogPostDao
Get the blog post by name and date. If there is no blog post by that name on that date, the method will return null

Specified by:
getBlogPost in interface BlogPostDao
Parameters:
spaceKey - the space to look for the post in
title - the title of the post we are looking for
day - the DAY the post was created on. Any part of the calendar more specific than a day will be ignored

getBlogPosts

public java.util.List getBlogPosts(java.lang.String spaceKey,
                                   java.util.Calendar date,
                                   int period)
Description copied from interface: BlogPostDao
Get the blog posts in a space for a particular period.

TODO: add Calendar.WEEK range support.

Specified by:
getBlogPosts in interface BlogPostDao
Parameters:
spaceKey - the space to look for posts in
date - a calendar object representing the date range we are looking for. Any part of the calendar more specific than the supplied period will be ignored.
period - one of the Calendar constants specifying the granularity of the search. currently, only Calendar.MONTH and Calendar.DATE are supported
Returns:
a list of blog posts in that time-range. The list may be empty but will never be null

getBlogPosts

public java.util.List getBlogPosts(java.lang.String spaceKey,
                                   java.util.Calendar date,
                                   int period,
                                   int startIndex,
                                   int maxResultCount)
Description copied from interface: BlogPostDao
Get list of blogPost by Date.

Specified by:
getBlogPosts in interface BlogPostDao
Parameters:
spaceKey - the space to look for posts in
date - a calendar object representing the date range we are looking for. Any part of the calendar more specific than the supplied period will be ignored.
period - one of the Calendar constants specifying the granularity of the search. currently, only Calendar.MONTH and Calendar.DATE are supported
startIndex - start number of posts
maxResultCount - Maximum number of posts to return
Returns:
a list of blogPost

getBlogPostCount

public long getBlogPostCount(java.lang.String spaceKey,
                             java.util.Calendar date,
                             int period)
Description copied from interface: BlogPostDao
Get total number of blogPost.

Specified by:
getBlogPostCount in interface BlogPostDao
Parameters:
spaceKey - the space to look for posts in
date - a calendar object representing the date range we are looking for. Any part of the calendar more specific than the supplied period will be ignored.
period - one of the Calendar constants specifying the granularity of the search. currently, only Calendar.MONTH and Calendar.DATE are supported
Returns:
a count number of blogPosts

getBlogPostDates

public java.util.List<java.util.Date> getBlogPostDates(java.lang.String spaceKey)
Description copied from interface: BlogPostDao
Returns a list of creation dates for all the blog posts in a space.

Specified by:
getBlogPostDates in interface BlogPostDao

getBlogPostDates

public java.util.List<java.util.Date> getBlogPostDates(java.lang.String spaceKey,
                                                       java.util.Calendar date,
                                                       int period)
Description copied from interface: BlogPostDao
Returns a list of creation dates for all the blog posts in a space for a particular period.

Specified by:
getBlogPostDates in interface BlogPostDao
Parameters:
spaceKey - the space to look for posts in.
date - a calendar object representing the date range we are looking for. Any part of the calendar more specific than the supplied period will be ignored.
period - one of the Calendar constants specifying the granularity of the search. currently, only Calendar.YEAR, Calendar.MONTH and Calendar.DATE are supported
Returns:
a list creation dates for the blog posts created in the time-range. The list may be empty but will never be null

getBlogPosts

public java.util.List<BlogPost> getBlogPosts(Space space,
                                             boolean currentOnly)
Description copied from interface: BlogPostDao
Return an iterator for the specified space. This is an efficient alternative to space.getBlogPosts

Specified by:
getBlogPosts in interface BlogPostDao

getRecentlyAddedBlogPosts

public java.util.List getRecentlyAddedBlogPosts(int maxCount,
                                                java.lang.String spaceKey)
Description copied from interface: BlogPostDao
Get list of recently created blog posts.

Specified by:
getRecentlyAddedBlogPosts in interface BlogPostDao
Parameters:
maxCount - Maximum number of posts to return
spaceKey - the spaceKey to look for the posts in. If this key is null, we look acrosns all spaces
Returns:
a list of the most recently added blog posts. The list can be empty but will never be null.

getFirstPostBefore

public BlogPost getFirstPostBefore(java.lang.String spaceKey,
                                   java.util.Date creationDate)
Description copied from interface: BlogPostDao
Used for finding the "previous" post to an existing post

Specified by:
getFirstPostBefore in interface BlogPostDao
Parameters:
spaceKey - the space to look in
creationDate - the date the post must be before
Returns:
the first post created before that date, or null if there are none.

getFirstPostAfter

public BlogPost getFirstPostAfter(java.lang.String spaceKey,
                                  java.util.Date creationDate)
Description copied from interface: BlogPostDao
Used for finding the "previous" post to an existing post

Specified by:
getFirstPostAfter in interface BlogPostDao
Parameters:
spaceKey - the space to look in
creationDate - the date the post must be after
Returns:
the first post created after that date, or null if there are none

getFirstPostBefore

public BlogPost getFirstPostBefore(BlogPost post)
Description copied from interface: BlogPostDao
Used for finding the "previous" post to an existing post. If you are comparing blog posts, you should always prefer this over the method that takes a date, because this method will avoid date comparison bugs that can sneak in with certain databases. (*cough* Oracle)

Specified by:
getFirstPostBefore in interface BlogPostDao
Parameters:
post - the blog post that this must preceed
Returns:
the first post created before the given blog post, or null if there are none.

getFirstPostAfter

public BlogPost getFirstPostAfter(BlogPost post)
Description copied from interface: BlogPostDao
Used for finding the "previous" post to an existing post. If you are comparing blog posts, you should always prefer this over the method that takes a date, because this method will avoid date comparison bugs that can sneak in with certain databases. (*cough* Oracle)

Specified by:
getFirstPostAfter in interface BlogPostDao
Parameters:
post - the blog post that this must be after
Returns:
the first post created after the given blog post, or null if there are none.

getRecentlyAddedBlogPosts

public java.util.List getRecentlyAddedBlogPosts(int maxPosts,
                                                java.util.Date timeSince,
                                                java.lang.String spaceKey)
Specified by:
getRecentlyAddedBlogPosts in interface BlogPostDao

getMostRecentBlogPost

public BlogPost getMostRecentBlogPost(java.lang.String spaceKey)
Specified by:
getMostRecentBlogPost in interface BlogPostDao


Copyright © 2003-2014 Atlassian. All Rights Reserved.