Class ExcelGenericReferenceValidator
java.lang.Object
com.hybris.backoffice.excel.validators.ExcelGenericReferenceValidator
- All Implemented Interfaces:
ExcelValidator
- Direct Known Subclasses:
CatalogVersionPermissionValidator
Validator for
ExcelGenericReferenceTranslator The validator
tries to load all references and checks whether the references exist-
Field Summary
FieldsFields inherited from interface com.hybris.backoffice.excel.validators.ExcelValidator
CTX_MEDIA_CONTENT_ENTRIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<FlexibleSearchQuery>buildFlexibleSearchQuery(RequiredAttribute rootUniqueAttribute, Map<String, String> importParameters, Map context) booleancanHandle(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor) Validator can handle request only if call value is not emptyprotected TypeServiceprotected booleanisBlacklisted(AttributeDescriptorModel attribute) protected ValidationMessageprepareValidationMessage(RequiredAttribute rootUniqueAttribute, Map<String, String> importParameters) protected List<ValidationMessage>recursivelyValidateAllLevels(RequiredAttribute rootUniqueAttribute, ImportParameters importParameters, Map<String, Object> context) Recursively checks whether reference exist.voidsetBlacklistedTypes(Collection<String> blacklistedTypes) voidsetExcelWorkbookEntriesService(ExcelWorkbookEntriesService excelWorkbookEntriesService) voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService) voidsetRequiredAttributesFactory(RequiredAttributesFactory requiredAttributesFactory) voidsetTypeService(TypeService typeService) validate(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor, Map<String, Object> context) Validates given cell and returns validation result.validateRequiredAttribute(RequiredAttribute requiredAttribute, ImportParameters importParameters, Map<String, Object> context) Validates given cell and returns validation result.protected List<ValidationMessage>validateSingleLevel(RequiredAttribute rootUniqueAttribute, ImportParameters importParameters, Map<String, Object> context) Validates just single level without checking children.protected Optional<ValidationMessage>validateSingleValue(RequiredAttribute rootUniqueAttribute, Map<String, String> importParameters, Map<String, Object> context) This method validates just single value from single level.
-
Field Details
-
VALIDATION_MESSAGE_KEY
- See Also:
-
-
Constructor Details
-
ExcelGenericReferenceValidator
public ExcelGenericReferenceValidator()
-
-
Method Details
-
canHandle
public boolean canHandle(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor) Validator can handle request only if call value is not empty- Specified by:
canHandlein interfaceExcelValidator- Parameters:
importParameters-attributeDescriptor-- Returns:
- boolean whether validator can handle the cell.
-
isBlacklisted
-
validate
public ExcelValidationResult validate(ImportParameters importParameters, AttributeDescriptorModel attributeDescriptor, Map<String, Object> context) 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 interfaceExcelValidatorcontext- - map which can be used as a cache. The map is shared between all request for given excel sheet.- Returns:
ExcelValidationResult
-
validateRequiredAttribute
public ExcelValidationResult validateRequiredAttribute(RequiredAttribute requiredAttribute, ImportParameters importParameters, Map<String, Object> context) Validates given cell and returns validation result. If cell doesn't have validation issues thenExcelValidationResultwith no validation errors should be returned.- Parameters:
requiredAttribute- hierarchical structure of required attributesimportParameters- parsed parameters for given cellcontext- map which can be used as a cache. The map is shared between all request for given excel sheet.- Returns:
ExcelValidationResult
-
recursivelyValidateAllLevels
protected List<ValidationMessage> recursivelyValidateAllLevels(RequiredAttribute rootUniqueAttribute, ImportParameters importParameters, Map<String, Object> context) Recursively checks whether reference exist. The method starts checking references from the lowest descendant. If reference from lower level doesn't exist then process is stopped. For example, if given Catalog.id doesn't exist then reference for catalog version is not checked.- Parameters:
rootUniqueAttribute-importParameters-context-- Returns:
-
validateSingleLevel
protected List<ValidationMessage> validateSingleLevel(RequiredAttribute rootUniqueAttribute, ImportParameters importParameters, Map<String, Object> context) Validates just single level without checking children. This method is taking into account multi-values.- Parameters:
rootUniqueAttribute-importParameters-context-- Returns:
-
validateSingleValue
protected Optional<ValidationMessage> validateSingleValue(RequiredAttribute rootUniqueAttribute, Map<String, String> importParameters, Map<String, Object> context) This method validates just single value from single level. For example, it checks whether given catalog version exist. To check catalog version, the method assumes that all children's references are checked and stored in context.- Parameters:
rootUniqueAttribute-importParameters-context-- Returns:
-
prepareValidationMessage
protected ValidationMessage prepareValidationMessage(RequiredAttribute rootUniqueAttribute, Map<String, String> importParameters) -
buildFlexibleSearchQuery
protected Optional<FlexibleSearchQuery> buildFlexibleSearchQuery(RequiredAttribute rootUniqueAttribute, Map<String, String> importParameters, Map context) -
getRequiredAttributesFactory
-
setRequiredAttributesFactory
-
getFlexibleSearchService
-
setFlexibleSearchService
-
setExcelWorkbookEntriesService
-
setTypeService
-
getTypeService
-
setBlacklistedTypes
-