Class StandardColumnDescriptor
java.lang.Object
de.hybris.platform.impex.jalo.header.AbstractDescriptor
de.hybris.platform.impex.jalo.header.AbstractColumnDescriptor
de.hybris.platform.impex.jalo.header.StandardColumnDescriptor
- All Implemented Interfaces:
Comparable<StandardColumnDescriptor>
public class StandardColumnDescriptor
extends AbstractColumnDescriptor
implements Comparable<StandardColumnDescriptor>
-
Nested Class Summary
Nested classes/interfaces inherited from class de.hybris.platform.impex.jalo.header.AbstractDescriptor
AbstractDescriptor.ColumnParams, AbstractDescriptor.DescriptorParams, AbstractDescriptor.HeaderParams -
Constructor Summary
ConstructorsConstructorDescriptionStandardColumnDescriptor(int position, HeaderDescriptor header, String expr) Self-parsing constructor.StandardColumnDescriptor(int position, HeaderDescriptor header, String expr, AbstractDescriptor.DescriptorParams params) Non-parsing constructor. -
Method Summary
Modifier and TypeMethodDescriptioncalculateDefaultValue(Item existing) Determines the default value given with this descriptor.intprotected AbstractValueTranslatorGets a value translator for translating values of this descriptor.exportValue(Object attributeValue) Tries to translate given attribute value to a string representing this value.static AttributeDescriptorfindAttributeDescriptor(HeaderDescriptor header, int position, String ownType, String qualifier) Tries to find the related attribute descriptor within composed type.static LanguagefindLanguage(HeaderDescriptor header, String value) Tries to get the language given by iso code or PK as string.Gets the related attribute descriptor within type.Gets the related attribute descriptor pk.Gets the type code specified in qualifier of this descriptor in header.Returns the default value associated with this descriptor.Gets the language defined by language modifier.Deprecated.Gets the qualifier of this column without prefix (If the qualifier is "Principal.uid", only "uid" will be returned, all until the first dot will be cut).Returns the used translator instance for translating values.booleanChecks whether the descriptor has given a default value or is virtual.final ObjectimportValue(String cellValue, Item forItem) Translated the cell string value.booleanDoes the attribute allows null values?booleanbooleanShould the attribute be updated even if it is read only?booleanDeprecated.since ages - UseisInitialOnly()insteadbooleanIs it an initial only attribute? (Not writable, not readable only and initial or just a PK).booleanIs it a localized descriptor?booleanIs it a mandatory attribute? (Not private and not optional).booleanisPartOf()Is it a part of attribute?booleanIs it a readable attribute? (read flag is true).booleanIs it a read only attribute? (Not writable, not initial and no PK).booleanbooleanisUnique()Is it an unique attribute?booleanIs it a virtual attribute? (As values only default values are used)booleanIs it a writable attribute? (write flag is true).toString()protected voidvalidate()Methods inherited from class de.hybris.platform.impex.jalo.header.AbstractColumnDescriptor
changePosition, createCSVDecorator, createTranslator, getCSVCellDecorator, getHeader, getValuePosition, shiftPositionMethods inherited from class de.hybris.platform.impex.jalo.header.AbstractDescriptor
extractItemPathElements, extractModifiersMap, getDefinitionSrc, getDescriptorData, getDescriptorTranslator, parseColumnDescriptor, parseHeaderDescriptor
-
Constructor Details
-
StandardColumnDescriptor
public StandardColumnDescriptor(int position, HeaderDescriptor header, String expr) throws HeaderValidationException Self-parsing constructor. Instantiates a new descriptor instance with given expression. Modifier map will be created and related descriptor in target type and translator is determined.- Parameters:
position- position within headerheader- header instance this descriptor belongsexpr- descriptor expression within header expression- Throws:
HeaderValidationException- error while constructing descriptor
-
StandardColumnDescriptor
public StandardColumnDescriptor(int position, HeaderDescriptor header, String expr, AbstractDescriptor.DescriptorParams params) throws HeaderValidationException Non-parsing constructor. (Used for XML) As above constructor but without creating modifier map (will be given as parameter).- Parameters:
position- position within headerheader- header instance this descriptor belongsexpr- descriptor expression within header expressionparams- descriptor data holding modifier map- Throws:
HeaderValidationException- error while instantiation of instance
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<StandardColumnDescriptor>
-
validate
- Overrides:
validatein classAbstractColumnDescriptor- Throws:
HeaderValidationException
-
findAttributeDescriptor
public static AttributeDescriptor findAttributeDescriptor(HeaderDescriptor header, int position, String ownType, String qualifier) throws HeaderValidationException Tries to find the related attribute descriptor within composed type.- Parameters:
header- header where descriptor is locatedposition- position of descriptor within header definitionownType- type declaration used in header definitionqualifier- qualifier of the descriptor (for this qualifier is searched within all descriptors of given type)- Returns:
- related attribute descriptor within type or null if not existent
- Throws:
HeaderValidationException- error while determining descriptor like type is not existent
-
createValueTranslator
Gets a value translator for translating values of this descriptor. If a custom translator is given in modifiers, this will be returned, else a translator appropriate to the attribute type.- Returns:
- value translator for translation of values
- Throws:
HeaderValidationException- illegal attribute type or malformed custom translator string
-
importValue
Translated the cell string value. Throws aUnresolvedValueExceptionin the following cases:- the non-empty cell value could not resolved e.g. item reference did not locate a existing item
- the language configured for this column doesnt exist (yet)
- the cell value was empty but the configured default value string could not be resolved
- Parameters:
cellValue- the cell string valueforItem- the target item (optional: only if it already exists)- Returns:
- the translated value
- Throws:
UnresolvedValueException- see above
-
exportValue
Tries to translate given attribute value to a string representing this value.- Parameters:
attributeValue- attribute to translate- Returns:
- resulting string representing given attribute value
- Throws:
UnresolvedValueException- attribute can not be translated
-
hasDefaultValueDefinition
public boolean hasDefaultValueDefinition()Checks whether the descriptor has given a default value or is virtual.- Returns:
- true if descriptor delivers a default value, otherwise false
-
getDefaultValue
Returns the default value associated with this descriptor.- Returns:
- default value or null if no value is given
- Throws:
UnresolvedValueException- default value can not be translated to an attribute
-
calculateDefaultValue
Determines the default value given with this descriptor. Checks the modifier for an default definition and translates it. If not provided and descriptor virtual, it tries to construct from sub-default values using import function ofItemExpressionTranslatorwithnullvalue.- Parameters:
existing- existing item in case of part of- Returns:
- default value translated
- Throws:
UnresolvedValueException- default value definition can not be resolved to an existing value
-
getAttributeDescriptor
Gets the related attribute descriptor within type.- Returns:
- the attribute descriptor this descriptor is mapped to
-
getAttributeDescriptorPk
Gets the related attribute descriptor pk.- Returns:
- the attribute descriptor pk
-
getComposedTypeCode
Gets the type code specified in qualifier of this descriptor in header.- Returns:
- code of defined type in qualifier or null, if qualifier was given without type code.
-
isLocalized
public boolean isLocalized()Is it a localized descriptor?- Returns:
- true if descriptor is localized, false otherwise
-
isMandatory
public boolean isMandatory()Is it a mandatory attribute? (Not private and not optional).- Returns:
- true if descriptor is mandatory, false otherwise
-
isUnique
public boolean isUnique()Is it an unique attribute?- Returns:
- true if modifiers declare attribute UNIQUE, false otherwise
-
isVirtual
public boolean isVirtual()Is it a virtual attribute? (As values only default values are used)- Returns:
- true if modifiers declare attribute VIRTUAL, false otherwise
-
isAllowNull
public boolean isAllowNull()Does the attribute allows null values?- Returns:
- true if modifiers declare attribute ALLOW_NULL, false otherwise
-
isForceWrite
public boolean isForceWrite()Should the attribute be updated even if it is read only?- Returns:
- true if modifiers declare attribute FORCE_WRITE, false otherwise
-
getLanguageIso
Deprecated.since ages - UsegetLanguageModifier()instead.Gets the value of modifierImpExConstants.Syntax.Modifier.LANGUAGE.- Returns:
- the set value of language modifier, null if no value is set (may be session language should be used)
-
getLanguageModifier
-
getLanguageIsoCode
-
isStringAttribute
public boolean isStringAttribute() -
isCaseInsensitiveStringAttribute
public boolean isCaseInsensitiveStringAttribute() -
getLanguage
Gets the language defined by language modifier.- Returns:
- the configured language; may be null if session language should be used
- Throws:
HeaderValidationException- specified language is invalidTODO replace it with Model method
-
findLanguage
public static Language findLanguage(HeaderDescriptor header, String value) throws HeaderValidationException Tries to get the language given by iso code or PK as string.- Parameters:
header- header instance for logging purposesvalue- iso code or pk string of needed language- Returns:
- language found instance
- Throws:
HeaderValidationException- iso code or PK string is not valid
-
toString
-
isInitalOnly
Deprecated.since ages - UseisInitialOnly()instead -
isInitialOnly
public boolean isInitialOnly()Is it an initial only attribute? (Not writable, not readable only and initial or just a PK).- Returns:
- true if attribute is initial only, false otherwise
-
isReadOnly
public boolean isReadOnly()Is it a read only attribute? (Not writable, not initial and no PK).- Returns:
- true if attribute is read only, otherwise false
-
isReadable
public boolean isReadable()Is it a readable attribute? (read flag is true).- Returns:
- true if attribute is readable, otherwise false
-
isWritable
public boolean isWritable()Is it a writable attribute? (write flag is true).- Returns:
- true if attribute is writable, otherwise false
-
isPartOf
public boolean isPartOf()Is it a part of attribute?- Returns:
- true if it is part of, otherwise false
-
getValueTranslator
Returns the used translator instance for translating values.- Returns:
- used translator
-
getQualifier
Description copied from class:AbstractColumnDescriptorGets the qualifier of this column without prefix (If the qualifier is "Principal.uid", only "uid" will be returned, all until the first dot will be cut).- Overrides:
getQualifierin classAbstractColumnDescriptor- Returns:
- qualifier of this column
-
getQualifierForComment
- Overrides:
getQualifierForCommentin classAbstractColumnDescriptor
-
getLanguageModifier()instead.