Class CMSCollection
java.lang.Object
io.goobi.viewer.model.cms.collections.CMSCollection
- All Implemented Interfaces:
CMSMediaHolder,IPolyglott,BrowseElementInfo,Serializable,Comparable<CMSCollection>
@Entity
public class CMSCollection
extends Object
implements Comparable<CMSCollection>, BrowseElementInfo, CMSMediaHolder, IPolyglott, Serializable
A class representing persistent configurations for a collection. A collections is identified by a SOLR-field name and a label. The most common
SOLR-field is "DC" and label is the internal name of the collection to edit. This class allows setting a representative image, names in multiple
languages and a uri linking to a collection page.
- Author:
- Florian Alpers
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new CMSCollection instance.CMSCollection(CMSCollection orig) Cloning constructor.CMSCollection(String solrField, String solrFieldValue) Default constructor, creating a Collection from the identifying fieldssolrFieldandsolrFieldValue. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDescription(CMSCollectionTranslation description) Adds a translation for the collection description.voidaddLabel(CMSCollectionTranslation label) Adds a translation for the collection label.intcompareTo(CMSCollection other) booleancontentEquals(CMSCollection other) booleanGetter for the fieldcollectionUrl.get the description for the current locale (given byBeanUtils.getLocale(), 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 the language should be the language code of aLocaleand is case insensitive.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 page with the tagDESCRIPTION_TAG.getIconURI.getIconURI(int size) getIconURI.getIconURI(int width, int height) getIconURI.getId()Getter for the fieldid.Get the label for the givenlocale, or an empty string if no matching label exists.getLabelAsTranslation(String language) getLabelAsTranslation.returns all translations of this page 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.Getter for the fieldmediaItem.getMediaItemWrapper.A string representing the allowed media formates for a user.getName()getName.getRepresentativeWork.Getter for the fieldrepresentativeWorkPI.Getter for the fieldsolrField.Getter for the fieldsolrFieldValue.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 info from Solr.voidpopulateDescriptions.voidpopulateDescriptions(List<String> languages) populateDescriptions.voidpopulateLabels.voidsetAccessPermissionThumbnail(AccessPermission accessPermissionThumbnail) voidsetCollectionUrl(String collectionUrl) Setter for the fieldcollectionUrl.voidsetDescription(String value, String language) setDescription.voidsetLabel.voidsetMediaItem(CMSMediaItem mediaItem) setMediaItem.voidsetRepresentativeWorkPI(String representativeWorkPI) Setter for the fieldrepresentativeWorkPI.voidsetSelectedLocale(Locale locale) Sets the locale to use for display and editing.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
-
CMSCollection
public CMSCollection()Creates a new CMSCollection instance. -
CMSCollection
Default constructor, creating a Collection from the identifying fieldssolrFieldandsolrFieldValue.- Parameters:
solrField- The name of the SOLR field holding the values for the collectionsolrFieldValue- The value of the solrField identifying this collection- Throws:
IllegalArgumentException- If either argument returns true forStringUtils.isBlank(CharSequence)
-
CMSCollection
Cloning constructor.- Parameters:
orig- the CMSCollection to clone
-
-
Method Details
-
loadRepresentativeImage
Loads representative image info from Solr.- Returns:
- this
-
getMediaItem
Getter for the fieldmediaItem.- Specified by:
getMediaItemin interfaceCMSMediaHolder- Returns:
- the CMS media item used as the representative image for this collection, 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
-
getLabels
returns all translations of this page with the tagLABEL_TAG.- Returns:
- all labels for this collections
-
getDescriptions
returns all translations of this page with the tagDESCRIPTION_TAG.- Returns:
- all descriptions for this collections
-
getLabel
Get the label for the givenlocale, or an empty string if no matching label exists.- Parameters:
locale- aLocaleobject.- Returns:
- The string value of the label of the given locale, or an empty string
-
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:
CMSCollectionTranslation
-
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 the language should be the language code of aLocaleand is case insensitive.- Specified by:
getDescriptionin interfaceBrowseElementInfo- Parameters:
language- ISO language code identifying the desired description- Returns:
- The string value of the description of 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 string value of the description of the given locale, or an empty string
-
getDescription
get the description for the current locale (given byBeanUtils.getLocale(), or an empty string if no matching description exists.- Specified by:
getDescriptionin interfaceBrowseElementInfo- Returns:
- The string value of the description of 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
-
getSolrField
Getter for the fieldsolrField.- Returns:
- the solrField. Guaranteed to hold a non-blank value
-
getSolrFieldValue
Getter for the fieldsolrFieldValue.- Returns:
- the solrFieldValue. Guaranteed to hold a non-blank value
-
compareTo
Compares collection by the alphabatical sorting of their
getSolrFieldValue()- Specified by:
compareToin interfaceComparable<CMSCollection>
-
hashCode
public int hashCode()Returns the hashCode of
getSolrFieldValue() -
equals
A
CMSCollectionis equal to any other object if that is also a CMSCollection and returns the same values forgetSolrField()andgetSolrFieldValue() -
contentEquals
- Parameters:
other- the other CMSCollection to compare content with- Returns:
- true if the content of this collection matches the given collection, false otherwise
-
populateLabels
public void populateLabels()populateLabels. -
populateDescriptions
public void populateDescriptions()populateDescriptions. -
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
-
getId
Getter for the fieldid.- Returns:
- the database primary key of this collection
-
toString
-
getName
getName.- Specified by:
getNamein interfaceBrowseElementInfo- Returns:
- the name of this browse element
-
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
-
getRepresentativeWork
getRepresentativeWork.- Returns:
- an Optional containing the representative StructElement, or empty if none is configured or found
-
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
-
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
Description copied from interface:CMSMediaHolderA 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
-
getMediaItemWrapper
Description copied from interface:CMSMediaHoldergetMediaItemWrapper.- Specified by:
getMediaItemWrapperin interfaceCMSMediaHolder- Returns:
- the CMS media item wrapped with category and selection state information
-
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 validate required fields for- Returns:
- true if all required fields contain a value in 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
-
getSelectedLocale
- Specified by:
getSelectedLocalein interfaceIPolyglott- Returns:
- the locale currently set by
IPolyglott.setSelectedLocale(Locale)
-
setSelectedLocale
Description copied from interface:IPolyglottSets the locale to use for display and editing.- Specified by:
setSelectedLocalein interfaceIPolyglott- Parameters:
locale- the locale to select
-
getAccessPermissionThumbnail
-
setAccessPermissionThumbnail
-