Class HibernateBlogPostDao
java.lang.Object
org.springframework.dao.support.DaoSupport
com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao<T>
com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao<T>
com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao<BlogPost>
com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateBlogPostDao
- All Implemented Interfaces:
BlogPostDao,org.springframework.beans.factory.InitializingBean
public class HibernateBlogPostDao
extends VersionedHibernateObjectDao<BlogPost>
implements BlogPostDao
Hibernate implementation of the BlogPost DAO
-
Nested Class Summary
Nested classes/interfaces inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
HibernateObjectDao.Cacheability -
Field Summary
Fields inherited from class org.springframework.dao.support.DaoSupport
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCounts the number of published blog posts that have unpublished changes.intCounts the total number of current blog posts across all spacesintCounts the number of blog posts that are drafts.@Nullable BlogPostgetBlogPost(@NonNull Space space, @NonNull String title, @NonNull Calendar day, boolean eagerLoadComments) Get the blog post by name and date.getBlogPostByTitle(String spaceKey, String title) Get a blog post by name.intCounts the total number of blog posts, for all spaces and posting dates.longgetBlogPostCount(String spaceKey, Calendar date, int period) Get total number of blogPost.getBlogPostDates(@NonNull Space space) Returns a list of creation dates for all the blog posts in a space.getBlogPostDates(String spaceKey, Calendar date, int period) Returns a list of creation dates for all the blog posts in a space for a particular period.getBlogPosts(@NonNull Space space, @NonNull Calendar date, int period) Get the blog posts in a space for a particular period.getBlogPosts(@NonNull Space space, @NonNull Calendar date, int period, int startIndex, int maxResultCount) Get list of blogPost by Date.getBlogPosts(Space space, boolean currentOnly) Return an iterator for the specified space.getBlogPostsInTrash(String spaceKey, String title) Gets a blog post that is in the trash for a given space that matches the given title.Fetches statistics about blog postsprotected BlogPostgetByClassId(long id) Retrieve the object with a particular id from the database.getById(long id) Get a blog post by id.intgetCommentCountOnBlog(long blogId) Get count of comments on a blogpost.Return a list of ids for all current blog posts.getFirstPostAfter(BlogPost post) Used for finding the "previous" post to an existing post.getFirstPostAfter(String spaceKey, Date creationDate) Used for finding the "previous" post to an existing postgetFirstPostBefore(BlogPost post) Used for finding the "previous" post to an existing post.getFirstPostBefore(String spaceKey, Date creationDate) Used for finding the "previous" post to an existing postgetMostRecentBlogPost(String spaceKey) getRecentlyAddedBlogPosts(int maxCount, @Nullable String spaceKey) Get list of recently created blog posts.getRecentlyAddedBlogPosts(int maxPosts, Date timeSince, String spaceKey) protected voidvoidsetEventPublisher(com.atlassian.event.api.EventPublisher eventPublisher) Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
applyChildVersioningPolicy, findAllSorted, findLatestVersionsCount, findLatestVersionsIterator, findLatestVersionsIterator, findNamedQueryStringParams, findNamedQueryStringParams, remove, saveMethods inherited from class com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao
updateModificationDataMethods inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
applyTransactionTimeout, applyTransactionTimeout, checkDaoConfig, createHibernateTemplate, findAll, findAllSorted, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getCountResult, getHibernateTemplate, getSessionFactory, reIndex, save, saveEntity, saveRaw, setHibernateTemplate, setSessionFactory, uniqueResultMethods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
-
Constructor Details
-
HibernateBlogPostDao
public HibernateBlogPostDao()
-
-
Method Details
-
getPersistentClass
- Specified by:
getPersistentClassin classHibernateObjectDao<BlogPost>
-
getById
Description copied from interface:BlogPostDaoGet a blog post by id. Will return null if the post does not exist- Specified by:
getByIdin interfaceBlogPostDao
-
getByClassId
Description copied from class:HibernateObjectDaoRetrieve 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:
getByClassIdin classHibernateObjectDao<BlogPost>- 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
Description copied from interface:BlogPostDaoGet 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:
getBlogPostByTitlein interfaceBlogPostDao- Parameters:
spaceKey- the spacetitle- 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.
-
getBlogPostsInTrash
Description copied from interface:BlogPostDaoGets a blog post that is in the trash for a given space that matches the given title.- Specified by:
getBlogPostsInTrashin interfaceBlogPostDao- Parameters:
spaceKey- The space key (case-insensitive) in which to look for the blogtitle- The title (case-insensitive) of the blog to look for- Returns:
- a list of blog posts in the trash that have the given title and space key.
-
getBlogPost
public @Nullable BlogPost getBlogPost(@NonNull Space space, @NonNull String title, @NonNull Calendar day, boolean eagerLoadComments) Description copied from interface:BlogPostDaoGet 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:
getBlogPostin interfaceBlogPostDao- Parameters:
space- the space to look for the post intitle- the title of the post we are looking forday- the DAY the post was created on. Any part of the calendar more specific than a day will be ignored
-
getBlogPosts
Description copied from interface:BlogPostDaoGet the blog posts in a space for a particular period.TODO: add Calendar.WEEK range support.
- Specified by:
getBlogPostsin interfaceBlogPostDao- Parameters:
space- the space to look for posts indate- 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 List<BlogPost> getBlogPosts(@NonNull Space space, @NonNull Calendar date, int period, int startIndex, int maxResultCount) Description copied from interface:BlogPostDaoGet list of blogPost by Date.- Specified by:
getBlogPostsin interfaceBlogPostDao- Parameters:
space- the space to look for posts indate- 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 supportedstartIndex- start number of postsmaxResultCount- Maximum number of posts to return- Returns:
- a list of blogPost
-
getBlogPostCount
Description copied from interface:BlogPostDaoGet total number of blogPost.- Specified by:
getBlogPostCountin interfaceBlogPostDao- Parameters:
spaceKey- the space to look for posts indate- 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
Description copied from interface:BlogPostDaoReturns a list of creation dates for all the blog posts in a space.- Specified by:
getBlogPostDatesin interfaceBlogPostDao
-
getBlogPostDates
Description copied from interface:BlogPostDaoReturns a list of creation dates for all the blog posts in a space for a particular period.- Specified by:
getBlogPostDatesin interfaceBlogPostDao- 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
Description copied from interface:BlogPostDaoReturn an iterator for the specified space. This is an efficient alternative to space.getBlogPosts- Specified by:
getBlogPostsin interfaceBlogPostDao
-
getCurrentBlogPostIds
Description copied from interface:BlogPostDaoReturn a list of ids for all current blog posts.- Specified by:
getCurrentBlogPostIdsin interfaceBlogPostDao
-
getRecentlyAddedBlogPosts
Description copied from interface:BlogPostDaoGet list of recently created blog posts.- Specified by:
getRecentlyAddedBlogPostsin interfaceBlogPostDao- Parameters:
maxCount- Maximum number of posts to returnspaceKey- 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
Description copied from interface:BlogPostDaoUsed for finding the "previous" post to an existing post- Specified by:
getFirstPostBeforein interfaceBlogPostDao- Parameters:
spaceKey- the space to look increationDate- the date the post must be before- Returns:
- the first post created before that date, or null if there are none.
-
getFirstPostAfter
Description copied from interface:BlogPostDaoUsed for finding the "previous" post to an existing post- Specified by:
getFirstPostAfterin interfaceBlogPostDao- Parameters:
spaceKey- the space to look increationDate- the date the post must be after- Returns:
- the first post created after that date, or null if there are none
-
getFirstPostBefore
Description copied from interface:BlogPostDaoUsed 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:
getFirstPostBeforein interfaceBlogPostDao- 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
Description copied from interface:BlogPostDaoUsed 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:
getFirstPostAfterin interfaceBlogPostDao- 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
- Specified by:
getRecentlyAddedBlogPostsin interfaceBlogPostDao
-
getMostRecentBlogPost
- Specified by:
getMostRecentBlogPostin interfaceBlogPostDao
-
getBlogPostCount
public int getBlogPostCount()Description copied from interface:BlogPostDaoCounts the total number of blog posts, for all spaces and posting dates.- Specified by:
getBlogPostCountin interfaceBlogPostDao- Returns:
- the number of blog posts
-
countCurrentBlogs
public int countCurrentBlogs()Description copied from interface:BlogPostDaoCounts the total number of current blog posts across all spaces- Specified by:
countCurrentBlogsin interfaceBlogPostDao- Returns:
- the number of current blog posts
-
countDraftBlogs
public int countDraftBlogs()Description copied from interface:BlogPostDaoCounts the number of blog posts that are drafts. This does not include drafts of blog posts that have already been published (i.e. blog posts with unpublished changes).- Specified by:
countDraftBlogsin interfaceBlogPostDao- Returns:
- the number of draft blog posts
-
countBlogsWithUnpublishedChanges
public int countBlogsWithUnpublishedChanges()Description copied from interface:BlogPostDaoCounts the number of published blog posts that have unpublished changes.- Specified by:
countBlogsWithUnpublishedChangesin interfaceBlogPostDao- Returns:
- the number of blog posts with unpublished changes.
-
getBlogPostStatistics
Description copied from interface:BlogPostDaoFetches statistics about blog posts- Specified by:
getBlogPostStatisticsin interfaceBlogPostDao- Returns:
- a BlogPostStatisticsDTO with statistics about blogs such as total, current, and draft count
-
getCommentCountOnBlog
public int getCommentCountOnBlog(long blogId) Description copied from interface:BlogPostDaoGet count of comments on a blogpost.- Specified by:
getCommentCountOnBlogin interfaceBlogPostDao- Parameters:
blogId- id of the blogpost- Returns:
- the number of comments on the blogpost
-
setEventPublisher
public void setEventPublisher(com.atlassian.event.api.EventPublisher eventPublisher) -
publishEvent
- Overrides:
publishEventin classHibernateObjectDao<BlogPost>
-