Package io.goobi.viewer.managedbeans
Class CrowdsourcingBean
java.lang.Object
io.goobi.viewer.managedbeans.CrowdsourcingBean
- All Implemented Interfaces:
Serializable
JSF backing bean for crowdsourcing campaign management, providing access to campaigns and annotation tasks.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new CrowdsourcingBean instance.CrowdsourcingBean(Configuration viewerConfig, IDAO dao) Creates a new CrowdsourcingBean instance. -
Method Summary
Modifier and TypeMethodDescriptionAdds a newQuestionto the selected campaign.Sets a newCampaignas theselectedCampaignand returns a pretty url to the view for creating a new campaign.deleteCampaignAction(Campaign campaign) Deletes the givenCampaignfrom the database and the loaded list of campaigns.editCampaignAction(Campaign campaign) Sets the givenCampaignas theselectedCampaignand returns a pretty url to the view for editing this campaign.filterCampaignsAction(Campaign.CampaignVisibility visibility) Filter the loaded campaigns byCampaign.CampaignVisibility.forwardToAnnotationTarget.forwardToCrowdsourcingAnnotation(Campaign campaign) forwardToCrowdsourcingAnnotation.forwardToCrowdsourcingAnnotation(Campaign campaign, String pi) forwardToCrowdsourcingAnnotation.forwardToCrowdsourcingReview(Campaign campaign) forwardToCrowdsourcingReview.forwardToCrowdsourcingReview(Campaign campaign, String pi) forwardToCrowdsourcingReview.forwardToReviewTarget.Returns a list of active campaigns for the given identifier that are visible to the current user.getAllCampaigns.getAllCampaigns(Campaign.CampaignVisibility visibility) getAllCampaigns.static Collection<Locale> getAllLocales.getAllowedCampaigns(User user) Returns the list of campaigns that are visible to the given user.getAvailableStatisticModes.longgetCampaignCount(Campaign.CampaignVisibility visibility) getCampaignCount.getCampaignsRootUrl.Getter for the fieldlazyModelCampaigns.getNextItemUrl(Campaign campaign, CrowdsourcingStatus status) getRandomItemUrl.getPossibleReviewModes.Getter for the fieldselectedCampaign.getSelectedCampaignId.Getter for the fieldtargetCampaign.getTargetCampaignId.Getter for the fieldtargetIdentifier.getTargetIdentifierForUrl.intGetter for the fieldtargetPage.getTargetRecordStatus.Getter for the fieldtargetStatus.handleInvalidTarget.voidinit()Initializes all campaigns as lazily loaded list.static booleanCheck if the given user is allowed access to the given campaign from a rights management standpoint alone.booleanisEditMode.booleanisUserOwnsAnyCampaigns(User user) isUserOwnsAnyCampaigns.removeQuestionAction(Question question) Removes the givenQuestionfrom the selected campaign.Resets dateStart + dateEnd to null.voidRemoves the target identifier (pi) from the bean, so that pi can be targeted again by random target resolution.Adds the current page to the database, if it doesn't exist or updates it otherwise.voidsetNextIdentifierForAnnotation.voidsetNextIdentifierForReview.voidsetSelectedCampaign(Campaign campaign) Sets the selected campaign to a clone of the given campaign.voidSets theselectedCampaignby a String containing the campaign id.voidsetTargetCampaign(Campaign targetCampaign) Setter for the fieldtargetCampaign.voidsetTargetCampaignId.voidsetTargetIdentifier(String targetIdentifier) Setter for the fieldtargetIdentifier.voidsetTargetIdentifierForUrl.voidsetTargetPage(int targetPage) Setter for the fieldtargetPage.voidsetTargetStatus(CrowdsourcingStatus targetStatus) Setter for the fieldtargetStatus.voidsetTargetStatus(String targetStatus) Setter for the fieldtargetStatus.voidSearches 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.
-
Field Details
-
userBean
-
-
Constructor Details
-
CrowdsourcingBean
public CrowdsourcingBean()Creates a new CrowdsourcingBean instance. -
CrowdsourcingBean
Creates a new CrowdsourcingBean instance.- Parameters:
viewerConfig- viewer configuration used within this beandao- DAO instance for database access
-
-
Method Details
-
init
Initializes all campaigns as lazily loaded list. -
getCampaignCount
getCampaignCount.- Parameters:
visibility- visibility level to filter by, or null for all campaigns- Returns:
- The total number of campaigns of a certain
Campaign.CampaignVisibility - Throws:
DAOException- if any.
-
filterCampaignsAction
Filter the loaded campaigns byCampaign.CampaignVisibility.- Parameters:
visibility- visibility level to filter by, or null to clear the filter- Returns:
- an empty string after applying the visibility filter to the campaign list
-
getAllLocales
getAllLocales.- Returns:
- A list of all locales supported by this viewer application
-
createNewCampaignAction
Sets a newCampaignas theselectedCampaignand returns a pretty url to the view for creating a new campaign.- Returns:
- an empty string after initializing a new empty campaign for creation
-
editCampaignAction
Sets the givenCampaignas theselectedCampaignand returns a pretty url to the view for editing this campaign.- Parameters:
campaign- campaign to open for editing- Returns:
- the pretty URL name for the campaign edit view
-
deleteCampaignAction
Deletes the givenCampaignfrom the database and the loaded list of campaigns.- Parameters:
campaign- campaign to delete from the database- Returns:
- an empty string after deleting the campaign from the database
- Throws:
DAOException- if any.
-
addNewQuestionAction
Adds a newQuestionto the selected campaign.- Returns:
- an empty string after adding the new question to the selected campaign
-
removeQuestionAction
Removes the givenQuestionfrom the selected campaign.- Parameters:
question- question to remove from the selected campaign- Returns:
- an empty string after removing the question from the selected campaign
-
resetDurationAction
Resets dateStart + dateEnd to null.- Returns:
- an empty string after clearing the campaign start and end dates
-
getAllCampaigns
getAllCampaigns.- Returns:
- All campaigns from the database
- Throws:
DAOException- if any.
-
getAllCampaigns
getAllCampaigns.- Parameters:
visibility- visibility level used to filter the full campaign list- Returns:
- All campaigns of the given
Campaign.CampaignVisibilityfrom the database - Throws:
DAOException- if any.
-
getAllowedCampaigns
Returns the list of campaigns that are visible to the given user.- Parameters:
user- user to check campaign visibility for, or null for anonymous access- Returns:
- List of campaigns allowed to the given user
- Throws:
DAOException
-
isUserOwnsAnyCampaigns
isUserOwnsAnyCampaigns.- Parameters:
user- user whose campaign ownership is checked- Returns:
- true if user owns any existing campaigns; false otherwise
- Throws:
DAOException
-
isAllowed
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- user requesting access, or null for anonymous accesscampaign- campaign to evaluate access for- Returns:
- true if campaign is allowed to the given user; false otherwise
- Throws:
DAOException- if any.
-
saveSelectedCampaignAction
public String saveSelectedCampaignAction() throws DAOException, PresentationException, IndexUnreachableExceptionAdds 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
getCampaignsRootUrl.- Returns:
- root URL for the permalink value
-
getLazyModelCampaigns
Getter for the fieldlazyModelCampaigns.- Returns:
- the lazy-loading table data provider for crowdsourcing campaigns
-
getSelectedCampaign
Getter for the fieldselectedCampaign.- Returns:
- the currently selected crowdsourcing campaign, or null if none is selected
-
setSelectedCampaign
Sets the selected campaign to a clone of the given campaign.- Parameters:
campaign- the campaign to select; a deep copy is stored internally
-
getSelectedCampaignId
getSelectedCampaignId.- Returns:
- The id of the
selectedCampaignas String
-
setSelectedCampaignId
Sets theselectedCampaignby a String containing the campaign id.- Parameters:
id- numeric campaign ID as string, or null to clear selection- Throws:
DAOException- if any.
-
isEditMode
public boolean isEditMode()isEditMode.- Returns:
- true if a campaign with a persisted ID is currently selected (edit mode), false otherwise
-
getTargetCampaign
Getter for the fieldtargetCampaign.- Returns:
- the
targetCampaign
-
setTargetCampaign
Setter for the fieldtargetCampaign.- Parameters:
targetCampaign- the campaign to use as the annotation or review target
-
getTargetCampaignId
getTargetCampaignId.- Returns:
- the identifier of the
targetCampaign
-
setTargetCampaignId
setTargetCampaignId.- Parameters:
id- numeric campaign ID as string, or null to clear the target- Throws:
NumberFormatException- if any.DAOException- if any.
-
setNextIdentifierForAnnotation
public void setNextIdentifierForAnnotation() throws PresentationException, IndexUnreachableExceptionsetNextIdentifierForAnnotation.- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
setNextIdentifierForReview
setNextIdentifierForReview.- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
resetTarget
public void resetTarget()Removes the target identifier (pi) from the bean, so that pi can be targeted again by random target resolution. -
forwardToAnnotationTarget
forwardToAnnotationTarget.- Returns:
- the pretty url to annotatate the
targetIdentifierby thetargetCampaign
-
forwardToReviewTarget
forwardToReviewTarget.- Returns:
- the pretty url to review the
targetIdentifierfor thetargetCampaign
-
getTargetIdentifier
Getter for the fieldtargetIdentifier.- Returns:
- the PI of a work selected for editing
-
getTargetIdentifierForUrl
getTargetIdentifierForUrl.- Returns:
- the PI of a work selected for editing or "-" if no targetIdentifier exists
-
setTargetIdentifierForUrl
setTargetIdentifierForUrl.- Parameters:
pi- persistent identifier from the URL, or "-" to clear the target
-
setTargetIdentifier
Setter for the fieldtargetIdentifier.- Parameters:
targetIdentifier- the persistent identifier (PI) of the record selected for annotation or review
-
getTargetPage
public int getTargetPage()Getter for the fieldtargetPage.- Returns:
- the page number within the target record to annotate or review
-
setTargetPage
public void setTargetPage(int targetPage) Setter for the fieldtargetPage.- Parameters:
targetPage- the page number within the target record to annotate or review
-
forwardToCrowdsourcingAnnotation
forwardToCrowdsourcingAnnotation.- Parameters:
campaign- campaign to set as the annotation target- Returns:
- a pretty url to annotate a random work with the given
Campaign
-
forwardToCrowdsourcingReview
forwardToCrowdsourcingReview.- Parameters:
campaign- campaign to set as the review target- Returns:
- a pretty url to review a random work with the given
Campaign
-
forwardToCrowdsourcingAnnotation
forwardToCrowdsourcingAnnotation.- Parameters:
campaign- campaign to use for annotating the recordpi- persistent identifier of the record to annotate- Returns:
- a pretty url to annotate the work with the given pi with the given
Campaign
-
forwardToCrowdsourcingReview
forwardToCrowdsourcingReview.- Parameters:
campaign- campaign to use for reviewing the recordpi- persistent identifier of the record to review- Returns:
- a pretty url to review the work with the given pi with the given
Campaign
-
getNextItemUrl
getRandomItemUrl.- Parameters:
campaign- The campaign with which to annotate/reviewstatus- ifCrowdsourcingStatus.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
getTargetRecordStatus.- Returns:
- the
CrowdsourcingStatusof thetargetCampaignfor thetargetIdentifier
-
handleInvalidTarget
handleInvalidTarget.- Returns:
- the pretty URL to the crowdsourcing campaigns page if
UserBean.getUser()is not eligible for viewing thetargetCampaign
-
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- persistent identifier of the record to look up- Returns:
- List of campaigns
- Throws:
DAOException- if any.PresentationException- if any.IndexUnreachableException- if any.
-
updateActiveCampaigns
public void updateActiveCampaigns() throws DAOException, PresentationException, IndexUnreachableExceptionSearches 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
getPossibleReviewModes.- Returns:
- the set of all available review mode values
-
getAvailableStatisticModes
getAvailableStatisticModes.- Returns:
- List of enum values
-
getTargetStatus
Getter for the fieldtargetStatus.- Returns:
- the crowdsourcing status used to filter or assign to the target
-
setTargetStatus
Setter for the fieldtargetStatus.- Parameters:
targetStatus- the crowdsourcing status to filter or assign to the target
-
setTargetStatus
Setter for the fieldtargetStatus.- Parameters:
targetStatus- status name resolved via CrowdsourcingStatus.forName
-