Class DynamicCollection
java.lang.Object
io.goobi.viewer.model.cms.collections.DynamicCollection
- All Implemented Interfaces:
CMSMediaHolder,IPolyglott,BrowseElementInfo,Serializable,Comparable<DynamicCollection>
@Entity
public class DynamicCollection
extends Object
implements Comparable<DynamicCollection>, BrowseElementInfo, CMSMediaHolder, IPolyglott, Serializable
A digital collection defined entirely in the database. Unlike
CMSCollection, whose membership is derived from a single Solr field value,
a dynamic collection is identified by a unique identifier and its contents are given by an arbitrary solrQuery. It carries a
representative image, a label and description in multiple languages and an optional URL linking to a collection page.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty DynamicCollection instance.Cloning constructor.DynamicCollection(String identifier) Creates a new DynamicCollection with the given identifier. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDescription(DynamicCollectionTranslation description) Adds a translation for the collection description.voidAdds a translation for the collection label.intcompareTo(DynamicCollection other) booleancontentEquals(DynamicCollection other) booleanGetter for the fieldcollectionUrl.get the description for the current locale, or an empty string if no matching description exists.getDescription(String language) get the description for the givenlanguage, or an empty string if no matching description exists.getDescription(Locale locale) Get the description for the givenlocale, or an empty string if no matching description exists.getDescriptionAsTranslation(String language) getDescriptionAsTranslation.returns all translations of this collection with the tagDESCRIPTION_TAG.Returns the search facet token identifying this collection, i.e.getIconURI.getIconURI(int size) getIconURI.getIconURI(int width, int height) getIconURI.getId()Getter for the fieldid.Getter for the fieldidentifier.Get the label for the givenlocale, falling back to the collectionidentifierif no matching label exists.getLabelAsTranslation for the currently selected locale.getLabelAsTranslation(String language) getLabelAsTranslation.returns all translations of this collection with the tagLABEL_TAG.getLinkURI.getLinkURI(HttpServletRequest request) getLinkURI.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.getName()getName.getRepresentativeWork.Getter for the fieldrepresentativeWorkPI.Getter for the fieldsolrQuery.intGetter for the fieldsortOrder.de.intranda.metadata.multilanguage.IMetadataValuede.intranda.metadata.multilanguage.IMetadataValuegetTranslationsForName.inthashCode()booleanhasImage()hasImage.booleanhasMediaItem.booleanhasRepresentativeWork.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.booleanIf this returns true, an associated language tab should have neither the 'already-translated' nor the '-partly-translated' class.booleanOnly meaningful for the default language for which all required fields must be filled.Loads representative image access info from Solr.loadRepresentativeImage(org.apache.solr.common.SolrDocument recordDoc) Sets the thumbnail access permission from an already-fetched representative record document.voidpopulateDescriptions.voidpopulateDescriptions(List<String> languages) populateDescriptions.voidpopulateLabels.voidpopulateLabels(List<String> languages) populateLabels.voidRemoves all label and description translations whose value is blank, so that empty translation rows are not persisted (they are re-created in memory for editing viapopulateLabels()/populateDescriptions()).voidsetAccessPermissionThumbnail(AccessPermission accessPermissionThumbnail) voidsetCollectionUrl(String collectionUrl) Setter for the fieldcollectionUrl.voidsetDescription(String value, String language) setDescription.voidsetIdentifier(String identifier) Setter for the fieldidentifier.voidsetLabel.voidsetMediaItem(CMSMediaItem mediaItem) setMediaItem.voidsetRepresentativeWorkPI(String representativeWorkPI) Setter for the fieldrepresentativeWorkPI.voidsetSelectedLocale(Locale locale) Sets the locale to use for display and editing.voidsetSolrQuery(String solrQuery) Setter for the fieldsolrQuery.voidsetSortOrder(int sortOrder) Setter for the fieldsortOrder.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.goobi.viewer.model.viewer.collections.BrowseElementInfo
hasDescriptionMethods inherited from interface io.goobi.viewer.model.translations.IPolyglott
getLocales, isDefaultLocaleSelected, isSelected, setSelectedLocale
-
Constructor Details
-
DynamicCollection
public DynamicCollection()Creates a new empty DynamicCollection instance. -
DynamicCollection
Creates a new DynamicCollection with the given identifier.- Parameters:
identifier- the unique identifier of the collection- Throws:
IllegalArgumentException- if the identifier is null, empty or blank
-
DynamicCollection
Cloning constructor.- Parameters:
orig- the DynamicCollection to clone
-
-
Method Details
-
loadRepresentativeImage
Loads representative image access info from Solr.- Returns:
- this
-
loadRepresentativeImage
Sets the thumbnail access permission from an already-fetched representative record document.Overload for callers that have loaded the representative record's Solr document in a single batched query, avoiding a per-collection
getFirstDocround-trip. The document is reused for the page lookup as well.- Parameters:
recordDoc- top-level Solr document of the representative work, or null to skip- Returns:
- this
-
getId
Getter for the fieldid.- Returns:
- the database primary key of this collection
-
getName
getName.The
BrowseElementInfo"name" is the collection's immutable identifier.- Specified by:
getNamein interfaceBrowseElementInfo- Returns:
- the name of this browse element
-
getIdentifier
Getter for the fieldidentifier.- Returns:
- the unique, immutable identifier of the collection
-
setIdentifier
Setter for the fieldidentifier.- Parameters:
identifier- the unique, immutable identifier of the collection
-
getSolrQuery
Getter for the fieldsolrQuery.- Returns:
- the Solr query defining the contents of this collection
-
setSolrQuery
Setter for the fieldsolrQuery.- Parameters:
solrQuery- the Solr query defining the contents of this collection
-
getSortOrder
public int getSortOrder()Getter for the fieldsortOrder.- Returns:
- the ordering position within the flat list of dynamic collections
-
setSortOrder
public void setSortOrder(int sortOrder) Setter for the fieldsortOrder.- Parameters:
sortOrder- the ordering position within the flat list of dynamic collections
-
getMediaItem
getMediaItem.- Specified by:
getMediaItemin interfaceCMSMediaHolder- Returns:
- the associated CMS media item, or null if none is set
-
setMediaItem
setMediaItem.- Specified by:
setMediaItemin interfaceCMSMediaHolder- Parameters:
mediaItem- aCMSMediaItemobject.
-
getCollectionUrl
Getter for the fieldcollectionUrl.- Returns:
- the custom URL overriding the default collection browse URL, or null if not set
-
setCollectionUrl
Setter for the fieldcollectionUrl.- Parameters:
collectionUrl- custom URL overriding the default collection browse URL
-
addLabel
Adds a translation for the collection label.- Parameters:
label- translation to add as a collection label
-
addDescription
Adds a translation for the collection description.- Parameters:
description- translation to add as a collection description
-
pruneEmptyTranslations
public void pruneEmptyTranslations()Removes all label and description translations whose value is blank, so that empty translation rows are not persisted (they are re-created in memory for editing viapopulateLabels()/populateDescriptions()). -
getLabels
returns all translations of this collection with the tagLABEL_TAG.- Returns:
- all labels for this collection
-
getDescriptions
returns all translations of this collection with the tagDESCRIPTION_TAG.- Returns:
- all descriptions for this collection
-
getLabel
Get the label for the givenlocale, falling back to the collectionidentifierif no matching label exists.- Parameters:
locale- aLocaleobject.- Returns:
- the label string for the given locale, or the collection identifier
-
getLabelAsTranslation
getLabelAsTranslation.- Parameters:
language- ISO language code to filter label translations by- Returns:
- the label translation for the given language, or null if none exists
-
getDescriptionAsTranslation
getDescriptionAsTranslation.- Parameters:
language- ISO language code to filter description translations by- Returns:
- the description translation for the given language, or null if none exists
-
getDescriptionAsTranslation
- Returns:
DynamicCollectionTranslation
-
getLabelAsTranslation
getLabelAsTranslation for the currently selected locale.- Returns:
DynamicCollectionTranslation
-
setLabel
setLabel.- Parameters:
value- new label text to set for the given languagelanguage- ISO language code identifying the label to update
-
getDescription
get the description for the givenlanguage, or an empty string if no matching description exists.- Specified by:
getDescriptionin interfaceBrowseElementInfo- Parameters:
language- ISO language code identifying the desired description- Returns:
- the description string for the given language, or an empty string
-
getDescription
Get the description for the givenlocale, or an empty string if no matching description exists.- Parameters:
locale- aLocaleobject.- Returns:
- the description string for the given locale, or an empty string
-
getDescription
get the description for the current locale, or an empty string if no matching description exists.- Specified by:
getDescriptionin interfaceBrowseElementInfo- Returns:
- the description string for the current locale, or an empty string
-
setDescription
setDescription.- Parameters:
value- new description text to set for the given languagelanguage- ISO language code identifying the description to update
-
populateLabels
public void populateLabels()populateLabels. Ensures a (possibly empty) label translation exists for every supported language. -
populateLabels
populateLabels.- Parameters:
languages- list of language codes to ensure labels exist for
-
populateDescriptions
public void populateDescriptions()populateDescriptions. Ensures a (possibly empty) description translation exists for every supported language. -
populateDescriptions
populateDescriptions.- Parameters:
languages- list of language codes to ensure descriptions exist for
-
hasMediaItem
public boolean hasMediaItem()hasMediaItem.- Specified by:
hasMediaItemin interfaceCMSMediaHolder- Returns:
- true if this collection has an associated media item, false otherwise
-
hasRepresentativeWork
public boolean hasRepresentativeWork()hasRepresentativeWork.- Returns:
- true if this collection has a non-blank representative work persistent identifier, false otherwise
-
hasImage
public boolean hasImage()hasImage.- Returns:
- true if this collection has a representative work or an associated media item, false otherwise
-
getRepresentativeWorkPI
Getter for the fieldrepresentativeWorkPI.- Returns:
- the persistent identifier of the record whose thumbnail represents this collection
-
setRepresentativeWorkPI
Setter for the fieldrepresentativeWorkPI.- Parameters:
representativeWorkPI- the persistent identifier of the record whose thumbnail represents this collection
-
getRepresentativeWork
getRepresentativeWork.- Returns:
- an Optional containing the representative StructElement, or empty if none is configured or found
-
getFacetString
Returns the search facet token identifying this collection, i.e.DC_DYNAMIC:<identifier>. Passed as the facets segment of a search URL, it makes the search list the collection's records with the collection selected as the active facet.- Returns:
- the unencoded facet token of this collection
-
getLinkURI
getLinkURI.- Specified by:
getLinkURIin interfaceBrowseElementInfo- Returns:
- the link URI for this browse element
-
getLinkURI
getLinkURI.- Specified by:
getLinkURIin interfaceBrowseElementInfo- Parameters:
request- aHttpServletRequestobject.- Returns:
- the link URI for this browse element, resolved relative to the given request context
-
getIconURI
getIconURI.- Specified by:
getIconURIin interfaceBrowseElementInfo- Returns:
- the icon URI for this browse element, or null if no icon is set
-
getIconURI
getIconURI.- Specified by:
getIconURIin interfaceBrowseElementInfo- Parameters:
width- a int.height- a int.- Returns:
- the icon URI scaled to the given width and height, or null if no icon is set
-
getIconURI
getIconURI.- Specified by:
getIconURIin interfaceBrowseElementInfo- Parameters:
size- a int.- Returns:
- the icon URI scaled to the given square size, or null if no icon is set
-
getTranslationsForName
public de.intranda.metadata.multilanguage.IMetadataValue getTranslationsForName()getTranslationsForName.- Specified by:
getTranslationsForNamein interfaceBrowseElementInfo- Returns:
- the multilingual name translations for this browse element
-
getTranslationsForDescription
public de.intranda.metadata.multilanguage.IMetadataValue getTranslationsForDescription()- Specified by:
getTranslationsForDescriptionin interfaceBrowseElementInfo- Returns:
IMetadataValue
-
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
A 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
-
getMediaItemWrapper
getMediaItemWrapper.- Specified by:
getMediaItemWrapperin interfaceCMSMediaHolder- Returns:
- the CMS media item wrapped with category and selection state information
-
isComplete
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.- 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
Only meaningful for the default language for which all required fields must be filled.- Specified by:
isValidin interfaceIPolyglott- Parameters:
locale- the locale to validate required fields for- Returns:
- true if all required fields contain a value in the given locale
-
isEmpty
If 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
-
getSelectedLocale
- Specified by:
getSelectedLocalein interfaceIPolyglott- Returns:
- the locale currently set by
IPolyglott.setSelectedLocale(Locale)
-
setSelectedLocale
Sets the locale to use for display and editing.- Specified by:
setSelectedLocalein interfaceIPolyglott- Parameters:
locale- the locale to select
-
getAccessPermissionThumbnail
-
setAccessPermissionThumbnail
-
contentEquals
- Parameters:
other- the other DynamicCollection to compare content with- Returns:
- true if the persisted content of this collection matches the given collection, false otherwise
-
compareTo
Compares collections by the alphabetical sorting of their
getName()- Specified by:
compareToin interfaceComparable<DynamicCollection>
-
hashCode
public int hashCode() -
equals
-
toString
-