Class EnhancedJsonPathAttributeConditionMetadataContributor

java.lang.Object
org.dspace.importer.external.metadatamapping.contributor.EnhancedJsonPathAttributeConditionMetadataContributor
All Implemented Interfaces:
MetadataContributor<String>

public class EnhancedJsonPathAttributeConditionMetadataContributor extends Object implements MetadataContributor<String>
A simple JsonPath Metadata processor that allow extract value from json object by configuring the path in the query variable via the bean. moreover this can also perform more compact extractions by configuring specific json processor in "metadataProcessor" In addition from some array where `query` points to the values can be selected using some additional condition check. This can be expressed in jsonpath, but not in jsonpointer expression. e.g. query /descriptions conditionkey "descriptionType" conditionvalue "Abstract" retrievedvalue "description" and json "descriptions": [ {"description":"Description A","descriptionType":"Abstract"}, {"description":"Description B","descriptionType":"Other"} ] should deliver the value "Description A". In addition there is some metadataPostProcessor modifying and changing the retrieved value, e.g. mapping to controlled values
Author:
Mykhaylo Boychuk (mykhaylo.boychuk@4science.com), Florian Gantner (florian.gantner@uni-bamberg.de)
  • Field Details

  • Constructor Details

    • EnhancedJsonPathAttributeConditionMetadataContributor

      public EnhancedJsonPathAttributeConditionMetadataContributor(String query, MetadataFieldConfig field)
      Initialize SimpleJsonPathMetadataContributor with a query, prefixToNamespaceMapping and MetadataFieldConfig
      Parameters:
      query - The JSonPath query
      field - the matadata field to map the result of the Json path query MetadataFieldConfig
    • EnhancedJsonPathAttributeConditionMetadataContributor

      public EnhancedJsonPathAttributeConditionMetadataContributor()
      Empty constructor for SimpleJsonPathMetadataContributor
  • Method Details

    • setMetadataFieldMapping

      public void setMetadataFieldMapping(MetadataFieldMapping<String,MetadataContributor<String>> rt)
      Unused by this implementation
      Specified by:
      setMetadataFieldMapping in interface MetadataContributor<String>
      Parameters:
      rt - the MetadataFieldMapping object to set to the MetadataContributor
    • getField

      public MetadataFieldConfig getField()
      Return the MetadataFieldConfig used while retrieving MetadatumDTO
      Returns:
      MetadataFieldConfig
    • setField

      public void setField(MetadataFieldConfig field)
      Setting the MetadataFieldConfig
      Parameters:
      field - MetadataFieldConfig used while retrieving MetadatumDTO
    • getQuery

      public String getQuery()
      Return query used to create the JSonPath
      Returns:
      the query this instance is based on
    • setQuery

      public void setQuery(String query)
      Return query used to create the JSonPath
    • getConditionKey

      public String getConditionKey()
      Return condition attribute key which is checked
      Returns:
      the attribute key which is checked
    • setConditionKey

      public void setConditionKey(String conditionKey)
      The key of the json attribute which is checked for the condition
      Parameters:
      conditionKey -
    • getConditionValue

      public String getConditionValue()
      Return condition attribute value which is checked
      Returns:
      the attribute value which is checked
    • setConditionValue

      public void setConditionValue(String conditionValue)
      The value of the json attribute which must match the condition
      Parameters:
      conditionValue -
    • getElementAttribute

      public String getElementAttribute()
      Return element attribute key where the final value is retrieved from
      Returns:
      the attribute key for the element
    • setElementAttribute

      public void setElementAttribute(String elementAttribute)
      The json attribute where the value is retrieved from
      Parameters:
      elementAttribute -
    • setMetadataProcessor

      public void setMetadataProcessor(JsonPathMetadataProcessor metadataProcessor)
      Used to process data got by jsonpath expression, like arrays to stringify, change date format or else If it is null, toString will be used.
      Parameters:
      metadataProcessor -
    • setMetadataPostProcessor

      public void setMetadataPostProcessor(JsonPathMetadataProcessor metadataPostProcessor)
      Used to process data got by jsonpath expression, like arrays to stringify, change date format or else If it is null, toString will be used.
      Parameters:
      metadataPostProcessor -
    • contributeMetadata

      public Collection<MetadatumDTO> contributeMetadata(String fullJson)
      Retrieve the metadata associated with the given object. The toString() of the resulting object will be used.
      Specified by:
      contributeMetadata in interface MetadataContributor<String>
      Parameters:
      fullJson - A class to retrieve metadata from.
      Returns:
      a collection of import records. Only the identifier of the found records may be put in the record.