Package ome.formats.importer
Class ImportLibrary
- java.lang.Object
-
- ome.formats.importer.ImportLibrary
-
- All Implemented Interfaces:
IObservable
public class ImportLibrary extends java.lang.Object implements IObservable
support class for the proper usage ofOMEROMetadataStoreClient
andFormatReader
instances. This library was factored out of ImportHandler to support ImportFixture- Since:
- 3.0-M3
- See Also:
FormatReader
,OMEROMetadataStoreClient
,ImportFixture
,IObservable
,IObserver
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ImportLibrary.ImportCallback
-
Constructor Summary
Constructors Constructor Description ImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader)
The default implementation ofFileTransfer
performs a no-op and therefore need not haveFileTransfer.afterTransfer(int, List)
as with theImportLibrary(OMEROMetadataStoreClient, OMEROWrapper, FileTransfer)
constructor.ImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer)
The library will not close the client instance.ImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer, int minutesToWait)
ImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer, java.util.List<FileExclusion> exclusions, int minutesToWait)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
addObserver(IObserver object)
Add observer for notificationvoid
clear()
ImportLibrary.ImportCallback
createCallback(ImportProcessPrx proc, HandlePrx handle, ImportContainer container)
ImportProcessPrx
createImport(ImportContainer container)
Provide initial configuration to the server in order to create theImportProcessPrx
which will manage state server-side.java.util.List<java.lang.String>
deleteFilesFromRepository(ImportContainer container)
Delete files from the managed repository.boolean
deleteObserver(IObserver object)
Delete observerOMEROMetadataStoreClient
getMetadataStore()
Retrieves the currently active metadata store.boolean
importCandidates(ImportConfig config, ImportCandidates candidates)
Primary user method for importing a number of import candidates.java.util.List<Pixels>
importImage(ImportContainer container, int index, int numDone, int total)
Deprecated.now used by tests onlyjava.util.List<Pixels>
importImage(ImportContainer container, java.util.concurrent.ExecutorService threadPool, int index)
Perform an image import uploading files if necessary.OriginalFile
loadOriginalFile(RawFileStorePrx uploader)
UseRawFileStorePrx.getFileId()
in order to load theOriginalFile
that the service argument is acting on.ManagedRepositoryPrx
lookupManagedRepository()
Retrieves the first managed repository from the list of current active repositories.void
notifyObservers(ImportEvent event)
Notify observers of eventjava.lang.String
uploadFile(ImportProcessPrx proc, java.lang.String[] srcFiles, int index, TimeEstimator estimator)
java.lang.String
uploadFile(ImportProcessPrx proc, java.lang.String[] srcFiles, int index, ome.util.checksum.ChecksumProviderFactory cpf, TimeEstimator estimator, byte[] buf)
java.util.List<java.lang.String>
uploadFilesToRepository(java.lang.String[] srcFiles, ImportProcessPrx proc)
Upload files to the managed repository.
-
-
-
Constructor Detail
-
ImportLibrary
public ImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader)
The default implementation ofFileTransfer
performs a no-op and therefore need not haveFileTransfer.afterTransfer(int, List)
as with theImportLibrary(OMEROMetadataStoreClient, OMEROWrapper, FileTransfer)
constructor.- Parameters:
client
- client-sideMetadataStore
, not nullreader
- a Bio-Formats reader (ignored), not null
-
ImportLibrary
public ImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer)
The library will not close the client instance. The reader will be closed between calls to import. Note: the responsibility of closingFileTransfer.afterTransfer(int, List)
falls to invokers of this method.- Parameters:
client
- client-sideMetadataStore
, not nullreader
- a Bio-Formats reader (ignored), not nulltransfer
- how files are to be transferred to the server
-
ImportLibrary
public ImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer, int minutesToWait)
-
ImportLibrary
public ImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer, java.util.List<FileExclusion> exclusions, int minutesToWait)
-
-
Method Detail
-
addObserver
public boolean addObserver(IObserver object)
Description copied from interface:IObservable
Add observer for notification- Specified by:
addObserver
in interfaceIObservable
- Parameters:
object
- - observer object- Returns:
- true if added
-
deleteObserver
public boolean deleteObserver(IObserver object)
Description copied from interface:IObservable
Delete observer- Specified by:
deleteObserver
in interfaceIObservable
- Parameters:
object
- - observer to delete- Returns:
- true if deleted
-
notifyObservers
public void notifyObservers(ImportEvent event)
Description copied from interface:IObservable
Notify observers of event- Specified by:
notifyObservers
in interfaceIObservable
- Parameters:
event
- - event that happened
-
importCandidates
public boolean importCandidates(ImportConfig config, ImportCandidates candidates)
Primary user method for importing a number of import candidates.- Parameters:
config
- The configuration information.candidates
- Hosts information about the files to import.- Returns:
- if the import did not exit because of an error
-
deleteFilesFromRepository
public java.util.List<java.lang.String> deleteFilesFromRepository(ImportContainer container) throws ServerError
Delete files from the managed repository.- Parameters:
container
- The current import container containing usedFiles to be deleted.- Returns:
- List of files that could not be deleted.
- Throws:
ServerError
- if file deletion failed
-
createImport
public ImportProcessPrx createImport(ImportContainer container) throws ServerError, java.io.IOException
Provide initial configuration to the server in order to create theImportProcessPrx
which will manage state server-side.- Parameters:
container
- the import container- Returns:
- the new import process from the server
- Throws:
ServerError
- if the import process could not be createdjava.io.IOException
- if the used files' absolute path could not be found
-
uploadFilesToRepository
public java.util.List<java.lang.String> uploadFilesToRepository(java.lang.String[] srcFiles, ImportProcessPrx proc)
Upload files to the managed repository. This is done by first passing in the possibly absolute local file paths. A common selection of those are chosen and passed back to the client. As each file is written to the server, a message digest is kept updated of the bytes that are being written. These are then returned to the caller so they can be checked against the values found on the server.- Parameters:
srcFiles
- the files to uploadproc
- the server import process to use for the upload- Returns:
- A list of the client-side (i.e. local) hashes for each file.
-
uploadFile
public java.lang.String uploadFile(ImportProcessPrx proc, java.lang.String[] srcFiles, int index, TimeEstimator estimator) throws ServerError, java.io.IOException
- Throws:
ServerError
java.io.IOException
-
uploadFile
public java.lang.String uploadFile(ImportProcessPrx proc, java.lang.String[] srcFiles, int index, ome.util.checksum.ChecksumProviderFactory cpf, TimeEstimator estimator, byte[] buf) throws ServerError, java.io.IOException
- Throws:
ServerError
java.io.IOException
-
importImage
@Deprecated public java.util.List<Pixels> importImage(ImportContainer container, int index, int numDone, int total) throws java.lang.Throwable
Deprecated.now used by tests onlyImage import with only one file upload thread.- Throws:
java.lang.Throwable
- See Also:
importImage(ImportContainer, ExecutorService, int)
-
importImage
public java.util.List<Pixels> importImage(ImportContainer container, java.util.concurrent.ExecutorService threadPool, int index) throws loci.formats.FormatException, java.io.IOException, java.lang.Throwable
Perform an image import uploading files if necessary.- Parameters:
container
- The import container which houses all the configuration values and target for the import.threadPool
- The pool of threads to use in file upload.index
- Index of the import in a set.0
is safe if this is a singular import.- Returns:
- List of Pixels that have been imported.
- Throws:
loci.formats.FormatException
- If there is a Bio-Formats image file format error during import.java.io.IOException
- If there is an I/O error.ServerError
- If there is an error communicating with the OMERO server we're importing into.java.lang.Throwable
- If there is some other kind of error during import.- Since:
- OMERO Beta 4.2.1.
-
createCallback
public ImportLibrary.ImportCallback createCallback(ImportProcessPrx proc, HandlePrx handle, ImportContainer container) throws ServerError
- Throws:
ServerError
-
getMetadataStore
public OMEROMetadataStoreClient getMetadataStore()
Retrieves the currently active metadata store.- Returns:
- See above.
-
lookupManagedRepository
public ManagedRepositoryPrx lookupManagedRepository()
Retrieves the first managed repository from the list of current active repositories.- Returns:
- Active proxy for the legacy repository.
-
clear
public void clear()
-
loadOriginalFile
public OriginalFile loadOriginalFile(RawFileStorePrx uploader) throws ServerError
UseRawFileStorePrx.getFileId()
in order to load theOriginalFile
that the service argument is acting on.- Parameters:
uploader
- not null- Returns:
- the original file
- Throws:
ServerError
- if the file could not be identified and loaded
-
-