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 intcountBlogsWithUnpublishedChanges()Counts the number of published blog posts that have unpublished changes.intcountCurrentBlogs()Counts the total number of current blog posts across all spacesintcountDraftBlogs()Counts 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.BlogPostgetBlogPostByTitle(String spaceKey, String title)Get a blog post by name.intgetBlogPostCount()Counts the total number of blog posts, for all spaces and posting dates.longgetBlogPostCount(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 BlogPostgetByClassId(long id)Retrieve the object with a particular id from the database.BlogPostgetById(long id)Get a blog post by id.intgetCommentCountOnBlog(long blogId)Get count of comments on a blogpost.List<Long>getCurrentBlogPostIds()Return a list of ids for all current blog posts.BlogPostgetFirstPostAfter(BlogPost post)Used for finding the "previous" post to an existing post.BlogPostgetFirstPostAfter(String spaceKey, Date creationDate)Used for finding the "previous" post to an existing postBlogPostgetFirstPostBefore(BlogPost post)Used for finding the "previous" post to an existing post.BlogPostgetFirstPostBefore(String spaceKey, Date creationDate)Used for finding the "previous" post to an existing postBlogPostgetMostRecentBlogPost(String spaceKey)Class<BlogPost>getPersistentClass()Gets the type ofEntityObjectthis Dao works with.List<BlogPost>getRecentlyAddedBlogPosts(int maxCount, @Nullable String spaceKey)Get list of recently created blog posts.ListgetRecentlyAddedBlogPosts(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:ObjectDaoInternalGets the type ofEntityObjectthis Dao works with.- Specified by:
getPersistentClassin interfaceObjectDao- Specified by:
getPersistentClassin interfaceObjectDaoInternal<BlogPost>- Returns:
- the type
-
getById
public BlogPost getById(long id)
Description copied from interface:BlogPostDaoGet a blog post by id. Will return null if the post does not exist- Specified by:
getByIdin interfaceBlogPostDao
-
getByClassId
protected BlogPost getByClassId(long id)
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
public BlogPost getBlogPostByTitle(String spaceKey, String title)
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
public List<BlogPost> getBlogPostsInTrash(String spaceKey, String title)
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
public List<BlogPost> getBlogPosts(@NonNull Space space, @NonNull Calendar date, int period)
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
public long getBlogPostCount(String spaceKey, Calendar date, int period)
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
public List<Date> getBlogPostDates(@NonNull Space space)
Description copied from interface:BlogPostDaoReturns a list of creation dates for all the blog posts in a space.- Specified by:
getBlogPostDatesin interfaceBlogPostDao
-
getBlogPostDates
public List<Date> getBlogPostDates(String spaceKey, Calendar date, int period)
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
public List<BlogPost> getBlogPosts(Space space, boolean currentOnly)
Description copied from interface:BlogPostDaoReturn an iterator for the specified space. This is an efficient alternative to space.getBlogPosts- Specified by:
getBlogPostsin interfaceBlogPostDao
-
getCurrentBlogPostIds
public List<Long> getCurrentBlogPostIds()
Description copied from interface:BlogPostDaoReturn a list of ids for all current blog posts.- Specified by:
getCurrentBlogPostIdsin interfaceBlogPostDao
-
getRecentlyAddedBlogPosts
public List<BlogPost> getRecentlyAddedBlogPosts(int maxCount, @Nullable String spaceKey)
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
public BlogPost getFirstPostBefore(String spaceKey, Date creationDate)
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
public BlogPost getFirstPostAfter(String spaceKey, Date creationDate)
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
public BlogPost getFirstPostBefore(BlogPost post)
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
public BlogPost getFirstPostAfter(BlogPost post)
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
public List getRecentlyAddedBlogPosts(int maxPosts, Date timeSince, String spaceKey)
- Specified by:
getRecentlyAddedBlogPostsin interfaceBlogPostDao
-
getMostRecentBlogPost
public BlogPost getMostRecentBlogPost(String spaceKey)
- 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
public Optional<BlogPostStatisticsDTO> 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
-
-