Class ArrayJsonPathMetadataContributor
java.lang.Object
org.dspace.importer.external.metadatamapping.contributor.ArrayJsonPathMetadataContributor
- All Implemented Interfaces:
MetadataContributor<String>
A metadata contributor that applies a given
MetadataContributor to each object within
a JSON array at a specified path. This enables extracting metadata from multiple objects
within a JSON structure.
This class is useful for processing JSON arrays where each element represents an entity that requires metadata extraction.
Example JSON structure:
{
"authors": [
{ "name": "John Doe", "id": "123" },
{ "name": "Jane Smith", "id": "456" }
]
}
If the pathToArray is set to "/authors", the contributor will
be applied to each author object in the array.
- Author:
- Adamo Fapohunda (adamo.fapohunda at 4science.com)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontributeMetadata(String fullJson) Extracts metadata from each object in a JSON array located atpathToArray.voidsetContributor(MetadataContributor<String> contributor) Sets the metadata contributor that will be applied to each element of the JSON array.voidUnused by this implementation.voidsetPathToArray(String pathToArray) Sets the JSONPath to the array in the JSON structure.
-
Constructor Details
-
ArrayJsonPathMetadataContributor
public ArrayJsonPathMetadataContributor()
-
-
Method Details
-
setMetadataFieldMapping
Unused by this implementation. This method is required by theMetadataContributorinterface.- Specified by:
setMetadataFieldMappingin interfaceMetadataContributor<String>- Parameters:
rt- The metadata field mapping (not used in this implementation).
-
contributeMetadata
Extracts metadata from each object in a JSON array located atpathToArray. The configuredcontributoris applied to each element of the array.- Specified by:
contributeMetadatain interfaceMetadataContributor<String>- Parameters:
fullJson- The JSON string containing the array.- Returns:
- A collection of
MetadatumDTOobjects extracted from the array elements.
-
setContributor
Sets the metadata contributor that will be applied to each element of the JSON array.- Parameters:
contributor- TheMetadataContributorresponsible for processing each array element.
-
setPathToArray
Sets the JSONPath to the array in the JSON structure.- Parameters:
pathToArray- A JSONPath expression indicating the location of the array.
-