Class GenericCSVImportStep

    • Constructor Detail

      • GenericCSVImportStep

        public GenericCSVImportStep()
    • Method Detail

      • processObjects

        protected abstract boolean processObjects​(java.util.Map map,
                                                  CronJob cronJob)
                                           throws JaloBusinessException
        Processes one parsed csv line. This method must be implemented by concrete subclasses which transforms this data.
        Parameters:
        map - the data of the line as a Map Integer -> String - the key contains the column index staring with 0
        cronJob -
        Returns:
        boolean returns true if processing has succeeded - the job will continue regardless of this result
        Throws:
        JaloBusinessException - may be thrown to indicate a process error - the job will abort after this line
      • skipFirstLine

        protected boolean skipFirstLine()
        Returns true, if the first line of the file should be skipped. This default implementation returns false. Overwrite this method in your subclass, to change this default implementation.
        Returns:
        true, if the first line of the file should be skipped
      • getTokenCharacters

        protected char[] getTokenCharacters()
        Returns a character array witch is used as value seperator token.

        As default CronJobConstants.CHARS.VERTICAL_LINE ( '|' ) is used. Override this method to specify a different separator token.

        Returns:
        a char array with of all token characters
      • getCommentOutCharacters

        protected char[] getCommentOutCharacters()
        Returns a char array with of all comment tokens. Each line starting with one of this tokens is considered as comment and will be ignored.

        As default this method returns CronJobConstants.CHARS.POUND + CronJobConstants.CHARS.PERCENT ( '#%' ). Override to specify a different token.

        Returns:
        a char array with of all comment tokens
      • createCSVReader

        protected CSVReader createCSVReader​(java.io.InputStream inputStream,
                                            java.lang.String encoding)
                                     throws java.io.UnsupportedEncodingException
        As default creates a new CSVReader instance with the given stream and encoding. Override when own parsing and tokenizing logic is needed.
        Parameters:
        inputStream - the csv data input stream
        encoding - the text encoding of the csv data stream
        Returns:
        a new reader instance
        Throws:
        java.io.UnsupportedEncodingException - if the given encoding is not supported
      • getCharSet

        protected java.lang.String getCharSet()
        define the character set for the performStep() method.
        Returns:
        the charset which should be used, default is "UTF-8"
        Since:
        2.10
      • openMedia

        protected java.io.InputStream openMedia​(JobMedia media,
                                                CronJob cronJob)
                                         throws JaloBusinessException,
                                                java.io.IOException
        Opens an InputStream to the JobMedia of the specified CronJob.

        This default implementation used Media.getDataFromStream() to open the stream to the media. Subclasses may override this e.g. to support zip file medias or similar.

        Parameters:
        media - the JobMedia which will be opened
        cronJob - the CronJob which this Step is executed for
        Returns:
        the DataInputStream to the specified JobMedia
        Throws:
        JaloBusinessException
        java.io.IOException
      • tokenise

        @Deprecated
        protected final java.util.Map tokenise​(java.lang.String line)
        Deprecated.
        since ages - to override line tokenizing usecreateCSVReader(InputStream, String)!
      • isAbortable

        public boolean isAbortable()
        Description copied from class: Step
        Returns true, if this Step is abortable.

        The default implementation returns always false. To mark your Step subclass as abortable, override this method and return true.

        Overrides:
        isAbortable in class Step
        Returns:
        true, if this Step is abortable
        See Also:
        Step.isAbortable()