Class ValueLine
- java.lang.Object
-
- de.hybris.platform.impex.jalo.imp.ValueLine
-
public class ValueLine extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ValueLine.ValueEntry
The actual value object inside a value line.
-
Constructor Summary
Constructors Constructor Description ValueLine(HeaderDescriptor header, java.lang.String firstCell, java.util.Map<java.lang.Integer,java.lang.String> cellValueStrings, int linenumber, java.lang.String location)
Creates a new value line.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addHiddenLine(ValueLine line)
Adds another value line mainly created by thecreateCopy()
method, representing another item resolved by this value line.void
clearProcessedItemPK()
java.util.Collection<ValueLine>
createCopies(int count)
Creates a number of copies of this line without copying the potentially assigned item pk, unresolved flags and/or hidden value lines.ValueLine
createCopy()
Creates a copy of this value except the assigned item, unresolved flag and/or hidden value lines.java.util.Map<java.lang.Integer,java.lang.String>
dump()
Produces a csv cell map to be written usingCSVWriter.write(Map)
into a file for being processed in a second-pass import.AbstractCodeLine
getAfterEachCode()
ComposedType
getComposedType()
Returns the actual composed type item defined by its owntype code
or the default type defined by its header (seeHeaderDescriptor.getDefaultComposedType()
.PK
getConflictingItemPk()
HeaderDescriptor
getHeader()
Gets the header descriptor this line belongs to.java.util.Collection<ValueLine>
getHiddenLines()
Gets all hidden lines.int
getLineNumber()
Returns the real document line number of this value line.java.lang.String
getLocation()
Returns the textual representation of the line number of this value line.ValueLineMetaData
getMetaData()
java.lang.String
getPlainUnresolvedReason()
PK
getProcessedItemPK()
In case a value line could not be completely processed during the first run this line may provide the item pk of the previously located or created item belonging to this line.java.util.Map<java.lang.Integer,java.lang.String>
getSource()
Gets the original source line of this value line.java.lang.String
getTypeCode()
Returns the own item type code of this line, ornull
if no type code was defined within the first cell of this line.java.util.Collection<StandardColumnDescriptor>
getUnresolved(java.util.Collection<StandardColumnDescriptor> columnDescriptors)
Filters all column descriptors whose column entries of this value line are unresolved.java.lang.String
getUnresolvedReason()
ValueLine.ValueEntry
getValueEntry(int index)
Provides the value entry object for a given position.boolean
hasHiddenLines()
Checks whether there are hidden lines stored.boolean
isUnrecoverable()
Checks if this line contains unrecoverable error.boolean
isUnresolved()
Checks if this line is either marked as completely unresolved ( viamarkUnresolved()
) or owns a non-ignored value entry which has not been resolved yet.boolean
isUnresolved(java.util.Collection<StandardColumnDescriptor> columnDescriptors)
Same asisUnresolved()
except that only value entries belonging to the given column descriptors are evaluated.boolean
isUsingJaloOnlyFeatures()
void
markUnrecoverable()
Marks this line as unrecoverable.void
markUnrecoverable(java.lang.String reason)
void
markUnresolved()
Marks this line as being completely unresolved.void
markUnresolved(java.lang.String reason)
Marks this line as being completely unresolved.void
resolve(PK processedItemPk, java.util.Collection<StandardColumnDescriptor> processedColumns)
void
resolve(Item processedItem, java.util.Collection<StandardColumnDescriptor> processedColumns)
Tries to resolve this line by passing the processed item and the used columns.protected ValueLine.ValueEntry
resolveMissingEntry(int index, java.lang.Object resolvingValue)
Marks the column value at positionindex
as resolved with given value.void
setAfterEachCode(AbstractCodeLine abstractCodeLine)
void
setComposedType(ComposedType type)
void
setConflictingItemPK(PK conflictingItemPK)
void
setTypeCode(java.lang.String typeCode)
protected java.lang.String[]
splitTypeCodeCell(java.lang.String typeCodeCell)
Deprecated.since ages - This method is deprecated in favor ofValueLineMetaData
class.java.lang.String
toString()
protected ValueLine.ValueEntry
unresolveMissingEntry(int index)
Marks the column value at positionindex
as unresolved.
-
-
-
Constructor Detail
-
ValueLine
public ValueLine(HeaderDescriptor header, java.lang.String firstCell, java.util.Map<java.lang.Integer,java.lang.String> cellValueStrings, int linenumber, java.lang.String location)
Creates a new value line.- Parameters:
header
- header descriptor this line belongs tofirstCell
- content of first cell containing the value line specific type code (maybe contains the three part text of the dumped lines)cellValueStrings
- Map of all column valueslinenumber
- line number of this value line within scriptlocation
- location text of this value line within script (containing also the line number)
-
-
Method Detail
-
createCopy
public ValueLine createCopy()
Creates a copy of this value except the assigned item, unresolved flag and/or hidden value lines.- Returns:
- a copy of this value line
-
createCopies
public java.util.Collection<ValueLine> createCopies(int count)
Creates a number of copies of this line without copying the potentially assigned item pk, unresolved flags and/or hidden value lines.- Parameters:
count
- amount of copies to create- Returns:
- Collection
-
getSource
public java.util.Map<java.lang.Integer,java.lang.String> getSource()
Gets the original source line of this value line.- Returns:
- original source line
-
addHiddenLine
public void addHiddenLine(ValueLine line)
Adds another value line mainly created by thecreateCopy()
method, representing another item resolved by this value line. Used if more than one item is resolved using this value line.- Parameters:
line
- value line to add
-
hasHiddenLines
public boolean hasHiddenLines()
Checks whether there are hidden lines stored. If more than item was resolved by this value line, for each further item an extra value line is created and added to his one as hidden line.- Returns:
- true if hidden lines are available
-
getHiddenLines
public java.util.Collection<ValueLine> getHiddenLines()
Gets all hidden lines. If more than item was resolved by this value line, for each further item an extra value line is created and added to his one as hidden line.- Returns:
- all hidden lines stored at this value line
-
splitTypeCodeCell
@Deprecated protected java.lang.String[] splitTypeCodeCell(java.lang.String typeCodeCell)
Deprecated.since ages - This method is deprecated in favor ofValueLineMetaData
class.Splits the first cell of line into the (optional) item type code and the (optional) item pk from a possible first import run.- Parameters:
typeCodeCell
- the first cell string as read by the csv parser- Returns:
- [ item type code , item pk, dumping comments ]
-
markUnresolved
public void markUnresolved()
Marks this line as being completely unresolved. The line will mark all cells as read, even if some cells have been resolved by now!
-
markUnresolved
public void markUnresolved(java.lang.String reason)
Marks this line as being completely unresolved. The line will mark all cells as read, even if some cells have been resolved by now!- Parameters:
reason
- reason for not resolving the line
-
getLineNumber
public int getLineNumber()
Returns the real document line number of this value line.- Returns:
- line number within script
-
getLocation
public java.lang.String getLocation()
Returns the textual representation of the line number of this value line.- Returns:
- location within script
-
getTypeCode
public java.lang.String getTypeCode()
Returns the own item type code of this line, ornull
if no type code was defined within the first cell of this line.- Returns:
- own type code or null if first cell was empty
-
setTypeCode
public void setTypeCode(java.lang.String typeCode)
-
getComposedType
public ComposedType getComposedType() throws InsufficientDataException
Returns the actual composed type item defined by its owntype code
or the default type defined by its header (seeHeaderDescriptor.getDefaultComposedType()
.- Returns:
- the composed type this value line belongs to
- Throws:
InsufficientDataException
- in case this line defines a type which is unknown in the current system
-
setComposedType
public void setComposedType(ComposedType type)
-
getValueEntry
public ValueLine.ValueEntry getValueEntry(int index)
Provides the value entry object for a given position. Please note that counting starts with 1 since the first cell is reserved for holding this lines type code and item pk.- Parameters:
index
- the value position ( starting at 1 )- Returns:
- the according value entry, or null if no value exists at this position
-
getHeader
public HeaderDescriptor getHeader()
Gets the header descriptor this line belongs to.- Returns:
- the header belonging to this line
-
getProcessedItemPK
public PK getProcessedItemPK()
In case a value line could not be completely processed during the first run this line may provide the item pk of the previously located or created item belonging to this line. With this no further searching is necessary in any second pass runs.- Returns:
- PK of processed item within second run, else null
-
dump
public java.util.Map<java.lang.Integer,java.lang.String> dump()
Produces a csv cell map to be written usingCSVWriter.write(Map)
into a file for being processed in a second-pass import. Unless the complete line was markedunresolved
all cells which have been resolved by now or have no been used at all will be prefixed with theImpExConstants.Syntax.IGNORE_PREFIX
token to skip their processing during a second pass.- Returns:
- line representation of this value line for writing to a dump file
-
getMetaData
public ValueLineMetaData getMetaData()
-
isUnresolved
public boolean isUnresolved()
Checks if this line is either marked as completely unresolved ( viamarkUnresolved()
) or owns a non-ignored value entry which has not been resolved yet.- Returns:
- true if line is unresolved, otherwise false
-
isUnresolved
public boolean isUnresolved(java.util.Collection<StandardColumnDescriptor> columnDescriptors)
Same asisUnresolved()
except that only value entries belonging to the given column descriptors are evaluated.- Parameters:
columnDescriptors
- a collection ofcolumn descriptors
to define which value entries to check- Returns:
- true if line is unresolved related to given descriptor, otherwise false
-
getUnresolved
public java.util.Collection<StandardColumnDescriptor> getUnresolved(java.util.Collection<StandardColumnDescriptor> columnDescriptors)
Filters all column descriptors whose column entries of this value line are unresolved.- Parameters:
columnDescriptors
- a collection ofcolumn descriptors
whose value lines entries will be checked for unresolving- Returns:
- collection of those descriptors which column entries of this valu eline are unresolved
-
resolve
public void resolve(Item processedItem, java.util.Collection<StandardColumnDescriptor> processedColumns)
Tries to resolve this line by passing the processed item and the used columns. This method stores the item pk and the actual type code. Additionally it marks all values which do not belong to any used column asunused
. The line stays unresolved if at least one unresolved value entry of the used columns exists! Usedump()
to store this line for retrying import later on.- Parameters:
processedItem
- the item created, removed or updated upon this lineprocessedColumns
- the columns used to processing the given item
-
resolve
public void resolve(PK processedItemPk, java.util.Collection<StandardColumnDescriptor> processedColumns)
-
resolveMissingEntry
protected ValueLine.ValueEntry resolveMissingEntry(int index, java.lang.Object resolvingValue)
Marks the column value at positionindex
as resolved with given value.- Parameters:
index
- index of the column value within value lineresolvingValue
- resolved value- Returns:
- the internal representation of an value entry with set resolved value
-
unresolveMissingEntry
protected ValueLine.ValueEntry unresolveMissingEntry(int index)
Marks the column value at positionindex
as unresolved.- Parameters:
index
- index of the column value within value line- Returns:
- the internal representation of an value entry
-
markUnrecoverable
public void markUnrecoverable()
Marks this line as unrecoverable. Line will be dumped but will NOT be proceeded in further passes.
-
markUnrecoverable
public void markUnrecoverable(java.lang.String reason)
-
isUnrecoverable
public boolean isUnrecoverable()
Checks if this line contains unrecoverable error.- Returns:
- true if line is unrecoverable, otherwise false.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getUnresolvedReason
public java.lang.String getUnresolvedReason()
-
getPlainUnresolvedReason
public java.lang.String getPlainUnresolvedReason()
-
setConflictingItemPK
public void setConflictingItemPK(PK conflictingItemPK)
-
getConflictingItemPk
public PK getConflictingItemPk()
-
isUsingJaloOnlyFeatures
public boolean isUsingJaloOnlyFeatures()
-
clearProcessedItemPK
public void clearProcessedItemPK()
-
getAfterEachCode
public AbstractCodeLine getAfterEachCode()
-
setAfterEachCode
public void setAfterEachCode(AbstractCodeLine abstractCodeLine)
-
-