Class AbstractJsonPathMetadataProcessor
java.lang.Object
org.dspace.importer.external.metadatamapping.contributor.AbstractJsonPathMetadataProcessor
- All Implemented Interfaces:
JsonPathMetadataProcessor
- Direct Known Subclasses:
InvertedIndexProcessor,OpenAlexDateMetadataProcessor,RegexReplacingJsonPathMetadataProcessor
public abstract class AbstractJsonPathMetadataProcessor
extends Object
implements JsonPathMetadataProcessor
An abstract implementation of
JsonPathMetadataProcessor that processes JSON data
using a JSONPath expression. This class provides a base structure for extracting values
from a JSON object while allowing subclasses to define specific behaviors.
The extraction process:
- Converts a JSON string into a
JsonNodeobject. - Retrieves a sub-node based on the JSONPath expression returned by
getPath(). - Extracts values from the node and processes them using
getStringValue(JsonNode). - Returns a collection of extracted values.
getStringValue(JsonNode)- Defines how values are extracted from a JSON node.getLogger()- Provides a logger instance for error handling.getPath()- Specifies the JSONPath used to extract data.
- Author:
- Adamo Fapohunda (adamo.fapohunda at 4science.com)
- See Also:
-
JsonPathMetadataProcessorJsonNodeObjectMapperLogger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract org.apache.logging.log4j.LoggerProvides the logger for logging errors and messages.protected abstract StringgetPath()Returns the JSONPath expression used for extracting values from JSON.protected abstract StringgetStringValue(com.fasterxml.jackson.databind.JsonNode node) Extracts a string representation of the value from aJsonNode.processMetadata(String json) Extracts metadata from a JSON string using a predefined JSONPath.
-
Constructor Details
-
AbstractJsonPathMetadataProcessor
public AbstractJsonPathMetadataProcessor()
-
-
Method Details
-
processMetadata
Extracts metadata from a JSON string using a predefined JSONPath. The extracted values are processed and returned as a collection of strings.- Specified by:
processMetadatain interfaceJsonPathMetadataProcessor- Parameters:
json- The JSON string to process.- Returns:
- A collection of extracted string values.
-
getStringValue
Extracts a string representation of the value from aJsonNode. The implementation of this method must be provided by subclasses.- Parameters:
node- The JSON node from which to extract the value.- Returns:
- A string representation of the value.
-
getLogger
protected abstract org.apache.logging.log4j.Logger getLogger()Provides the logger for logging errors and messages. The implementation of this method must be provided by subclasses.- Returns:
- A
Loggerinstance.
-
getPath
Returns the JSONPath expression used for extracting values from JSON. The implementation of this method must be provided by subclasses.- Returns:
- A string representing the JSONPath expression.
-