Package ome.formats.importer.cli
Class CommandLineImporter
- java.lang.Object
-
- ome.formats.importer.cli.CommandLineImporter
-
public class CommandLineImporter extends java.lang.ObjectThe base entry point for the CLI version of the OMERO importer.
-
-
Field Summary
Fields Modifier and Type Field Description protected ImportCandidatescandidatesCandidates for importImportConfigconfigConfiguration used by all componentsstatic intDEFAULT_WAITjava.util.List<FileExclusion>exclusionsFileExclusionmechanisms for skipping candidatesprotected booleangetUsedFilesIf true, then only a report on used files will be producedErrorHandlerhandlerErrorHandler which is also responsible for uploading filesprotected ImportOutputimportOutputFormat which should be preferred for standard out messagesImportLibrarylibraryBase importer library, this is what we actually use to import.protected OMEROWrapperreaderBio-Formats reader wrapper customized for OMERO.protected OMEROMetadataStoreClientstoreBio-FormatsMetadataStoreimplementation for OMERO.FileTransfertransferFileTransfermechanism to be used for uploading
-
Constructor Summary
Constructors Constructor Description CommandLineImporter(ImportConfig config, java.lang.String[] paths, boolean getUsedFiles)Legacy constructor which uses aUploadFileTransfer.CommandLineImporter(ImportConfig config, java.lang.String[] paths, boolean getUsedFiles, FileTransfer transfer, int minutesToWait)Legacy constructor without any file exclusions.CommandLineImporter(ImportConfig config, java.lang.String[] paths, boolean getUsedFiles, FileTransfer transfer, java.util.List<FileExclusion> exclusions, int minutesToWait)Main entry class for the application.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidadvUsage()Prints advanced usage to STDERR and exits with return code 1.protected voidcheckLogin()Checks that requisite command line options for OMERO session creation have been provided and if not callsusage().voidcleanup()Cleans up after a successful or unsuccessful image import.static intcloseCompleted(ImportConfig config)Look for allImportProcessPrxin the current session and close them if they return a non-nullResponse(i.e.protected ImportLibrarycreateImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer, java.util.List<FileExclusion> exclusions, int minutesToWait)Creates theImportLibrarythat this command line importer will use to import datastatic voidmain(java.lang.String[] args)Command line application entry point which parses CLI arguments and passes them into the importer.static voidsetArgument(java.util.Map<java.lang.String,java.lang.Boolean> map, java.lang.String key)Set a conflicting argument and return the usage if the key is already setImportOutputsetImportOutput(ImportOutput importOutput)Set the currentImportOutput(defaulting to null if a null value is passed).intstart()static voidusage()Prints usage to STDERR and exits with return code 1.static intwaitCompleted(ImportConfig config)Look for allImportProcessPrxin the current session and close them if they return a non-nullResponse(i.e.
-
-
-
Field Detail
-
DEFAULT_WAIT
public static final int DEFAULT_WAIT
- See Also:
- Constant Field Values
-
config
public final ImportConfig config
Configuration used by all components
-
transfer
public final FileTransfer transfer
FileTransfermechanism to be used for uploading
-
exclusions
public final java.util.List<FileExclusion> exclusions
FileExclusionmechanisms for skipping candidates
-
library
public final ImportLibrary library
Base importer library, this is what we actually use to import.
-
handler
public final ErrorHandler handler
ErrorHandler which is also responsible for uploading files
-
reader
protected final OMEROWrapper reader
Bio-Formats reader wrapper customized for OMERO.
-
store
protected final OMEROMetadataStoreClient store
Bio-FormatsMetadataStoreimplementation for OMERO.
-
candidates
protected final ImportCandidates candidates
Candidates for import
-
getUsedFiles
protected final boolean getUsedFiles
If true, then only a report on used files will be produced
-
importOutput
protected ImportOutput importOutput
Format which should be preferred for standard out messages
-
-
Constructor Detail
-
CommandLineImporter
public CommandLineImporter(ImportConfig config, java.lang.String[] paths, boolean getUsedFiles) throws java.lang.Exception
Legacy constructor which uses aUploadFileTransfer.- Parameters:
config- the import configurationpaths- files or directories to searchgetUsedFiles- if only getting a list of used files- Throws:
java.lang.Exception- if the import could not be set up
-
CommandLineImporter
public CommandLineImporter(ImportConfig config, java.lang.String[] paths, boolean getUsedFiles, FileTransfer transfer, int minutesToWait) throws java.lang.Exception
Legacy constructor without any file exclusions.- Parameters:
config- the import configurationpaths- files or directories to searchgetUsedFiles- if only getting a list of used filestransfer- how files are to be transferred to the serverminutesToWait- for how many minutes to wait for an import (negative for indefinitely)- Throws:
java.lang.Exception- if the import could not be set up
-
CommandLineImporter
public CommandLineImporter(ImportConfig config, java.lang.String[] paths, boolean getUsedFiles, FileTransfer transfer, java.util.List<FileExclusion> exclusions, int minutesToWait) throws java.lang.Exception
Main entry class for the application.- Parameters:
config- the import configurationpaths- files or directories to searchgetUsedFiles- if only getting a list of used filestransfer- how files are to be transferred to the serverexclusions- mechanisms to be used for skipping candidatesminutesToWait- for how many minutes to wait for an import (negative for indefinitely)- Throws:
java.lang.Exception- if the import could not be set up
-
-
Method Detail
-
checkLogin
protected void checkLogin()
Checks that requisite command line options for OMERO session creation have been provided and if not callsusage().
-
createImportLibrary
protected ImportLibrary createImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer, java.util.List<FileExclusion> exclusions, int minutesToWait)
Creates theImportLibrarythat this command line importer will use to import data- Parameters:
client- Bio-FormatsMetadataStoreimplementation for OMEROreader- Bio-Formats reader wrapper customized for OMEROtransfer-FileTransfermechanism to be used for uploadingexclusions-FileExclusionmechanisms for skipping candidatesminutesToWait- for how many minutes to wait for an import (negative for indefinitely)- Returns:
- See above.
-
closeCompleted
public static int closeCompleted(ImportConfig config) throws java.lang.Exception
Look for allImportProcessPrxin the current session and close them if they return a non-nullResponse(i.e. they are done).- Parameters:
config- the import configuration- Returns:
- how many import processes could not be accessed
- Throws:
java.lang.Exception- in the event of error
-
waitCompleted
public static int waitCompleted(ImportConfig config) throws java.lang.Exception
Look for allImportProcessPrxin the current session and close them if they return a non-nullResponse(i.e. they are done).- Parameters:
config- the import configuration- Returns:
- exit code,
0for success - Throws:
java.lang.Exception- in the event of error
-
setImportOutput
public ImportOutput setImportOutput(ImportOutput importOutput)
Set the currentImportOutput(defaulting to null if a null value is passed).- Parameters:
importOutput- possibly null enumeration value.- Returns:
- previous value.
-
start
public int start()
-
cleanup
public void cleanup()
Cleans up after a successful or unsuccessful image import. This method only does the minimum required cleanup, so that it can be called during shutdown.
-
usage
public static void usage()
Prints usage to STDERR and exits with return code 1.
-
advUsage
public static void advUsage()
Prints advanced usage to STDERR and exits with return code 1.
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionCommand line application entry point which parses CLI arguments and passes them into the importer. Return codes for import are:- 0 on success
- 1 on argument parsing failure
- 2 on exception during import
- 0 on success, even if errors exist in the files
- 1 only if an exception propagates up the stack
- Parameters:
args- Command line arguments.- Throws:
java.lang.Exception- in the event of error
-
setArgument
public static void setArgument(java.util.Map<java.lang.String,java.lang.Boolean> map, java.lang.String key)Set a conflicting argument and return the usage if the key is already set- Parameters:
map- map of conflicting propertieskey- configuration property to be set
-
-