@Component(value="blSkuCustomPersistenceHandler") public class SkuCustomPersistenceHandler extends CustomPersistenceHandlerAdapter
Modifier and Type | Field and Description |
---|---|
protected PersistenceModule |
adornedPersistenceModule |
protected CatalogService |
catalogService |
static String |
CONSOLIDATED_PRODUCT_OPTIONS_DELIMETER |
static String |
CONSOLIDATED_PRODUCT_OPTIONS_FIELD_NAME
This represents the field that all of the product option values will be stored in.
|
protected CriteriaTranslator |
criteriaTranslator |
protected javax.persistence.EntityManager |
em |
protected SkuCustomPersistenceHandlerExtensionManager |
extensionManager |
static String |
INVENTORY_ONLY_CRITERIA |
static String |
PRODUCT_OPTION_FIELD_PREFIX |
protected SandBoxHelper |
sandBoxHelper |
protected SkuMetadataCacheService |
skuMetadataCacheService |
protected boolean |
useToOneLookupSkuProductOptionValue |
DEFAULT_ORDER
Constructor and Description |
---|
SkuCustomPersistenceHandler() |
Modifier and Type | Method and Description |
---|---|
Entity |
add(PersistencePackage persistencePackage,
DynamicEntityDao dynamicEntityDao,
RecordHelper helper) |
void |
applyAdditionalFetchCriteria(List<FilterMapping> filterMappings,
CriteriaTransferObject cto,
PersistencePackage persistencePackage)
Available override point for subclasses if they would like to add additional criteria via the queryCritiera.
|
void |
applyProductOptionValueCriteria(List<FilterMapping> filterMappings,
CriteriaTransferObject cto,
PersistencePackage persistencePackage,
String skuPropertyPrefix) |
protected void |
associateProductOptionValuesToSku(Entity entity,
Sku adminInstance,
DynamicEntityDao dynamicEntityDao)
This initially removes all of the product option values that are currently related to the Sku and then re-associates
the
ProductOptionValue s |
protected Boolean |
canHandle(PersistencePackage persistencePackage,
OperationType operationType)
Since this is the default for all Skus, it's possible that we are providing custom criteria for this
Sku lookup.
|
Boolean |
canHandleAdd(PersistencePackage persistencePackage)
Is this persistence handler capable of dealing with an add request from the admin
|
Boolean |
canHandleFetch(PersistencePackage persistencePackage)
Is this persistence handler capable of dealing with an fetch request from the admin
|
Boolean |
canHandleInspect(PersistencePackage persistencePackage)
Is this persistence handler capable of dealing with an inspect request from the admin
|
Boolean |
canHandleUpdate(PersistencePackage persistencePackage)
Is this persistence handler capable of dealing with an update request from the admin
|
FieldMetadata |
createConsolidatedOptionField(Class<?> inheritedFromType)
Creates the metadata necessary for displaying all of the product option values in a single field.
|
protected FieldMetadata |
createExplicitEnumerationIndividualOptionField(ProductOption option,
int order) |
FieldMetadata |
createIndividualOptionField(ProductOption option,
int order)
Creates an individual property for the specified product option.
|
protected FieldMetadata |
createToOneIndividualOptionField(ProductOption option,
int order)
Using a ToOne lookup performs much better for large product option value lists, speeds up initial page load,
and is generally more accurate in relation to option value updates and how they impact available selections and cache.
|
DynamicResultSet |
fetch(PersistencePackage persistencePackage,
CriteriaTransferObject cto,
DynamicEntityDao dynamicEntityDao,
RecordHelper helper) |
protected void |
filterOutProductMetadata(Map<String,FieldMetadata> map) |
Property |
getBlankConsolidatedOptionProperty() |
Property |
getConsolidatedOptionProperty(Collection<ProductOptionValue> values)
Returns a
Property filled out with a delimited list of the values that are passed in. |
protected String |
getOwningProductId(SectionCrumb[] sectionCrumbs) |
protected String[] |
getPolymorphicClasses(Class<?> clazz,
javax.persistence.EntityManager em,
boolean useCache) |
protected List<Property> |
getProductOptionProperties(Entity entity) |
DynamicResultSet |
inspect(PersistencePackage persistencePackage,
DynamicEntityDao dynamicEntityDao,
InspectHelper helper)
Build out the extra fields for the product options
|
Entity |
update(PersistencePackage persistencePackage,
DynamicEntityDao dynamicEntityDao,
RecordHelper helper) |
void |
updateProductOptionFieldsForFetch(List<Serializable> records,
Entity[] payload)
Sets the
ProductOptionValue s of the given Sku s in a list format for display in a ListGrid context. |
protected Entity |
validateUniqueProductOptionValueCombination(Product product,
List<Property> productOptionProperties,
Sku currentSku)
Ensures that the given list of
ProductOptionValue IDs is unique for the given Product . |
canHandleRemove, getClassForName, getMetadata, getOrder, getResultSet, isAdornedListOperation, isAssignableFrom, isBasicOperation, isMapOperation, meetsCustomCriteria, remove, willHandleSecurity
public static String PRODUCT_OPTION_FIELD_PREFIX
public static String INVENTORY_ONLY_CRITERIA
@Value(value="${use.to.one.lookup.sku.product.option.value:false}") protected boolean useToOneLookupSkuProductOptionValue
protected SkuMetadataCacheService skuMetadataCacheService
protected PersistenceModule adornedPersistenceModule
protected SkuCustomPersistenceHandlerExtensionManager extensionManager
public static String CONSOLIDATED_PRODUCT_OPTIONS_FIELD_NAME
public static String CONSOLIDATED_PRODUCT_OPTIONS_DELIMETER
protected CatalogService catalogService
protected javax.persistence.EntityManager em
protected CriteriaTranslator criteriaTranslator
protected SandBoxHelper sandBoxHelper
public Boolean canHandleInspect(PersistencePackage persistencePackage)
CustomPersistenceHandler
canHandleInspect
in interface CustomPersistenceHandler
canHandleInspect
in class CustomPersistenceHandlerAdapter
persistencePackage
- details about the inspect operationpublic Boolean canHandleFetch(PersistencePackage persistencePackage)
CustomPersistenceHandler
canHandleFetch
in interface CustomPersistenceHandler
canHandleFetch
in class CustomPersistenceHandlerAdapter
persistencePackage
- details about the fetch operationpublic Boolean canHandleAdd(PersistencePackage persistencePackage)
CustomPersistenceHandler
canHandleAdd
in interface CustomPersistenceHandler
canHandleAdd
in class CustomPersistenceHandlerAdapter
persistencePackage
- details about the add operationpublic Boolean canHandleUpdate(PersistencePackage persistencePackage)
CustomPersistenceHandler
canHandleUpdate
in interface CustomPersistenceHandler
canHandleUpdate
in class CustomPersistenceHandlerAdapter
persistencePackage
- details about the update operationprotected Boolean canHandle(PersistencePackage persistencePackage, OperationType operationType)
public DynamicResultSet inspect(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, InspectHelper helper) throws ServiceException
inspect
in interface CustomPersistenceHandler
inspect
in class CustomPersistenceHandlerAdapter
ServiceException
protected String getOwningProductId(SectionCrumb[] sectionCrumbs)
protected void filterOutProductMetadata(Map<String,FieldMetadata> map)
public FieldMetadata createConsolidatedOptionField(Class<?> inheritedFromType)
inheritedFromType
- which type this should appear on. This would normally be SkuImpl.class, but if you want to
display this field with a different entity then this should be that entitypublic Property getConsolidatedOptionProperty(Collection<ProductOptionValue> values)
Property
filled out with a delimited list of the values that are passed in. This should be
invoked on a fetch and the returned property should be added to the fetched Entity
dto.values
- #createConsolidatedOptionField(Class)};
public Property getBlankConsolidatedOptionProperty()
Property
corresponding to the CONSOLIDATED_PRODUCT_OPTIONS_FIELD_NAMEpublic FieldMetadata createIndividualOptionField(ProductOption option, int order)
Creates an individual property for the specified product option. This should set up an enum field whose values will be the option values for this option. This is useful when you would like to display each product option in as its own field in a grid so that you can further filter by product option values.
In order for these fields to be utilized property on the fetch, in the GWT frontend you must use the for your datasource.
option
- order
- protected FieldMetadata createExplicitEnumerationIndividualOptionField(ProductOption option, int order)
protected FieldMetadata createToOneIndividualOptionField(ProductOption option, int order)
option
- order
- public DynamicResultSet fetch(PersistencePackage persistencePackage, CriteriaTransferObject cto, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException
fetch
in interface CustomPersistenceHandler
fetch
in class CustomPersistenceHandlerAdapter
ServiceException
public void updateProductOptionFieldsForFetch(List<Serializable> records, Entity[] payload)
ProductOptionValue
s of the given Sku
s in a list format for display in a ListGrid context.records
- payload
- public void applyProductOptionValueCriteria(List<FilterMapping> filterMappings, CriteriaTransferObject cto, PersistencePackage persistencePackage, String skuPropertyPrefix)
public void applyAdditionalFetchCriteria(List<FilterMapping> filterMappings, CriteriaTransferObject cto, PersistencePackage persistencePackage)
Available override point for subclasses if they would like to add additional criteria via the queryCritiera. At the point that this method has been called, criteria from the frontend has already been applied, thus allowing you to override from there as well.
Subclasses that choose to override this should also call this super method so that correct filter criteria can be applied for product option values
public Entity add(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException
add
in interface CustomPersistenceHandler
add
in class CustomPersistenceHandlerAdapter
ServiceException
public Entity update(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException
update
in interface CustomPersistenceHandler
update
in class CustomPersistenceHandlerAdapter
ServiceException
protected String[] getPolymorphicClasses(Class<?> clazz, javax.persistence.EntityManager em, boolean useCache)
getPolymorphicClasses
in class CustomPersistenceHandlerAdapter
protected void associateProductOptionValuesToSku(Entity entity, Sku adminInstance, DynamicEntityDao dynamicEntityDao)
ProductOptionValue
sentity
- adminInstance
- protected Entity validateUniqueProductOptionValueCombination(Product product, List<Property> productOptionProperties, Sku currentSku)
ProductOptionValue
IDs is unique for the given Product
.
If sku browsing is enabled, then it is assumed that a single combination of ProductOptionValue
IDs
is not unique and more than one Sku
could have the exact same combination of ProductOptionValue
IDs.
In this case, the following validation is skipped.product
- productOptionProperties
- currentSku
- - for update operations, this is the current Sku that is being updated; should be excluded from
attempting validationCopyright © 2022. All rights reserved.