java.lang.Object
io.goobi.viewer.model.crowdsourcing.campaigns.Campaign
All Implemented Interfaces:
CMSMediaHolder, ILicenseType, IPolyglott, Serializable

@Entity public class Campaign extends Object implements CMSMediaHolder, ILicenseType, IPolyglott, Serializable
A Campaign is a template to create annotations of specific types for a limited set of target resources and optionally by limited user group within a limited time frame. The types of annotations created are determined by the Questions contained in this Campaign
Author:
florian
See Also:
  • Constructor Details

    • Campaign

      public Campaign()
      Empty constructor.
    • Campaign

      public Campaign(Locale selectedLocale)
      Locale constructor.
      Parameters:
      selectedLocale - a Locale object.
    • Campaign

      public Campaign(Campaign orig)
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getCampaignVisibilityValues

      public List<Campaign.CampaignVisibility> getCampaignVisibilityValues()

      getCampaignVisibilityValues.

      Returns:
      available values of the CampaignVisibility enum
    • getNumRecords

      public long getNumRecords() throws IndexUnreachableException

      getNumRecords.

      Returns:
      total number of records encompassed by the configured solrQuery
      Throws:
      IndexUnreachableException - if any.
    • getNumRecordsForStatus

      public long getNumRecordsForStatus(String status)

      getNumRecordsForStatus.

      Parameters:
      status - a String object.
      Returns:
      number of records with the given status
    • getNumRecordsToAnnotate

      public long getNumRecordsToAnnotate() throws IndexUnreachableException

      getNumRecordsToAnnotate.

      Returns:
      Number of records whose status is neither REVIEW nor FINISHED
      Throws:
      IndexUnreachableException - if any.
    • getContributorCount

      public long getContributorCount() throws DAOException
      Determines the number of distinct users that have created or reviewed annotations in the context of this campaign.
      Returns:
      number of users who either annotated or reviewed annotations
      Throws:
      DAOException - if any.
    • isHasAnnotations

      public boolean isHasAnnotations()
      Returns:
      true if this campaign has at least one annotation; false otherwise
    • getProgress

      public int getProgress() throws IndexUnreachableException, PresentationException
      FINISHED records in percent
      Returns:
      percentage of records marked as finished relative to the total number or records
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
    • getDaysBeforeStart

      public long getDaysBeforeStart()
      Returns the number of whole days between today and the starting date for this campaign.
      Returns:
      whole days left between today and dateStart; -1 if no dateStart
    • getDaysLeft

      public long getDaysLeft()
      Returns the number of whole days between today and the end date for this campaign. Because this method only returns the number of whole days left, its main purpose is for displaying the number of days to the user, and it shouldn't be used for access control.
      Returns:
      whole days left between today and dateEnd; -1 if no dateEnd
    • getDaysLeftAsString

      public String getDaysLeftAsString()

      getDaysLeftAsString.

      Returns:
      number of days left as string; infinity symbol if no dateEnd
    • isHasStarted

      public boolean isHasStarted()

      isHasStarted.

      Returns:
      true if dateStart lies after now; false otherwise
    • isHasEnded

      public boolean isHasEnded()

      isHasEnded.

      Returns:
      true if dateEnd lies before now; false otherwise
    • isUserAllowedAction

      public boolean isUserAllowedAction(User user, CrowdsourcingStatus status) throws PresentationException, IndexUnreachableException, DAOException
      Checks whether the given user may annotate or review records based on the given status.
      Parameters:
      user - a User object.
      status - a CrowdsourcingStatus object.
      Returns:
      true if the given user is allowed to perform the action associated with the given status; false otherwise
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
    • isUserMayEdit

      public boolean isUserMayEdit(User user) throws DAOException
      Parameters:
      user - User for whom to check access
      Returns:
      true if given User has permission to edit this Campaign; false otherwise
      Throws:
      DAOException
    • getName

      public String getName()
      Specified by:
      getName in interface ILicenseType
    • getTitle

      public String getTitle()
      Returns the title value in the current language of the campaign object (current tab). This is meant to be used for campaign editing only, since the language will not be in sync with the selected locale!
      Returns:
      a String object.
    • setTitle

      public void setTitle(String title)

      setTitle.

      Parameters:
      title - a String object.
    • getMenuTitle

      public String getMenuTitle()
      Returns the menu title value in the current language of the campaign object (current tab). This is meant to be used for campaign editing only, since the language will not be in sync with the selected locale!
      Returns:
      a String object.
    • getMenuTitleOrElseTitle

      public String getMenuTitleOrElseTitle()

      getMenuTitleOrElseTitle.

      Returns:
      a String object.
    • getMenuTitleOrElseTitle

      public String getMenuTitleOrElseTitle(String lang, boolean useFallback)

      getMenuTitleOrElseTitle.

      Parameters:
      lang - a String object.
      useFallback - a boolean.
      Returns:
      a String object.
    • setMenuTitle

      public void setMenuTitle(String menuTitle)

      setMenuTitle.

      Parameters:
      menuTitle - a String object.
    • getDescription

      public String getDescription()
      Returns the description value in the current language of the campaign object (current tab). This is meant to be used for campaign editing only, since the language will not be in sync with the selected locale!
      Returns:
      Description value in the current language in the campaign object
    • setDescription

      public void setDescription(String description)

      setDescription.

      Parameters:
      description - a String object.
    • getTitle

      public String getTitle(String lang)

      getTitle.

      Parameters:
      lang - a String object.
      Returns:
      a String object.
    • getTitle

      public String getTitle(String lang, boolean useFallback)

      getTitle.

      Parameters:
      lang - a String object.
      useFallback - a boolean.
      Returns:
      the title of the given language or if it doesn't exist the title of the default language
    • getDescription

      public String getDescription(String lang)

      getDescription.

      Parameters:
      lang - a String object.
      Returns:
      a String object.
    • getDescription

      public String getDescription(String lang, boolean useFallback)

      getDescription.

      Parameters:
      lang - a String object.
      useFallback - a boolean.
      Returns:
      a String object.
    • getMenuTitle

      public String getMenuTitle(String lang)

      getMenuTitle.

      Parameters:
      lang - a String object.
      Returns:
      a String object.
    • getMenuTitle

      public String getMenuTitle(String lang, boolean useFallback)

      getMenuTitle.

      Parameters:
      lang - a String object.
      useFallback - a boolean.
      Returns:
      a String object.
    • getDisplayTitle

      public String getDisplayTitle()
    • getDisplayDescription

      public String getDisplayDescription()
    • getId

      public Long getId()

      Getter for the field id.

      Returns:
      the id
    • getId

      public static Long getId(URI idAsURI)

      Getter for the field id.

      Parameters:
      idAsURI - a URI object.
      Returns:
      a Long object.
    • getIdAsURI

      public URI getIdAsURI()

      getIdAsURI.

      Returns:
      a URI object.
    • setId

      public void setId(Long id)

      Setter for the field id.

      Parameters:
      id - the id to set
    • getDateCreated

      public LocalDateTime getDateCreated()

      Getter for the field dateCreated.

      Returns:
      the dateCreated
    • setDateCreated

      public void setDateCreated(LocalDateTime dateCreated)

      Setter for the field dateCreated.

      Parameters:
      dateCreated - the dateCreated to set
    • getDateUpdated

      public LocalDateTime getDateUpdated()

      Getter for the field dateUpdated.

      Returns:
      the dateUpdated
    • setDateUpdated

      public void setDateUpdated(LocalDateTime dateUpdated)

      Setter for the field dateUpdated.

      Parameters:
      dateUpdated - the dateUpdated to set
    • getVisibility

      public Campaign.CampaignVisibility getVisibility()

      Getter for the field visibility.

      Returns:
      the visibility
    • setVisibility

      public void setVisibility(Campaign.CampaignVisibility visibility)

      Setter for the field visibility.

      Parameters:
      visibility - the visibility to set
    • getDateOnlyStart

      public LocalDate getDateOnlyStart()
      Returns:
      LocalDate
    • setDateOnlyStart

      public void setDateOnlyStart(LocalDate dateStart)
      Parameters:
      dateStart -
    • getDateStart

      public LocalDateTime getDateStart()

      Getter for the field dateStart.

      Returns:
      the dateStart
    • setDateStart

      public void setDateStart(LocalDateTime dateStart)

      Setter for the field dateStart.

      Parameters:
      dateStart - the dateStart to set
    • getDateStartString

      @Deprecated(since="24.10") public String getDateStartString()
      Deprecated.

      getDateStartString.

      Returns:
      formatted ISO string representation of stateStart
    • setDateStartString

      @Deprecated(since="24.10") public void setDateStartString(String dateStartString)
      Deprecated.

      setDateStartString.

      Parameters:
      dateStartString - a String object.
    • getDateOnlyEnd

      public LocalDate getDateOnlyEnd()
      Returns:
      LocalDate
    • setDateOnlyEnd

      public void setDateOnlyEnd(LocalDate dateEnd)
      Parameters:
      dateEnd -
    • getDateEnd

      public LocalDateTime getDateEnd()

      Getter for the field dateEnd.

      Returns:
      the dateEnd
    • setDateEnd

      public void setDateEnd(LocalDateTime dateEnd)

      Setter for the field dateEnd.

      Parameters:
      dateEnd - the dateEnd to set
    • getDateEndString

      @Deprecated(since="24.10") public String getDateEndString()
      Deprecated.

      getDateEndString.

      Returns:
      formatted ISO string representation of dateEnd
    • setDateEndString

      @Deprecated(since="24.10") public void setDateEndString(String dateEndString)
      Deprecated.

      setDateEndString.

      Parameters:
      dateEndString - a String object.
    • getSolrQuery

      public String getSolrQuery()

      Getter for the field solrQuery.

      Returns:
      the solrQuery
    • setSolrQuery

      public void setSolrQuery(String solrQuery)

      Setter for the field solrQuery.

      Parameters:
      solrQuery - the solrQuery to set
    • getPermalink

      public String getPermalink()

      Getter for the field permalink.

      Returns:
      the permalink
    • setPermalink

      public void setPermalink(String permalink)

      Setter for the field permalink.

      Parameters:
      permalink - the permalink to set
    • getBreadcrumbParentCmsPageId

      public String getBreadcrumbParentCmsPageId()

      Getter for the field breadcrumbParentCmsPageId.

      Returns:
      the breadcrumbParentCmsPageId
    • setBreadcrumbParentCmsPageId

      public void setBreadcrumbParentCmsPageId(String breadcrumbParentCmsPageId)

      Setter for the field breadcrumbParentCmsPageId.

      Parameters:
      breadcrumbParentCmsPageId - the breadcrumbParentCmsPageId to set
    • getTranslations

      public List<CampaignTranslation> getTranslations()

      Getter for the field translations.

      Returns:
      the translations
    • setTranslations

      public void setTranslations(List<CampaignTranslation> translations)

      Setter for the field translations.

      Parameters:
      translations - the translations to set
    • getQuestions

      public List<Question> getQuestions()

      Getter for the field questions.

      Returns:
      the questions
    • setQuestions

      public void setQuestions(List<Question> questions)

      Setter for the field questions.

      Parameters:
      questions - the questions to set
    • getStatistics

      public Map<String,CampaignRecordStatistic> getStatistics()

      Getter for the field statistics.

      Returns:
      the statistics
    • setStatistics

      public void setStatistics(Map<String,CampaignRecordStatistic> statistics)

      Setter for the field statistics.

      Parameters:
      statistics - the statistics to set
    • getSelectedLocale

      public Locale getSelectedLocale()

      Getter for the field selectedLocale.

      Specified by:
      getSelectedLocale in interface IPolyglott
      Returns:
      the selectedLocale
    • setSelectedLocale

      public void setSelectedLocale(Locale selectedLocale)

      Setter for the field selectedLocale.

      Specified by:
      setSelectedLocale in interface IPolyglott
      Parameters:
      selectedLocale - the selectedLocale to set
    • isReady

      public boolean isReady()
      Return true if the campaign is ready for use. For this, the title in the default language must exists and there must be at least one question
      Returns:
      a boolean
    • isComplete

      public boolean isComplete(Locale locale)
      Description copied from interface: IPolyglott
      If this returns true, an associated language tab should have the 'already-translated' class, otherwise the '-partly-translated' class unless IPolyglott.isEmpty(Locale) also returns true
      Specified by:
      isComplete in interface IPolyglott
      Returns:
      true if IPolyglott.isValid(Locale) returns true for the given locale and all fields contain a value which have a value in the default locale. For the default locale, IPolyglott.isComplete(Locale) and IPolyglott.isValid(Locale) are identical. For implementations with only one field, both methods are also always identical
    • isValid

      public boolean isValid(Locale locale)
      Description copied from interface: IPolyglott
      Only meaningfull for the default language for which all required fields must be filled
      Specified by:
      isValid in interface IPolyglott
      Returns:
      true if the title is not empty for the given locale
    • isEmpty

      public boolean isEmpty(Locale locale)
      Description copied from interface: IPolyglott
      If this returns true, an associated language tab should have neither the 'already-translated' nor the '-partly-translated' class
      Specified by:
      isEmpty in interface IPolyglott
      Returns:
      true if no fields are filled for the given locale
    • getRandomizedTarget

      public String getRandomizedTarget(CrowdsourcingStatus status, String piToIgnore, User user) throws PresentationException, IndexUnreachableException
      Get the targetIdentifier to a random PI from the Solr query result list.
      Parameters:
      status - a CrowdsourcingStatus object.
      piToIgnore - a String object.
      user -
      Returns:
      a String object.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getNextTarget

      public String getNextTarget(CrowdsourcingStatus status, String currentPi, User user) throws PresentationException, IndexUnreachableException
      Get the targetIdentifier to a random PI from the Solr query result list.
      Parameters:
      status - a CrowdsourcingStatus object.
      currentPi - a String object.
      user -
      Returns:
      a String object.
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • resetSolrQueryResults

      public void resetSolrQueryResults()
    • isEligibleToEdit

      public boolean isEligibleToEdit(String pi, CrowdsourcingStatus status, User user)
      Check if the given user may annotate/review (depending on status) a specific pi within this campaign
      Parameters:
      status - a CrowdsourcingStatus object.
      user - a User object.
      pi - a String object.
      Returns:
      true if
      • the status is REVIEW and the user is not contained in the annotators list
      • or
      • the status is ANNOTATE and the user is not contained in the reviewers list
      • or
      • The user is admin
      • or
      • The user is null
    • hasRecordsToReview

      public boolean hasRecordsToReview(User user) throws PresentationException, IndexUnreachableException
      check if the given user is eligible to review any records
      Parameters:
      user - a User object.
      Returns:
      true if there are any records in review status for which isEligibleToEdit(String, CrowdsourcingStatus, User) returns true
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • hasRecordsToAnnotate

      public boolean hasRecordsToAnnotate(User user) throws PresentationException, IndexUnreachableException
      check if the given user is eligible to annotate any records
      Parameters:
      user - a User object.
      Returns:
      true if there are any records in annotate status for which isEligibleToEdit(String, CrowdsourcingStatus, User) returns true
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • mayAnnotate

      public boolean mayAnnotate(User user, String pi) throws PresentationException, IndexUnreachableException
      check if the user is allowed to annotate the given pi for this campaign
      Parameters:
      user - a User object.
      pi - a String object.
      Returns:
      true if the pi is ready for annotation and the user hasn't reviewed it or is a superuser
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • mayReview

      public boolean mayReview(User user, String pi) throws PresentationException, IndexUnreachableException
      check if the user is allowed to review the given pi for this campaign
      Parameters:
      user - a User object.
      pi - a String object.
      Returns:
      true if the pi is ready for review and the user hasn't annotated it or is a superuser
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getRecordStatus

      public CrowdsourcingStatus getRecordStatus(String pi)

      getRecordStatus.

      Parameters:
      pi - a String object.
      Returns:
      record status for the given pi
    • getPageStatus

      public CrowdsourcingStatus getPageStatus(String pi, int page)
    • isGroupLimitActive

      public boolean isGroupLimitActive()
      Returns:
      true if this Campaign is limited to a UserGroup; false otherwise
    • isReviewGroupLimitActive

      public boolean isReviewGroupLimitActive()
    • isReviewModeActive

      public boolean isReviewModeActive()
    • setRecordStatus

      public void setRecordStatus(String pi, CrowdsourcingStatus status, Optional<User> user)
      Updates record status in the campaign statistics.
      Parameters:
      pi - a String object.
      status - a CrowdsourcingStatus object.
      user - a Optional object.
    • setRecordPageStatus

      public void setRecordPageStatus(String pi, int page, CrowdsourcingStatus status, Optional<User> user)
      Parameters:
      pi -
      page -
      status -
      user -
    • setMediaItem

      public void setMediaItem(CMSMediaItem item)

      setMediaItem.

      Specified by:
      setMediaItem in interface CMSMediaHolder
      Parameters:
      item - a CMSMediaItem object.
    • getMediaItem

      public CMSMediaItem getMediaItem()

      getMediaItem.

      Specified by:
      getMediaItem in interface CMSMediaHolder
      Returns:
      a CMSMediaItem object.
    • getMediaFilter

      public String getMediaFilter()

      A regular expression determining which filenames are shown in the media list and may be uploaded

      Specified by:
      getMediaFilter in interface CMSMediaHolder
      Returns:
      a String object.
    • getMediaTypes

      public String getMediaTypes()
      Description copied from interface: CMSMediaHolder
      A string representing the allowed media formates for a user. Should be a comma separated list of format names or filename suffixes
      Specified by:
      getMediaTypes in interface CMSMediaHolder
      Returns:
      String
    • hasMediaItem

      public boolean hasMediaItem()

      hasMediaItem.

      Specified by:
      hasMediaItem in interface CMSMediaHolder
      Returns:
      a boolean.
    • setShowLog

      public void setShowLog(boolean showLog)
      Parameters:
      showLog - the showLog to set
    • isShowLog

      public boolean isShowLog()
      Returns:
      the showLog
    • isLimitToGroup

      public boolean isLimitToGroup()
      Returns:
      the limitToGroup
    • setLimitToGroup

      public void setLimitToGroup(boolean limitToGroup)
      Parameters:
      limitToGroup - the limitToGroup to set
    • getReviewMode

      public Campaign.ReviewMode getReviewMode()
      Returns:
      the reviewMode
    • setReviewMode

      public void setReviewMode(Campaign.ReviewMode reviewMode)
      Parameters:
      reviewMode - the reviewMode to set
    • getStatisticMode

      public Campaign.StatisticMode getStatisticMode()
      Returns:
      the statisticMode
    • setStatisticMode

      public void setStatisticMode(Campaign.StatisticMode statisticMode)
      Parameters:
      statisticMode - the statisticMode to set
    • getUserGroup

      public UserGroup getUserGroup()
      Returns:
      the userGroup
    • setUserGroup

      public void setUserGroup(UserGroup userGroup)
      Parameters:
      userGroup - the userGroup to set
    • getReviewerUserGroup

      public UserGroup getReviewerUserGroup()
      Returns:
      the reviewerUserGroup
    • setReviewerUserGroup

      public void setReviewerUserGroup(UserGroup reviewerUserGroup)
      Parameters:
      reviewerUserGroup - the reviewerUserGroup to set
    • isTimePeriodEnabled

      public boolean isTimePeriodEnabled()
      Returns:
      the timePeriodEnabled
    • isRestrictAnnotationAccess

      public boolean isRestrictAnnotationAccess()
      Returns:
      the restrictAnnotationAccess
    • setRestrictAnnotationAccess

      public void setRestrictAnnotationAccess(boolean restrictAnnotationAccess)
      Parameters:
      restrictAnnotationAccess - the restrictAnnotationAccess to set
    • setTimePeriodEnabled

      public void setTimePeriodEnabled(boolean timePeriodEnabled)
      Parameters:
      timePeriodEnabled - the timePeriodEnabled to set
    • getLogMessages

      public List<CampaignLogMessage> getLogMessages()
      Returns:
      the logMessages
    • addLogMessage

      public CampaignLogMessage addLogMessage(LogMessage message, String pi)
    • deleteLogMessage

      public void deleteLogMessage(Long messageId)
      Parameters:
      messageId -
    • getMediaItemWrapper

      public CategorizableTranslatedSelectable<CMSMediaItem> getMediaItemWrapper()

      getMediaItemWrapper.

      Specified by:
      getMediaItemWrapper in interface CMSMediaHolder
      Returns:
      a CategorizableTranslatedSelectable object.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAccessConditionValue

      public String getAccessConditionValue()
      Returns:
      String