Package ome.formats.importer.cli
Class CommandLineImporter
- java.lang.Object
-
- ome.formats.importer.cli.CommandLineImporter
-
public class CommandLineImporter extends java.lang.Object
The base entry point for the CLI version of the OMERO importer.
-
-
Field Summary
Fields Modifier and Type Field Description protected ImportCandidates
candidates
Candidates for importImportConfig
config
Configuration used by all componentsstatic int
DEFAULT_WAIT
java.util.List<FileExclusion>
exclusions
FileExclusion
mechanisms for skipping candidatesprotected boolean
getUsedFiles
If true, then only a report on used files will be producedErrorHandler
handler
ErrorHandler which is also responsible for uploading filesprotected ImportOutput
importOutput
Format which should be preferred for standard out messagesImportLibrary
library
Base importer library, this is what we actually use to import.protected OMEROWrapper
reader
Bio-Formats reader wrapper customized for OMERO.protected OMEROMetadataStoreClient
store
Bio-FormatsMetadataStore
implementation for OMERO.FileTransfer
transfer
FileTransfer
mechanism 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 void
advUsage()
Prints advanced usage to STDERR and exits with return code 1.protected void
checkLogin()
Checks that requisite command line options for OMERO session creation have been provided and if not callsusage()
.void
cleanup()
Cleans up after a successful or unsuccessful image import.static int
closeCompleted(ImportConfig config)
Look for allImportProcessPrx
in the current session and close them if they return a non-nullResponse
(i.e.protected ImportLibrary
createImportLibrary(OMEROMetadataStoreClient client, OMEROWrapper reader, FileTransfer transfer, java.util.List<FileExclusion> exclusions, int minutesToWait)
Creates theImportLibrary
that this command line importer will use to import datastatic void
main(java.lang.String[] args)
Command line application entry point which parses CLI arguments and passes them into the importer.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 setImportOutput
setImportOutput(ImportOutput importOutput)
Set the currentImportOutput
(defaulting to null if a null value is passed).int
start()
static void
usage()
Prints usage to STDERR and exits with return code 1.static int
waitCompleted(ImportConfig config)
Look for allImportProcessPrx
in 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
FileTransfer
mechanism to be used for uploading
-
exclusions
public final java.util.List<FileExclusion> exclusions
FileExclusion
mechanisms 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-FormatsMetadataStore
implementation 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 theImportLibrary
that this command line importer will use to import data- Parameters:
client
- Bio-FormatsMetadataStore
implementation for OMEROreader
- Bio-Formats reader wrapper customized for OMEROtransfer
-FileTransfer
mechanism to be used for uploadingexclusions
-FileExclusion
mechanisms 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 allImportProcessPrx
in 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 allImportProcessPrx
in 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,
0
for 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.Exception
Command 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
-
-