Class ImpExImportReader
- java.lang.Object
-
- de.hybris.platform.impex.jalo.ImpExReader
-
- de.hybris.platform.impex.jalo.imp.ImpExImportReader
-
- Direct Known Subclasses:
ImpExImportJob.MyImpExImportReader,MultiThreadedImpExImportReader
public class ImpExImportReader extends ImpExReader
-
-
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
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()Closes all used readers.protected ValueLinecreateValueLine(HeaderDescriptor header, java.util.Map<java.lang.Integer,java.lang.String> line)Creates from a line which represents a data row a value line.voiddiscardNextLine()Sets the next line processed as discarded.voiddumpNextLine()Sets the next line processed as unresolved.voiddumpNextLine(java.lang.String reason)Sets the next line processed as unresolved.protected voiddumpUnresolvedLine(ValueLine line)protected booleanensureValidHeaderOrMarkUnresolved(ValueLine valueLine)protected java.lang.StringfindMarker(java.lang.String expr)Checks if the given expression starts with a marker (special construct, seeImpExConstants.Syntax.CodeMarkers) and returns the marker string..AbstractCodeLinegetAfterEachCode()CSVWritergetCSVWriter()Returns the dumped line writer.ValueLinegetCurrentValueLine()Returns the ValueLine which is currently processed.ImportProcessorgetCustomImportProcessor(HeaderDescriptor header)Evaluates the 'processor' modifier of the header and creates the defined processor if present, otherwise null.intgetDumpedLineCount()Returns the amount of lines written to the dump data file intended to be processed within a second import run or more.intgetDumpedLineCountPerHeader()Returns the amount of lines of current header written to the dump data file.AbstractCodeLinegetForEachCode()Deprecated.since ages - usegetAfterEachCode()insteadImportProcessorgetImportProcessor()ItemgetLastImportedItem()intgetLastImportedItemLineNumber()ValueLinegetLastImportedLine()intgetProcessedItemsCount()Returns the overall processed item count.intgetProcessedItemsCountPerHeader()Returns the overall processed item count of current header.intgetResolvedItemsCount()Returns the overall item count processed and not dumped (means all dependencies are resolved).protected java.util.Map<java.lang.String,java.lang.Object>getScriptExecutionContext(java.util.Map<java.lang.Integer,java.lang.String> line)EnumerationValuegetValidationMode()intgetValueLineCount()Returns the overall value line count.protected voidincDumpCount(int toAdd)protected voidincItemsCount(int toAdd)booleanisCreateHMCSavedValues()Tells whether or not the impex reader will automatically create hmc saved values for each created, removed or updated item.booleanisDumpingAllowed()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 ).booleanisLegacyMode()booleanisSecondPass()Return true if csv data is parsed again to resolve previously unresolvable item references.protected voidpostProcessValueLine(ValueLine currentValueLine, Item ret, java.lang.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 booleanprocessMarkerCodeLine(AbstractCodeLine line)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.voidreadAll()java.lang.ObjectreadLine()Imports the next item from the csv reader.protected voidsetAfterEachCode(AbstractCodeLine line)protected voidsetBeanShellContext(bsh.Interpreter bsh, java.util.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 voidsetForEachCode(AbstractCodeLine line)Deprecated.since ages - usesetAfterEachCode(de.hybris.platform.impex.jalo.AbstractCodeLine)insteadvoidsetIsSecondPass()If 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 Detail
-
ImpExImportReader
public ImpExImportReader(java.lang.String lines)
-
ImpExImportReader
public ImpExImportReader(CSVReader reader)
-
ImpExImportReader
public ImpExImportReader(CSVReader reader, boolean legacyMode)
-
ImpExImportReader
public ImpExImportReader(CSVReader reader, CSVWriter dumpWriter, ImportProcessor processor)
-
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 Detail
-
isLegacyMode
public boolean isLegacyMode()
-
getImportProcessor
public final ImportProcessor getImportProcessor()
-
findMarker
protected java.lang.String findMarker(java.lang.String expr)
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
protected boolean processMarkerCodeLine(AbstractCodeLine line) throws ImpExException
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
public void setCurrentHeader(HeaderDescriptor header)
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
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
-
setForEachCode
@Deprecated protected void setForEachCode(AbstractCodeLine line)
Deprecated.since ages - usesetAfterEachCode(de.hybris.platform.impex.jalo.AbstractCodeLine)instead
-
setAfterEachCode
protected void setAfterEachCode(AbstractCodeLine line)
-
getForEachCode
@Deprecated public AbstractCodeLine getForEachCode()
Deprecated.since ages - usegetAfterEachCode()instead
-
getAfterEachCode
public AbstractCodeLine getAfterEachCode()
-
createValueLine
protected ValueLine createValueLine(HeaderDescriptor header, java.util.Map<java.lang.Integer,java.lang.String> line)
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
public ValueLine getCurrentValueLine()
Returns the ValueLine which is currently processed. ASpecialValueTranslatormay 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.IOExceptionDescription copied from class:ImpExReaderCloses all used readers.- Overrides:
closein classImpExReader- Throws:
java.io.IOException- error while closing streams
-
readAll
public void readAll() throws ImpExException- Throws:
ImpExException
-
readLine
public java.lang.Object readLine() throws ImpExExceptionImports 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
protected boolean ensureValidHeaderOrMarkUnresolved(ValueLine valueLine)
-
incItemsCount
protected void incItemsCount(int toAdd)
-
incDumpCount
protected void incDumpCount(int toAdd)
-
postProcessValueLine
protected void postProcessValueLine(ValueLine currentValueLine, Item ret, java.lang.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
protected Item processLine(ValueLine valueLine) throws ImpExException
- Throws:
ImpExException
-
setBeanShellContext
protected void setBeanShellContext(bsh.Interpreter bsh, java.util.Map csvLine) throws bsh.EvalErrorDescription 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
protected java.util.Map<java.lang.String,java.lang.Object> getScriptExecutionContext(java.util.Map<java.lang.Integer,java.lang.String> line)
- Overrides:
getScriptExecutionContextin classImpExReader
-
getLastImportedItem
public Item getLastImportedItem()
-
getLastImportedItemLineNumber
public int getLastImportedItemLineNumber()
-
getLastImportedLine
public ValueLine getLastImportedLine()
-
dumpUnresolvedLine
protected void dumpUnresolvedLine(ValueLine line) throws ImpExException
- 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
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
-
getValidationMode
public EnumerationValue getValidationMode()
- Overrides:
getValidationModein classImpExReader
-
-