Class Metadata

java.lang.Object
io.goobi.viewer.model.metadata.Metadata
All Implemented Interfaces:
MetadataListElement, Serializable

public class Metadata extends Object implements MetadataListElement, Serializable
Metadata field configuration.
See Also:
  • Constructor Details

    • Metadata

      public Metadata(Metadata orig)
    • Metadata

      public Metadata()
      Default constructor.
    • Metadata

      public Metadata(String ownerIddoc, String label, String masterValue, String paramValue)
      Constructor with a single metadata value.
      Parameters:
      ownerIddoc - IDDOC of the owning structure element
      label - display label key from messages.properties
      masterValue - value template with placeholders
      paramValue - single initial parameter value to populate
    • Metadata

      public Metadata(String label, String masterValue, List<MetadataParameter> params)
      Constructor with a MetadataParameter list.
      Parameters:
      label - display label key from messages.properties
      masterValue - value template with placeholders
      params - list of metadata parameters to configure
    • Metadata

      public Metadata(String label, String key, String masterValue, List<MetadataParameter> params)
      Constructor with a MetadataParameter list.
      Parameters:
      label - display label key from messages.properties
      key - LABEL field value used to identify grouped metadata docs
      masterValue - value template with placeholders
      params - list of metadata parameters to configure
    • Metadata

      public Metadata(String ownerIddoc, String label, String masterValue, MetadataParameter param, String paramValue, Locale locale)
      Creates a new Metadata instance.
      Parameters:
      ownerIddoc - IDDOC of the owning structure element
      label - display label key from messages.properties
      masterValue - value template with placeholders
      param - metadata parameter defining how the value is processed
      paramValue - initial value to populate via setParamValue
      locale - locale used for value translation and formatting
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • isHasLabel

      public boolean isHasLabel()
      isHasLabel.
      Returns:
      true if this metadata field has a non-blank display label, false otherwise
    • getLabel

      public String getLabel()
      Getter for the field label.
      Returns:
      the display label of this metadata field
    • getMasterValue

      public String getMasterValue()
      Getter for the field masterValue.
      Returns:
      the master value format string, or a generated placeholder string if not set
    • getType

      public int getType()
      Getter for the field type.
      Returns:
      the metadata display type (e.g. 0 for default, 1 for group, 2 for citation)
    • setType

      public Metadata setType(int type)
      Parameters:
      type - the metadata display type (e.g. 0 for default, 1 for group, 2 for citation)
      Returns:
      this
    • getSortFields

      public List<StringPair> getSortFields()
      Returns:
      List
    • getSortField

      public String getSortField()
    • setSortField

      public Metadata setSortField(String sortField)
      Parameters:
      sortField - the Solr field name used for sorting this metadata field
      Returns:
      this
    • getValues

      public List<MetadataValue> getValues()
      Getter for the field values.
      Returns:
      the list of MetadataValue objects associated with this metadata field
    • getValuesForOwner

      public List<MetadataValue> getValuesForOwner(String ownerIddoc)
      Parameters:
      ownerIddoc - IDDOC of the owning structure element to filter values by
      Returns:
      Sublist of all values that belong to ownerIddoc; all values if ownerIddoc null
    • getFirstValue

      public String getFirstValue()
      Returns:
      First MetadataValue
    • setParamValue

      public void setParamValue(int valueIndex, int paramIndex, List<String> inValues, String paramLabel, String url, Map<String,String> options, String groupType, Locale locale)
      setParamValue.
      Parameters:
      valueIndex - index of the MetadataValue to populate
      paramIndex - index of the parameter within this metadata
      inValues - List with values
      paramLabel - display label for the parameter
      url - optional hyperlink URL associated with the value
      options - additional key/value options (e.g. NORM_TYPE)
      groupType - value of METADATATYPE, if available
      locale - locale for value translation and formatting
    • setParamValue

      public void setParamValue(int valueIndex, int paramIndex, List<String> inValues, RelationshipMetadataContainer relatedMetadata, String paramLabel, String url, Map<String,String> options, String groupType, Locale locale)
    • getParams

      public List<MetadataParameter> getParams()
      Getter for the field params.
      Returns:
      the list of MetadataParameter objects that define how values are retrieved for this metadata field
    • getParamFieldNames

      public List<String> getParamFieldNames()
      Returns:
      Configured index field names of parameters
    • hasParam

      public boolean hasParam(String paramName)
      hasParam.
      Parameters:
      paramName - Solr field name of the parameter to find
      Returns:
      true if this metadata has a parameter with the given field name, false otherwise
    • getParamCount

      public int getParamCount()
      Returns:
      Number of params
    • getParamValue

      public String getParamValue(String field)
    • isBlank

      public boolean isBlank()
      Checks whether any parameter values are set. 'empty' seems to be a reserved word in JSF, so use 'blank'.
      Returns:
      true if all paramValues are empty or blank; false otherwise.
    • isBlank

      public boolean isBlank(String ownerIddoc)
      Parameters:
      ownerIddoc - IDDOC of the owning structure element to filter values by
      Returns:
      true if this metadata contains no non-blank values; false otherwise
    • populate

      public boolean populate(StructElement se, String ownerIddoc, List<StringPair> sortFields, Locale locale) throws IndexUnreachableException, PresentationException
      Parameters:
      se - structure element providing the metadata field values
      ownerIddoc - IDDOC of the owner document
      sortFields - field/order pairs used for sorting grouped metadata
      locale - locale used for value translation and formatting
      Returns:
      true if at least one value was populated successfully, false otherwise
      Throws:
      IndexUnreachableException
      PresentationException
    • populate

      public boolean populate(StructElement se, StructElement anchorSe, String ownerIddoc, List<StringPair> sortFields, Map<String,Set<String>> searchTerms, int truncateLength, Locale locale) throws IndexUnreachableException, PresentationException
      Populates the parameters of the given metadata with values from the given StructElement.
      Parameters:
      se - structure element providing the metadata field values
      anchorSe - Optional anchor StructElement
      ownerIddoc - IDDOC of the owner document (either docstruct or parent metadata)
      sortFields - field/order pairs used for sorting grouped metadata
      searchTerms - map of search terms for adding highlighting to matched values
      truncateLength - maximum character length before truncation; 0 to disable
      locale - locale for value translation and formatting
      Returns:
      true if at least one value was populated successfully, false otherwise
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
    • getPersonDisplayName

      public static String getPersonDisplayName(String aggregatedMetadata)
      Converts aggregated person/corporation metadata to just the displayable name.
      Parameters:
      aggregatedMetadata - semicolon-delimited person metadata string to parse
      Returns:
      the displayable person name extracted from the aggregated metadata string
    • getNumber

      public int getNumber()
      Getter for the field number.
      Returns:
      a int.
    • setNumber

      public Metadata setNumber(int number)
      Parameters:
      number - the display order number of this metadata field within its section
      Returns:
      this
    • isGroup

      public boolean isGroup()
      isGroup.
      Returns:
      true if this metadata represents a grouped metadata element, false otherwise
    • setGroup

      public Metadata setGroup(boolean group)
      Parameters:
      group - true if this metadata represents a grouped metadata element
      Returns:
      this
    • isSingleString

      public boolean isSingleString()
    • setSingleString

      public Metadata setSingleString(boolean singleString)
      Parameters:
      singleString - true if all parameter values should be concatenated into a single string for display
      Returns:
      this
    • isHideIfOnlyMetadataField

      public boolean isHideIfOnlyMetadataField()
    • setHideIfOnlyMetadataField

      public Metadata setHideIfOnlyMetadataField(boolean hideIfOnlyMetadataField)
      Parameters:
      hideIfOnlyMetadataField - true if this field should be hidden when it is the only metadata field displayed
      Returns:
      this
    • isTopstructOnly

      public boolean isTopstructOnly()
    • setTopstructOnly

      public Metadata setTopstructOnly(boolean topstructOnly)
      Parameters:
      topstructOnly - true if this metadata should only be displayed for the top-level structure element
      Returns:
      this
    • getLabelField

      public String getLabelField()
    • setLabelField

      public Metadata setLabelField(String labelField)
      Parameters:
      labelField - the Solr field name whose value is used as the display label for this metadata
      Returns:
      this
    • getSeparator

      public String getSeparator()
    • setSeparator

      public Metadata setSeparator(String separator)
      Parameters:
      separator - the string used to separate multiple values when rendering this metadata field
      Returns:
      this
    • getOwnerDocstrctType

      public String getOwnerDocstrctType()
    • setOwnerDocstrctType

      public Metadata setOwnerDocstrctType(String ownerDocstrctType)
      Parameters:
      ownerDocstrctType - the document structure type of the owning structure element
      Returns:
      this
    • setFilterQuery

      public Metadata setFilterQuery(String filterQuery)
    • getFilterQuery

      public String getFilterQuery()
    • isAccessGranted

      public boolean isAccessGranted()
    • setAccessGranted

      public void setAccessGranted(boolean accessGranted)
    • getCitationTemplate

      public String getCitationTemplate()
    • setCitationTemplate

      public Metadata setCitationTemplate(String citationTemplate)
      Parameters:
      citationTemplate - the CSL citation style template name used to format citation output
      Returns:
      this
    • getCitationProcessorWrapper

      public CitationProcessorWrapper getCitationProcessorWrapper()
    • setCitationProcessorWrapper

      public void setCitationProcessorWrapper(CitationProcessorWrapper citationProcessorWrapper)
    • getParentMetadata

      public Metadata getParentMetadata()
    • setParentMetadata

      public void setParentMetadata(Metadata parentMetadata)
    • isHasChildren

      public boolean isHasChildren()
      Returns:
      true if childMetadata not empty; false otherwise
    • getChildMetadata

      public List<Metadata> getChildMetadata()
    • getIndentation

      public int getIndentation()
    • setIndentation

      public Metadata setIndentation(int indentation)
      Parameters:
      indentation - the nesting level used for visual indentation when rendering child metadata
      Returns:
      this
    • filterMetadata

      public static List<Metadata> filterMetadata(List<Metadata> metadataList, String language, String field)
      Returns a metadata list that contains the fields of the given metadata list minus any language-specific fields that do not match the given language.
      Parameters:
      metadataList - list of Metadata objects to filter
      language - two-letter language code to match field variants against
      field - metadata field name to filter by; null to include all fields
      Returns:
      Metadata list without any fields with non-matching language; original list if no language is given
    • toString

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

      public String getCombinedValue(String separator)
    • forField

      public static Metadata forField(String field)