Class ImpExImportReader
java.lang.Object
de.hybris.platform.impex.jalo.ImpExReader
de.hybris.platform.impex.jalo.imp.ImpExImportReader
- Direct Known Subclasses:
ImpExImportJob.MyImpExImportReader,MultiThreadedImpExImportReader
-
Nested Class Summary
Nested classes/interfaces inherited from class de.hybris.platform.impex.jalo.ImpExReader
ImpExReader.ResultSetCSVReader -
Field Summary
Fields inherited from class de.hybris.platform.impex.jalo.ImpExReader
FIRST -
Constructor Summary
ConstructorsConstructorDescriptionImpExImportReader(CSVReader reader) ImpExImportReader(CSVReader reader, boolean legacyMode) ImpExImportReader(CSVReader reader, CSVWriter dumpWriter) ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, DocumentIDRegistry docIDRegistry, ImportProcessor processor, EnumerationValue mode) ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, DocumentIDRegistry docIDRegistry, ImportProcessor processor, EnumerationValue mode, boolean legacyMode) ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, DocumentIDRegistry docIDRegistry, ImportProcessor processor, EnumerationValue mode, boolean legacyMode, InvalidHeaderPolicy policy) ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, DocumentIDRegistry docIDRegistry, ImportProcessor processor, EnumerationValue mode, InvalidHeaderPolicy policy) ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, ImportProcessor processor) ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, ImportProcessor processor, boolean legacyMode) ImpExImportReader(String lines) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes all used readers.protected ValueLinecreateValueLine(HeaderDescriptor header, Map<Integer, String> line) Creates from a line which represents a data row a value line.voidSets the next line processed as discarded.voidSets the next line processed as unresolved.voiddumpNextLine(String reason) Sets the next line processed as unresolved.protected voiddumpUnresolvedLine(ValueLine line) protected booleanensureValidHeaderOrMarkUnresolved(ValueLine valueLine) protected StringfindMarker(String expr) Checks if the given expression starts with a marker (special construct, seeImpExConstants.Syntax.CodeMarkers) and returns the marker string..Returns the dumped line writer.Returns the ValueLine which is currently processed.Evaluates the 'processor' modifier of the header and creates the defined processor if present, otherwise null.intReturns the amount of lines written to the dump data file intended to be processed within a second import run or more.intReturns the amount of lines of current header written to the dump data file.Deprecated.final ImportProcessorintintReturns the overall processed item count.intReturns the overall processed item count of current header.intReturns the overall item count processed and not dumped (means all dependencies are resolved).intReturns the overall value line count.protected voidincDumpCount(int toAdd) protected voidincItemsCount(int toAdd) booleanTells whether or not the impex reader will automatically create hmc saved values for each created, removed or updated item.booleanTells 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 ).booleanbooleanReturn true if csv data is parsed again to resolve previously unresolvable item references.protected voidpostProcessValueLine(ValueLine currentValueLine, Item ret, Exception error) protected de.hybris.platform.impex.jalo.imp.ImpExImportReader.PreProcessResultpreProcessLine(ValueLine valueLine) Does pre-processing and tells if line can be imported at all.protected ItemprocessLine(ValueLine valueLine) protected booleanProcesses 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.voidreadAll()readLine()Imports the next item from the csv reader.protected voidprotected voidsetBeanShellContext(bsh.Interpreter bsh, Map csvLine) Declares default variables within the bean shell context which therefore are available within bean shell code interpretation.voidsetCreateHMCSavedValues(boolean savedValueCreation) Enables/disables the automatic creation of hmc saved values for each created, removed or modified item.voidsetCSVWriter(CSVWriter csvWriter) Changes the dumped line writer.voidsetCurrentHeader(HeaderDescriptor header) Sets the given header instance as current header.voidsetDumpingAllowed(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 ).protected voidDeprecated.since ages - usesetAfterEachCode(de.hybris.platform.impex.jalo.AbstractCodeLine)insteadvoidIf secondpass flag is enabled, csv data is parsed again to resolve previously unresolvable item references.voidsetValueLinesToSkip(int toSkip) Configures how many value lines (not actual csv lines, mind) should be skipped when callingreadLine()the first time.Methods inherited from class de.hybris.platform.impex.jalo.ImpExReader
addDefinition, addExternalDataMedia, addExternalDataMedias, addHeaderExceptionInfoAsComment, addHeaderReplacementRule, addToBeanShellContext, adjustLineIndexes, applyHeaderReplacements, assureBeanShellLoaded, checkDefinitonKey, createCodeLine, createCodeLineLegacyWay, createCodeLineModernWay, createInvalidHeader, createNewHeader, debug, debug, enableCodeExecution, enableExternalCodeExecution, enableExternalDataCodeExecution, enableExternalImpExSyntaxParsing, enableExternalSyntaxParsing, enterIfBlock, error, error, execute, execute, exitIfBlock, findExternalDataMedia, findExternalDataMedia, getAllExternalDataMediaCodes, getAttributeConstraintFilter, getBeforeEachCode, getCellDecorators, getCSVReader, getCurrentHeader, getCurrentLocation, getCurrentReader, getDefaultReplacements, getDocumentIDRegistry, getFromBeanShellContext, getInvalidHeaderPolicy, getLineSize, getLocale, getStrictMode, gotInsertedLines, hasCellDecorators, includeExternalData, includeExternalData, includeExternalData, includeExternalData, includeExternalData, includeExternalData, includeExternalData, includeExternalData, includeExternalData, includeExternalData, includeExternalDataMedia, includeExternalDataMedia, includeExternalDataMedia, includeExternalDataMedia, includeExternalDataMedia, includeExternalDataMedia, includeExternalDataMedia, includeExternalDataMedia, includeExternalDataMedia, includeExternalDataMedia, includeSQLData, includeSQLData, includeSQLData, info, info, initDatabase, insertLine, isCodeExecutionEnabled, isCodeLine, isCombinedSearchEnabled, isCommentLine, isDebugEnabled, isDefinition, isEmptyLine, isEndUserRights, isExternalCodeExecutionEnabled, isExternalSyntaxParsingEnabled, isHeaderLine, isIncludingExternalData, isInfoEnabled, isNotInInactiveIfBlock, isStartUserRights, legacyExecute, lineToList, modernExecute, parseHeader, parseHeader, parseHeader, parseHeader, processCodeLine, readNextCSVLine, removeExternalDataMedia, removeExternalDataMedias, replaceDefinitions, setAttributeConstraintFilter, setBeforeEachCode, setCellDecorators, setCurrentHeader, setInvalidHeaderPolicy, setLocale, setRelaxedMode, setRelaxedMode, setValidationMode, setValidationMode, sortRulesList, splitDefinitonCell, storeUserRightsLine, warn, warn, writeUserRightsLines
-
Constructor Details
-
ImpExImportReader
-
ImpExImportReader
-
ImpExImportReader
-
ImpExImportReader
-
ImpExImportReader
-
ImpExImportReader
public ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, ImportProcessor processor, boolean legacyMode) -
ImpExImportReader
public ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, DocumentIDRegistry docIDRegistry, ImportProcessor processor, EnumerationValue mode) -
ImpExImportReader
public ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, DocumentIDRegistry docIDRegistry, ImportProcessor processor, EnumerationValue mode, boolean legacyMode, InvalidHeaderPolicy policy) -
ImpExImportReader
public ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, DocumentIDRegistry docIDRegistry, ImportProcessor processor, EnumerationValue mode, InvalidHeaderPolicy policy) -
ImpExImportReader
public ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, DocumentIDRegistry docIDRegistry, ImportProcessor processor, EnumerationValue mode, boolean legacyMode)
-
-
Method Details
-
isLegacyMode
public boolean isLegacyMode() -
getImportProcessor
-
findMarker
Description copied from class:ImpExReaderChecks if the given expression starts with a marker (special construct, seeImpExConstants.Syntax.CodeMarkers) and returns the marker string..- Overrides:
findMarkerin classImpExReader- Parameters:
expr- the expression to check- Returns:
- the marker string if the expression starts with it or null
-
processMarkerCodeLine
Description copied from class:ImpExReaderProcesses 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:
processMarkerCodeLinein classImpExReader- 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
Description copied from class:ImpExReaderSets the given header instance as current header. The current header is set for each read value line.- Overrides:
setCurrentHeaderin classImpExReader- Parameters:
header- the header which will be used from now as header for read value lines
-
getCustomImportProcessor
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
-
setForEachCode
Deprecated.since ages - usesetAfterEachCode(de.hybris.platform.impex.jalo.AbstractCodeLine)instead -
setAfterEachCode
-
getForEachCode
Deprecated.since ages - usegetAfterEachCode()instead -
getAfterEachCode
-
createValueLine
Description copied from class:ImpExReaderCreates from a line which represents a data row a value line.- Overrides:
createValueLinein classImpExReader- Parameters:
header- the header which corresponds to the given lineline- 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 callingreadLine()the first time. Nevertheless even skipped lines are included in the total value count (seegetValueLineCount()).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 usegetProcessedItemsCount().
To get the amount of lines written to the dump data file usegetDumpedLineCount().- Returns:
- the overall value line count
-
getProcessedItemsCount
public int getProcessedItemsCount()Returns the overall processed item count. EqualsgetValueCountwithout skipped and discarded value lines.
To get the overall value line count usegetValueLineCount().
To get the amount of lines written to the dump data file usegetDumpedLineCount().- 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 usegetValueLineCount().
To get the amount of lines processed usegetProcessedItemsCount().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
Returns the ValueLine which is currently processed. ASpecialValueTranslatormay use this to get the other cellvalues too.- Returns:
- ValueLine
-
getCSVWriter
Returns the dumped line writer. -
setCSVWriter
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
Description copied from class:ImpExReaderCloses all used readers.- Overrides:
closein classImpExReader- Throws:
IOException- error while closing streams
-
readAll
- Throws:
ImpExException
-
readLine
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:
readLinein classImpExReader- Returns:
- the next item which was processed
- Throws:
ImpExException- any import/export error exceptUnresolvedValueException, which is handled internally
-
ensureValidHeaderOrMarkUnresolved
-
incItemsCount
protected void incItemsCount(int toAdd) -
incDumpCount
protected void incDumpCount(int toAdd) -
postProcessValueLine
protected void postProcessValueLine(ValueLine currentValueLine, Item ret, Exception error) throws ImpExException - Throws:
ImpExException
-
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
-
processLine
- Throws:
ImpExException
-
setBeanShellContext
Description copied from class:ImpExReaderDeclares default variables within the bean shell context which therefore are available within bean shell code interpretation. These variables are:
line- the given line objectcurrentLineNumber- the current line numbercurrentLocation- the current location of the active reader
- Overrides:
setBeanShellContextin classImpExReader- Parameters:
bsh- bean shell interpreter where the variables will be setcsvLine- line object which will be set to variableline- Throws:
bsh.EvalError- error while setting variables
-
getScriptExecutionContext
- Overrides:
getScriptExecutionContextin classImpExReader
-
getLastImportedItem
-
getLastImportedItemLineNumber
public int getLastImportedItemLineNumber() -
getLastImportedLine
-
dumpUnresolvedLine
- Throws:
ImpExException
-
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
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
-
getValidationMode
- Overrides:
getValidationModein classImpExReader
-
getAfterEachCode()instead