Class HeaderDescriptor
java.lang.Object
de.hybris.platform.impex.jalo.header.AbstractDescriptor
de.hybris.platform.impex.jalo.header.HeaderDescriptor
Represents an header line within an ImpEx script. It mainly consists of the header mode, the configured composed type
and a list of configured columns.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFilter which decides if an attribute has to be treated as mandatory and initial only.protected static classDefault implementation of an attribute constraint filter which decides for mandatory if the attributeis not private and not optional and for initial only if it is not writable and and initial.protected final classObject representing one permitted type ex- or importable by this header.Nested classes/interfaces inherited from class de.hybris.platform.impex.jalo.header.AbstractDescriptor
AbstractDescriptor.ColumnParams, AbstractDescriptor.DescriptorParams, AbstractDescriptor.HeaderParams -
Constructor Summary
ConstructorsConstructorDescriptionHeaderDescriptor(ImpExReader reader, String expr, AbstractDescriptor.DescriptorParams headerParams, String location, DocumentIDRegistry docIDRegistry) Non-parsing constructor - Creates a new header instance.HeaderDescriptor(ImpExReader reader, String expr, List<String> columnExpressions, String location, DocumentIDRegistry docIDRegistry) Self-parsing constructor - Creates a new header instance.HeaderDescriptor(ImpExReader reader, String expr, List<String> columnExpressions, String location, DocumentIDRegistry docIDRegistry, HeaderValidationException headerException) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddOmittedTypeMessage(PK typePK, String msg) Adds an message to the omitted type messages list.protected voidDiscovers all virtual columns and removes them from the column range[0,x].protected ComposedTypeCalculates the top-most permitted composed type starting at configured type.protected HeaderDescriptor.PermittedTypeMappingCreates aHeaderDescriptor.PermittedTypeMappingfor given composed type.protected Map<String,HeaderDescriptor.PermittedTypeMapping> Filters any composed (sub)type which doesn't fit the currently configured columns.Gets the configured columns which are describing attributes of the default composed type (seegetDefaultComposedType()) and are unique.protected Set<StandardColumnDescriptor>calculateUniqueAttributeColumns(ComposedType targetType) Gets all columns configured at header which are describing an attribute of given type and are unique.protected HeaderCellTranslatorcreateTranslator(String expr) Creates the translator class which parses the own definition text of this descriptor.voidDeprecated.dump()Gets the header as list of Strings for dumping purposes.voidDeprecated.since ages - use logging methodCategory.error(Object)directlyprotected ComposedTypeTries to gather the composed type instance configured in header line.Gets a list of all configured columns represented by their qualifier.getAllColumns(ComposedType targetType) Gets all columns for given composed type.Gets the column descriptors configured for this header.protected Collection<StandardColumnDescriptor>Searches the set of configured columns for columns which are describing given type attribute (which are mapped to this descriptor).getColumnsByQualifier(String qualifier) Searches the set of configured columns for columns with given qualifier.getColumnsForCreation(ComposedType targetType) Deprecated.since ages - usegetColumnsForCreation(String)insteadgetColumnsForCreation(String targetTypeCode) Gets all permitted columns for given composed type's code which are not read-only and part-of. These columns has to be used for creation case.getColumnsForUpdate(ComposedType targetType) Deprecated.since ages - usegetColumnsForUpdate(String)instead.getColumnsForUpdate(String targetTypeCode) Gets all permitted columns for given composed type's code which are not read-only, and inital-only and unique columns. These columns has to be used for update case.Returns the configured composed type, regardless of whether or not it is actually permitted by this header.Returns the configured composed type, regardless of whether or not it is actually permitted by this header.Gets the top-most permitted composed type starting at configured type (seecalculateDefaultComposedType().Gets the top-most permitted composed type starting at configured type (seecalculateDefaultComposedType().Returns the used registry for document id's.Gets exception associated with invalid header or null if header is valid.Gets the location of this header line within the read ImpExScript.getMode()Gets the mode of this header configured at header line.intgetOmittedTypesMessages(PK typePK) Gets a reason text for not omitting given type for this header.getPartOfColumns(ComposedType targetType) Gets all permitted columns for given composed type which are part-of and not read-only.getPartOfColumns(String targetTypeCode) Gets all permitted columns for given composed type's code which are part-of and not read-only.Gets the codes of all types which are subtypes of the configured one and have passed all checks of thecalculatePermittedType(ComposedType)method.Gets the reader instance which had created this header.<T extends AbstractColumnDescriptor>
Collection<T>getSpecificColumns(Class<T> descriptor) Returns a collection of all column descriptors instances which are instance of the given descriptor class.Gets the code of the configured composed type of header.getUniqueAttributeColumns(ComposedType targetType) Gets all columns for given composed type which are unique.getUniqueAttributeColumns(String targetTypeCode) Gets all permitted columns for given composed type which are unique.voidDeprecated.since ages - use logging methodCategory.info(Object)directlybooleanChecks if the batch modifier is set for this header.booleanDeprecated.since ages - use logging methodCategory.isDebugEnabled()directlybooleanReturns whether the default composed typegetDefaultComposedType()is a singleton.booleanDeprecated.since ages - use logging methodCategory.isInfoEnabled()directlybooleanChecks whether the header mode isINSERT.booleanChecks whether the header mode isINSERT_UPDATE.booleanChecks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)).booleanisPermittedType(String code) Checks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)).booleanDeprecated.since ages - @deprecated useisPermittedTypeForInsert(String)booleanChecks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)) for inserts inINSERT or INSERT_UPDATEmodes.booleanDeprecated.since ages - useisPermittedTypeForUpdate(String)booleanChecks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)) for updates inUPDATE or INSERT_UPDATEmodes.booleanChecks whether the header mode isREMOVE.booleanChecks whether the header mode isUPDATE.booleanisValid()True, if validvoidsetColumns(List<AbstractColumnDescriptor> columnDescriptors) Sets the columns of this header and triggers depending steps like Determination of the permitted types, the configured columns and the correct positions of the columns.toString()voidvalidate()voidDeprecated.since ages - use logging methodCategory.warn(Object)directlyMethods inherited from class de.hybris.platform.impex.jalo.header.AbstractDescriptor
extractItemPathElements, extractModifiersMap, getDefinitionSrc, getDescriptorData, getDescriptorTranslator, parseColumnDescriptor, parseHeaderDescriptor
-
Constructor Details
-
HeaderDescriptor
public HeaderDescriptor(ImpExReader reader, String expr, List<String> columnExpressions, String location, DocumentIDRegistry docIDRegistry) throws HeaderValidationException Self-parsing constructor - Creates a new header instance. Use this constructor if you have a header line as list of Strings. Determines header params, the configured composed type, the permitted types, the configured columns, the default composed type and determines the correct positions of the columns.- Parameters:
reader- calling reader instance mainly for logging purposesexpr- the first record entry of the header linecolumnExpressions- list of all further records (columns) of header linelocation- current location of used readerdocIDRegistry- registry used for storing used documents IDs- Throws:
HeaderValidationException- error while determining and checking type and columns
-
HeaderDescriptor
public HeaderDescriptor(ImpExReader reader, String expr, AbstractDescriptor.DescriptorParams headerParams, String location, DocumentIDRegistry docIDRegistry) throws HeaderValidationException Non-parsing constructor - Creates a new header instance. Use this constructor if you get the header line column by column. Determines the configured composed type. Columns will not be checked and determined as well as other tasks depending on that step.. Please callsetColumns(List)later for performing these missing steps.- Parameters:
reader- calling reader instance mainly for logging purposesexpr- the first record entry of the header lineheaderParams- already parsed params of headerlocation- current location of used readerdocIDRegistry- registry used for storing used documents IDs- Throws:
HeaderValidationException- error while determining and checking type and columns
-
HeaderDescriptor
public HeaderDescriptor(ImpExReader reader, String expr, List<String> columnExpressions, String location, DocumentIDRegistry docIDRegistry, HeaderValidationException headerException) throws HeaderValidationException - Throws:
HeaderValidationException
-
-
Method Details
-
isValid
public boolean isValid()True, if valid- Returns:
- true if header is valid
-
getInvalidHeaderException
Gets exception associated with invalid header or null if header is valid.- Returns:
- exception or null if valid
-
setColumns
public void setColumns(List<AbstractColumnDescriptor> columnDescriptors) throws HeaderValidationException Sets the columns of this header and triggers depending steps like Determination of the permitted types, the configured columns and the correct positions of the columns. Can only be called once!!- Parameters:
columnDescriptors- list of all column descriptors for this header- Throws:
HeaderValidationException- error while determining and checking columns
-
adjustValuePositions
Discovers all virtual columns and removes them from the column range[0,x]. All virtual columns are set to the position-1 * position. Furthermore it maps each column to the column position defined by modifier 'pos' (if used). If the modifier is used for one column then it has to be used for each other column, for avoiding position conflicts. Furthermore, the defined position has to be unique.- Throws:
HeaderValidationException- Modifier position is not used consequently by all or nothing columns, or two position modifiers have the same value
-
getReader
Gets the reader instance which had created this header. Mainly used for logging purposes.- Returns:
- reader which had created this header
-
isDebugEnabled
Deprecated.since ages - use logging methodCategory.isDebugEnabled()directlyChecks if the debug method of the reader is enabled or if no reader set the logger will be checked.- Returns:
- is debug mode enabled?
-
debug
Deprecated.since ages - use logging methodCategory.debug(Object)directlyDebugs a message with the reader or the current logger instance.- Parameters:
msg- debug message
-
isInfoEnabled
Deprecated.since ages - use logging methodCategory.isInfoEnabled()directlyChecks if the info method of the reader is enabled or if no reader set the logger will be checked.- Returns:
- is info mode enabled?
-
info
Deprecated.since ages - use logging methodCategory.info(Object)directlyLogs an info message with the reader or the current logger instance.- Parameters:
msg- info message
-
warn
Deprecated.since ages - use logging methodCategory.warn(Object)directlyLogs an warn message with the reader or the current logger instance.- Parameters:
msg- warn message
-
error
Deprecated.since ages - use logging methodCategory.error(Object)directlyLogs an error message with the reader or the current logger instance.- Parameters:
msg- error message
-
createTranslator
Description copied from class:AbstractDescriptorCreates the translator class which parses the own definition text of this descriptor.- Specified by:
createTranslatorin classAbstractDescriptor- Parameters:
expr- the definition text- Returns:
- the translator instance
-
isBatchMode
public boolean isBatchMode()Checks if the batch modifier is set for this header.- Returns:
- true if
batch=trueis set for header, false otherwise
-
isInsertMode
public boolean isInsertMode()Checks whether the header mode isINSERT.- Returns:
- true if header mode is
INSERT, false otherwise
-
isUpdateMode
public boolean isUpdateMode()Checks whether the header mode isUPDATE.- Returns:
- true if header mode is
UPDATE, false otherwise
-
isInsertUpdateMode
public boolean isInsertUpdateMode()Checks whether the header mode isINSERT_UPDATE.- Returns:
- true if header mode is
INSERT_UPDATE, false otherwise
-
isRemoveMode
public boolean isRemoveMode()Checks whether the header mode isREMOVE.- Returns:
- true if header mode is
REMOVE, false otherwise
-
getColumns
Gets the column descriptors configured for this header.- Returns:
- list of all configured column descriptors
-
getNumCols
public int getNumCols() -
getSpecificColumns
Returns a collection of all column descriptors instances which are instance of the given descriptor class. With that you can get for example all special columns.- Type Parameters:
T- Type of column descriptors the result will contain (will be filtered)- Parameters:
descriptor- the class of which the descriptors have top be an instance of- Returns:
- a collection of objects which are instances of the given class
-
getTypeCode
Gets the code of the configured composed type of header.- Returns:
- code of configured composed type
-
findConfiguredComposedType
Tries to gather the composed type instance configured in header line.- Returns:
- the composed type configured at header line
- Throws:
HeaderValidationException- configured type is not existent at type system
-
getConfiguredComposedType
Returns the configured composed type, regardless of whether or not it is actually permitted by this header. To get the top-most permitted type usegetDefaultComposedType().- Returns:
- the configured composed type instance
-
getConfiguredComposedTypeCode
Returns the configured composed type, regardless of whether or not it is actually permitted by this header. To get the top-most permitted type usegetDefaultComposedType().- Returns:
- the configured composed type instance
-
calculateDefaultComposedType
Calculates the top-most permitted composed type starting at configured type. Gets the configured composed type if it is permitted (seeisPermittedType(ComposedType)) and not abstract and not jalo, it will be used, else the subtypes will be searched until a type is found which fits the condition. The check of the subtypes is done as in breath depth search.- Returns:
- the top-most permitted composed type starting at configured one
-
getDefaultComposedType
Gets the top-most permitted composed type starting at configured type (seecalculateDefaultComposedType().- Returns:
- the top-most permitted composed type starting at configured one
-
isDefaultComposedTypeSingleton
public boolean isDefaultComposedTypeSingleton()Returns whether the default composed typegetDefaultComposedType()is a singleton. Does noNullPointerExceptioncheck. -
getDefaultComposedTypeCode
Gets the top-most permitted composed type starting at configured type (seecalculateDefaultComposedType().- Returns:
- the top-most permitted composed type starting at configured one
-
getPermittedTypeCodes
Gets the codes of all types which are subtypes of the configured one and have passed all checks of thecalculatePermittedType(ComposedType)method.- Returns:
- codes of all permitted types
-
isPermittedType
Checks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)).- Parameters:
ct- type to check for permitted type- Returns:
- true if given type is permitted by this header, false otherwise
-
isPermittedTypeForInsert
@Deprecated(since="ages", forRemoval=false) public boolean isPermittedTypeForInsert(ComposedType ct) Deprecated.since ages - @deprecated useisPermittedTypeForInsert(String)Checks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)) for inserts inINSERT or INSERT_UPDATEmodes.Permits only when the type can be found in the permitted types and the type is not marked only for updates (see also
HeaderDescriptor.PermittedTypeMapping.isOnlyForUpdate()).- Parameters:
ct- type to check for permitted type- Returns:
- true if given type is permitted by this header, false otherwise
-
isPermittedTypeForInsert
Checks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)) for inserts inINSERT or INSERT_UPDATEmodes.Permits only when the type can be found in the permitted types and the type is not marked only for updates (see also
HeaderDescriptor.PermittedTypeMapping.isOnlyForUpdate()).- Parameters:
ct- type to check for permitted type- Returns:
- true if given type is permitted by this header, false otherwise
-
isPermittedTypeForUpdate
@Deprecated(since="ages", forRemoval=false) public boolean isPermittedTypeForUpdate(ComposedType ct) Deprecated.since ages - useisPermittedTypeForUpdate(String)Checks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)) for updates inUPDATE or INSERT_UPDATEmodes.- Parameters:
ct- type to check for permitted type- Returns:
- true if given type is permitted by this header, false otherwise
-
isPermittedTypeForUpdate
Checks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)) for updates inUPDATE or INSERT_UPDATEmodes.- Parameters:
ct- type to check for permitted type- Returns:
- true if given type is permitted by this header, false otherwise
-
isPermittedType
Checks whether the given type is permitted by this header (is subtype of configured one and fits all checks ofcalculatePermittedType(ComposedType)).- Parameters:
code- code of type to check for permitted type- Returns:
- true if given type is permitted by this header, false otherwise
-
getMode
Gets the mode of this header configured at header line.- Returns:
- configured header mode
-
dump
Gets the header as list of Strings for dumping purposes.- Returns:
- header as list of strings mapped to their position
-
addOmittedTypeMessage
Adds an message to the omitted type messages list. These messages are created if a type is found which fits the configured type but does not has passed all checks of thecalculatePermittedType(ComposedType).- Parameters:
msg- message containing the omitted type code and reason why it was omitted
-
calculatePermittedType
Creates aHeaderDescriptor.PermittedTypeMappingfor given composed type. While creation it checks that- it is not abstract and not jalo-only
- at least one unique attribute column can be found in INSERT or INSERT_UPDATE mode
- no mandatory attribute columns are missing except REMOVE mode
- an no initial-only attribute columns are missing in INSERT or INSERT_UPDATE mode
ImpExConstants.Enumerations.ImpExValidationModeEnum.IMPORT_RELAXEDmode all checks are disabled. If an check fails, anullwill be returned and theaddOmittedTypeMessage(PK, String)will be called.- Parameters:
ct- composed type for which a mapping will be created- Returns:
- created type mapping with all columns enabled which are configured at header or null if an check fails
-
calculatePermittedTypes
Filters any composed (sub)type which doesn't fit the currently configured columns. A type is not permitted when:- it is abstract or jalo-only
- no unique attribute columns can be found in INSERT or INSERT_UPDATE mode
- mandatory attribute columns are missing except REMOVE mode
- initial-only attribute columns are missing in INSERT or INSERT_UPDATE mode
- Returns:
- all permitted types based upon this headers composed type
-
validate
- Specified by:
validatein classAbstractDescriptor- Throws:
HeaderValidationException
-
getColumnsForUpdate
@Deprecated(since="ages", forRemoval=false) public Set<StandardColumnDescriptor> getColumnsForUpdate(ComposedType targetType) Deprecated.since ages - usegetColumnsForUpdate(String)instead.Gets all permitted columns for given composed type which are not- read-only,
- and inital-only
- and unique columns.
- Parameters:
targetType- type for which the columns for update are needed- Returns:
- set of columns for update or empty set if type is not permitted
-
getColumnsForUpdate
Gets all permitted columns for given composed type's code which are not- read-only,
- and inital-only
- and unique columns.
- Parameters:
targetTypeCode- type code for which the columns for update are needed- Returns:
- set of columns for update or empty set if type is not permitted
-
getColumnsForCreation
@Deprecated(since="ages", forRemoval=false) public Set<StandardColumnDescriptor> getColumnsForCreation(ComposedType targetType) Deprecated.since ages - usegetColumnsForCreation(String)insteadGets all permitted columns for given composed type which are not- read-only
- and part-of.
- Parameters:
targetType- type for which the columns for creation are needed- Returns:
- set of columns for creation or empty set if type is not permitted
-
getColumnsForCreation
Gets all permitted columns for given composed type's code which are not- read-only
- and part-of.
- Parameters:
targetTypeCode- type coce for which the columns for creation are needed- Returns:
- set of columns for creation or empty set if type is not permitted
-
getPartOfColumns
Gets all permitted columns for given composed type which are- part-of
- read-only.
- Parameters:
targetType- type for which the part-of columns are needed- Returns:
- set of part-of columns or empty set if type is not permitted
-
getPartOfColumns
Gets all permitted columns for given composed type's code which are- part-of
- read-only.
- Parameters:
targetTypeCode- type for which the part-of columns are needed- Returns:
- set of part-of columns or empty set if type is not permitted
-
getAllColumns
Gets all columns for given composed type.- Parameters:
targetType- type for which the all columns are needed- Returns:
- set of columns or empty set if type is not permitted
-
getUniqueAttributeColumns
Gets all columns for given composed type which are- unique.
- Parameters:
targetType- type for which the unique columns are needed- Returns:
- set of unique columns or empty set if type is not permitted
-
getUniqueAttributeColumns
Gets all permitted columns for given composed type which are- unique.
- Parameters:
targetTypeCode- code of type for which the unique columns are needed- Returns:
- set of unique columns or empty set if type is not permitted
-
calculateUniqueAttributeColumns
Gets all columns configured at header which are describing an attribute of given type and are unique.- Parameters:
targetType- type to which all configured unique columns will be returned- Returns:
- list of all unique columns in respect to given type
-
calculateUniqueAttributeColumns
Gets the configured columns which are describing attributes of the default composed type (seegetDefaultComposedType()) and are unique.- Returns:
- unique columns of default composed type
-
getAllColumnQualifiers
Gets a list of all configured columns represented by their qualifier.- Returns:
- list of all configured columns
-
getColumnsByAttribute
Searches the set of configured columns for columns which are describing given type attribute (which are mapped to this descriptor).- Parameters:
ad- descriptor to which all configured columns are needed- Returns:
- list of all columns which are matched to given descriptor or an empty list
-
getColumnsByQualifier
Searches the set of configured columns for columns with given qualifier.- Parameters:
qualifier- qualifier of resulting columns- Returns:
- list of all columns which have given qualifier as qualifier
-
getLocation
Gets the location of this header line within the read ImpExScript.- Returns:
- location of based header line
-
getDocumentIDRegistry
Returns the used registry for document id's.- Returns:
- the used document id registry
-
toString
-
getOmittedTypesMessages
Gets a reason text for not omitting given type for this header.- Returns:
- reason text for omitting the type or null if there is no reason.
-
getInterceptorRelatedParameters
-
Category.debug(Object)directly