Class ValueLine

java.lang.Object
de.hybris.platform.impex.jalo.imp.ValueLine

public class ValueLine extends Object
Data object representing a parsed csv item (value) line. Each line belongs to exactly one header, holds one entry per non-empty cell and may provides an own item type code differing from the one defined by the header.
  • Constructor Details

    • ValueLine

      public ValueLine(HeaderDescriptor header, String firstCell, Map<Integer,String> cellValueStrings, int linenumber, String location)
      Creates a new value line.
      Parameters:
      header - header descriptor this line belongs to
      firstCell - 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 values
      linenumber - line number of this value line within script
      location - location text of this value line within script (containing also the line number)
  • Method Details

    • 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 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 Map<Integer,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 the createCopy() 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 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(since="ages", forRemoval=false) protected String[] splitTypeCodeCell(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(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 String getLocation()
      Returns the textual representation of the line number of this value line.
      Returns:
      location within script
    • getTypeCode

      public String getTypeCode()
      Returns the own item type code of this line, or null 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(String typeCode)
    • getComposedType

      public ComposedType getComposedType() throws InsufficientDataException
      Returns the actual composed type item defined by its own type code or the default type defined by its header (see HeaderDescriptor.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 Map<Integer,String> dump()
      Produces a csv cell map to be written using CSVWriter.write(Map) into a file for being processed in a second-pass import.

      Unless the complete line was marked unresolved all cells which have been resolved by now or have no been used at all will be prefixed with the ImpExConstants.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 ( via markUnresolved() ) 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(Collection<StandardColumnDescriptor> columnDescriptors)
      Same as isUnresolved() except that only value entries belonging to the given column descriptors are evaluated.
      Parameters:
      columnDescriptors - a collection of column descriptors to define which value entries to check
      Returns:
      true if line is unresolved related to given descriptor, otherwise false
    • getUnresolved

      public Collection<StandardColumnDescriptor> getUnresolved(Collection<StandardColumnDescriptor> columnDescriptors)
      Filters all column descriptors whose column entries of this value line are unresolved.
      Parameters:
      columnDescriptors - a collection of column 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, 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 as unused.

      The line stays unresolved if at least one unresolved value entry of the used columns exists! Use dump() to store this line for retrying import later on.

      Parameters:
      processedItem - the item created, removed or updated upon this line
      processedColumns - the columns used to processing the given item
    • resolve

      public void resolve(PK processedItemPk, Collection<StandardColumnDescriptor> processedColumns)
    • resolveMissingEntry

      protected ValueLine.ValueEntry resolveMissingEntry(int index, Object resolvingValue)
      Marks the column value at position index as resolved with given value.
      Parameters:
      index - index of the column value within value line
      resolvingValue - 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 position index 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(String reason)
    • isUnrecoverable

      public boolean isUnrecoverable()
      Checks if this line contains unrecoverable error.
      Returns:
      true if line is unrecoverable, otherwise false.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUnresolvedReason

      public String getUnresolvedReason()
    • getPlainUnresolvedReason

      public 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)