Class OpenAlexDateMetadataProcessor

java.lang.Object
org.dspace.importer.external.metadatamapping.contributor.AbstractJsonPathMetadataProcessor
org.dspace.importer.external.openalex.metadatamapping.OpenAlexDateMetadataProcessor
All Implemented Interfaces:
JsonPathMetadataProcessor

public class OpenAlexDateMetadataProcessor extends AbstractJsonPathMetadataProcessor
A metadata processor that extracts and validates date values from JSON data. This processor retrieves a date string from a specified JSON path and ensures that it is correctly formatted according to the ISO 8601 date standard.

Example JSON:

 {
   "published_date": "2023-05-10"
 }
 
If the `path` is set to `"/published_date"`, the extracted value will be `"2023-05-10"`.

This class extends AbstractJsonPathMetadataProcessor, which handles JSON parsing and path extraction.

Author:
Adamo Fapohunda (adamo.fapohunda at 4science.com)
  • Constructor Details

    • OpenAlexDateMetadataProcessor

      public OpenAlexDateMetadataProcessor()
  • Method Details

    • getStringValue

      protected String getStringValue(com.fasterxml.jackson.databind.JsonNode node)
      Extracts and validates a date value from a JSON node. The extracted value must conform to the ISO 8601 format (YYYY-MM-DD).
      Specified by:
      getStringValue in class AbstractJsonPathMetadataProcessor
      Parameters:
      node - The JSON node containing the date as a text value.
      Returns:
      The parsed date as a string in ISO 8601 format.
      Throws:
      IllegalArgumentException - If the node is null, not textual, or does not contain a valid date.
    • getLogger

      protected org.apache.logging.log4j.Logger getLogger()
      Provides the logger instance for error reporting.
      Specified by:
      getLogger in class AbstractJsonPathMetadataProcessor
      Returns:
      The Logger instance.
    • getPath

      protected String getPath()
      Retrieves the JSON path expression used to extract the date value.
      Specified by:
      getPath in class AbstractJsonPathMetadataProcessor
      Returns:
      The JSONPath expression as a string.
    • setPath

      public void setPath(String path)
      Sets the JSON path from which the date value should be extracted.
      Parameters:
      path - The JSONPath expression specifying the location of the date in the JSON structure.