Class CMSCollection

java.lang.Object
io.goobi.viewer.model.cms.collections.CMSCollection
All Implemented Interfaces:
CMSMediaHolder, IPolyglott, BrowseElementInfo, Serializable, Comparable<CMSCollection>

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 Details

    • CMSCollection

      public CMSCollection()
      Creates a new CMSCollection instance.
    • CMSCollection

      public CMSCollection(String solrField, String solrFieldValue)
      Default constructor, creating a Collection from the identifying fields solrField and solrFieldValue.
      Parameters:
      solrField - The name of the SOLR field holding the values for the collection
      solrFieldValue - The value of the solrField identifying this collection
      Throws:
      IllegalArgumentException - If either argument returns true for StringUtils.isBlank(CharSequence)
    • CMSCollection

      public CMSCollection(CMSCollection orig)
      Cloning constructor.
      Parameters:
      orig - the CMSCollection to clone
  • Method Details

    • loadRepresentativeImage

      public CMSCollection loadRepresentativeImage()
      Loads representative image info from Solr.
      Returns:
      this
    • getMediaItem

      public CMSMediaItem getMediaItem()
      Getter for the field mediaItem.
      Specified by:
      getMediaItem in interface CMSMediaHolder
      Returns:
      the CMS media item used as the representative image for this collection, or null if none is set
    • setMediaItem

      public void setMediaItem(CMSMediaItem mediaItem)
      setMediaItem.
      Specified by:
      setMediaItem in interface CMSMediaHolder
      Parameters:
      mediaItem - a CMSMediaItem object.
    • getCollectionUrl

      public String getCollectionUrl()
      Getter for the field collectionUrl.
      Returns:
      the custom URL overriding the default collection browse URL, or null if not set
    • setCollectionUrl

      public void setCollectionUrl(String collectionUrl)
      Setter for the field collectionUrl.
      Parameters:
      collectionUrl - custom URL overriding the default collection browse URL
    • addLabel

      public void addLabel(CMSCollectionTranslation label)
      Adds a translation for the collection label.
      Parameters:
      label - translation to add as a collection label
    • addDescription

      public void addDescription(CMSCollectionTranslation description)
      Adds a translation for the collection description.
      Parameters:
      description - translation to add as a collection description
    • getLabels

      public List<CMSCollectionTranslation> getLabels()
      returns all translations of this page with the tag LABEL_TAG.
      Returns:
      all labels for this collections
    • getDescriptions

      public List<CMSCollectionTranslation> getDescriptions()
      returns all translations of this page with the tag DESCRIPTION_TAG.
      Returns:
      all descriptions for this collections
    • getLabel

      public String getLabel(Locale locale)
      Get the label for the given locale, or an empty string if no matching label exists.
      Parameters:
      locale - a Locale object.
      Returns:
      The string value of the label of the given locale, or an empty string
    • getLabelAsTranslation

      public CMSCollectionTranslation getLabelAsTranslation(String language)
      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

      public CMSCollectionTranslation getDescriptionAsTranslation(String language)
      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

      public CMSCollectionTranslation getDescriptionAsTranslation()
      Returns:
      CMSCollectionTranslation
    • setLabel

      public void setLabel(String value, String language)
      setLabel.
      Parameters:
      value - new label text to set for the given language
      language - ISO language code identifying the label to update
    • getDescription

      public String getDescription(String language)
      get the description for the given language, or an empty string if no matching description exists the language should be the language code of a Locale and is case insensitive.
      Specified by:
      getDescription in interface BrowseElementInfo
      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

      public String getDescription(Locale locale)
      Get the description for the given locale, or an empty string if no matching description exists.
      Parameters:
      locale - a Locale object.
      Returns:
      The string value of the description of the given locale, or an empty string
    • getDescription

      public String getDescription()
      get the description for the current locale (given by BeanUtils.getLocale(), or an empty string if no matching description exists.
      Specified by:
      getDescription in interface BrowseElementInfo
      Returns:
      The string value of the description of the current locale, or an empty string
    • setDescription

      public void setDescription(String value, String language)
      setDescription.
      Parameters:
      value - new description text to set for the given language
      language - ISO language code identifying the description to update
    • getSolrField

      public String getSolrField()
      Getter for the field solrField.
      Returns:
      the solrField. Guaranteed to hold a non-blank value
    • getSolrFieldValue

      public String getSolrFieldValue()
      Getter for the field solrFieldValue.
      Returns:
      the solrFieldValue. Guaranteed to hold a non-blank value
    • compareTo

      public int compareTo(CMSCollection other)

      Compares collection by the alphabatical sorting of their getSolrFieldValue()

      Specified by:
      compareTo in interface Comparable<CMSCollection>
    • hashCode

      public int hashCode()

      Returns the hashCode of getSolrFieldValue()

      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)

      A CMSCollection is equal to any other object if that is also a CMSCollection and returns the same values for getSolrField() and getSolrFieldValue()

      Overrides:
      equals in class Object
    • contentEquals

      public boolean contentEquals(CMSCollection other)
      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

      public void populateDescriptions(List<String> languages)
      populateDescriptions.
      Parameters:
      languages - list of language codes to ensure descriptions exist for
    • hasMediaItem

      public boolean hasMediaItem()
      hasMediaItem.
      Specified by:
      hasMediaItem in interface CMSMediaHolder
      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

      public Long getId()
      Getter for the field id.
      Returns:
      the database primary key of this collection
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName()
      getName.
      Specified by:
      getName in interface BrowseElementInfo
      Returns:
      the name of this browse element
    • getLinkURI

      public URI getLinkURI()
      getLinkURI.
      Specified by:
      getLinkURI in interface BrowseElementInfo
      Returns:
      the link URI for this browse element
    • getLinkURI

      public URI getLinkURI(HttpServletRequest request)
      getLinkURI.
      Specified by:
      getLinkURI in interface BrowseElementInfo
      Parameters:
      request - a HttpServletRequest object.
      Returns:
      the link URI for this browse element, resolved relative to the given request context
    • getIconURI

      public URI getIconURI()
      getIconURI.
      Specified by:
      getIconURI in interface BrowseElementInfo
      Returns:
      the icon URI for this browse element, or null if no icon is set
    • getIconURI

      public URI getIconURI(int width, int height)
      getIconURI.
      Specified by:
      getIconURI in interface BrowseElementInfo
      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

      public URI getIconURI(int size)
      getIconURI.
      Specified by:
      getIconURI in interface BrowseElementInfo
      Parameters:
      size - a int.
      Returns:
      the icon URI scaled to the given square size, or null if no icon is set
    • getRepresentativeWork

      public Optional<StructElement> getRepresentativeWork()
      getRepresentativeWork.
      Returns:
      an Optional containing the representative StructElement, or empty if none is configured or found
    • getRepresentativeWorkPI

      public String getRepresentativeWorkPI()
      Getter for the field representativeWorkPI.
      Returns:
      the persistent identifier of the record whose thumbnail represents this collection
    • setRepresentativeWorkPI

      public void setRepresentativeWorkPI(String representativeWorkPI)
      Setter for the field representativeWorkPI.
      Parameters:
      representativeWorkPI - the persistent identifier of the record whose thumbnail represents this collection
    • getTranslationsForName

      public de.intranda.metadata.multilanguage.IMetadataValue getTranslationsForName()
      getTranslationsForName.
      Specified by:
      getTranslationsForName in interface BrowseElementInfo
      Returns:
      the multilingual name translations for this browse element
    • getTranslationsForDescription

      public de.intranda.metadata.multilanguage.IMetadataValue getTranslationsForDescription()
      Specified by:
      getTranslationsForDescription in interface BrowseElementInfo
      Returns:
      IMetadataValue
    • getMediaFilter

      public String getMediaFilter()
      Description copied from interface: CMSMediaHolder
      A regular expression determining which filenames are shown in the media list and may be uploaded.
      Specified by:
      getMediaFilter in interface CMSMediaHolder
      Returns:
      the regex pattern used to filter acceptable media filenames for this holder
    • getMediaTypes

      public String getMediaTypes()
      Description copied from interface: CMSMediaHolder
      A string representing the allowed media formates for a user. Should be a comma separated list of format names or filename suffixes
      Specified by:
      getMediaTypes in interface CMSMediaHolder
      Returns:
      String
    • getMediaItemWrapper

      public CategorizableTranslatedSelectable<CMSMediaItem> getMediaItemWrapper()
      Description copied from interface: CMSMediaHolder
      getMediaItemWrapper.
      Specified by:
      getMediaItemWrapper in interface CMSMediaHolder
      Returns:
      the CMS media item wrapped with category and selection state information
    • isComplete

      public boolean isComplete(Locale locale)
      Description copied from interface: IPolyglott
      If this returns true, an associated language tab should have the 'already-translated' class, otherwise the '-partly-translated' class unless IPolyglott.isEmpty(Locale) also returns true.
      Specified by:
      isComplete in interface IPolyglott
      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) and IPolyglott.isValid(Locale) are identical. For implementations with only one field, both methods are also always identical
    • isValid

      public boolean isValid(Locale locale)
      Description copied from interface: IPolyglott
      Only meaningful for the default language for which all required fields must be filled.
      Specified by:
      isValid in interface IPolyglott
      Parameters:
      locale - the locale to validate required fields for
      Returns:
      true if all required fields contain a value in the given locale
    • isEmpty

      public boolean isEmpty(Locale locale)
      Description copied from interface: IPolyglott
      If this returns true, an associated language tab should have neither the 'already-translated' nor the '-partly-translated' class.
      Specified by:
      isEmpty in interface IPolyglott
      Parameters:
      locale - the locale to check for empty fields
      Returns:
      true if no fields are filled for the given locale
    • getSelectedLocale

      public Locale getSelectedLocale()
      Specified by:
      getSelectedLocale in interface IPolyglott
      Returns:
      the locale currently set by IPolyglott.setSelectedLocale(Locale)
    • setSelectedLocale

      public void setSelectedLocale(Locale locale)
      Description copied from interface: IPolyglott
      Sets the locale to use for display and editing.
      Specified by:
      setSelectedLocale in interface IPolyglott
      Parameters:
      locale - the locale to select
    • getAccessPermissionThumbnail

      public AccessPermission getAccessPermissionThumbnail()
    • setAccessPermissionThumbnail

      public void setAccessPermissionThumbnail(AccessPermission accessPermissionThumbnail)