Class MetadataBean

java.lang.Object
io.goobi.viewer.managedbeans.MetadataBean

@Named @RequestScoped public class MetadataBean extends Object
Provides the metadata for the current structure and event elements.
  • Constructor Details

    • MetadataBean

      public MetadataBean()
      Empty constructor.
  • Method Details

    • setActiveDocumentBean

      public void setActiveDocumentBean(ActiveDocumentBean activeDocumentBean)
      Required setter for ManagedProperty injection.
      Parameters:
      activeDocumentBean - the ActiveDocumentBean instance to inject
    • loadMetadata

      public String loadMetadata(int index, Locale locale) throws IndexUnreachableException, DAOException
      loadMetadata.
      Parameters:
      index - Metadata view index to load
      locale - Locale used for translating metadata values
      Returns:
      navigation outcome string for the metadata view
      Throws:
      IndexUnreachableException - if any.
      DAOException - if any.
    • getMetadataElementList

      public List<MetadataElement> getMetadataElementList()
      Convenience method for getMetadataElementList(0).
      Returns:
      the first metadata element list
    • getMetadataElementList

      public List<MetadataElement> getMetadataElementList(int index)
      Getter for the field metadataElementList.
      Parameters:
      index - Metadata view index to retrieve
      Returns:
      the list of metadata elements for the given view index
    • getMetadataElementList

      public List<MetadataElement> getMetadataElementList(int index, boolean forceReload)
      Returns the list of MetadataElements for the given metadata view index, optionally forcing a reload.
      Parameters:
      index - the metadata view index
      forceReload - if true, always reload from the current document
      Returns:
      list of metadata elements, or an empty list if no document is loaded or loading fails
    • getMetadataElementsAsList

      public List<MetadataElement> getMetadataElementsAsList(MetadataElement... elements)
      Returns given MetadataElements as an ArrayList. Used for supplying a custom list of elements for the metadata sidebar widget.
      Parameters:
      elements - Vararg metadata elements to wrap in a list
      Returns:
      List
    • getTopMetadataElement

      public MetadataElement getTopMetadataElement(int index)
      getTopMetadataElement.
      Parameters:
      index - Metadata view index
      Returns:
      the top MetadataElement at the given view index, or null if none is available
    • getMainMetadataElement

      public MetadataElement getMainMetadataElement(int index)
      The main metadata element is the first element which isn't an anchor if any such elements are in the metadata element list. Otherwise it is just the first (anchor) metadata element
      Parameters:
      index - Metadata view index to retrieve
      Returns:
      the main MetadataElement (first non-anchor) for the given view index, or null if none is available
    • getBottomMetadataElement

      public MetadataElement getBottomMetadataElement(int metadataViewIndex)
      Returns the last element in metadataElementList, which is the bottom element in the hierarchy. If the element contains no side bar metadata, the next higher element is checked until an element with sidebar metadata is found. TODO for some reason this method is called 6-15 times per page
      Parameters:
      metadataViewIndex - Metadata view index
      Returns:
      the bottom MetadataElement with sidebar metadata for the given view index, or null if none is available
    • getBottomMetadataElementAsList

      public List<MetadataElement> getBottomMetadataElementAsList(int metadataViewIndex)
      Parameters:
      metadataViewIndex - Metadata view index to retrieve
      Returns:
      List
    • getDefaultMetadataLabel

      public String getDefaultMetadataLabel()
      Convenience method for the metadata page/link label key, depending on the document type.
      Returns:
      Message key for the label
    • getDefaultSidebarMetadataLabel

      public String getDefaultSidebarMetadataLabel()
      Convenience method for the sidebar metadata widget label key, depending on the document type.
      Returns:
      Message key for the label
    • getEvents

      public List<EventElement> getEvents()
      Getter for the field events.
      Returns:
      the list of LIDO event elements for the current record
    • setEvents

      public void setEvents(List<EventElement> events)
      Setter for the field events.
      Parameters:
      events - LIDO event elements to display
    • displayChildStructs

      public boolean displayChildStructs()
      displayChildStructs.
      Returns:
      true if child structural elements should be displayed in the metadata view, false otherwise
    • setSelectedRecordLanguage

      public void setSelectedRecordLanguage(String selectedRecordLanguage)
      setSelectedRecordLanguage.
      Parameters:
      selectedRecordLanguage - ISO language code to use for multi-language fields
    • getMetadataViews

      public List<MetadataView> getMetadataViews()
      Returns:
      List of available MetadataViews
    • getMetadataViewUrl

      public String getMetadataViewUrl()
    • setMetadataViewUrl

      public void setMetadataViewUrl(String metadataViewUrl)
      Parameters:
      metadataViewUrl - URL segment identifying the metadata view to activate
    • selectFirstMetadataViewOfLocation

      public void selectFirstMetadataViewOfLocation(String location)
      Sets activeMetadataView to the first configured MetadataView with location="location".
      Parameters:
      location - Location name
    • getActiveMetadataView

      public MetadataView getActiveMetadataView()
    • setActiveMetadataView

      public void setActiveMetadataView(MetadataView activeMetadataView)
      Parameters:
      activeMetadataView - metadata view configuration to make active
    • getComplexMetadataFieldsToList

      public List<String> getComplexMetadataFieldsToList(String... fields)
      Parameters:
      fields - Vararg Solr field names to convert to a list
      Returns:
      Given strings as List
    • getMetadataValuesForPage

      public List<String> getMetadataValuesForPage(int metadataViewIndex, String mainFieldName, String language, String subFieldName, int order)
      Returns a list of String values for subFieldName of a grouped metadata field mainFieldName where the subfield value of MD_ORDER matches the given order value.
      Parameters:
      metadataViewIndex - Index of the requested metadataView where the requested metadata is configured
      mainFieldName - Main metadata field
      language - Optional metadata field language
      subFieldName - Child metadata field
      order - Page number
      Returns:
      Metadata values of subFieldName; empty list if none found
    • getFirstMetadataValueForPage

      public String getFirstMetadataValueForPage(int metadataViewIndex, String mainFieldName, String language, String subFieldName, int order)
      Returns the first String values for subFieldName of a grouped metadata field mainFieldName where the subfield value of MD_ORDER matches the given order value.
      Parameters:
      metadataViewIndex - Index of the requested metadataView where the requested metadata is configured
      mainFieldName - Main metadata field
      language - Optional metadata field language
      subFieldName - Child metadata field
      order - Page number
      Returns:
      First value of subFieldName; null if none found
    • getFirstMetadataValue

      public String getFirstMetadataValue(int metadataViewIndex, String mainFieldName, String language, String subFieldName)
      Returns the first String values for subFieldName of a grouped metadata field mainFieldName.
      Parameters:
      metadataViewIndex - Index of the requested metadataView where the requested metadata is configured
      mainFieldName - Main metadata field
      language - Optional metadata field language
      subFieldName - Child metadata field
      Returns:
      First value of subFieldName; null if none found
    • getMetadataValues

      public List<String> getMetadataValues(int metadataViewIndex, String mainFieldName, String subFieldName, String language)
      Returns a list of String values for subFieldName of a grouped metadata field mainFieldName.
      Parameters:
      metadataViewIndex - Index of the requested metadataView where the requested metadata is configured
      mainFieldName - Main metadata field
      subFieldName - Child metadata field
      language - Optional metadata field language
      Returns:
      Metadata values of subFieldName; empty list if none found
    • range

      public List<Integer> range(int start, int end)
    • getMetadataList

      public List<Metadata> getMetadataList(StructElement struct, String type)
      Returns a populated list of Metadata for the given struct element and metadata type.
      Parameters:
      struct - the struct element to retrieve metadata for; may be null
      type - the metadata configuration type key
      Returns:
      populated list of metadata, or an empty list if struct is null