Class MetadataElement

java.lang.Object
io.goobi.viewer.model.metadata.MetadataElement
All Implemented Interfaces:
Serializable

public class MetadataElement extends Object implements Serializable
Represents a group of metadata fields belonging to a single structural element of a digitized record.
See Also:
  • Constructor Details

    • MetadataElement

      public MetadataElement()
  • Method Details

    • init

      public MetadataElement init(StructElement se, int metadataViewIndex, Locale sessionLocale) throws PresentationException, IndexUnreachableException
      Parameters:
      se - StructElement
      metadataViewIndex - Metadata view index
      sessionLocale - locale for translations/formatting
      Returns:
      Constructed MetadataElement
      Throws:
      PresentationException
      IndexUnreachableException
    • isHasMetadataListFold

      public boolean isHasMetadataListFold()
    • getMetadataFoldIndex

      public int getMetadataFoldIndex()
    • isSkip

      public boolean isSkip()
      Returns:
      true if all available metadata fields for this element are marked as hidden; false otherwise
    • getMetadataTypes

      public List<MetadataElement.MetadataType> getMetadataTypes()
      Returns a sorted list of all metadata types contained in metadataList.
      Returns:
      a list of distinct metadata types present in the metadata list
    • hasMetadataTypeLabels

      public boolean hasMetadataTypeLabels(int viewIndex)
    • getMetadata

      public Metadata getMetadata(String name)
      Returns the first instance of a Metadata object whose label matches the given field name.
      Parameters:
      name - Solr field name to look up
      Returns:
      the first Metadata object whose label matches the given field name, or null if not found
    • getMetadata

      public Metadata getMetadata(String name, String language)
      Returns the first instance of a Metadata object whose label matches the given field name. If a language is given, a localized field name will be used.
      Parameters:
      name - Solr field name to look up
      language - Optional language
      Returns:
      the first Metadata object matching the field name and optional language, or null if not found
    • getMetadata

      public List<Metadata> getMetadata(List<String> fields)
      getMetadata.
      Parameters:
      fields - Solr field names to retrieve metadata for
      Returns:
      List of Metadata objects that match the given field names
    • setMetadataList

      public void setMetadataList(List<Metadata> metadataList)
      Setter for the field metadataList.
      Parameters:
      metadataList - the list of metadata fields to display in the main metadata section
    • getMetadataList

      public List<Metadata> getMetadataList()
      Getter for the field metadataList.
      Returns:
      the full list of Metadata objects for this element, filtered by the selected record language
    • getMetadataList

      public List<Metadata> getMetadataList(boolean beforeFold)
      Getter for the field metadataList.
      Parameters:
      beforeFold - if true, only list metadata before index #metadataFoldIndex
      Returns:
      the list of Metadata objects, optionally truncated at the fold index
    • getMetadataListBeforeFold

      public List<Metadata> getMetadataListBeforeFold()
      Returns:
      the list of Metadata objects that appear before the fold index
    • getMetadataListAfterFold

      public List<Metadata> getMetadataListAfterFold()
    • hasMetadata

      public boolean hasMetadata()
      hasMetadata.
      Returns:
      true if this element has at least one non-blank metadata entry in the main metadata list, false otherwise
    • isDisplayBoxed

      public boolean isDisplayBoxed(int type)
      Checks whether all metadata fields for this element can be displayed in a single box (i.e. no table type grouped metadata are configured).
      Parameters:
      type - the metadata type to check
      Returns:
      true if all metadata are not configured as single string; false otherwise
    • hasSidebarMetadata

      public boolean hasSidebarMetadata()
      hasSidebarMetadata.
      Returns:
      true if this element has at least one non-blank metadata entry in the sidebar metadata list, false otherwise
    • getSidebarMetadataList

      public List<Metadata> getSidebarMetadataList()
      Getter for the field sidebarMetadataList.
      Returns:
      the list of Metadata objects configured for display in the sidebar, filtered by the selected record language
    • setSidebarMetadataList

      public void setSidebarMetadataList(List<Metadata> sidebarMetadataList)
      Setter for the field sidebarMetadataList.
      Parameters:
      sidebarMetadataList - the list of metadata fields to display in the sidebar section
    • isHasSidebarMetadata

      public boolean isHasSidebarMetadata()
      isHasSidebarMetadata.
      Returns:
      true if the sidebar metadata list is non-null and not empty, false otherwise
    • getDocStructTypeLabel

      public String getDocStructTypeLabel()
      Returns the docstruct type or the group type if this is a record group.
      Returns:
      docstruct type if record; group type if group
    • getLabel

      public String getLabel()
      Getter for the field label.
      Returns:
      the display label for this metadata element, or null if not set
    • setLabel

      public void setLabel(String label)
      Setter for the field label.
      Parameters:
      label - display label for this metadata element
    • getTitle

      public String getTitle()
      Getter for the field title.
      Returns:
      the title of the record or structure element represented by this metadata element
    • getUrl

      public String getUrl()
      Getter for the field url.
      Returns:
      the URL associated with this metadata element
    • setUrl

      public void setUrl(String url)
      Setter for the field url.
      Parameters:
      url - viewer URL for this element's record page
    • isTopElement

      public boolean isTopElement()
      Returns true if this MetadataElement represents a stand-alone record, volume or anchor element.
      Returns:
      topElement
    • getDocType

      public String getDocType()
      Getter for the field docType.
      Returns:
      the document type string (e.g. "monograph", "periodical") of the record represented by this element
    • getDocStructType

      public String getDocStructType()
      Getter for the field docStructType.
      Returns:
      the document structure type (e.g. "Chapter", "Article") of the record represented by this element
    • getGroupType

      public String getGroupType()
    • getPi

      public String getPi()
    • isAnchor

      public boolean isAnchor()
      isAnchor.
      Returns:
      true if this metadata element belongs to an anchor (multi-volume) record, false otherwise
    • isFilesOnly

      public boolean isFilesOnly()
      isFilesOnly.
      Returns:
      true if this metadata element represents a files-only record (no displayable image), false otherwise
    • isHasImages

      public boolean isHasImages()
    • getFirstMetadataValue

      public String getFirstMetadataValue(String name)
      getFirstMetadataValue.
      Parameters:
      name - The name of the metadata
      Returns:
      the best available metadata value, or an empty string if no metadata was found
    • getFirstMetadataValueIfExists

      public Optional<String> getFirstMetadataValueIfExists(String name)
      getFirstMetadataValueIfExists.
      Parameters:
      name - Solr field name to look up
      Returns:
      an Optional containing the first non-blank metadata value for the field, or empty if not found
    • getFirstMetadataValue

      public String getFirstMetadataValue(String prefix, String name, String suffix)
      getFirstMetadataValue.
      Parameters:
      prefix - string prepended to the metadata value
      name - Solr field name to look up
      suffix - string appended to the metadata value
      Returns:
      the first metadata value for the given Solr field, wrapped with the given prefix and suffix
    • setSelectedRecordLanguage

      public MetadataElement setSelectedRecordLanguage(String language)
      Setter for the field selectedRecordLanguage.
      Parameters:
      language - ISO language code for the selected record language
      Returns:
      this