Class HibernateBlogPostDao
- java.lang.Object
-
- org.springframework.dao.support.DaoSupport
-
- com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao<T>
-
- com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao<T>
-
- com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao<BlogPost>
-
- com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateBlogPostDao
-
- All Implemented Interfaces:
ObjectDao
,VersionedObjectDao<BlogPost>
,BlogPostDaoInternal
,ObjectDaoInternal<BlogPost>
,VersionedObjectDaoInternal<BlogPost>
,BlogPostDao
,org.springframework.beans.factory.InitializingBean
public class HibernateBlogPostDao extends ConfluenceHibernateObjectDao<BlogPost> implements BlogPostDaoInternal
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 com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
cacheFactory, confluenceUserDao
-
-
Constructor Summary
Constructors Constructor Description HibernateBlogPostDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
countBlogsWithUnpublishedChanges()
Counts the number of published blog posts that have unpublished changes.int
countCurrentBlogs()
Counts the total number of current blog posts across all spacesint
countDraftBlogs()
Counts the number of blog posts that are drafts.@Nullable BlogPost
getBlogPost(@NonNull Space space, @NonNull String title, @NonNull Calendar day, boolean eagerLoadComments)
Get the blog post by name and date.BlogPost
getBlogPostByTitle(String spaceKey, String title)
Get a blog post by name.int
getBlogPostCount()
Counts the total number of blog posts, for all spaces and posting dates.long
getBlogPostCount(String spaceKey, Calendar date, int period)
Get total number of blogPost.List<Date>
getBlogPostDates(@NonNull Space space)
Returns a list of creation dates for all the blog posts in a space.List<Date>
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.List<BlogPost>
getBlogPosts(@NonNull Space space, @NonNull Calendar date, int period)
Get the blog posts in a space for a particular period.List<BlogPost>
getBlogPosts(@NonNull Space space, @NonNull Calendar date, int period, int startIndex, int maxResultCount)
Get list of blogPost by Date.List<BlogPost>
getBlogPosts(Space space, boolean currentOnly)
Return an iterator for the specified space.List<BlogPost>
getBlogPostsInTrash(String spaceKey, String title)
Gets a blog post that is in the trash for a given space that matches the given title.Optional<BlogPostStatisticsDTO>
getBlogPostStatistics()
Fetches statistics about blog postsprotected BlogPost
getByClassId(long id)
Retrieve the object with a particular id from the database.BlogPost
getById(long id)
Get a blog post by id.int
getCommentCountOnBlog(long blogId)
Get count of comments on a blogpost.List<Long>
getCurrentBlogPostIds()
Return a list of ids for all current blog posts.BlogPost
getFirstPostAfter(BlogPost post)
Used for finding the "previous" post to an existing post.BlogPost
getFirstPostAfter(String spaceKey, Date creationDate)
Used for finding the "previous" post to an existing postBlogPost
getFirstPostBefore(BlogPost post)
Used for finding the "previous" post to an existing post.BlogPost
getFirstPostBefore(String spaceKey, Date creationDate)
Used for finding the "previous" post to an existing postBlogPost
getMostRecentBlogPost(String spaceKey)
Class<BlogPost>
getPersistentClass()
Gets the type ofEntityObject
this Dao works with.List<BlogPost>
getRecentlyAddedBlogPosts(int maxCount, @Nullable String spaceKey)
Get list of recently created blog posts.List
getRecentlyAddedBlogPosts(int maxPosts, Date timeSince, String spaceKey)
-
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
findAllSorted, findLatestVersionsCount, findLatestVersionsCount, findLatestVersionsIterator, findLatestVersionsIterator, findNamedQueryStringParams, findNamedQueryStringParams, save, saveEntity, setCacheFactory, setConfluenceUserDao, updateEntityModificationData, updateModificationData
-
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
applyTransactionTimeout, applyTransactionTimeout, checkDaoConfig, createHibernateTemplate, findAll, findAllSorted, findByClassIds, findByClassIdsFiltered, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getCountResult, getHibernateTemplate, getSessionFactory, index, indexEntity, refresh, refreshEntity, reIndex, reIndexEntity, remove, removeEntity, replicate, replicateEntity, save, saveEntity, saveRaw, saveRawEntity, setEventPublisher, setHibernateTemplate, setIndexer, setSessionFactory, unIndex, unIndexEntity, uniqueResult
-
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.internal.persistence.ObjectDaoInternal
findAll, findAllSorted, findAllSorted, findByClassIds, findByClassIdsFiltered, refresh, refreshEntity, remove, removeEntity, replicate, replicateEntity, save, saveEntity, saveRaw, saveRawEntity
-
Methods inherited from interface com.atlassian.confluence.core.persistence.VersionedObjectDao
findLatestVersionsCount, findLatestVersionsIterator, save
-
Methods inherited from interface com.atlassian.confluence.internal.persistence.VersionedObjectDaoInternal
saveEntity
-
-
-
-
Method Detail
-
getPersistentClass
public Class<BlogPost> getPersistentClass()
Description copied from interface:ObjectDaoInternal
Gets the type ofEntityObject
this Dao works with.- Specified by:
getPersistentClass
in interfaceObjectDao
- Specified by:
getPersistentClass
in interfaceObjectDaoInternal<BlogPost>
- Returns:
- the type
-
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 interfaceBlogPostDao
-
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 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
public BlogPost getBlogPostByTitle(String spaceKey, 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 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
public List<BlogPost> getBlogPostsInTrash(String spaceKey, String title)
Description copied from interface:BlogPostDao
Gets a blog post that is in the trash for a given space that matches the given title.- Specified by:
getBlogPostsInTrash
in 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: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 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
public List<BlogPost> getBlogPosts(@NonNull Space space, @NonNull 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 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:BlogPostDao
Get list of blogPost by Date.- Specified by:
getBlogPosts
in 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
public long getBlogPostCount(String spaceKey, Calendar date, int period)
Description copied from interface:BlogPostDao
Get total number of blogPost.- Specified by:
getBlogPostCount
in 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
public List<Date> getBlogPostDates(@NonNull Space space)
Description copied from interface:BlogPostDao
Returns a list of creation dates for all the blog posts in a space.- Specified by:
getBlogPostDates
in interfaceBlogPostDao
-
getBlogPostDates
public List<Date> getBlogPostDates(String spaceKey, 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 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
public 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 interfaceBlogPostDao
-
getCurrentBlogPostIds
public List<Long> getCurrentBlogPostIds()
Description copied from interface:BlogPostDao
Return a list of ids for all current blog posts.- Specified by:
getCurrentBlogPostIds
in interfaceBlogPostDao
-
getRecentlyAddedBlogPosts
public List<BlogPost> getRecentlyAddedBlogPosts(int maxCount, @Nullable String spaceKey)
Description copied from interface:BlogPostDao
Get list of recently created blog posts.- Specified by:
getRecentlyAddedBlogPosts
in 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
public BlogPost getFirstPostBefore(String spaceKey, Date creationDate)
Description copied from interface:BlogPostDao
Used for finding the "previous" post to an existing post- Specified by:
getFirstPostBefore
in 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
public BlogPost getFirstPostAfter(String spaceKey, Date creationDate)
Description copied from interface:BlogPostDao
Used for finding the "previous" post to an existing post- Specified by:
getFirstPostAfter
in 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
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 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
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 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
public List getRecentlyAddedBlogPosts(int maxPosts, Date timeSince, String spaceKey)
- Specified by:
getRecentlyAddedBlogPosts
in interfaceBlogPostDao
-
getMostRecentBlogPost
public BlogPost getMostRecentBlogPost(String spaceKey)
- Specified by:
getMostRecentBlogPost
in interfaceBlogPostDao
-
getBlogPostCount
public int getBlogPostCount()
Description copied from interface:BlogPostDao
Counts the total number of blog posts, for all spaces and posting dates.- Specified by:
getBlogPostCount
in interfaceBlogPostDao
- Returns:
- the number of blog posts
-
countCurrentBlogs
public int countCurrentBlogs()
Description copied from interface:BlogPostDao
Counts the total number of current blog posts across all spaces- Specified by:
countCurrentBlogs
in interfaceBlogPostDao
- Returns:
- the number of current blog posts
-
countDraftBlogs
public int countDraftBlogs()
Description copied from interface:BlogPostDao
Counts 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:
countDraftBlogs
in interfaceBlogPostDao
- Returns:
- the number of draft blog posts
-
countBlogsWithUnpublishedChanges
public int countBlogsWithUnpublishedChanges()
Description copied from interface:BlogPostDao
Counts the number of published blog posts that have unpublished changes.- Specified by:
countBlogsWithUnpublishedChanges
in interfaceBlogPostDao
- Returns:
- the number of blog posts with unpublished changes.
-
getBlogPostStatistics
public Optional<BlogPostStatisticsDTO> getBlogPostStatistics()
Description copied from interface:BlogPostDao
Fetches statistics about blog posts- Specified by:
getBlogPostStatistics
in 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:BlogPostDao
Get count of comments on a blogpost.- Specified by:
getCommentCountOnBlog
in interfaceBlogPostDao
- Parameters:
blogId
- id of the blogpost- Returns:
- the number of comments on the blogpost
-
-