Class ExcelEurope1PricesTypeTranslator
- java.lang.Object
-
- com.hybris.backoffice.excel.translators.AbstractValidationAwareTranslator<T>
-
- com.hybris.backoffice.excel.translators.AbstractExcelValueTranslator<java.util.Collection<PriceRowModel>>
-
- com.hybris.backoffice.excel.translators.ExcelEurope1PricesTypeTranslator
-
- All Implemented Interfaces:
ExcelValueTranslator<java.util.Collection<PriceRowModel>>
,org.springframework.core.Ordered
public class ExcelEurope1PricesTypeTranslator extends AbstractExcelValueTranslator<java.util.Collection<PriceRowModel>>
Price translator which allows to import product prices. It utilises impexEurope1PricesTranslator
andEurope1PricesTranslator.Europe1PriceRowTranslator
to import prices. Format: price currency:'N'|'G':user|userPriceGroup:quantity unit:[dateFrom to dateTo]:channel where:- price currency: defines price and currency which are mandatory fields
- N|G: N stands for
Europe1PricesTranslator.NETTO
and G forEurope1PricesTranslator.GROSS
which is taken as default when not provided. - user|userPriceGroup: User or userPriceGroup for which the price is created
- quantity unit: if not defined then default quantity is 1 and unit is taken from the product but when user or userPriceGroup is given this field is mandatory
- [dateFrom to dateTo]: defines price active range. The date time should be in format
ExcelDateUtils.getDateTimeFormat()
. Date is exported inExcelDateUtils.getExportTimeZone()
time zone. During import dates are converted from exported time zone to system time zone. By default export/import is done in UTC - channel: defines channel in which price is valid
- 10 EUR::axel:2 pieces:[10.11.2017 12:00:00 to 15:12:2017 12:00:00]:mobile - defines price with value 10 EUR Gross for user axel with min quantity 2 pieces, active from 10.11.2017 12:00:00 to 15:12:2017 12:00:00 in mobile channel
- 20 EUR:N::3 pieces - defines price with value 20 EUR Netto for 3 pieces
- 15 EUR - defines price 15 EUR for 1 unit which will be taken from
ProductModel.getUnit()
Europe1PricesTranslator.Europe1PriceRowTranslator
- 10 EUR::axel:2 pieces:[10.11.2017 12:00:00 to 15:12:2017 12:00:00]:mobile -> axel 2 pieces = 10 EUR [10.11.2017 12:00:00,15:12:2017 12:00:00] mobile
- 20 EUR:N::3 pieces ->2 pieces = 20 EUR N
- 15 EUR -> 15 EUR
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CHANNEL
static java.lang.String
EUROPE1_PRICE_HEADER
Deprecated.since 1811, not used anymore.static java.lang.String
NET_GROSS
static java.lang.String
PRICE_CURRENCY
static java.lang.String
QUANTITY_UNIT
static java.lang.String
USER_OR_UPG
-
Fields inherited from class com.hybris.backoffice.excel.translators.AbstractExcelValueTranslator
order
-
Fields inherited from class com.hybris.backoffice.excel.translators.AbstractValidationAwareTranslator
validators
-
-
Constructor Summary
Constructors Constructor Description ExcelEurope1PricesTypeTranslator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
appendIfPresent(java.lang.StringBuilder sb, java.lang.String value)
protected java.lang.String
buildSinglePriceImpexValue(java.util.Map<java.lang.String,java.lang.String> params)
boolean
canHandle(AttributeDescriptorModel attributeDescriptor)
Indicates whether the translator can handle given attribute descriptor.java.util.Optional<java.lang.Object>
exportData(java.util.Collection<PriceRowModel> objectToExport)
Converts given object to value which should be put into cell of exported excel file.protected java.lang.String
exportPriceRow(PriceRowModel priceRow)
protected java.lang.String
getDateRange(StandardDateRange range)
ExcelDateUtils
getExcelDateUtils()
protected java.lang.String
getImpexDateRange(java.lang.String dateRange)
protected <T> java.lang.String
getValueOrEmpty(T reference, java.util.function.Function<T,java.lang.String> valueSupplier)
ImpexValue
importValue(AttributeDescriptorModel attributeDescriptor, ImportParameters importParameters)
Imports single value instead of whole Impex object.java.lang.String
referenceFormat(AttributeDescriptorModel attributeDescriptor)
Format how a reference should be presented.void
setExcelDateUtils(ExcelDateUtils excelDateUtils)
-
Methods inherited from class com.hybris.backoffice.excel.translators.AbstractExcelValueTranslator
getOrder, getTypeService, importData, isLocalizedOfType, setOrder, setTypeService
-
Methods inherited from class com.hybris.backoffice.excel.translators.AbstractValidationAwareTranslator
getValidators, setValidators, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.hybris.backoffice.excel.translators.ExcelValueTranslator
exportData
-
-
-
-
Field Detail
-
EUROPE1_PRICE_HEADER
@Deprecated public static final java.lang.String EUROPE1_PRICE_HEADER
Deprecated.since 1811, not used anymore. The attribute qualifier (DescriptorModel.getQualifier()
) will be used as impex header value name (ImpexHeaderValue.name
)- See Also:
- Constant Field Values
-
PRICE_CURRENCY
public static final java.lang.String PRICE_CURRENCY
- See Also:
- Constant Field Values
-
NET_GROSS
public static final java.lang.String NET_GROSS
- See Also:
- Constant Field Values
-
USER_OR_UPG
public static final java.lang.String USER_OR_UPG
- See Also:
- Constant Field Values
-
QUANTITY_UNIT
public static final java.lang.String QUANTITY_UNIT
- See Also:
- Constant Field Values
-
CHANNEL
public static final java.lang.String CHANNEL
- See Also:
- Constant Field Values
-
-
Method Detail
-
canHandle
public boolean canHandle(AttributeDescriptorModel attributeDescriptor)
Description copied from interface:ExcelValueTranslator
Indicates whether the translator can handle given attribute descriptor.- Parameters:
attributeDescriptor
-AttributeDescriptorModel
- Returns:
- whether the translator can handle request
-
exportData
public java.util.Optional<java.lang.Object> exportData(java.util.Collection<PriceRowModel> objectToExport)
Description copied from interface:ExcelValueTranslator
Converts given object to value which should be put into cell of exported excel file.- Returns:
- value which will be put into cell of exported excel file.
-
exportPriceRow
protected java.lang.String exportPriceRow(PriceRowModel priceRow)
-
getDateRange
protected java.lang.String getDateRange(StandardDateRange range)
-
getValueOrEmpty
protected <T> java.lang.String getValueOrEmpty(T reference, java.util.function.Function<T,java.lang.String> valueSupplier)
-
referenceFormat
public java.lang.String referenceFormat(AttributeDescriptorModel attributeDescriptor)
Description copied from interface:ExcelValueTranslator
Format how a reference should be presented. Usually references consist of a few fields indicated as unique. Therefore all unique attributes should be included in the format. Example reference format: "catalog:version"- Parameters:
attributeDescriptor
-AttributeDescriptorModel
- Returns:
- Format how a reference should be presented
-
importValue
public ImpexValue importValue(AttributeDescriptorModel attributeDescriptor, ImportParameters importParameters)
Description copied from class:AbstractExcelValueTranslator
Imports single value instead of whole Impex object. Impex value consists of header and value.- Specified by:
importValue
in classAbstractExcelValueTranslator<java.util.Collection<PriceRowModel>>
- Parameters:
attributeDescriptor
-AttributeDescriptorModel
describes attribute which should be importedimportParameters
- - contains information about language for localized field, type code, parsed parameters inserted into excel's cell.- Returns:
ImpexValue
value which should be imported
-
buildSinglePriceImpexValue
protected java.lang.String buildSinglePriceImpexValue(java.util.Map<java.lang.String,java.lang.String> params)
-
appendIfPresent
protected void appendIfPresent(java.lang.StringBuilder sb, java.lang.String value)
-
getImpexDateRange
protected java.lang.String getImpexDateRange(java.lang.String dateRange)
-
getExcelDateUtils
public ExcelDateUtils getExcelDateUtils()
-
setExcelDateUtils
public void setExcelDateUtils(ExcelDateUtils excelDateUtils)
-
-