Class OpenAlexDateMetadataProcessor
java.lang.Object
org.dspace.importer.external.metadatamapping.contributor.AbstractJsonPathMetadataProcessor
org.dspace.importer.external.openalex.metadatamapping.OpenAlexDateMetadataProcessor
- All Implemented Interfaces:
JsonPathMetadataProcessor
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.logging.log4j.LoggerProvides the logger instance for error reporting.protected StringgetPath()Retrieves the JSON path expression used to extract the date value.protected StringgetStringValue(com.fasterxml.jackson.databind.JsonNode node) Extracts and validates a date value from a JSON node.voidSets the JSON path from which the date value should be extracted.Methods inherited from class org.dspace.importer.external.metadatamapping.contributor.AbstractJsonPathMetadataProcessor
processMetadata
-
Constructor Details
-
OpenAlexDateMetadataProcessor
public OpenAlexDateMetadataProcessor()
-
-
Method Details
-
getStringValue
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:
getStringValuein classAbstractJsonPathMetadataProcessor- 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:
getLoggerin classAbstractJsonPathMetadataProcessor- Returns:
- The
Loggerinstance.
-
getPath
Retrieves the JSON path expression used to extract the date value.- Specified by:
getPathin classAbstractJsonPathMetadataProcessor- Returns:
- The JSONPath expression as a string.
-
setPath
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.
-