Class ExcelEurope1PricesValidator
java.lang.Object
com.hybris.backoffice.excel.validators.ExcelEurope1PricesValidator
- All Implemented Interfaces:
ExcelValidator
Validates prices for
ExcelEurope1PricesTypeTranslator.
Format:price currency:'N'|'G':user|userPriceGroup:quantity unit:[dateFrom to dateTo]:channel
Validator checks if:
- price is defined and given currency exists
- Netto | Gross are in correct format
- user or userPriceGroup exists
- unit exists and if user or userPriceGroup is provided this field is mandatory
- dateFrom and dateTo are in correct format
ExcelDateUtils.getDateTimeFormat()and dateFrom is not after dateTo - defined channel exists
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringstatic final Patternstatic final Patternstatic final Patternprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface com.hybris.backoffice.excel.validators.ExcelValidator
CTX_MEDIA_CONTENT_ENTRIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanHandle(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor) Indicates whether given validator can handle a cell based on attribute descriptor and import parameters.protected booleancheckIfCurrencyExist(Map<String, Object> ctx, String currency) protected booleancontainsCurrency(Map<String, Object> ctx, String currency) protected booleancontainsUnit(Map<String, Object> ctx, String unit) protected Dateprotected voidpopulateContext(Map<String, Object> ctx) voidsetCurrencyDao(CurrencyDao currencyDao) voidsetEnumerationService(EnumerationService enumerationService) voidsetExcelDateUtils(ExcelDateUtils excelDateUtils) voidsetUnitService(UnitService unitService) voidsetUserService(UserService userService) validate(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor, Map<String, Object> ctx) Validates given cell and returns validation result.protected Optional<ValidationMessage>validateChannel(String channel) protected Optional<ValidationMessage>validateCurrency(Map<String, Object> ctx, String currency) protected Optional<ValidationMessage>validateDateRange(String dateRange) protected Optional<ValidationMessage>validateNetGross(String netGross) protected Optional<List<ValidationMessage>>validatePrice(Map<String, Object> ctx, String value) protected Optional<ValidationMessage>validatePriceValue(String price) protected Optional<ValidationMessage>validateQuantity(String quantity) protected Optional<List<ValidationMessage>>protected List<ValidationMessage>protected Optional<ValidationMessage>validateUnit(Map<String, Object> ctx, String unit) protected Optional<ValidationMessage>validateUserPriceGroup(String groupOrUser)
-
Field Details
-
UNIT_KEY
- See Also:
-
CURRENCY_KEY
- See Also:
-
PATTERN_PRICE_CURRENCY
-
PATTERN_QUANTITY_UNIT
-
PATTERN_DATE_RANGE
-
VALIDATION_CURRENCY_DOESNT_EXIST
- See Also:
-
VALIDATION_INCORRECT_PRICE_CURRENCY
- See Also:
-
VALIDATION_EMPTY_PRICE_CURRENCY
- See Also:
-
VALIDATION_INCORRECT_PRICE_VALUE
- See Also:
-
VALIDATION_INVALID_NET_GROSS
- See Also:
-
VALIDATION_INCORRECT_QUANTITY_UNIT
- See Also:
-
VALIDATION_INCORRECT_QUANTITY
- See Also:
-
VALIDATION_INCORRECT_UNIT
- See Also:
-
VALIDATION_INCORRECT_QUANTITY_LOWE_THAN_ONE
- See Also:
-
VALIDATION_INCORRECT_USER_OR_USER_PRICE_GROUP
- See Also:
-
VALIDATION_QUANTITY_UNIT_CANNOT_BE_EMPTY_WHEN_USER_DEFINED
- See Also:
-
VALIDATION_NO_SUCH_CHANNEL
- See Also:
-
VALIDATION_INCORRECT_DATE_RANGE
- See Also:
-
VALIDATION_START_DATE_AFTER_END_DATE
- See Also:
-
-
Constructor Details
-
ExcelEurope1PricesValidator
public ExcelEurope1PricesValidator()
-
-
Method Details
-
validate
public ExcelValidationResult validate(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor, Map<String, Object> ctx) Description copied from interface:ExcelValidatorValidates given cell and returns validation result. If cell doesn't have validation issues thenExcelValidationResult.SUCCESSshould be returned.- Specified by:
validatein interfaceExcelValidatorctx- - map which can be used as a cache. The map is shared between all request for given excel sheet.- Returns:
ExcelValidationResult
-
validateSingleValue
-
validatePrice
-
validatePriceValue
-
validateCurrency
-
validateNetGross
-
validateUserPriceGroup
-
validateDateRange
-
parseDate
-
validateChannel
-
validateQuantityUnit
-
validateQuantity
-
validateUnit
-
containsCurrency
-
containsUnit
-
populateContext
-
checkIfCurrencyExist
-
canHandle
public boolean canHandle(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor) Description copied from interface:ExcelValidatorIndicates whether given validator can handle a cell based on attribute descriptor and import parameters.- Specified by:
canHandlein interfaceExcelValidator- Returns:
- boolean whether validator can handle the cell.
-
getCurrencyDao
-
setCurrencyDao
-
getUnitService
-
setUnitService
-
getEnumerationService
-
setEnumerationService
-
getUserService
-
setUserService
-
getExcelDateUtils
-
setExcelDateUtils
-