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 impexEurope1PricesTranslatorandEurope1PricesTranslator.Europe1PriceRowTranslatorto 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.NETTOand G forEurope1PricesTranslator.GROSSwhich 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.StringCHANNELstatic java.lang.StringEUROPE1_PRICE_HEADERDeprecated.since 1811, not used anymore.static java.lang.StringNET_GROSSstatic java.lang.StringPRICE_CURRENCYstatic java.lang.StringQUANTITY_UNITstatic java.lang.StringUSER_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 voidappendIfPresent(java.lang.StringBuilder sb, java.lang.String value)protected java.lang.StringbuildSinglePriceImpexValue(java.util.Map<java.lang.String,java.lang.String> params)booleancanHandle(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.StringexportPriceRow(PriceRowModel priceRow)protected java.lang.StringgetDateRange(StandardDateRange range)ExcelDateUtilsgetExcelDateUtils()protected java.lang.StringgetImpexDateRange(java.lang.String dateRange)protected <T> java.lang.StringgetValueOrEmpty(T reference, java.util.function.Function<T,java.lang.String> valueSupplier)ImpexValueimportValue(AttributeDescriptorModel attributeDescriptor, ImportParameters importParameters)Imports single value instead of whole Impex object.java.lang.StringreferenceFormat(AttributeDescriptorModel attributeDescriptor)Format how a reference should be presented.voidsetExcelDateUtils(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:ExcelValueTranslatorIndicates 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:ExcelValueTranslatorConverts 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:ExcelValueTranslatorFormat 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:AbstractExcelValueTranslatorImports single value instead of whole Impex object. Impex value consists of header and value.- Specified by:
importValuein classAbstractExcelValueTranslator<java.util.Collection<PriceRowModel>>- Parameters:
attributeDescriptor-AttributeDescriptorModeldescribes attribute which should be importedimportParameters- - contains information about language for localized field, type code, parsed parameters inserted into excel's cell.- Returns:
ImpexValuevalue 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)
-
-