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, addExcelCatalogVersionValidator
to a list of validators.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
CATEGORY_PATTERN
protected static java.lang.String
VALIDATION_CATEGORY_DOESNT_MATCH
protected static java.lang.String
VALIDATION_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 boolean
canHandle(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)
CatalogVersionService
getCatalogVersionService()
CategoryService
getCategoryService()
protected java.lang.String
getFormattedCategory(java.util.Map<java.lang.String,java.lang.String> parameters)
void
setCatalogVersionService(CatalogVersionService catalogVersionService)
void
setCategoryService(CategoryService categoryService)
ExcelValidationResult
validate(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:ExcelValidator
Validates given cell and returns validation result. If cell doesn't have validation issues thenExcelValidationResult.SUCCESS
should be returned.- Specified by:
validate
in interfaceExcelValidator
ctx
- - 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:ExcelValidator
Indicates whether given validator can handle a cell based on attribute descriptor and import parameters.- Specified by:
canHandle
in 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)
-
-