Class CommentLegacy

java.lang.Object
io.goobi.viewer.model.annotation.comments.CommentLegacy
All Implemented Interfaces:
Comparable<CommentLegacy>

public class CommentLegacy extends Object implements Comparable<CommentLegacy>
Legacy comment model for migrating user comments from the old persistence format.
  • Constructor Details

    • CommentLegacy

      public CommentLegacy()
      Creates a new Comment instance.
    • CommentLegacy

      public CommentLegacy(String pi, int page, User owner, String text, CommentLegacy parent)
      Creates a new Comment instance.
      Parameters:
      pi - persistent identifier of the commented record
      page - page number the comment is attached to
      owner - user who created this comment
      text - comment body text
      parent - unused parent comment (legacy field)
  • Method Details

    • compareTo

      public int compareTo(CommentLegacy o)
      Specified by:
      compareTo in interface Comparable<CommentLegacy>
    • sendEmailNotifications

      public static boolean sendEmailNotifications(CommentLegacy comment, String oldText, Locale locale)
      Sends an email notification about a new or altered comment to the configured recipient addresses.
      Parameters:
      comment - comment that was created or modified
      oldText - previous comment text, or empty/null if this is a new comment
      locale - Language locale for the email text.
      Returns:
      true if the email notification was sent successfully, false otherwise
    • mayEdit

      public boolean mayEdit(User user)
      Checks whether the user with the given ID is allowed to edit this comment (i.e. the annotation belongs to this (proper) user.
      Parameters:
      user - user requesting edit access
      Returns:
      true if allowed; false otherwise
    • getDisplayDate

      public String getDisplayDate(LocalDateTime date)
      getDisplayDate.
      Parameters:
      date - date and time to format for display
      Returns:
      the given date and time formatted as a German date-time string
    • checkAndCleanScripts

      public void checkAndCleanScripts()
      Removes any script tags from the text value.
    • getId

      public Long getId()
      Getter for the field id.
      Returns:
      the database primary key of this comment
    • setId

      public void setId(Long id)
      Setter for the field id.
      Parameters:
      id - the database ID to set
    • getPi

      public String getPi()
      Getter for the field pi.
      Returns:
      the persistent identifier of the record this comment belongs to
    • setPi

      public void setPi(String pi)
      Setter for the field pi.
      Parameters:
      pi - the persistent identifier of the record this comment belongs to
    • getPage

      public Integer getPage()
      Getter for the field page.
      Returns:
      the 1-based page order number within the record this comment targets
    • setPage

      public void setPage(Integer page)
      Setter for the field page.
      Parameters:
      page - the 1-based page order number within the record this comment targets
    • getOwner

      public User getOwner()
      Getter for the field owner.
      Returns:
      the user who authored this comment
    • setOwner

      public void setOwner(User owner)
      Setter for the field owner.
      Parameters:
      owner - the user who authored this comment
    • setText

      public void setText(String text)
      Setter for the field text.
      Parameters:
      text - the new comment text; the previous value is preserved in oldText
    • getText

      public String getText()
      Getter for the field text.
      Returns:
      the current comment text
    • getDisplayText

      public String getDisplayText()
      getDisplayText.
      Returns:
      the comment text with any JavaScript stripped out
    • getOldText

      public String getOldText()
      Getter for the field oldText.
      Returns:
      the previous comment text before the last update, or null if the text has not been changed
    • getDateCreated

      public LocalDateTime getDateCreated()
      Getter for the field dateCreated.
      Returns:
      the timestamp when this comment was created
    • setDateCreated

      public void setDateCreated(LocalDateTime dateCreated)
      Setter for the field dateCreated.
      Parameters:
      dateCreated - the creation timestamp to set
    • getDateUpdated

      public LocalDateTime getDateUpdated()
      Getter for the field dateUpdated.
      Returns:
      the timestamp when this comment was last updated
    • setDateUpdated

      public void setDateUpdated(LocalDateTime dateUpdated)
      Setter for the field dateUpdated.
      Parameters:
      dateUpdated - the last-updated timestamp to set
    • getLinkToRecord

      public String getLinkToRecord()