Class MessageThread

java.lang.Object
org.deltava.beans.DatabaseBean
org.deltava.beans.cooler.MessageThread
All Implemented Interfaces:
Serializable, Comparable<Object>, AuthoredBean, IDBean, ViewEntry, Cacheable

public class MessageThread extends DatabaseBean implements AuthoredBean, ViewEntry
A class to store Water Cooler message threads.
Since:
1.0
Version:
11.1
Author:
Luke
See Also:
  • Constructor Details

    • MessageThread

      public MessageThread(String subject)
      Create a new thread with a particular subject.
      Parameters:
      subject - the thread subject
      Throws:
      NullPointerException - if subject is null
      See Also:
  • Method Details

    • getChannel

      public String getChannel()
      Returns the channel name for this thread.
      Returns:
      the channel name
      See Also:
    • getAuthorID

      public int getAuthorID()
      Returns the database ID of the first Person to post to this thread.
      Specified by:
      getAuthorID in interface AuthoredBean
      Returns:
      the database ID
      See Also:
    • getLastUpdateID

      public int getLastUpdateID()
      Returns the database ID of the last Person to post to this thread.
      Returns:
      the database ID
      See Also:
    • getNextPostID

      public int getNextPostID(Instant dt)
      Returns the post ID of the first post created after a particular date/time.
      Parameters:
      dt - the date/time to check
      Returns:
      the post ID, or MAX_INTEGER if none
    • getLastUpdatedOn

      public Instant getLastUpdatedOn()
      Returns the date of the latest post in this thread.
      Returns:
      the date/time of the latest post
      See Also:
    • getReportCount

      public int getReportCount()
      Returns the number of times this post has been reported for content.
      Returns:
      the number of reports, or -1 if no further reports can be made
      See Also:
    • getStickyUntil

      public Instant getStickyUntil()
      Returns the date/time this thread will be "stuck" at the top of the thread list until.
      Returns:
      the date/time the post will be a sticky until
      See Also:
    • getStickyInChannelOnly

      public boolean getStickyInChannelOnly()
      Returns if this thread should be considered a "sticky" thread in its Channel only.
      Returns:
      TRUE if the thread is "sticky" and is sticky in the Channel, otherwise FALSE
    • getViews

      public int getViews()
      Returns the number of times this thread has been read.
      Returns:
      the number of views
      See Also:
    • getPostCount

      public int getPostCount()
      Returns the number of messages in this thread.
      Returns:
      the number of posts
      See Also:
    • getImage

      public int getImage()
      Returns the linked image ID for this thread.
      Returns:
      the linked Image ID
      See Also:
    • getSubject

      public String getSubject()
      Returns the thread's subject.
      Returns:
      the subject
    • getHidden

      public boolean getHidden()
      Returns if this thread is hidden to general users.
      Returns:
      TRUE if the thread is hidden, otherwise FALSE
      See Also:
    • getLocked

      public boolean getLocked()
      Returns if this thread is locked (no new posts allowed).
      Returns:
      TRUE if the thread is locked, otherwise FALSE
      See Also:
    • getPoll

      public boolean getPoll()
      Returns if this thread has a poll.
      Returns:
      TRUE if there is a poll, otherwise FALSE
      See Also:
    • getHasDisabledLinks

      public boolean getHasDisabledLinks()
      Returns whether this thread has any disabled Image Links.
      Returns:
      TRUE if any links are disabled, otherwise FALSE
    • getOptions

      public Collection<PollOption> getOptions()
      Returns all poll options for this Message Thread.
      Returns:
      a Collection of PollOption beans
      See Also:
    • getVotes

      public Collection<PollVote> getVotes()
      Returns all poll votes for this Message Thread.
      Returns:
      a Collection of PollVote beans
      See Also:
    • getImageURLs

      public Collection<LinkedImage> getImageURLs()
      Returns all linked Image URLs for this Message Thread.
      Returns:
      a Collection of LinkedImages
      See Also:
    • getReportIDs

      public Collection<Integer> getReportIDs()
      Returns the database IDs of all users reporting this thread for content.
      Returns:
      a Collection of database IDs
      See Also:
    • hasVoted

      public boolean hasVoted(int pilotID)
      Returns whether a Pilot has voted in a particular Water Cooler poll.
      Parameters:
      pilotID - the Pilot's database ID
      Returns:
      TRUE if the Pilot has voted, otherwise FALSE
    • setChannel

      public void setChannel(String channelName)
      Updates this thread's Channel.
      Parameters:
      channelName - the name of the channel
      Throws:
      NullPointerException - if channelName is null
      See Also:
    • setAuthorID

      public void setAuthorID(int id)
      Updates the database ID of the first Person to post to this thread.
      Specified by:
      setAuthorID in interface AuthoredBean
      Parameters:
      id - the database ID
      Throws:
      IllegalArgumentException - if the ID is invalid
      See Also:
    • setLastUpdateID

      public void setLastUpdateID(int id)
      Updates the database ID of the last Person to post to this thread.
      Parameters:
      id - the database ID
      Throws:
      IllegalArgumentException - if the ID is invalid
      See Also:
    • setLastUpdatedOn

      public void setLastUpdatedOn(Instant dt)
      Updates the date this thread's latest message was posted.
      Parameters:
      dt - the date/time the last message was posted
    • setStickyUntil

      public void setStickyUntil(Instant dt)
      Updates the date/time this thread will be a "sticky" until.
      Parameters:
      dt - the date/time
      See Also:
    • setStickyInChannelOnly

      public void setStickyInChannelOnly(boolean isSticky)
      Updates whether the thread will be sticky in the current channel only.
      Parameters:
      isSticky - TRUE if the thread is stick in the current channel, otherwise FALSE
      See Also:
    • setReportCount

      public void setReportCount(int count)
      Updates the thread's content report count.
      Parameters:
      count - the number of times it has been reported, or -1 if no reports allowed
      See Also:
    • setHidden

      public void setHidden(boolean hidden)
      Sets this thread's hidden flag.
      Parameters:
      hidden - TRUE if the thread is hidden, otherwise FALSE
      See Also:
    • setLocked

      public void setLocked(boolean locked)
      Sets this thread's locked flag.
      Parameters:
      locked - TRUE if the thread is locked, otherwise FALSE
      See Also:
    • setPoll

      public void setPoll(boolean poll)
      Sets this thread's poll flag.
      Parameters:
      poll - TRUE if the thread has a poll, otherwise FALSE
      See Also:
    • setImage

      public void setImage(int id)
      Updates the linked image for this thread.
      Parameters:
      id - the linked image database ID
      See Also:
    • setViews

      public void setViews(int views)
      Updates the number of times this thread has been read.
      Parameters:
      views - the number of views
      Throws:
      IllegalArgumentException - if views is negative
      See Also:
    • view

      public void view()
      Increments the view counter.
    • setPostCount

      public void setPostCount(int posts)
      Updates the number of messages in this thread.
      Parameters:
      posts - the number of messages
      Throws:
      IllegalArgumentException - if posts is negative
      IllegalStateException - if a message has been added via addPost()
      See Also:
    • addPost

      public void addPost(Message msg)
      Adds a message to this thread.
      Parameters:
      msg - the message to add
      Throws:
      NullPointerException - if msg is null
      See Also:
    • addUpdate

      public void addUpdate(ThreadUpdate upd)
      Adds a thread update entry to this thread.
      Parameters:
      upd - the update entry bean
      See Also:
    • addReportID

      public void addReportID(int id)
      Adds a database ID to the list of users reporting a thread for content.
      Parameters:
      id - the database ID
      See Also:
    • addOptions

      public void addOptions(Collection<PollOption> opts)
      Adds poll options to this thread.
      Parameters:
      opts - a Colllection of PollOption beans
      See Also:
    • addImageURL

      public void addImageURL(String url, String desc)
      Adds a URL to the list of linked Image URLs for this Message Thread.
      Parameters:
      url - the image URL
      desc - the image description
      See Also:
    • addImageURL

      public void addImageURL(LinkedImage img)
      Adds a URL to the list of linked Image URLs for this Message Thread.
      Parameters:
      img - the LinkedImage bean
      See Also:
    • addOption

      public void addOption(PollOption opt)
      Adds a single poll option to this thread.
      Parameters:
      opt - the PollOption bean
      See Also:
    • addVotes

      public void addVotes(Collection<PollVote> votes)
      Adds poll votes to this thread.
      Parameters:
      votes - a Collection of PollVote beans
      See Also:
    • getPosts

      public List<Message> getPosts()
      Returns this thread's messages.
      Returns:
      a List of posts, or an empty list if no messages have been added
      See Also:
    • getUpdates

      public Collection<ThreadUpdate> getUpdates()
      Returns this thread's update history
      Returns:
      a Collection of ThreadUpdate beans
      See Also:
    • getLastPost

      public Message getLastPost()
      Returns the last post in a message thread.
      Returns:
      the last post, or null if no messages have been added.
      See Also:
    • compareTo

      public int compareTo(Object o2)
      Compares to another thread via the last updated on date.
      Specified by:
      compareTo in interface Comparable<Object>
      Overrides:
      compareTo in class DatabaseBean
    • getRowClassName

      public String getRowClassName()
      Selects a table row class based upon whether the thread is hidden or not.
      Specified by:
      getRowClassName in interface ViewEntry
      Returns:
      the row CSS class name