Class ImportService
java.lang.Object
org.dspace.importer.external.service.ImportService
- All Implemented Interfaces:
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)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Call destroy on allDestroyableMetadataSourceobjects set in this ImportServicefindMatchingRecords(String uri, Item item) Finds records based on an item Delegates to one or more MetadataSource implementations based on the uri.findMatchingRecords(String uri, Query query) Finds records based on query object.protected Map<String,MetadataSource> Retrieve the importSources set to this class.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;Get a single record from a source.Get a single record from the source.getRecords(String uri, String query, int start, int count) Find the number of records matching a string query.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 Details
-
ANY
- See Also:
-
-
Constructor Details
-
ImportService
public ImportService()Constructs an empty ImportService class object
-
-
Method Details
-
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
Retrieve the importSources set to this class.- Returns:
- An unmodifiableMap of importSources
-
matchingImports
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
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
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
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
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
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
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
Call destroy on allDestroyableMetadataSourceobjects set in this ImportService- Specified by:
destroyin interfaceDestroyable- Throws:
Exception- on generic exception
-