Class ExcelCategoryValidator
- java.lang.Object
-
- com.hybris.backoffice.excel.validators.ExcelCategoryValidator
-
- All Implemented Interfaces:
ExcelValidator
public class ExcelCategoryValidator extends java.lang.Object implements ExcelValidator
Default excel validator for product's supercategories. The validator checks whether import parameters contains "category" key, whether category exists and the category belongs to given catalog and version. This validator doesn't check whether catalog and version exist. To do this, addExcelCatalogVersionValidatorto a list of validators.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCATEGORY_PATTERNprotected static java.lang.StringVALIDATION_CATEGORY_DOESNT_MATCHprotected static java.lang.StringVALIDATION_CATEGORY_EMPTY-
Fields inherited from interface com.hybris.backoffice.excel.validators.ExcelValidator
CTX_MEDIA_CONTENT_ENTRIES
-
-
Constructor Summary
Constructors Constructor Description ExcelCategoryValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanHandle(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor)Indicates whether given validator can handle a cell based on attribute descriptor and import parameters.protected java.util.Optional<CategoryModel>findValueInCache(java.util.Map<java.lang.String,java.lang.Object> ctx, java.util.Map<java.lang.String,java.lang.String> parameters)CatalogVersionServicegetCatalogVersionService()CategoryServicegetCategoryService()protected java.lang.StringgetFormattedCategory(java.util.Map<java.lang.String,java.lang.String> parameters)voidsetCatalogVersionService(CatalogVersionService catalogVersionService)voidsetCategoryService(CategoryService categoryService)ExcelValidationResultvalidate(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor, java.util.Map<java.lang.String,java.lang.Object> ctx)Validates given cell and returns validation result.protected java.util.Optional<ValidationMessage>validateSingleValue(java.util.Map<java.lang.String,java.lang.Object> ctx, java.util.Map<java.lang.String,java.lang.String> parameters)
-
-
-
Field Detail
-
CATEGORY_PATTERN
protected static final java.lang.String CATEGORY_PATTERN
- See Also:
- Constant Field Values
-
VALIDATION_CATEGORY_DOESNT_MATCH
protected static final java.lang.String VALIDATION_CATEGORY_DOESNT_MATCH
- See Also:
- Constant Field Values
-
VALIDATION_CATEGORY_EMPTY
protected static final java.lang.String VALIDATION_CATEGORY_EMPTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
validate
public ExcelValidationResult validate(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor, java.util.Map<java.lang.String,java.lang.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
protected java.util.Optional<ValidationMessage> validateSingleValue(java.util.Map<java.lang.String,java.lang.Object> ctx, java.util.Map<java.lang.String,java.lang.String> parameters)
-
findValueInCache
protected java.util.Optional<CategoryModel> findValueInCache(java.util.Map<java.lang.String,java.lang.Object> ctx, java.util.Map<java.lang.String,java.lang.String> parameters)
-
getFormattedCategory
protected java.lang.String getFormattedCategory(java.util.Map<java.lang.String,java.lang.String> parameters)
-
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.
-
getCatalogVersionService
public CatalogVersionService getCatalogVersionService()
-
setCatalogVersionService
public void setCatalogVersionService(CatalogVersionService catalogVersionService)
-
getCategoryService
public CategoryService getCategoryService()
-
setCategoryService
public void setCategoryService(CategoryService categoryService)
-
-