Class OpenAlexImportMetadataSourceServiceImpl
java.lang.Object
org.dspace.importer.external.service.components.AbstractRemoteMetadataSource
org.dspace.importer.external.service.AbstractImportMetadataSourceService<String>
org.dspace.importer.external.openalex.service.OpenAlexImportMetadataSourceServiceImpl
- All Implemented Interfaces:
OpenAlexImportMetadataSourceService,MetadataSource,QuerySource
public class OpenAlexImportMetadataSourceServiceImpl
extends AbstractImportMetadataSourceService<String>
implements OpenAlexImportMetadataSourceService
Implementation of
OpenAlexImportMetadataSourceService that provides
metadata import functionality from OpenAlex into DSpace.
This class interacts with the OpenAlex API to fetch metadata records based on
queries or identifiers. It uses LiveImportClient to perform HTTP requests
and processes responses to extract metadata.- Author:
- Adamo Fapohunda (adamo.fapohunda at 4science.com)
-
Field Summary
Fields inherited from class org.dspace.importer.external.service.components.AbstractRemoteMetadataSource
error, exceptionHandlersMap, interRequestTime, lastRequest, lock, maxRetry, operationId, retry, warning -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindMatchingRecords(Item item) Finds records based on an item Delegates to one or more MetadataSource implementations based on the uri.findMatchingRecords(Query query) Finds records based on query object.Returns the source name of the metadata provider.Retrieves a metadata record by its OpenAlex identifier.Retrieves a metadata record by its identifier.getRecords(String query, int start, int count) Retrieves a collection of metadata records based on a query with pagination.getRecords(Query query) Find records based on a object query.intgetRecordsCount(String query) Counts the number of metadata records matching a query.intgetRecordsCount(Query query) Counts the number of metadata records matching a query.voidinit()Initializes the service by validating necessary configurations.voidSets the base URL for OpenAlex API requests.Methods inherited from class org.dspace.importer.external.service.AbstractImportMetadataSourceService
getGenerateQueryForItem, getMetadataFieldMapping, setGenerateQueryForItem, setMetadataFieldMapping, transformSourceRecordsMethods inherited from class org.dspace.importer.external.service.components.AbstractRemoteMetadataSource
getError, getExceptionHandler, getMaxRetry, getOperationId, getRetry, getWarning, handleException, initExceptionHandlers, retry, setError, setInterRequestTime, setMaxRetry, setWarning, throwSourceException, throwSourceExceptionHook
-
Constructor Details
-
OpenAlexImportMetadataSourceServiceImpl
public OpenAlexImportMetadataSourceServiceImpl()
-
-
Method Details
-
getImportSource
Returns the source name of the metadata provider.- Specified by:
getImportSourcein interfaceMetadataSource- Returns:
- The string "openalex".
-
getRecord
Retrieves a metadata record by its OpenAlex identifier.- Specified by:
getRecordin interfaceQuerySource- Parameters:
id- The identifier of the record to fetch.- Returns:
- The corresponding
ImportRecordor null if not found. - Throws:
MetadataSourceException- If the ID is null or an error occurs.
-
getRecordsCount
Counts the number of metadata records matching a query.- Specified by:
getRecordsCountin interfaceQuerySource- Parameters:
query- a query string to base the search on.- Returns:
- The number of matching records.
- Throws:
MetadataSourceException- If the query is null or an error occurs.
-
getRecordsCount
Counts the number of metadata records matching a query.- Specified by:
getRecordsCountin interfaceQuerySource- Parameters:
query- a query object to base the search on.- Returns:
- The number of matching records.
- Throws:
MetadataSourceException- If the query is null or an error occurs.
-
getRecords
public Collection<ImportRecord> getRecords(String query, int start, int count) throws MetadataSourceException Retrieves a collection of metadata records based on a query with pagination.- Specified by:
getRecordsin interfaceQuerySource- Parameters:
query- a query string to base the search on.start- The starting index for pagination.count- The maximum number of records to return.- Returns:
- A collection of matching
ImportRecord. - Throws:
MetadataSourceException- If the query is null or an error occurs.
-
getRecords
Description copied from interface:QuerySourceFind records based on a object query.- Specified by:
getRecordsin interfaceQuerySource- Parameters:
query- a query object to base the search on.- Returns:
- a set of records. Fully transformed.
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getRecord
Retrieves a metadata record by its identifier.- Specified by:
getRecordin interfaceQuerySource- Parameters:
query- a query object containing the identifier of the record to fetch.- Returns:
- The corresponding
ImportRecordor null if not found. - Throws:
MetadataSourceException- If the query is null or an error occurs.
-
findMatchingRecords
Description copied from interface:QuerySourceFinds records based on query object. Delegates to one or more MetadataSource implementations based on the uri. Results will be aggregated.- Specified by:
findMatchingRecordsin interfaceQuerySource- Parameters:
query- a query object to base the search on.- Returns:
- a collection of import records. Only the identifier of the found records may be put in the record.
- Throws:
MetadataSourceException- passed through.
-
findMatchingRecords
Description copied from interface:QuerySourceFinds records based on an item Delegates to one or more MetadataSource implementations based on the uri. Results will be aggregated.- Specified by:
findMatchingRecordsin interfaceQuerySource- Parameters:
item- an item to base the search on- Returns:
- a collection of import records. Only the identifier of the found records may be put in the record.
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
init
Initializes the service by validating necessary configurations.- Specified by:
initin classAbstractRemoteMetadataSource- Throws:
Exception- If required properties are not properly set.
-
setUrl
Sets the base URL for OpenAlex API requests.- Parameters:
url- The OpenAlex API base URL.
-