Class Campaign
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 Alpers
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe visibility of the campaign to other users.static enumEnumerates the review workflows available for a crowdsourcing campaign, controlling whether annotations require a second pass by another user.static enumStatistics calculation mode (status per record or per record page). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLogMessage(LogMessage message, String pi) voiddeleteLogMessage(Long messageId) booleanGetter for the fieldbreadcrumbParentCmsPageId.getCampaignVisibilityValues.longDetermines the number of distinct users that have created or reviewed annotations in the context of this campaign.Getter for the fielddateCreated.Getter for the fielddateEnd.Getter for the fielddateStart.Getter for the fielddateUpdated.longReturns the number of whole days between today and the starting date for this campaign.longReturns the number of whole days between today and the end date for this campaign.getDaysLeftAsString.Returns the description value in the current language of the campaign object (current tab).getDescription(String lang) getDescription.getDescription(String lang, boolean useFallback) getDescription.getId()Getter for the fieldid.static LongGetter for the fieldid.getIdAsURI.A regular expression determining which filenames are shown in the media list and may be uploaded.getMediaItem.getMediaItemWrapper.A string representing the allowed media formates for a user.Returns the menu title value in the current language of the campaign object (current tab).getMenuTitle(String lang) getMenuTitle.getMenuTitle(String lang, boolean useFallback) getMenuTitle.getMenuTitleOrElseTitle.getMenuTitleOrElseTitle(String lang, boolean useFallback) getMenuTitleOrElseTitle.getName()getNextTarget(CrowdsourcingStatus status, String currentPi, User user) Get the targetIdentifier to a random PI from the Solr query result list.longgetNumRecords.longgetNumRecordsForStatus(String status) getNumRecordsForStatus.longgetNumRecordsToAnnotate.getPageStatus(String pi, int page) Getter for the fieldpermalink.intFINISHED records in percent.Getter for the fieldquestions.getRandomizedTarget(CrowdsourcingStatus status, String piToIgnore, User user) Get the targetIdentifier to a random PI from the Solr query result list.getRecordStatus.Getter for the fieldselectedLocale.Getter for the fieldsolrQuery.Getter for the fieldstatistics.getTitle()Returns the title value in the current language of the campaign object (current tab).getTitle.getTitle.Getter for the fieldtranslations.Getter for the fieldvisibility.inthashCode()booleanhasMediaItem.booleanhasRecordsToAnnotate(User user) Check if the given user is eligible to annotate any records.booleanhasRecordsToReview(User user) Check if the given user is eligible to review any records.booleanisComplete(Locale locale) If this returns true, an associated language tab should have the 'already-translated' class, otherwise the '-partly-translated' class unlessIPolyglott.isEmpty(Locale)also returns true.booleanisEligibleToEdit(String pi, CrowdsourcingStatus status, User user) Checks if the given user may annotate/review (depending on status) a specific pi within this campaign.booleanIf this returns true, an associated language tab should have neither the 'already-translated' nor the '-partly-translated' class.booleanbooleanbooleanisHasEnded.booleanisHasStarted.booleanbooleanisReady()Return true if the campaign is ready for use.booleanbooleanbooleanbooleanbooleanbooleanisUserAllowedAction(User user, CrowdsourcingStatus status) Checks whether the given user may annotate or review records based on the given status.booleanisUserMayEdit(User user) booleanOnly meaningful for the default language for which all required fields must be filled.booleanmayAnnotate(User user, String pi) Check if the user is allowed to annotate the given pi for this campaign.booleanCheck if the user is allowed to review the given pi for this campaign.voidvoidsetBreadcrumbParentCmsPageId(String breadcrumbParentCmsPageId) Setter for the fieldbreadcrumbParentCmsPageId.voidsetDateCreated(LocalDateTime dateCreated) Setter for the fielddateCreated.voidsetDateEnd(LocalDateTime dateEnd) Setter for the fielddateEnd.voidsetDateOnlyEnd(LocalDate dateEnd) voidsetDateOnlyStart(LocalDate dateStart) voidsetDateStart(LocalDateTime dateStart) Setter for the fielddateStart.voidsetDateUpdated(LocalDateTime dateUpdated) Setter for the fielddateUpdated.voidsetDescription(String description) setDescription.voidSetter for the fieldid.voidsetLimitToGroup(boolean limitToGroup) voidsetMediaItem(CMSMediaItem item) setMediaItem.voidsetMenuTitle(String menuTitle) setMenuTitle.voidsetPermalink(String permalink) Setter for the fieldpermalink.voidsetQuestions(List<Question> questions) Setter for the fieldquestions.voidsetRecordPageStatus(String pi, int page, CrowdsourcingStatus status, Optional<User> user) voidsetRecordStatus(String pi, CrowdsourcingStatus status, Optional<User> user) Updates record status in the campaign statistics.voidsetRestrictAnnotationAccess(boolean restrictAnnotationAccess) voidsetReviewerUserGroup(UserGroup reviewerUserGroup) voidsetReviewMode(Campaign.ReviewMode reviewMode) voidsetSelectedLocale(Locale selectedLocale) Setter for the fieldselectedLocale.voidsetShowLog(boolean showLog) voidsetSolrQuery(String solrQuery) Setter for the fieldsolrQuery.voidsetStatisticMode(Campaign.StatisticMode statisticMode) voidsetStatistics(Map<String, CampaignRecordStatistic> statistics) Setter for the fieldstatistics.voidsetTimePeriodEnabled(boolean timePeriodEnabled) voidsetTitle.voidsetTranslations(List<CampaignTranslation> translations) Setter for the fieldtranslations.voidsetUserGroup(UserGroup userGroup) voidsetVisibility(Campaign.CampaignVisibility visibility) Setter for the fieldvisibility.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.goobi.viewer.model.translations.IPolyglott
getLocales, isDefaultLocaleSelected, isSelected, setSelectedLocale
-
Constructor Details
-
Campaign
public Campaign()Empty constructor. -
Campaign
Locale constructor.- Parameters:
selectedLocale- locale used for editing translations
-
Campaign
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
getCampaignVisibilityValues
getCampaignVisibilityValues.- Returns:
- available values of the CampaignVisibility enum
-
getNumRecords
getNumRecords.- Returns:
- total number of records encompassed by the configured solrQuery
- Throws:
IndexUnreachableException- if any.
-
getNumRecordsForStatus
getNumRecordsForStatus.- Parameters:
status- crowdsourcing status name to count records for- Returns:
- number of records with the given status
-
getNumRecordsToAnnotate
getNumRecordsToAnnotate.- Returns:
- Number of records whose status is neither REVIEW nor FINISHED
- Throws:
IndexUnreachableException- if any.
-
getContributorCount
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
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
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- user whose permission is checked; may be null for anonymousstatus- desired action (ANNOTATE or REVIEW) to check permission for- 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
- Parameters:
user- User for whom to check access- Returns:
- true if given
Userhas permission to edit thisCampaign; false otherwise - Throws:
DAOException
-
getName
- Specified by:
getNamein interfaceILicenseType
-
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:
- the campaign title in the currently selected editing locale
-
setTitle
setTitle.- Parameters:
title- title text in the currently selected locale
-
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:
- the campaign menu title in the currently selected editing locale
-
getMenuTitleOrElseTitle
getMenuTitleOrElseTitle.- Returns:
- the campaign menu title in the currently selected locale, falling back to the title if no menu title is set
-
getMenuTitleOrElseTitle
getMenuTitleOrElseTitle.- Parameters:
lang- BCP 47 language tag for the requested translationuseFallback- whether to fall back to the default language translation- Returns:
- the menu title in the given language, falling back to the title if not available
-
setMenuTitle
setMenuTitle.- Parameters:
menuTitle- menu title text in the currently selected locale
-
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
setDescription.- Parameters:
description- description text in the currently selected locale
-
getTitle
getTitle.- Parameters:
lang- BCP 47 language tag for the requested translation- Returns:
- the campaign title in the given language, without fallback
-
getTitle
getTitle.- Parameters:
lang- BCP 47 language tag for the requested translationuseFallback- whether to fall back to the default language translation- Returns:
- the title of the given language or if it doesn't exist the title of the default language
-
getDescription
getDescription.- Parameters:
lang- BCP 47 language tag for the requested translation- Returns:
- the campaign description in the given language, without fallback
-
getDescription
getDescription.- Parameters:
lang- BCP 47 language tag for the requested translationuseFallback- whether to fall back to the default language translation- Returns:
- the campaign description in the given language, optionally falling back to the default language
-
getMenuTitle
getMenuTitle.- Parameters:
lang- BCP 47 language tag for the requested translation- Returns:
- the campaign menu title in the given language, without fallback
-
getMenuTitle
getMenuTitle.- Parameters:
lang- BCP 47 language tag for the requested translationuseFallback- whether to fall back to the default language translation- Returns:
- the campaign menu title in the given language, optionally falling back to the default language
-
getDisplayTitle
-
getDisplayDescription
-
getId
Getter for the fieldid.- Returns:
- the database primary key of this campaign
-
getId
Getter for the fieldid.- Parameters:
idAsURI- campaign REST API URI containing the numeric ID- Returns:
- the numeric campaign ID extracted from the URI, or null if not found
-
getIdAsURI
getIdAsURI.- Returns:
- the REST API URI for this campaign, constructed from the campaign ID
-
setId
Setter for the fieldid.- Parameters:
id- the database primary key to set
-
getDateCreated
Getter for the fielddateCreated.- Returns:
- the date and time when this campaign was created
-
setDateCreated
Setter for the fielddateCreated.- Parameters:
dateCreated- the date and time when this campaign was created
-
getDateUpdated
Getter for the fielddateUpdated.- Returns:
- the date and time when this campaign was last updated
-
setDateUpdated
Setter for the fielddateUpdated.- Parameters:
dateUpdated- the date and time when this campaign was last updated
-
getVisibility
Getter for the fieldvisibility.- Returns:
- the visibility setting controlling who can see and participate in this campaign
-
setVisibility
Setter for the fieldvisibility.- Parameters:
visibility- the visibility setting controlling who can see and participate in this campaign
-
getDateOnlyStart
- Returns:
LocalDate
-
setDateOnlyStart
- Parameters:
dateStart- the campaign start date (date only, no time)
-
getDateStart
Getter for the fielddateStart.- Returns:
- the date and time when this campaign becomes active
-
setDateStart
Setter for the fielddateStart.- Parameters:
dateStart- the date and time when this campaign becomes active
-
getDateOnlyEnd
- Returns:
LocalDate
-
setDateOnlyEnd
- Parameters:
dateEnd- the campaign end date (date only, no time)
-
getDateEnd
Getter for the fielddateEnd.- Returns:
- the date and time when this campaign ends
-
setDateEnd
Setter for the fielddateEnd.- Parameters:
dateEnd- the date and time when this campaign ends
-
getSolrQuery
Getter for the fieldsolrQuery.- Returns:
- the Solr query defining the set of records covered by this campaign
-
setSolrQuery
Setter for the fieldsolrQuery.- Parameters:
solrQuery- the Solr query defining the set of records covered by this campaign
-
getPermalink
Getter for the fieldpermalink.- Returns:
- the permanent URL path for this campaign's public page
-
setPermalink
Setter for the fieldpermalink.- Parameters:
permalink- the permanent URL path for this campaign's public page
-
getBreadcrumbParentCmsPageId
Getter for the fieldbreadcrumbParentCmsPageId.- Returns:
- the ID of the CMS page to use as parent in the breadcrumb navigation
-
setBreadcrumbParentCmsPageId
Setter for the fieldbreadcrumbParentCmsPageId.- Parameters:
breadcrumbParentCmsPageId- the ID of the CMS page to use as parent in the breadcrumb navigation
-
getTranslations
Getter for the fieldtranslations.- Returns:
- the list of translations for this campaign's localizable text fields
-
setTranslations
Setter for the fieldtranslations.- Parameters:
translations- list of campaign translations replacing the current one
-
getQuestions
Getter for the fieldquestions.- Returns:
- the list of annotation question templates belonging to this campaign
-
setQuestions
Setter for the fieldquestions.- Parameters:
questions- list of annotation question templates to assign
-
getStatistics
Getter for the fieldstatistics.- Returns:
- the map of record statistics keyed by persistent identifier
-
setStatistics
Setter for the fieldstatistics.- Parameters:
statistics- map of record statistics keyed by persistent identifier
-
getSelectedLocale
Getter for the fieldselectedLocale.- Specified by:
getSelectedLocalein interfaceIPolyglott- Returns:
- the locale used to select the active translation tab in the UI
-
setSelectedLocale
Setter for the fieldselectedLocale.- Specified by:
setSelectedLocalein interfaceIPolyglott- Parameters:
selectedLocale- locale used to select the active translation tab
-
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:
- true if the campaign is fully configured and ready to accept contributions, false otherwise
-
isComplete
Description copied from interface:IPolyglottIf this returns true, an associated language tab should have the 'already-translated' class, otherwise the '-partly-translated' class unlessIPolyglott.isEmpty(Locale)also returns true.- Specified by:
isCompletein interfaceIPolyglott- Parameters:
locale- the locale to check translation completeness for- 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)andIPolyglott.isValid(Locale)are identical. For implementations with only one field, both methods are also always identical
-
isValid
Description copied from interface:IPolyglottOnly meaningful for the default language for which all required fields must be filled.- Specified by:
isValidin interfaceIPolyglott- Parameters:
locale- the locale to check validity for- Returns:
- true if the title is not empty for the given locale
-
isEmpty
Description copied from interface:IPolyglottIf this returns true, an associated language tab should have neither the 'already-translated' nor the '-partly-translated' class.- Specified by:
isEmptyin interfaceIPolyglott- Parameters:
locale- the locale to check for empty fields- 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- desired record status to filter candidates bypiToIgnore- persistent identifier of the record to excludeuser- the user requesting the target; used to filter eligible records- Returns:
- the persistent identifier of a randomly selected eligible target record, or an empty string if none is available
- 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- desired record status to filter candidates bycurrentPi- persistent identifier of the currently viewed recorduser- the user requesting the target; used to filter eligible records- Returns:
- the persistent identifier of the next eligible target record after the current one, or an empty string if none is available
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
resetSolrQueryResults
public void resetSolrQueryResults() -
isEligibleToEdit
Checks if the given user may annotate/review (depending on status) a specific pi within this campaign.- Parameters:
pi- persistent identifier of the record to checkstatus- desired action (ANNOTATE or REVIEW) to check eligibility foruser- user whose eligibility is checked; may be null for anonymous- Returns:
- true if
-
hasRecordsToReview
public boolean hasRecordsToReview(User user) throws PresentationException, IndexUnreachableException Check if the given user is eligible to review any records.- Parameters:
user- user for whom eligible review records are checked- 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- user for whom eligible annotation records are checked- 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- user requesting annotation access; may be null for anonymouspi- persistent identifier of the record to annotate- 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- user requesting review access; may be null for anonymouspi- persistent identifier of the record to review- 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
getRecordStatus.- Parameters:
pi- persistent identifier of the record to look up- Returns:
- record status for the given pi
-
getPageStatus
-
isGroupLimitActive
public boolean isGroupLimitActive() -
isReviewGroupLimitActive
public boolean isReviewGroupLimitActive() -
isReviewModeActive
public boolean isReviewModeActive() -
setRecordStatus
Updates record status in the campaign statistics.- Parameters:
pi- persistent identifier of the record being updatedstatus- new crowdsourcing status to assign to the recorduser- optional user performing the annotation or review
-
setRecordPageStatus
public void setRecordPageStatus(String pi, int page, CrowdsourcingStatus status, Optional<User> user) - Parameters:
pi- the persistent identifier of the recordpage- the physical page numberstatus- the new crowdsourcing status to setuser- the user performing the status update
-
setMediaItem
setMediaItem.- Specified by:
setMediaItemin interfaceCMSMediaHolder- Parameters:
item- aCMSMediaItemobject.
-
getMediaItem
getMediaItem.- Specified by:
getMediaItemin interfaceCMSMediaHolder- Returns:
- the associated CMS media item, or null if none is set
-
getMediaFilter
A regular expression determining which filenames are shown in the media list and may be uploaded.- Specified by:
getMediaFilterin interfaceCMSMediaHolder- Returns:
- the regex pattern used to filter acceptable media filenames for this holder
-
getMediaTypes
Description copied from interface:CMSMediaHolderA string representing the allowed media formates for a user. Should be a comma separated list of format names or filename suffixes- Specified by:
getMediaTypesin interfaceCMSMediaHolder- Returns:
String
-
hasMediaItem
public boolean hasMediaItem()hasMediaItem.- Specified by:
hasMediaItemin interfaceCMSMediaHolder- Returns:
- true if this holder has an associated CMS media item, false otherwise
-
setShowLog
public void setShowLog(boolean showLog) -
isShowLog
public boolean isShowLog() -
isLimitToGroup
public boolean isLimitToGroup() -
setLimitToGroup
public void setLimitToGroup(boolean limitToGroup) -
getReviewMode
-
setReviewMode
-
getStatisticMode
-
setStatisticMode
-
getUserGroup
-
setUserGroup
-
getReviewerUserGroup
-
setReviewerUserGroup
-
isTimePeriodEnabled
public boolean isTimePeriodEnabled() -
isRestrictAnnotationAccess
public boolean isRestrictAnnotationAccess()- Returns:
- the
restrictAnnotationAccess
-
setRestrictAnnotationAccess
public void setRestrictAnnotationAccess(boolean restrictAnnotationAccess) - Parameters:
restrictAnnotationAccess- therestrictAnnotationAccessto set
-
setTimePeriodEnabled
public void setTimePeriodEnabled(boolean timePeriodEnabled) -
getLogMessages
-
addLogMessage
-
deleteLogMessage
- Parameters:
messageId- the ID of the log message to delete
-
getMediaItemWrapper
getMediaItemWrapper.- Specified by:
getMediaItemWrapperin interfaceCMSMediaHolder- Returns:
- the CMS media item wrapped with category and selection state information
-
toString
-
getAccessConditionValue
- Returns:
String
-