Skip to content

Commit

Permalink
[CST-18016] Updated OpenAlexAuthorNameContributor doc
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamF42 committed Feb 26, 2025
1 parent 75f39c6 commit a9b5a05
Showing 1 changed file with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,69 @@
import org.dspace.importer.external.metadatamapping.contributor.SimpleJsonPathMetadataContributor;

/**
* This class is responsible for extracting and contributing author name metadata
* from a JSON response using a specified query path.
* <p>
* The extracted name is split into given name and family name, and the metadata
* is stored based on the field configuration.
* </p>
*
* <p>
* Example JSON structure:
* </p>
* <pre>
* {
* "author": {
* "full_name": "John Doe"
* }
* }
* </pre>
*
* <p>
* If the query path points to `author.full_name`, this class will extract
* "John" as the given name and "Doe" as the family name.
* </p>
*
* @author Adamo Fapohunda (adamo.fapohunda at 4science.com)
**/
*/
public class OpenAlexAuthorNameContributor extends SimpleJsonPathMetadataContributor {

private final static Logger log = LogManager.getLogger();

private String query;
private MetadataFieldConfig field;

/**
* Sets the JSON query path for extracting the author name.
*
* @param query the JSON path to the author name
*/
@Override
public void setQuery(String query) {
this.query = query;
}

/**
* Sets the metadata field configuration that determines where
* the extracted metadata should be stored.
*
* @param field the metadata field configuration
*/
@Override
public void setField(MetadataFieldConfig field) {
this.field = field;
}

/**
* Extracts and contributes metadata based on the configured JSON query path and field.
* <p>
* If the extracted author name contains both given and family names, it assigns
* them accordingly based on the configured field.
* </p>
*
* @param fullJson the JSON response containing author information
* @return a collection of metadata entries representing the extracted name parts
*/
@Override
public Collection<MetadatumDTO> contributeMetadata(String fullJson) {
Collection<MetadatumDTO> metadata = new ArrayList<>();
Expand Down

0 comments on commit a9b5a05

Please sign in to comment.