Package io.goobi.viewer.model.metadata
Class Metadata
java.lang.Object
io.goobi.viewer.model.metadata.Metadata
- All Implemented Interfaces:
MetadataListElement,Serializable
Metadata field configuration.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMetadata()Default constructor.Metadata(String ownerIddoc, String label, String masterValue, MetadataParameter param, String paramValue, Locale locale) Creates a new Metadata instance.Constructor with a single metadata value.Constructor with aMetadataParameterlist.Metadata(String label, String masterValue, List<MetadataParameter> params) Constructor with aMetadataParameterlist. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfilterMetadata(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.static MetadatagetCombinedValue(String separator) intgetLabel()Getter for the fieldlabel.Getter for the fieldmasterValue.intGetter for the fieldnumber.intGetter for the fieldparams.getParamValue(String field) static StringgetPersonDisplayName(String aggregatedMetadata) Converts aggregated person/corporation metadata to just the displayable name.intgetType()Getter for the fieldtype.Getter for the fieldvalues.getValuesForOwner(String ownerIddoc) inthashCode()booleanhasParam.booleanbooleanisBlank()Checks whether any parameter values are set.booleanbooleanisGroup()isGroup.booleanbooleanisHasLabel.booleanbooleanbooleanbooleanpopulate(StructElement se, StructElement anchorSe, String ownerIddoc, List<StringPair> sortFields, Map<String, Set<String>> searchTerms, int truncateLength, Locale locale) Populates the parameters of the given metadata with values from the given StructElement.booleanpopulate(StructElement se, String ownerIddoc, List<StringPair> sortFields, Locale locale) voidsetAccessGranted(boolean accessGranted) voidsetCitationProcessorWrapper(CitationProcessorWrapper citationProcessorWrapper) setCitationTemplate(String citationTemplate) setFilterQuery(String filterQuery) setGroup(boolean group) setHideIfOnlyMetadataField(boolean hideIfOnlyMetadataField) setIndentation(int indentation) setLabelField(String labelField) setNumber(int number) setOwnerDocstrctType(String ownerDocstrctType) voidsetParamValue(int valueIndex, int paramIndex, List<String> inValues, RelationshipMetadataContainer relatedMetadata, String paramLabel, String url, Map<String, String> options, String groupType, Locale locale) voidsetParamValue(int valueIndex, int paramIndex, List<String> inValues, String paramLabel, String url, Map<String, String> options, String groupType, Locale locale) setParamValue.voidsetParentMetadata(Metadata parentMetadata) setSeparator(String separator) setSingleString(boolean singleString) setSortField(String sortField) setTopstructOnly(boolean topstructOnly) setType(int type) toString()
-
Constructor Details
-
Metadata
-
Metadata
public Metadata()Default constructor. -
Metadata
Constructor with a single metadata value.- Parameters:
ownerIddoc- IDDOC of the owning structure elementlabel- display label key from messages.propertiesmasterValue- value template with placeholdersparamValue- single initial parameter value to populate
-
Metadata
Constructor with aMetadataParameterlist.- Parameters:
label- display label key from messages.propertiesmasterValue- value template with placeholdersparams- list of metadata parameters to configure
-
Metadata
Constructor with aMetadataParameterlist.- Parameters:
label- display label key from messages.propertieskey- LABEL field value used to identify grouped metadata docsmasterValue- value template with placeholdersparams- 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 elementlabel- display label key from messages.propertiesmasterValue- value template with placeholdersparam- metadata parameter defining how the value is processedparamValue- initial value to populate via setParamValuelocale- locale used for value translation and formatting
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
isHasLabel
public boolean isHasLabel()isHasLabel.- Returns:
- true if this metadata field has a non-blank display label, false otherwise
-
getLabel
Getter for the fieldlabel.- Returns:
- the display label of this metadata field
-
getMasterValue
Getter for the fieldmasterValue.- Returns:
- the master value format string, or a generated placeholder string if not set
-
getType
public int getType()Getter for the fieldtype.- Returns:
- the metadata display type (e.g. 0 for default, 1 for group, 2 for citation)
-
setType
- Parameters:
type- the metadata display type (e.g. 0 for default, 1 for group, 2 for citation)- Returns:
- this
-
getSortFields
- Returns:
- List
-
getSortField
-
setSortField
- Parameters:
sortField- the Solr field name used for sorting this metadata field- Returns:
- this
-
getValues
Getter for the fieldvalues.- Returns:
- the list of
MetadataValueobjects associated with this metadata field
-
getValuesForOwner
- Parameters:
ownerIddoc- IDDOC of the owning structure element to filter values by- Returns:
- Sublist of all values that belong to
ownerIddoc; all values ifownerIddocnull
-
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 populateparamIndex- index of the parameter within this metadatainValues- List with valuesparamLabel- display label for the parameterurl- optional hyperlink URL associated with the valueoptions- additional key/value options (e.g. NORM_TYPE)groupType- value of METADATATYPE, if availablelocale- locale for value translation and formatting
-
setParamValue
-
getParams
Getter for the fieldparams.- Returns:
- the list of
MetadataParameterobjects that define how values are retrieved for this metadata field
-
getParamFieldNames
- Returns:
- Configured index field names of parameters
-
hasParam
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
-
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
- 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 valuesownerIddoc- IDDOC of the owner documentsortFields- field/order pairs used for sorting grouped metadatalocale- locale used for value translation and formatting- Returns:
- true if at least one value was populated successfully, false otherwise
- Throws:
IndexUnreachableExceptionPresentationException
-
populate
public boolean populate(StructElement se, StructElement anchorSe, String ownerIddoc, List<StringPair> sortFields, Map<String, Set<String>> searchTerms, int truncateLength, Locale locale) throws IndexUnreachableException, PresentationExceptionPopulates the parameters of the given metadata with values from the given StructElement.- Parameters:
se- structure element providing the metadata field valuesanchorSe- Optional anchorStructElementownerIddoc- IDDOC of the owner document (either docstruct or parent metadata)sortFields- field/order pairs used for sorting grouped metadatasearchTerms- map of search terms for adding highlighting to matched valuestruncateLength- maximum character length before truncation; 0 to disablelocale- 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
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 fieldnumber.- Returns:
- a int.
-
setNumber
- 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
- Parameters:
group- true if this metadata represents a grouped metadata element- Returns:
- this
-
isSingleString
public boolean isSingleString() -
setSingleString
- Parameters:
singleString- true if all parameter values should be concatenated into a single string for display- Returns:
- this
-
isHideIfOnlyMetadataField
public boolean isHideIfOnlyMetadataField() -
setHideIfOnlyMetadataField
- Parameters:
hideIfOnlyMetadataField- true if this field should be hidden when it is the only metadata field displayed- Returns:
- this
-
isTopstructOnly
public boolean isTopstructOnly() -
setTopstructOnly
- Parameters:
topstructOnly- true if this metadata should only be displayed for the top-level structure element- Returns:
- this
-
getLabelField
-
setLabelField
- Parameters:
labelField- the Solr field name whose value is used as the display label for this metadata- Returns:
- this
-
getSeparator
-
setSeparator
- Parameters:
separator- the string used to separate multiple values when rendering this metadata field- Returns:
- this
-
getOwnerDocstrctType
-
setOwnerDocstrctType
- Parameters:
ownerDocstrctType- the document structure type of the owning structure element- Returns:
- this
-
setFilterQuery
-
getFilterQuery
-
isAccessGranted
public boolean isAccessGranted() -
setAccessGranted
public void setAccessGranted(boolean accessGranted) -
getCitationTemplate
-
setCitationTemplate
- Parameters:
citationTemplate- the CSL citation style template name used to format citation output- Returns:
- this
-
getCitationProcessorWrapper
-
setCitationProcessorWrapper
-
getParentMetadata
-
setParentMetadata
-
isHasChildren
public boolean isHasChildren()- Returns:
- true if childMetadata not empty; false otherwise
-
getChildMetadata
-
getIndentation
public int getIndentation() -
setIndentation
- 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 filterlanguage- two-letter language code to match field variants againstfield- 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
-
getCombinedValue
-
forField
-