Class EnhancedJsonPathAttributeConditionMetadataContributor
java.lang.Object
org.dspace.importer.external.metadatamapping.contributor.EnhancedJsonPathAttributeConditionMetadataContributor
- All Implemented Interfaces:
MetadataContributor<String>
public class EnhancedJsonPathAttributeConditionMetadataContributor
extends Object
implements MetadataContributor<String>
A simple JsonPath Metadata processor
that allow extract value from json object
by configuring the path in the query variable via the bean.
moreover this can also perform more compact extractions
by configuring specific json processor in "metadataProcessor"
In addition from some array where `query` points to the values can be selected using some additional condition check.
This can be expressed in jsonpath, but not in jsonpointer expression.
e.g.
query /descriptions
conditionkey "descriptionType"
conditionvalue "Abstract"
retrievedvalue "description"
and json
"descriptions": [
{"description":"Description A","descriptionType":"Abstract"},
{"description":"Description B","descriptionType":"Other"}
]
should deliver the value "Description A".
In addition there is some metadataPostProcessor modifying and changing the retrieved value,
e.g. mapping to controlled values
- Author:
- Mykhaylo Boychuk (mykhaylo.boychuk@4science.com), Florian Gantner (florian.gantner@uni-bamberg.de)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JsonPathMetadataProcessorprotected JsonPathMetadataProcessor -
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor for SimpleJsonPathMetadataContributorInitialize SimpleJsonPathMetadataContributor with a query, prefixToNamespaceMapping and MetadataFieldConfig -
Method Summary
Modifier and TypeMethodDescriptioncontributeMetadata(String fullJson) Retrieve the metadata associated with the given object.Return condition attribute key which is checkedReturn condition attribute value which is checkedReturn element attribute key where the final value is retrieved fromgetField()Return the MetadataFieldConfig used while retrieving MetadatumDTOgetQuery()Return query used to create the JSonPathvoidsetConditionKey(String conditionKey) The key of the json attribute which is checked for the conditionvoidsetConditionValue(String conditionValue) The value of the json attribute which must match the conditionvoidsetElementAttribute(String elementAttribute) The json attribute where the value is retrieved fromvoidsetField(MetadataFieldConfig field) Setting the MetadataFieldConfigvoidUnused by this implementationvoidsetMetadataPostProcessor(JsonPathMetadataProcessor metadataPostProcessor) Used to process data got by jsonpath expression, like arrays to stringify, change date format or else If it is null, toString will be used.voidsetMetadataProcessor(JsonPathMetadataProcessor metadataProcessor) Used to process data got by jsonpath expression, like arrays to stringify, change date format or else If it is null, toString will be used.voidReturn query used to create the JSonPath
-
Field Details
-
metadataProcessor
-
metadataPostProcessor
-
-
Constructor Details
-
EnhancedJsonPathAttributeConditionMetadataContributor
public EnhancedJsonPathAttributeConditionMetadataContributor(String query, MetadataFieldConfig field) Initialize SimpleJsonPathMetadataContributor with a query, prefixToNamespaceMapping and MetadataFieldConfig- Parameters:
query- The JSonPath queryfield- the matadata field to map the result of the Json path query MetadataFieldConfig
-
EnhancedJsonPathAttributeConditionMetadataContributor
public EnhancedJsonPathAttributeConditionMetadataContributor()Empty constructor for SimpleJsonPathMetadataContributor
-
-
Method Details
-
setMetadataFieldMapping
Unused by this implementation- Specified by:
setMetadataFieldMappingin interfaceMetadataContributor<String>- Parameters:
rt- the MetadataFieldMapping object to set to the MetadataContributor
-
getField
Return the MetadataFieldConfig used while retrieving MetadatumDTO- Returns:
- MetadataFieldConfig
-
setField
Setting the MetadataFieldConfig- Parameters:
field- MetadataFieldConfig used while retrieving MetadatumDTO
-
getQuery
Return query used to create the JSonPath- Returns:
- the query this instance is based on
-
setQuery
Return query used to create the JSonPath -
getConditionKey
Return condition attribute key which is checked- Returns:
- the attribute key which is checked
-
setConditionKey
The key of the json attribute which is checked for the condition- Parameters:
conditionKey-
-
getConditionValue
Return condition attribute value which is checked- Returns:
- the attribute value which is checked
-
setConditionValue
The value of the json attribute which must match the condition- Parameters:
conditionValue-
-
getElementAttribute
Return element attribute key where the final value is retrieved from- Returns:
- the attribute key for the element
-
setElementAttribute
The json attribute where the value is retrieved from- Parameters:
elementAttribute-
-
setMetadataProcessor
Used to process data got by jsonpath expression, like arrays to stringify, change date format or else If it is null, toString will be used.- Parameters:
metadataProcessor-
-
setMetadataPostProcessor
Used to process data got by jsonpath expression, like arrays to stringify, change date format or else If it is null, toString will be used.- Parameters:
metadataPostProcessor-
-
contributeMetadata
Retrieve the metadata associated with the given object. The toString() of the resulting object will be used.- Specified by:
contributeMetadatain interfaceMetadataContributor<String>- Parameters:
fullJson- A class to retrieve metadata from.- Returns:
- a collection of import records. Only the identifier of the found records may be put in the record.
-