Class ArXivImportMetadataSourceServiceImpl

All Implemented Interfaces:
MetadataSource, QuerySource

public class ArXivImportMetadataSourceServiceImpl extends AbstractImportMetadataSourceService<org.jdom2.Element> implements QuerySource
Implements a data source for querying ArXiv
Author:
Pasquale Cavallo (pasquale.cavallo at 4Science dot it)
  • Constructor Details

    • ArXivImportMetadataSourceServiceImpl

      public ArXivImportMetadataSourceServiceImpl()
  • Method Details

    • getRecords

      public Collection<ImportRecord> getRecords(String query, int start, int count) throws MetadataSourceException
      Find the number of records matching the query string in ArXiv. Supports pagination.
      Specified by:
      getRecords in interface QuerySource
      Parameters:
      query - a query string to base the search on.
      start - offset to start at
      count - number of records to retrieve.
      Returns:
      a set of records. Fully transformed.
      Throws:
      MetadataSourceException - if the underlying methods throw any exception.
    • getRecords

      public Collection<ImportRecord> getRecords(Query query) throws MetadataSourceException
      Find records based on a object query and convert them to a list metadata mapped in ImportRecord. The entry with the key "query" of the Query's map will be used as query string value.
      Specified by:
      getRecords in interface QuerySource
      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.
      See Also:
    • getRecordsCount

      public int getRecordsCount(String query) throws MetadataSourceException
      Find the number of records matching the query string in ArXiv;
      Specified by:
      getRecordsCount in interface QuerySource
      Parameters:
      query - a query object to base the search on.
      Returns:
      the sum of the matching records over this import source
      Throws:
      MetadataSourceException - if the underlying methods throw any exception.
    • getRecordsCount

      public int getRecordsCount(Query query) throws MetadataSourceException
      Find the number of records matching a query; The entry with the key "query" of the Query's map will be used to get the query string.
      Specified by:
      getRecordsCount in interface QuerySource
      Parameters:
      query - a query string to base the search on.
      Returns:
      the sum of the matching records over this import source
      Throws:
      MetadataSourceException - if the underlying methods throw any exception.
      See Also:
    • getRecord

      public ImportRecord getRecord(String id) throws MetadataSourceException
      Get a single record of metadata from the arxiv by ArXiv ID.
      Specified by:
      getRecord in interface QuerySource
      Parameters:
      id - id of the record in ArXiv
      Returns:
      the first matching record
      Throws:
      MetadataSourceException - if the underlying methods throw any exception.
    • getRecord

      public ImportRecord getRecord(Query query) throws MetadataSourceException
      Get a single record from the ArXiv matching the query. Field "query" will be used to get data from.
      Specified by:
      getRecord in interface QuerySource
      Parameters:
      query - a query matching a single record
      Returns:
      the first matching record
      Throws:
      MetadataSourceException - if the underlying methods throw any exception.
      See Also:
    • init

      public void init() throws Exception
      Initialize the class
      Specified by:
      init in class AbstractRemoteMetadataSource
      Throws:
      Exception - on generic exception
    • getImportSource

      public String getImportSource()
      The string that identifies this import implementation. Preferable a URI
      Specified by:
      getImportSource in interface MetadataSource
      Returns:
      the identifying uri
    • findMatchingRecords

      public Collection<ImportRecord> findMatchingRecords(Item item) throws MetadataSourceException
      Expect this method will be not used and erased from the interface soon
      Specified by:
      findMatchingRecords in interface QuerySource
      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.
    • findMatchingRecords

      public Collection<ImportRecord> findMatchingRecords(Query query) throws MetadataSourceException
      Finds records based on query object. Supports search by title and/or author
      Specified by:
      findMatchingRecords in interface QuerySource
      Parameters:
      query - a query object to base the search on.
      Returns:
      a collection of import records.
      Throws:
      MetadataSourceException - if the underlying methods throw any exception.
    • getBaseAddress

      public String getBaseAddress()
      Return the baseAddress set to this object
      Returns:
      The String object that represents the baseAddress of this object
    • setBaseAddress

      public void setBaseAddress(String baseAddress)
      Set the baseAddress to this object
      Parameters:
      baseAddress - The String object that represents the baseAddress of this object