Class ImportCandidates


  • public class ImportCandidates
    extends org.apache.commons.io.DirectoryWalker
    Utility class which given any File object will determine the correct number and members of a given import. This facility permits iterating over a directory. This class is NOT thread-safe.
    Since:
    Beta4.1
    • Field Detail

      • DEPTH

        public static final int DEPTH
      • METADATA_LEVEL

        public static final loci.formats.in.MetadataLevel METADATA_LEVEL
    • Constructor Detail

      • ImportCandidates

        public ImportCandidates​(OMEROWrapper reader,
                                java.lang.String[] paths,
                                IObserver observer)
        Parameters:
        reader - instance used for parsing each of the paths. Not used once the constructor completes.
        paths - file paths which are searched. May be directories.
        observer - IObserver which will monitor any exceptions during ReaderWrapper.setId(String). Otherwise no error reporting takes place.
      • ImportCandidates

        public ImportCandidates​(int depth,
                                OMEROWrapper reader,
                                java.lang.String[] paths,
                                IObserver observer)
        Main constructor which starts depth-first descent into all the paths and permits a descent to the given depth.
        Parameters:
        depth - number of directory levels to search down.
        reader - instance used for parsing each of the paths. Not used once the constructor completes.
        paths - file paths which are searched. May be directories.
        observer - IObserver which will monitor any exceptions during ReaderWrapper.setId(String). Otherwise no error reporting takes place.
    • Method Detail

      • print

        public void print()
        Prints the "standard" representation of the groups, which is parsed by other software layers. The format is: 1) any empty lines are ignored, 2) any blocks of comments separate groups, 3) each group is begun by the "key", 4) all other files in a group will also be imported. The ordering of the used files is taken into account.
      • printYaml

        public void printYaml()
      • size

        public int size()
        Returns:
        containers size
      • wasCancelled

        public boolean wasCancelled()
        Returns:
        if import was cancelled
      • getPaths

        public java.util.List<java.lang.String> getPaths()
        Returns:
        array of string paths for files in containers
      • getReaderType

        public java.lang.String getReaderType​(java.lang.String path)
        Retrieve reader type for file specified in path
        Parameters:
        path - - absolute path for container
        Returns:
        reader type
      • getUsedFiles

        public java.lang.String[] getUsedFiles​(java.lang.String path)
        Return string of files used by container item at path
        Parameters:
        path - - absolute path for container
        Returns:
        string array of used files
      • getContainers

        public java.util.List<ImportContainer> getContainers()
        Returns:
        all containers as an array list
      • execute

        protected void execute​(java.lang.String[] paths)
        Method called during ImportCandidates(OMEROWrapper, String[], IObserver) to operate on all the given paths. This will be called twice: once without reading the files, and once (with the known total) using reader
        Parameters:
        paths -
      • singleFile

        protected ImportContainer singleFile​(java.io.File file,
                                             ImportConfig config)
        Return an import container for a single file
        Parameters:
        file - - single file
        Returns:
        importer container
      • handleFile

        public void handleFile​(java.io.File file,
                               int depth,
                               java.util.Collection collection)
        Handle a file import
        Overrides:
        handleFile in class org.apache.commons.io.DirectoryWalker
        Parameters:
        file - the selected file
        depth - the depth of the scan
        collection - the result objects, ignored