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:
  1. Converts a JSON string into a JsonNode object.
  2. Retrieves a sub-node based on the JSONPath expression returned by getPath().
  3. Extracts values from the node and processes them using getStringValue(JsonNode).
  4. Returns a collection of extracted values.
Subclasses must implement:
Author:
Adamo Fapohunda (adamo.fapohunda at 4science.com)
See Also:
  • Constructor Details

    • AbstractJsonPathMetadataProcessor

      public AbstractJsonPathMetadataProcessor()
  • Method Details

    • processMetadata

      public Collection<String> processMetadata(String json)
      Extracts metadata from a JSON string using a predefined JSONPath. The extracted values are processed and returned as a collection of strings.
      Specified by:
      processMetadata in interface JsonPathMetadataProcessor
      Parameters:
      json - The JSON string to process.
      Returns:
      A collection of extracted string values.
    • getStringValue

      protected abstract String getStringValue(com.fasterxml.jackson.databind.JsonNode node)
      Extracts a string representation of the value from a JsonNode. 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 Logger instance.
    • getPath

      protected abstract String 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.