Class ImpExImportReader

    • Method Detail

      • isLegacyMode

        public boolean isLegacyMode()
      • findMarker

        protected java.lang.String findMarker​(java.lang.String expr)
        Description copied from class: ImpExReader
        Checks if the given expression starts with a marker (special construct, see ImpExConstants.Syntax.CodeMarkers ) and returns the marker string..
        Overrides:
        findMarker in class ImpExReader
        Parameters:
        expr - the expression to check
        Returns:
        the marker string if the expression starts with it or null
      • processMarkerCodeLine

        protected boolean processMarkerCodeLine​(AbstractCodeLine line)
                                         throws ImpExException
        Description copied from class: ImpExReader
        Processes the special logic of the marker set to the given code line and returns true, if the code line should be executed or the marker prohibits the execution.
        Overrides:
        processMarkerCodeLine in class ImpExReader
        Parameters:
        line - the code line with set marker
        Returns:
        true, if line has to be executed
        Throws:
        ImpExException - the marker set to the code line is unknown
      • setCurrentHeader

        public void setCurrentHeader​(HeaderDescriptor header)
        Description copied from class: ImpExReader
        Sets the given header instance as current header. The current header is set for each read value line.
        Overrides:
        setCurrentHeader in class ImpExReader
        Parameters:
        header - the header which will be used from now as header for read value lines
      • getCustomImportProcessor

        public ImportProcessor getCustomImportProcessor​(HeaderDescriptor header)
                                                 throws ImpExException
        Evaluates the 'processor' modifier of the header and creates the defined processor if present, otherwise null.
        Parameters:
        header - header where modifier is situated
        Returns:
        at modifier defined processor or null
        Throws:
        ImpExException - defined process class can not be instantiated
      • createValueLine

        protected ValueLine createValueLine​(HeaderDescriptor header,
                                            java.util.Map<java.lang.Integer,​java.lang.String> line)
        Description copied from class: ImpExReader
        Creates from a line which represents a data row a value line.
        Overrides:
        createValueLine in class ImpExReader
        Parameters:
        header - the header which corresponds to the given line
        line - line for which a value line is needed
        Returns:
        value line created from given line
      • setValueLinesToSkip

        public void setValueLinesToSkip​(int toSkip)
        Configures how many value lines (not actual csv lines, mind) should be skipped when calling readLine() the first time. Nevertheless even skipped lines are included in the total value count (see getValueLineCount()).

        Please note that this method cannot be called after readLine() has been called once!

      • getValueLineCount

        public int getValueLineCount()
        Returns the overall value line count. This count includes all value lines which are read, including skipped, unresolved or otherwise unprocessable lines!
        To get the amount of lines processed use getProcessedItemsCount().
        To get the amount of lines written to the dump data file use getDumpedLineCount().
        Returns:
        the overall value line count
      • getProcessedItemsCount

        public int getProcessedItemsCount()
        Returns the overall processed item count. Equals getValueCount without skipped and discarded value lines.
        To get the overall value line count use getValueLineCount().
        To get the amount of lines written to the dump data file use getDumpedLineCount().
        Returns:
        the overall processed item count
      • getProcessedItemsCountPerHeader

        public int getProcessedItemsCountPerHeader()
        Returns the overall processed item count of current header.
        Returns:
        overall processed item count of current header
      • getDumpedLineCount

        public int getDumpedLineCount()
        Returns the amount of lines written to the dump data file intended to be processed within a second import run or more.
        To get the overall value line count use getValueLineCount().
        To get the amount of lines processed use getProcessedItemsCount().

        If this method returns 0 all value lines should have been processed properly and no second pass is necessary.

        Returns:
        amount of lines written to the dump data file
      • getDumpedLineCountPerHeader

        public int getDumpedLineCountPerHeader()
        Returns the amount of lines of current header written to the dump data file.
        Returns:
        amount of lines of current header written to the dump data file
      • getResolvedItemsCount

        public int getResolvedItemsCount()
        Returns the overall item count processed and not dumped (means all dependencies are resolved).
        Returns:
        overall item count processed and not dumped
      • getCurrentValueLine

        public ValueLine getCurrentValueLine()
        Returns the ValueLine which is currently processed. A SpecialValueTranslator may use this to get the other cellvalues too.
        Returns:
        ValueLine
      • getCSVWriter

        public CSVWriter getCSVWriter()
        Returns the dumped line writer.
      • setCSVWriter

        public void setCSVWriter​(CSVWriter csvWriter)
        Changes the dumped line writer. Be careful using this method since previously dumped lines get lost when replacing the writer.
        Parameters:
        csvWriter - the new dumped lines writer
      • close

        public void close()
                   throws java.io.IOException
        Description copied from class: ImpExReader
        Closes all used readers.
        Overrides:
        close in class ImpExReader
        Throws:
        java.io.IOException - error while closing streams
      • readLine

        public java.lang.Object readLine()
                                  throws ImpExException
        Imports the next item from the csv reader. This method will return any created, updated or removed (!) item. It will not return headers, empty lines or comments!
        Overrides:
        readLine in class ImpExReader
        Returns:
        the next item which was processed
        Throws:
        ImpExException - any import/export error except UnresolvedValueException, which is handled internally
      • ensureValidHeaderOrMarkUnresolved

        protected boolean ensureValidHeaderOrMarkUnresolved​(ValueLine valueLine)
      • incItemsCount

        protected void incItemsCount​(int toAdd)
      • incDumpCount

        protected void incDumpCount​(int toAdd)
      • preProcessLine

        protected de.hybris.platform.impex.jalo.imp.ImpExImportReader.PreProcessResult preProcessLine​(ValueLine valueLine)
        Does pre-processing and tells if line can be imported at all.
        Parameters:
        valueLine -
        Returns:
        true if the line is allowed to be imported
      • setBeanShellContext

        protected void setBeanShellContext​(bsh.Interpreter bsh,
                                           java.util.Map csvLine)
                                    throws bsh.EvalError
        Description copied from class: ImpExReader
        Declares default variables within the bean shell context which therefore are available within bean shell code interpretation. These variables are:
        • line - the given line object
        • currentLineNumber - the current line number
        • currentLocation - the current location of the active reader
        Overrides:
        setBeanShellContext in class ImpExReader
        Parameters:
        bsh - bean shell interpreter where the variables will be set
        csvLine - line object which will be set to variable line
        Throws:
        bsh.EvalError - error while setting variables
      • getScriptExecutionContext

        protected java.util.Map<java.lang.String,​java.lang.Object> getScriptExecutionContext​(java.util.Map<java.lang.Integer,​java.lang.String> line)
        Overrides:
        getScriptExecutionContext in class ImpExReader
      • getLastImportedItem

        public Item getLastImportedItem()
      • getLastImportedItemLineNumber

        public int getLastImportedItemLineNumber()
      • getLastImportedLine

        public ValueLine getLastImportedLine()
      • isSecondPass

        public boolean isSecondPass()
        Return true if csv data is parsed again to resolve previously unresolvable item references. Now mandatory fields are no longer checked (except when the item has not been created yet) but only unresolved fields are tried to translate and being written.
      • setIsSecondPass

        public void setIsSecondPass()
        If secondpass flag is enabled, csv data is parsed again to resolve previously unresolvable item references. Now mandatory fields are no longer checked (except when the item has not been created yet) but only unresolved fields are tried to translate and being written.
      • isDumpingAllowed

        public boolean isDumpingAllowed()
        Tells whether or not this import reader is allowed to dump unresolvable lines ( complete line or single cells could not be translated ) into a temporary file for later re-import ( when references may have become resolvable ).
      • setDumpingAllowed

        public void setDumpingAllowed​(boolean dumpingAllowed)
        Tells whether or not this import reader is allowed to dump unresolvable lines ( complete line or single cells could not be translated ) into a temporary file for later re-import ( when references may have become resolvable ).
      • isCreateHMCSavedValues

        public boolean isCreateHMCSavedValues()
        Tells whether or not the impex reader will automatically create hmc saved values for each created, removed or updated item.
      • setCreateHMCSavedValues

        public void setCreateHMCSavedValues​(boolean savedValueCreation)
        Enables/disables the automatic creation of hmc saved values for each created, removed or modified item.
        Parameters:
        savedValueCreation - if true saved value creation is enabled
      • discardNextLine

        public void discardNextLine()
        Sets the next line processed as discarded. Line will be not processed. This is a method intended to be used by bean shell within beforeEach code.
      • dumpNextLine

        public void dumpNextLine()
        Sets the next line processed as unresolved. Line will be dumped to dump file and processed in next import pass. This is a method intended to be used by bean shell.
      • dumpNextLine

        public void dumpNextLine​(java.lang.String reason)
        Sets the next line processed as unresolved. Line will be dumped to dump file and processed in next import pass. This is a method intended to be used by bean shell.
        Parameters:
        reason - message stored with value line to dump describing reason for dumping