Class 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 impex Europe1PricesTranslator and Europe1PricesTranslator.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 for Europe1PricesTranslator.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 in ExcelDateUtils.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
    Examples:
    • 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()
    Under the hood Above examples are translated into format accepted by 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
    • Constructor Detail

      • ExcelEurope1PricesTypeTranslator

        public ExcelEurope1PricesTypeTranslator()
    • Method Detail

      • 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
      • 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)
      • setExcelDateUtils

        public void setExcelDateUtils​(ExcelDateUtils excelDateUtils)