Class CiniiImportMetadataSourceServiceImpl
- java.lang.Object
-
- org.dspace.importer.external.service.components.AbstractRemoteMetadataSource
-
- org.dspace.importer.external.service.AbstractImportMetadataSourceService<org.jdom2.Element>
-
- org.dspace.importer.external.cinii.CiniiImportMetadataSourceServiceImpl
-
- All Implemented Interfaces:
MetadataSource,QuerySource
public class CiniiImportMetadataSourceServiceImpl extends AbstractImportMetadataSourceService<org.jdom2.Element> implements QuerySource
Implements a data source for querying Cinii- Author:
- Mykhaylo Boychuk (mykhaylo.boychuk 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 Constructor Description CiniiImportMetadataSourceServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<ImportRecord>findMatchingRecords(Item item)Finds records based on an item Delegates to one or more MetadataSource implementations based on the uri.Collection<ImportRecord>findMatchingRecords(Query query)Finds records based on query object.StringgetImportSource()The string that identifies this import implementation.ImportRecordgetRecord(String id)Get a single record from the source.ImportRecordgetRecord(Query query)Get a single record from the source.Collection<ImportRecord>getRecords(String query, int start, int count)Gets a set of records matching a query.Collection<ImportRecord>getRecords(Query query)Find records based on a object query.intgetRecordsCount(String query)Gets the number of records matching a queryintgetRecordsCount(Query query)Gets the number of records matching a queryStringgetUrl()StringgetUrlSearch()voidinit()Attempts to init a sessionprotected List<ImportRecord>search(String id, String appId)Get metadata by searching CiNii RDF API with CiNii NAIDvoidsetUrl(String url)voidsetUrlSearch(String urlSearch)-
Methods inherited from class org.dspace.importer.external.service.AbstractImportMetadataSourceService
getGenerateQueryForItem, getMetadataFieldMapping, setGenerateQueryForItem, setMetadataFieldMapping, transformSourceRecords
-
Methods 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
-
-
-
-
Method Detail
-
getImportSource
public String getImportSource()
Description copied from interface:MetadataSourceThe string that identifies this import implementation. Preferable a URI- Specified by:
getImportSourcein interfaceMetadataSource- Returns:
- the identifying uri
-
init
public void init() throws ExceptionDescription copied from class:AbstractRemoteMetadataSourceAttempts to init a session- Specified by:
initin classAbstractRemoteMetadataSource- Throws:
Exception- on generic exception
-
getRecord
public ImportRecord getRecord(String id) throws MetadataSourceException
Description copied from interface:QuerySourceGet a single record from the source. The first match will be returned- Specified by:
getRecordin interfaceQuerySource- Parameters:
id- identifier for the record- Returns:
- a matching record
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getRecordsCount
public int getRecordsCount(String query) throws MetadataSourceException
Description copied from interface:QuerySourceGets the number of records matching a query- Specified by:
getRecordsCountin interfaceQuerySource- Parameters:
query- the query in string format- Returns:
- the number of records matching the query
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getRecordsCount
public int getRecordsCount(Query query) throws MetadataSourceException
Description copied from interface:QuerySourceGets the number of records matching a query- Specified by:
getRecordsCountin interfaceQuerySource- Parameters:
query- the query object- Returns:
- the number of records matching the query
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getRecords
public Collection<ImportRecord> getRecords(String query, int start, int count) throws MetadataSourceException
Description copied from interface:QuerySourceGets a set of records matching a query. Supports pagination- Specified by:
getRecordsin interfaceQuerySource- Parameters:
query- the query. The query will generally be posted 'as is' to the sourcestart- offsetcount- page size- Returns:
- a collection of fully transformed id's
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getRecords
public Collection<ImportRecord> getRecords(Query query) throws MetadataSourceException
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
public ImportRecord getRecord(Query query) throws MetadataSourceException
Description copied from interface:QuerySourceGet a single record from the source. The first match will be returned- Specified by:
getRecordin interfaceQuerySource- Parameters:
query- a query matching a single record- Returns:
- a matching record
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
findMatchingRecords
public Collection<ImportRecord> findMatchingRecords(Query query) throws MetadataSourceException
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
public Collection<ImportRecord> findMatchingRecords(Item item) throws MetadataSourceException
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.
-
getUrl
public String getUrl()
-
setUrl
public void setUrl(String url)
-
getUrlSearch
public String getUrlSearch()
-
setUrlSearch
public void setUrlSearch(String urlSearch)
-
search
protected List<ImportRecord> search(String id, String appId) throws IOException, org.apache.http.HttpException
Get metadata by searching CiNii RDF API with CiNii NAID- Parameters:
id- CiNii NAID to search byappId- registered application identifier for the API- Returns:
- record metadata
- Throws:
IOException- A general class of exceptions produced by failed or interrupted I/O operations.org.apache.http.HttpException- Represents a XML/HTTP fault and provides access to the HTTP status code.
-
-