Class MetadataContainer

java.lang.Object
io.goobi.viewer.model.metadata.MetadataContainer

public class MetadataContainer extends Object
An object containing a number of translatable metadata values. The values are mapped to a key which is a string corresponding to the SOLR field name the values are taken from Each field name/key is mapped to a list of IMetadataValue objects which may contain a single string or translations in several languages Used in GeoCoordinateConverter to add translatable metadata entites to geomap features
Author:
florian
  • Constructor Details

    • MetadataContainer

      public MetadataContainer(String solrId, de.intranda.metadata.multilanguage.IMetadataValue label, Map<String,List<de.intranda.metadata.multilanguage.IMetadataValue>> metadata)
      Parameters:
      solrId -
      label -
      metadata -
    • MetadataContainer

      public MetadataContainer(String solrId, de.intranda.metadata.multilanguage.IMetadataValue label)
      Parameters:
      solrId -
      label -
    • MetadataContainer

      public MetadataContainer(String solrId, String label)
      Parameters:
      solrId -
      label -
    • MetadataContainer

      public MetadataContainer(MetadataContainer orig)
      Cloning constructor.
      Parameters:
      orig -
  • Method Details

    • getSolrId

      public String getSolrId()
    • getLabel

      public de.intranda.metadata.multilanguage.IMetadataValue getLabel()
    • setLabel

      public void setLabel(de.intranda.metadata.multilanguage.IMetadataValue label)
    • getLabel

      public String getLabel(Locale locale)
    • getMetadata

      public Map<String,List<de.intranda.metadata.multilanguage.IMetadataValue>> getMetadata()
    • get

      public List<de.intranda.metadata.multilanguage.IMetadataValue> get(String key)
      Get all metadata for the given key
      Parameters:
      key - the field name for which to get the metadata value
      Returns:
      List
    • getFirst

      public de.intranda.metadata.multilanguage.IMetadataValue getFirst(String key)
      get the first metadata value for the given key. If no such value exists, an empty IMetadataValue is returned
      Parameters:
      key - the field name for which to get the metadata value
      Returns:
      IMetadataValue
    • getValues

      public List<String> getValues(String key)
      Get all values of the default language (or any value of no default langauge value exists) for the given field
      Parameters:
      key - the field name for which to get the metadata value
      Returns:
      List
    • getFirstValue

      public String getFirstValue(String key)
      Get the first found value in the default language for the given key
      Parameters:
      key - the field name for which to get the metadata value
      Returns:
      First value for the given key; empty string if not found
    • getValues

      public List<String> getValues(String key, Locale locale)
      Get all values of the default language (or any value of no default langauge value exists) for the given field
      Parameters:
      key - the field name for which to get the metadata value
      locale - the language for which to find a value. If there is no translation in that langauge, use the default language and failing that any language entry
      Returns:
      List of values for the given key and locale
    • getFirstValue

      public String getFirstValue(String key, Locale locale)
      Get the first found value for the given key and locale
      Parameters:
      key - the field name for which to get the metadata value
      locale - the language for which to find a value. If there is no translation in that langauge, use the default language and failing that any language entry
      Returns:
      First value for the given key and locale; empty string if not found
    • put

      public void put(String key, List<de.intranda.metadata.multilanguage.IMetadataValue> values)
      Parameters:
      key -
      values -
    • add

      public void add(String key, de.intranda.metadata.multilanguage.IMetadataValue value)
      Parameters:
      key -
      value -
    • add

      public void add(String key, String value)
      Parameters:
      key -
      value -
    • addAll

      public void addAll(String key, Collection<de.intranda.metadata.multilanguage.IMetadataValue> values)
      Parameters:
      key -
      values -
    • addAll

      public void addAll(String key, Collection<de.intranda.metadata.multilanguage.IMetadataValue> values, boolean overwrite)
      Parameters:
      key -
      values -
      overwrite -
    • remove

      public void remove(String key)
      Parameters:
      key -
    • createMetadataEntity

      public static MetadataContainer createMetadataEntity(org.apache.solr.common.SolrDocument doc, List<org.apache.solr.common.SolrDocument> children, Predicate<String> mainDocFieldNameFilter, Predicate<String> childDocFieldNameFilter)
      Returns a MetadataContainer which includes all metadata fields matching the given fieldNameFilter from the given SolrDocument doc as well as the values of those child documents which label matches the fieldnameFilter
      Parameters:
      doc - The main DOCSTRUCT document
      children - METADATA type documents belonging to the main doc
      mainDocFieldNameFilter - A function which should return true for all metadata field names to be included in the main doc
      childDocFieldNameFilter - A function which should return true for all metadata field names to be included in child docs
      Returns:
      a MetadataContainer
    • createMetadataEntity

      public static MetadataContainer createMetadataEntity(StructElement doc)
    • createMetadataEntity

      public static MetadataContainer createMetadataEntity(org.apache.solr.common.SolrDocument doc, Predicate<String> fieldNameFilter)
      Returns a MetadataContainer which includes all metadata fields matching the given fieldNameFilter from the given SolrDocument doc
      Parameters:
      doc - The main DOCSTRUCT document
      fieldNameFilter - A function which should return true for all metadata field names to be included in the return value
      Returns:
      a MetadataContainer
    • createMetadataEntity

      public static MetadataContainer createMetadataEntity(org.apache.solr.common.SolrDocument doc)
      Returns a MetadataContainer which includes all metadata fields matching the given fieldNameFilter from the given SolrDocument doc
      Parameters:
      doc - The main DOCSTRUCT document
      Returns:
      a MetadataContainer