Class ImportService
- java.lang.Object
-
- org.dspace.importer.external.service.ImportService
-
- All Implemented Interfaces:
Destroyable
public class ImportService extends Object implements Destroyable
Main entry point for the import framework. Instead of calling the different importer implementations, the ImportService should be called instead. This class contains the same methods as the other implementations, but has an extra parameter URL. This URL should be the same identifier that is returned by the "getImportSource" method that is defined in the importer implementation you want to use.- Author:
- Roeland Dillen (roeland at atmire dot com), Pasquale Cavallo (pasquale.cavallo@4science.it)
-
-
Constructor Summary
Constructors Constructor Description ImportService()Constructs an empty ImportService class object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Call destroy on allDestroyableMetadataSourceobjects set in this ImportServiceCollection<ImportRecord>findMatchingRecords(String uri, Item item)Finds records based on an item Delegates to one or more MetadataSource implementations based on the uri.Collection<ImportRecord>findMatchingRecords(String uri, Query query)Finds records based on query object.protected Map<String,MetadataSource>getImportSources()Retrieve the importSources set to this class.Collection<String>getImportUrls()Retrieve the importUrls that are set on the importSources .intgetNbRecords(String uri, String query)Find the number of records matching a string query;intgetNbRecords(String uri, Query query)Find the number of records matching a query;ImportRecordgetRecord(File file, String originalName)ImportRecordgetRecord(String uri, String id)Get a single record from a source.ImportRecordgetRecord(String uri, Query query)Get a single record from the source.Collection<ImportRecord>getRecords(String uri, String query, int start, int count)Find the number of records matching a string query.Collection<ImportRecord>getRecords(String uri, Query query)Find the number of records matching a object query.protected Collection<MetadataSource>matchingImports(String uri)Utility method to find what import implementations match the imports uri.voidsetImportSources(List<MetadataSource> importSources)Sets the importsources that will be used to delegate the retrieving and matching of records to
-
-
-
Field Detail
-
ANY
protected static final String ANY
- See Also:
- Constant Field Values
-
-
Method Detail
-
setImportSources
@Autowired(required=false) public void setImportSources(List<MetadataSource> importSources) throws MetadataSourceException
Sets the importsources that will be used to delegate the retrieving and matching of records to- Parameters:
importSources- A list ofMetadataSourceto set to this service- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getImportSources
protected Map<String,MetadataSource> getImportSources()
Retrieve the importSources set to this class.- Returns:
- An unmodifiableMap of importSources
-
matchingImports
protected Collection<MetadataSource> matchingImports(String uri)
Utility method to find what import implementations match the imports uri.- Parameters:
uri- the identifier of the import implementation or * for all- Returns:
- matching MetadataSource implementations
-
findMatchingRecords
public Collection<ImportRecord> findMatchingRecords(String uri, Item item) throws MetadataSourceException
Finds records based on an item Delegates to one or more MetadataSource implementations based on the uri. Results will be aggregated.- Parameters:
uri- the identifier of the import implementation or * for allitem- 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(String uri, Query query) throws MetadataSourceException
Finds records based on query object. Delegates to one or more MetadataSource implementations based on the uri. Results will be aggregated.- Parameters:
uri- the identifier of the import implementation or * for allquery- a query object to base the search on. The implementation decides how the query is interpreted.- 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.
-
getNbRecords
public int getNbRecords(String uri, String query) throws MetadataSourceException
Find the number of records matching a string query;- Parameters:
uri- the identifier of the import implementation or * for allquery- a query to base the search on- Returns:
- the sum of the matching records over all import sources
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getNbRecords
public int getNbRecords(String uri, Query query) throws MetadataSourceException
Find the number of records matching a query;- Parameters:
uri- the identifier of the import implementation or * for allquery- a query object to base the search on The implementation decides how the query is interpreted.- Returns:
- the sum of the matching records over all import sources
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getRecords
public Collection<ImportRecord> getRecords(String uri, String query, int start, int count) throws MetadataSourceException
Find the number of records matching a string query. Supports pagination- Parameters:
uri- the identifier of the import implementation or * for allquery- a query object to base the search on. The implementation decides how the query is interpreted.start- offset to start atcount- 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(String uri, Query query) throws MetadataSourceException
Find the number of records matching a object query.- Parameters:
uri- the identifier of the import implementation or * for allquery- a query object to base the search on. The implementation decides how the query is interpreted.- Returns:
- a set of records. Fully transformed.
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getRecord
public ImportRecord getRecord(String uri, String id) throws MetadataSourceException
Get a single record from a source. The first match will be returned- Parameters:
uri- uri the identifier of the import implementation or * for allid- identifier for the record- Returns:
- a matching record
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getRecord
public ImportRecord getRecord(String uri, Query query) throws MetadataSourceException
Get a single record from the source. The first match will be returned- Parameters:
uri- uri the identifier of the import implementation or * for allquery- a query matching a single record- Returns:
- a matching record
- Throws:
MetadataSourceException- if the underlying methods throw any exception.
-
getImportUrls
public Collection<String> getImportUrls()
Retrieve the importUrls that are set on the importSources .- Returns:
- a Collection of string, representing the configured importUrls
-
getRecord
public ImportRecord getRecord(File file, String originalName) throws FileMultipleOccurencesException, FileSourceException
-
destroy
public void destroy() throws ExceptionCall destroy on allDestroyableMetadataSourceobjects set in this ImportService- Specified by:
destroyin interfaceDestroyable- Throws:
Exception- on generic exception
-
-