Class CrowdsourcingBean

java.lang.Object
io.goobi.viewer.managedbeans.CrowdsourcingBean
All Implemented Interfaces:
Serializable

@Named @SessionScoped public class CrowdsourcingBean extends Object implements Serializable

CrowdsourcingBean class.

See Also:
  • Field Details

    • userBean

      @Inject protected UserBean userBean
  • Constructor Details

    • CrowdsourcingBean

      public CrowdsourcingBean()
    • CrowdsourcingBean

      public CrowdsourcingBean(Configuration viewerConfig, IDAO dao)
  • Method Details

    • init

      @PostConstruct public void init()
      Initialize all campaigns as lazily loaded list
    • getCampaignCount

      public long getCampaignCount(Campaign.CampaignVisibility visibility) throws DAOException

      getCampaignCount.

      Parameters:
      visibility - a Campaign.CampaignVisibility object.
      Returns:
      The total number of campaigns of a certain Campaign.CampaignVisibility
      Throws:
      DAOException - if any.
    • filterCampaignsAction

      public String filterCampaignsAction(Campaign.CampaignVisibility visibility)
      Filter the loaded campaigns by Campaign.CampaignVisibility
      Parameters:
      visibility - a Campaign.CampaignVisibility object.
      Returns:
      a String object.
    • getAllLocales

      public static Collection<Locale> getAllLocales()

      getAllLocales.

      Returns:
      A list of all locales supported by this viewer application
    • createNewCampaignAction

      public String createNewCampaignAction()
      Sets a new Campaign as the selectedCampaign and returns a pretty url to the view for creating a new campaign
      Returns:
      a String object.
    • editCampaignAction

      public String editCampaignAction(Campaign campaign)
      Sets the given Campaign as the selectedCampaign and returns a pretty url to the view for editing this campaign
      Parameters:
      campaign - a Campaign object.
      Returns:
      a String object.
    • deleteCampaignAction

      public String deleteCampaignAction(Campaign campaign) throws DAOException
      Delete the given Campaign from the database and the loaded list of campaigns
      Parameters:
      campaign - a Campaign object.
      Returns:
      a String object.
      Throws:
      DAOException - if any.
    • addNewQuestionAction

      public String addNewQuestionAction()
      Add a new Question to the selected campaign
      Returns:
      a String object.
    • removeQuestionAction

      public String removeQuestionAction(Question question)
      Remove the given Question from the selected campaign
      Parameters:
      question - a Question object.
      Returns:
      a String object.
    • resetDurationAction

      public String resetDurationAction()
      Resets dateStart + dateEnd to null.
      Returns:
      a String object.
    • getAllCampaigns

      public List<Campaign> getAllCampaigns() throws DAOException

      getAllCampaigns.

      Returns:
      All campaigns from the database
      Throws:
      DAOException - if any.
    • getAllCampaigns

      public List<Campaign> getAllCampaigns(Campaign.CampaignVisibility visibility) throws DAOException

      getAllCampaigns.

      Parameters:
      visibility - a Campaign.CampaignVisibility object.
      Returns:
      All campaigns of the given Campaign.CampaignVisibility from the database
      Throws:
      DAOException - if any.
    • getAllowedCampaigns

      public List<Campaign> getAllowedCampaigns(User user) throws DAOException
      Returns the list of campaigns that are visible to the given user.
      Parameters:
      user -
      Returns:
      List of campaigns allowed to the given user
      Throws:
      DAOException
    • isUserOwnsAnyCampaigns

      @Deprecated public boolean isUserOwnsAnyCampaigns(User user) throws DAOException
      Deprecated.
      Parameters:
      user -
      Returns:
      true if user owns any existing campaigns; false otherwise
      Throws:
      DAOException
    • isAllowed

      public static boolean isAllowed(User user, Campaign campaign) throws DAOException
      Check if the given user is allowed access to the given campaign from a rights management standpoint alone. If the user is null, access is granted for public campaigns only, otherwise access is granted if the user has the appropriate rights
      Parameters:
      user - a User object.
      campaign - a Campaign object.
      Returns:
      true if campaign is allowed to the given user; false otherwise
      Throws:
      DAOException - if any.
    • saveSelectedCampaignAction

      public String saveSelectedCampaignAction() throws DAOException, PresentationException, IndexUnreachableException
      Adds the current page to the database, if it doesn't exist or updates it otherwise
      Returns:
      Navigation outcome
      Throws:
      DAOException - if any.
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getCampaignsRootUrl

      public String getCampaignsRootUrl()

      getCampaignsRootUrl.

      Returns:
      root URL for the permalink value
    • getLazyModelCampaigns

      public TableDataProvider<Campaign> getLazyModelCampaigns()

      Getter for the field lazyModelCampaigns.

      Returns:
      the lazyModelCampaigns
    • getSelectedCampaign

      public Campaign getSelectedCampaign()

      Getter for the field selectedCampaign.

      Returns:
      the selectedCampaign
    • setSelectedCampaign

      public void setSelectedCampaign(Campaign campaign)
      Set the selected campaign to a clone of the given campaign
      Parameters:
      campaign - the campaign to set
    • getSelectedCampaignId

      public String getSelectedCampaignId()

      getSelectedCampaignId.

      Returns:
      The id of the selectedCampaign as String
    • setSelectedCampaignId

      public void setSelectedCampaignId(String id) throws DAOException
      Set the selectedCampaign by a String containing the campaign id
      Parameters:
      id - a String object.
      Throws:
      DAOException - if any.
    • isEditMode

      public boolean isEditMode()

      isEditMode.

      Returns:
      the editMode
    • getTargetCampaign

      public Campaign getTargetCampaign()

      Getter for the field targetCampaign.

      Returns:
      the targetCampaign
    • setTargetCampaign

      public void setTargetCampaign(Campaign targetCampaign)

      Setter for the field targetCampaign.

      Parameters:
      targetCampaign - the targetCampaign to set
    • getTargetCampaignId

      public String getTargetCampaignId()

      getTargetCampaignId.

      Returns:
      the identifier of the targetCampaign
    • setTargetCampaignId

      public void setTargetCampaignId(String id) throws NumberFormatException, DAOException

      setTargetCampaignId.

      Parameters:
      id - a String object.
      Throws:
      NumberFormatException - if any.
      DAOException - if any.
    • setNextIdentifierForAnnotation

      public void setNextIdentifierForAnnotation() throws PresentationException, IndexUnreachableException
      Throws:
      PresentationException
      IndexUnreachableException
    • setNextIdentifierForReview

      public void setNextIdentifierForReview() throws PresentationException, IndexUnreachableException
      Throws:
      PresentationException
      IndexUnreachableException
    • resetTarget

      public void resetTarget()
      removes the target identifier (pi) from the bean, so that pi can be targeted again by random target resolution
    • forwardToAnnotationTarget

      public String forwardToAnnotationTarget()

      forwardToAnnotationTarget.

      Returns:
      the pretty url to annotatate the targetIdentifier by the targetCampaign
    • forwardToReviewTarget

      public String forwardToReviewTarget()

      forwardToReviewTarget.

      Returns:
      the pretty url to review the targetIdentifier for the targetCampaign
    • getTargetIdentifier

      public String getTargetIdentifier()

      Getter for the field targetIdentifier.

      Returns:
      the PI of a work selected for editing
    • getTargetIdentifierForUrl

      public String getTargetIdentifierForUrl()

      getTargetIdentifierForUrl.

      Returns:
      the PI of a work selected for editing or "-" if no targetIdentifier exists
    • setTargetIdentifierForUrl

      public void setTargetIdentifierForUrl(String pi)

      setTargetIdentifierForUrl.

      Parameters:
      pi - a String object.
    • setTargetIdentifier

      public void setTargetIdentifier(String targetIdentifier)

      Setter for the field targetIdentifier.

      Parameters:
      targetIdentifier - the targetIdentifier to set
    • getTargetPage

      public int getTargetPage()
      Returns:
      the targetPage
    • setTargetPage

      public void setTargetPage(int targetPage)
      Parameters:
      targetPage - the targetPage to set
    • forwardToCrowdsourcingAnnotation

      public String forwardToCrowdsourcingAnnotation(Campaign campaign)

      forwardToCrowdsourcingAnnotation.

      Parameters:
      campaign - a Campaign object.
      Returns:
      a pretty url to annotate a random work with the given Campaign
    • forwardToCrowdsourcingReview

      public String forwardToCrowdsourcingReview(Campaign campaign)

      forwardToCrowdsourcingReview.

      Parameters:
      campaign - a Campaign object.
      Returns:
      a pretty url to review a random work with the given Campaign
    • forwardToCrowdsourcingAnnotation

      public String forwardToCrowdsourcingAnnotation(Campaign campaign, String pi)

      forwardToCrowdsourcingAnnotation.

      Parameters:
      campaign - a Campaign object.
      pi - a String object.
      Returns:
      a pretty url to annotate the work with the given pi with the given Campaign
    • forwardToCrowdsourcingReview

      public String forwardToCrowdsourcingReview(Campaign campaign, String pi)

      forwardToCrowdsourcingReview.

      Parameters:
      campaign - a Campaign object.
      pi - a String object.
      Returns:
      a pretty url to review the work with the given pi with the given Campaign
    • getNextItemUrl

      public String getNextItemUrl(Campaign campaign, CrowdsourcingStatus status)

      getRandomItemUrl.

      Parameters:
      campaign - The campaign with which to annotate/review
      status - if io.goobi.viewer.model.crowdsourcing.campaigns.CampaignRecordStatistic.CrowdsourcingStatus#REVIEW, return a url for reviewing, otherwise for annotating
      Returns:
      The pretty url to either review or annotate a random work with the given Campaign
    • getTargetRecordStatus

      public CrowdsourcingStatus getTargetRecordStatus()

      getTargetRecordStatus.

      Returns:
      the io.goobi.viewer.model.crowdsourcing.campaigns.CampaignRecordStatistic.CrowdsourcingStatus of the targetCampaign for the targetIdentifier
    • handleInvalidTarget

      public String handleInvalidTarget()

      handleInvalidTarget.

      Returns:
      the pretty URL to the crowdsourcing campaigns page if UserBean.getUser() is not eligible for viewing the targetCampaign
    • getActiveCampaignsForRecord

      public List<Campaign> getActiveCampaignsForRecord(String pi) throws DAOException, PresentationException, IndexUnreachableException
      Returns a list of active campaigns for the given identifier that are visible to the current user.
      Parameters:
      pi - a String object.
      Returns:
      List of campaigns
      Throws:
      DAOException - if any.
      PresentationException - if any.
      IndexUnreachableException - if any.
    • updateActiveCampaigns

      public void updateActiveCampaigns() throws DAOException, PresentationException, IndexUnreachableException
      Searches for all identifiers that are encompassed by the Solr query of each active campaign and initializes and fills a map of active campaigns for each identifier. Should be called once after the application first starts (or upon first access) or when a campaign has been updated.
      Throws:
      DAOException - if any.
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getPossibleReviewModes

      public Set<Campaign.ReviewMode> getPossibleReviewModes()
    • getAvailableStatisticModes

      public Set<Campaign.StatisticMode> getAvailableStatisticModes()
      Returns:
      List of enum values
    • getTargetStatus

      public CrowdsourcingStatus getTargetStatus()
      Returns:
      the targetStatus
    • setTargetStatus

      public void setTargetStatus(CrowdsourcingStatus targetStatus)
      Parameters:
      targetStatus - the targetStatus to set
    • setTargetStatus

      public void setTargetStatus(String targetStatus)