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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CrowdsourcingBean()
CrowdsourcingBean(Configuration viewerConfig, IDAO dao)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
addNewQuestionAction()
Add a newQuestion
to the selected campaignString
createNewCampaignAction()
Sets a newCampaign
as theselectedCampaign
and returns a pretty url to the view for creating a new campaignString
deleteCampaignAction(Campaign campaign)
Delete the givenCampaign
from the database and the loaded list of campaignsString
editCampaignAction(Campaign campaign)
Sets the givenCampaign
as theselectedCampaign
and returns a pretty url to the view for editing this campaignString
filterCampaignsAction(Campaign.CampaignVisibility visibility)
Filter the loaded campaigns byCampaign.CampaignVisibility
String
forwardToAnnotationTarget()
forwardToAnnotationTarget.String
forwardToCrowdsourcingAnnotation(Campaign campaign)
forwardToCrowdsourcingAnnotation.String
forwardToCrowdsourcingAnnotation(Campaign campaign, String pi)
forwardToCrowdsourcingAnnotation.String
forwardToCrowdsourcingReview(Campaign campaign)
forwardToCrowdsourcingReview.String
forwardToCrowdsourcingReview(Campaign campaign, String pi)
forwardToCrowdsourcingReview.String
forwardToReviewTarget()
forwardToReviewTarget.List<Campaign>
getActiveCampaignsForRecord(String pi)
Returns a list of active campaigns for the given identifier that are visible to the current user.List<Campaign>
getAllCampaigns()
getAllCampaigns.List<Campaign>
getAllCampaigns(Campaign.CampaignVisibility visibility)
getAllCampaigns.static Collection<Locale>
getAllLocales()
getAllLocales.List<Campaign>
getAllowedCampaigns(User user)
Returns the list of campaigns that are visible to the given user.Set<Campaign.StatisticMode>
getAvailableStatisticModes()
long
getCampaignCount(Campaign.CampaignVisibility visibility)
getCampaignCount.String
getCampaignsRootUrl()
getCampaignsRootUrl.TableDataProvider<Campaign>
getLazyModelCampaigns()
Getter for the fieldlazyModelCampaigns
.String
getNextItemUrl(Campaign campaign, CrowdsourcingStatus status)
getRandomItemUrl.Set<Campaign.ReviewMode>
getPossibleReviewModes()
Campaign
getSelectedCampaign()
Getter for the fieldselectedCampaign
.String
getSelectedCampaignId()
getSelectedCampaignId.Campaign
getTargetCampaign()
Getter for the fieldtargetCampaign
.String
getTargetCampaignId()
getTargetCampaignId.String
getTargetIdentifier()
Getter for the fieldtargetIdentifier
.String
getTargetIdentifierForUrl()
getTargetIdentifierForUrl.int
getTargetPage()
CrowdsourcingStatus
getTargetRecordStatus()
getTargetRecordStatus.CrowdsourcingStatus
getTargetStatus()
String
handleInvalidTarget()
handleInvalidTarget.void
init()
Initialize all campaigns as lazily loaded liststatic boolean
isAllowed(User user, Campaign campaign)
Check if the given user is allowed access to the given campaign from a rights management standpoint alone.boolean
isEditMode()
isEditMode.boolean
isUserOwnsAnyCampaigns(User user)
Deprecated.String
removeQuestionAction(Question question)
Remove the givenQuestion
from the selected campaignString
resetDurationAction()
Resets dateStart + dateEnd to null.void
resetTarget()
removes the target identifier (pi) from the bean, so that pi can be targeted again by random target resolutionString
saveSelectedCampaignAction()
Adds the current page to the database, if it doesn't exist or updates it otherwisevoid
setNextIdentifierForAnnotation()
void
setNextIdentifierForReview()
void
setSelectedCampaign(Campaign campaign)
Set the selected campaign to a clone of the given campaignvoid
setSelectedCampaignId(String id)
Set theselectedCampaign
by a String containing the campaign idvoid
setTargetCampaign(Campaign targetCampaign)
Setter for the fieldtargetCampaign
.void
setTargetCampaignId(String id)
setTargetCampaignId.void
setTargetIdentifier(String targetIdentifier)
Setter for the fieldtargetIdentifier
.void
setTargetIdentifierForUrl(String pi)
setTargetIdentifierForUrl.void
setTargetPage(int targetPage)
void
setTargetStatus(CrowdsourcingStatus targetStatus)
void
setTargetStatus(String targetStatus)
void
updateActiveCampaigns()
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.
-
-
-
Field Detail
-
userBean
@Inject protected UserBean userBean
-
-
Constructor Detail
-
CrowdsourcingBean
public CrowdsourcingBean()
-
CrowdsourcingBean
public CrowdsourcingBean(Configuration viewerConfig, IDAO dao)
-
-
Method Detail
-
init
@PostConstruct public void init()
Initialize all campaigns as lazily loaded list
-
getCampaignCount
public long getCampaignCount(Campaign.CampaignVisibility visibility) throws DAOException
getCampaignCount.
- Parameters:
visibility
- aCampaign.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 byCampaign.CampaignVisibility
- Parameters:
visibility
- aCampaign.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 newCampaign
as theselectedCampaign
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 givenCampaign
as theselectedCampaign
and returns a pretty url to the view for editing this campaign
-
deleteCampaignAction
public String deleteCampaignAction(Campaign campaign) throws DAOException
Delete the givenCampaign
from the database and the loaded list of campaigns- Parameters:
campaign
- aCampaign
object.- Returns:
- a
String
object. - Throws:
DAOException
- if any.
-
addNewQuestionAction
public String addNewQuestionAction()
Add a newQuestion
to the selected campaign- Returns:
- a
String
object.
-
removeQuestionAction
public String removeQuestionAction(Question question)
Remove the givenQuestion
from the selected campaign
-
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
- aCampaign.CampaignVisibility
object.- Returns:
- All camapaigns 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:
- Throws:
DAOException
-
isUserOwnsAnyCampaigns
@Deprecated public boolean isUserOwnsAnyCampaigns(User user) throws DAOException
Deprecated.- Parameters:
user
-- Returns:
- 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
- aUser
object.campaign
- aCampaign
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- 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:
selectedCampaign
- the selectedCampaign to set
-
getSelectedCampaignId
public String getSelectedCampaignId()
getSelectedCampaignId.
- Returns:
- The id of the
selectedCampaign
as String
-
setSelectedCampaignId
public void setSelectedCampaignId(String id) throws DAOException
Set theselectedCampaign
by a String containing the campaign id- Parameters:
id
- aString
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
- aString
object.- Throws:
NumberFormatException
- if any.DAOException
- if any.
-
setNextIdentifierForAnnotation
public void setNextIdentifierForAnnotation() throws PresentationException, IndexUnreachableException
-
setNextIdentifierForReview
public void setNextIdentifierForReview() 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 thetargetCampaign
-
forwardToReviewTarget
public String forwardToReviewTarget()
forwardToReviewTarget.
- Returns:
- the pretty url to review the
targetIdentifier
for thetargetCampaign
-
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
- aString
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.
-
forwardToCrowdsourcingReview
public String forwardToCrowdsourcingReview(Campaign campaign)
forwardToCrowdsourcingReview.
-
forwardToCrowdsourcingAnnotation
public String forwardToCrowdsourcingAnnotation(Campaign campaign, String pi)
forwardToCrowdsourcingAnnotation.
-
forwardToCrowdsourcingReview
public String forwardToCrowdsourcingReview(Campaign campaign, String pi)
forwardToCrowdsourcingReview.
-
getNextItemUrl
public String getNextItemUrl(Campaign campaign, CrowdsourcingStatus status)
getRandomItemUrl.
- Parameters:
campaign
- The campaign with which to annotate/reviewstatus
- ifio.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 thetargetCampaign
for thetargetIdentifier
-
handleInvalidTarget
public String 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
- aString
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)
-
-