Package io.goobi.viewer.model.metadata
Class MetadataContainer
java.lang.Object
io.goobi.viewer.model.metadata.MetadataContainer
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 Alpers
-
Constructor Summary
ConstructorsConstructorDescriptionCloning constructor.MetadataContainer(String solrId, de.intranda.metadata.multilanguage.IMetadataValue label) MetadataContainer(String solrId, de.intranda.metadata.multilanguage.IMetadataValue label, Map<String, List<de.intranda.metadata.multilanguage.IMetadataValue>> metadata) MetadataContainer(String solrId, String label) MetadataContainer(Map<String, List<de.intranda.metadata.multilanguage.IMetadataValue>> metadata) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidaddAll(String key, Collection<de.intranda.metadata.multilanguage.IMetadataValue> values) voidaddAll(String key, Collection<de.intranda.metadata.multilanguage.IMetadataValue> values, boolean overwrite) booleancontainsField(String field) static MetadataContainerstatic MetadataContainercreateMetadataEntity(org.apache.solr.common.SolrDocument doc) Returns aMetadataContainerwhich includes all metadata fields matching the given fieldNameFilter from the givenSolrDocumentdoc.static MetadataContainercreateMetadataEntity(org.apache.solr.common.SolrDocument doc, Predicate<String> fieldNameFilter) Returns aMetadataContainerwhich includes all metadata fields matching the given fieldNameFilter from the givenSolrDocumentdoc.static MetadataContainercreateMetadataEntity(org.apache.solr.common.SolrDocument doc, List<org.apache.solr.common.SolrDocument> children, Predicate<String> mainDocFieldNameFilter, Predicate<String> childDocFieldNameFilter) Returns aMetadataContainerwhich includes all metadata fields matching the given fieldNameFilter from the givenSolrDocumentdoc as well as thevaluesof those child documents whichlabelmatches the fieldnameFilter.List<de.intranda.metadata.multilanguage.IMetadataValue> Get all metadata for the given key.de.intranda.metadata.multilanguage.IMetadataValueget the first metadata value for the given key.getFirstIntValue(String key) getFirstValue(String key) Get the first found value in the default language for the given key.getFirstValue(String key, Locale locale) Get the first found value for the given key and locale.de.intranda.metadata.multilanguage.IMetadataValuegetLabel()Gets all values of the default language (or any value of no default langauge value exists) for the given field.Get all values of the default language (or any value of no default langauge value exists) for the given field.voidvoidvoidsetLabel(de.intranda.metadata.multilanguage.IMetadataValue label) toString()
-
Constructor Details
-
MetadataContainer
-
MetadataContainer
public MetadataContainer(String solrId, de.intranda.metadata.multilanguage.IMetadataValue label, Map<String, List<de.intranda.metadata.multilanguage.IMetadataValue>> metadata) - Parameters:
solrId- Solr document identifier (IDDOC) for this containerlabel- display label for this metadata containermetadata- map of field names to their list of metadata values
-
MetadataContainer
- Parameters:
solrId- Solr document identifier (IDDOC) for this containerlabel- display label for this metadata container
-
MetadataContainer
- Parameters:
solrId- Solr document identifier (IDDOC) for this containerlabel- display label string for this metadata container
-
MetadataContainer
Cloning constructor.- Parameters:
orig- source container to copy
-
-
Method Details
-
getSolrId
-
getLabel
public de.intranda.metadata.multilanguage.IMetadataValue getLabel() -
setLabel
public void setLabel(de.intranda.metadata.multilanguage.IMetadataValue label) -
getLabel
-
getMetadata
-
get
Get all metadata for the given key.- Parameters:
key- the field name for which to get the metadata value- Returns:
- List
-
getFirst
get the first metadata value for the given key. If no such value exists, an emptyIMetadataValueis returned.- Parameters:
key- the field name for which to get the metadata value- Returns:
IMetadataValue
-
getValues
Gets 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
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
-
getFirstIntValue
-
getFirstBooleanValue
-
getValues
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 valuelocale- 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
Get the first found value for the given key and locale.- Parameters:
key- the field name for which to get the metadata valuelocale- 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
- Parameters:
key- metadata field name to map the values tovalues- list of metadata values to store for the given field
-
add
- Parameters:
key- metadata field name to add the value tovalue- metadata value to append for the given field
-
add
- Parameters:
key- metadata field name to add the value tovalue- string value to append for the given field
-
addAll
public void addAll(String key, Collection<de.intranda.metadata.multilanguage.IMetadataValue> values) - Parameters:
key- metadata field name to add the values tovalues- collection of metadata values to append for the given field
-
addAll
public void addAll(String key, Collection<de.intranda.metadata.multilanguage.IMetadataValue> values, boolean overwrite) - Parameters:
key- metadata field name to add the values tovalues- collection of metadata values to store for the given fieldoverwrite- if true, replaces existing values instead of appending
-
remove
- Parameters:
key- metadata field name to remove from this container
-
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 aMetadataContainerwhich includes all metadata fields matching the given fieldNameFilter from the givenSolrDocumentdoc as well as thevaluesof those child documents whichlabelmatches the fieldnameFilter.- Parameters:
doc- The main DOCSTRUCT documentchildren- METADATA type documents belonging to the main docmainDocFieldNameFilter- A function which should return true for all metadata field names to be included in the main docchildDocFieldNameFilter- A function which should return true for all metadata field names to be included in child docs- Returns:
- a
MetadataContainer
-
createMetadataEntity
-
createMetadataEntity
public static MetadataContainer createMetadataEntity(org.apache.solr.common.SolrDocument doc, Predicate<String> fieldNameFilter) Returns aMetadataContainerwhich includes all metadata fields matching the given fieldNameFilter from the givenSolrDocumentdoc.- Parameters:
doc- The main DOCSTRUCT documentfieldNameFilter- A function which should return true for all metadata field names to be included in the return value- Returns:
- a
MetadataContainer
-
createMetadataEntity
Returns aMetadataContainerwhich includes all metadata fields matching the given fieldNameFilter from the givenSolrDocumentdoc.- Parameters:
doc- The main DOCSTRUCT document- Returns:
- a
MetadataContainer
-
containsField
-
toString
-