Interface BlogPostDao

All Known Implementing Classes:
HibernateBlogPostDao

public interface BlogPostDao
  • Method Details

    • getById

      BlogPost getById(long id)
      Get a blog post by id. Will return null if the post does not exist
    • getBlogPostByTitle

      BlogPost getBlogPostByTitle(String spaceKey, String title)
      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
      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.
    • getBlogPostsInTrash

      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.
      Parameters:
      spaceKey - The space key (case-insensitive) in which to look for the blog
      title - 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

      @Nullable BlogPost getBlogPost(@NonNull Space space, @NonNull String title, @NonNull Calendar day, boolean eagerLoadComments)
      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
      Parameters:
      space - 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

      List<BlogPost> getBlogPosts(@NonNull Space space, @NonNull Calendar date, int period)
      Get the blog posts in a space for a particular period.

      TODO: add Calendar.WEEK range support.

      Parameters:
      space - 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

      List<BlogPost> getBlogPosts(Space space, boolean currentOnly)
      Return an iterator for the specified space. This is an efficient alternative to space.getBlogPosts
    • getCurrentBlogPostIds

      List<Long> getCurrentBlogPostIds()
      Return a list of ids for all current blog posts.
      Since:
      6.1.4
    • getBlogPostDates

      List<Date> getBlogPostDates(@NonNull Space space)
      Returns a list of creation dates for all the blog posts in a space.
    • getBlogPostDates

      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.
      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
    • getRecentlyAddedBlogPosts

      List<BlogPost> getRecentlyAddedBlogPosts(int maxCount, @Nullable String spaceKey)
      Get list of recently created blog posts.
      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

      BlogPost getFirstPostBefore(String spaceKey, Date creationDate)
      Used for finding the "previous" post to an existing post
      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

      BlogPost getFirstPostAfter(String spaceKey, Date creationDate)
      Used for finding the "previous" post to an existing post
      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

      BlogPost getFirstPostBefore(BlogPost post)
      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)
      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

      BlogPost getFirstPostAfter(BlogPost post)
      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)
      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

      List<BlogPost> getRecentlyAddedBlogPosts(int maxPosts, Date timeSince, String spaceKey)
    • getMostRecentBlogPost

      BlogPost getMostRecentBlogPost(String spaceKey)
    • getBlogPosts

      List<BlogPost> getBlogPosts(@NonNull Space space, @NonNull Calendar postingDate, int period, int startIndex, int maxResultCount)
      Get list of blogPost by Date.
      Parameters:
      space - the space to look for posts in
      postingDate - 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

      long getBlogPostCount(String spaceKey, Calendar postingDate, int period)
      Get total number of blogPost.
      Parameters:
      spaceKey - the space to look for posts in
      postingDate - 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
    • getBlogPostCount

      int getBlogPostCount()
      Counts the total number of blog posts, for all spaces and posting dates.
      Returns:
      the number of blog posts
      Since:
      5.9
    • countCurrentBlogs

      int countCurrentBlogs()
      Counts the total number of current blog posts across all spaces
      Returns:
      the number of current blog posts
      Since:
      6.3.1
    • countDraftBlogs

      int countDraftBlogs()
      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).
      Returns:
      the number of draft blog posts
      Since:
      6.3.1
    • countBlogsWithUnpublishedChanges

      int countBlogsWithUnpublishedChanges()
      Counts the number of published blog posts that have unpublished changes.
      Returns:
      the number of blog posts with unpublished changes.
      Since:
      6.3.1
    • getCommentCountOnBlog

      int getCommentCountOnBlog(long id)
      Get count of comments on a blogpost.
      Parameters:
      id - id of the blogpost
      Returns:
      the number of comments on the blogpost
    • getBlogPostStatistics

      Optional<BlogPostStatisticsDTO> getBlogPostStatistics()
      Fetches statistics about blog posts
      Returns:
      a BlogPostStatisticsDTO with statistics about blogs such as total, current, and draft count