Class CommandLineImporter


  • public class CommandLineImporter
    extends java.lang.Object
    The base entry point for the CLI version of the OMERO importer.
    • Field Detail

      • config

        public final ImportConfig config
        Configuration used by all components
      • 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.
      • 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 a UploadFileTransfer.
        Parameters:
        config - the import configuration
        paths - files or directories to search
        getUsedFiles - 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 configuration
        paths - files or directories to search
        getUsedFiles - if only getting a list of used files
        transfer - how files are to be transferred to the server
        minutesToWait - 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 configuration
        paths - files or directories to search
        getUsedFiles - if only getting a list of used files
        transfer - how files are to be transferred to the server
        exclusions - mechanisms to be used for skipping candidates
        minutesToWait - 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 calls usage().
      • createImportLibrary

        protected ImportLibrary createImportLibrary​(OMEROMetadataStoreClient client,
                                                    OMEROWrapper reader,
                                                    FileTransfer transfer,
                                                    java.util.List<FileExclusion> exclusions,
                                                    int minutesToWait)
        Creates the ImportLibrary that this command line importer will use to import data
        Parameters:
        client - Bio-Formats MetadataStore implementation for OMERO
        reader - Bio-Formats reader wrapper customized for OMERO
        transfer - FileTransfer mechanism to be used for uploading
        exclusions - FileExclusion mechanisms for skipping candidates
        minutesToWait - 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 all ImportProcessPrx in the current session and close them if they return a non-null Response (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 all ImportProcessPrx in the current session and close them if they return a non-null Response (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 current ImportOutput (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
        Return codes for the "-f" option (getUsedFiles) are:
        • 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 properties
        key - configuration property to be set