Class ConditionEqualJsonPathMetadataContributor
java.lang.Object
org.dspace.importer.external.metadatamapping.contributor.SimpleJsonPathMetadataContributor
org.dspace.importer.external.metadatamapping.contributor.ConditionEqualJsonPathMetadataContributor
- All Implemented Interfaces:
MetadataContributor<String>
A metadata contributor that extracts a value from JSON using a
JsonPathMetadataProcessor
and compares it against a predefined right operand. If the extracted value matches the right operand,
the specified SimpleJsonPathMetadataContributor is used to extract additional metadata.
Otherwise, an empty collection is returned.
This class extends SimpleJsonPathMetadataContributor and allows conditional metadata extraction
based on JSON path processing.- Author:
- Adamo Fapohunda (adamo.fapohunda at 4science.com)
-
Field Summary
Fields inherited from class org.dspace.importer.external.metadatamapping.contributor.SimpleJsonPathMetadataContributor
metadataProcessor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontributeMetadata(String json) Extracts metadata from the provided JSON string.voidsetLeftOperandProcessor(JsonPathMetadataProcessor leftOperandProcessor) Sets theJsonPathMetadataProcessorresponsible for extracting the left operand value from the JSON.voidsetMetadatumContributor(SimpleJsonPathMetadataContributor metadatumContributor) Sets theSimpleJsonPathMetadataContributorresponsible for extracting metadata if the condition is met.voidsetRightOperand(String rightOperand) Sets the right operand value that the extracted JSON value must match for metadata extraction to proceed.Methods inherited from class org.dspace.importer.external.metadatamapping.contributor.SimpleJsonPathMetadataContributor
getField, getQuery, setField, setMetadataFieldMapping, setMetadataProcessor, setQuery
-
Constructor Details
-
ConditionEqualJsonPathMetadataContributor
public ConditionEqualJsonPathMetadataContributor()
-
-
Method Details
-
contributeMetadata
Extracts metadata from the provided JSON string. The extraction process follows these steps:- Uses
JsonPathMetadataProcessorto extract a value from the JSON. - Compares the extracted value with the predefined right operand.
- If they match, the
SimpleJsonPathMetadataContributoris used to extract and return metadata. - If they do not match, an empty collection is returned.
- Specified by:
contributeMetadatain interfaceMetadataContributor<String>- Overrides:
contributeMetadatain classSimpleJsonPathMetadataContributor- Parameters:
json- The JSON string to process.- Returns:
- A collection of
MetadatumDTOif the condition is met; otherwise, an empty collection.
- Uses
-
setLeftOperandProcessor
Sets theJsonPathMetadataProcessorresponsible for extracting the left operand value from the JSON.- Parameters:
leftOperandProcessor- The JSON path processor used for extraction.
-
setRightOperand
Sets the right operand value that the extracted JSON value must match for metadata extraction to proceed.- Parameters:
rightOperand- The expected value to compare against.
-
setMetadatumContributor
Sets theSimpleJsonPathMetadataContributorresponsible for extracting metadata if the condition is met.- Parameters:
metadatumContributor- The metadata contributor to use upon a successful match.
-