Class ProductConfigurationServiceImpl
java.lang.Object
de.hybris.platform.sap.productconfig.services.impl.ProductConfigurationServiceImpl
- All Implemented Interfaces:
ProductConfigurationService
- Direct Known Subclasses:
ProductConfigurationRuleAwareServiceImpl
Default implementation of the
This implementation will synchronize access to the
ProductConfigurationService.This implementation will synchronize access to the
ConfigurationProvider, so that it is guaranteed that only
exactly one thread will access the configuration provider for a given configuration session. Furthermore a simple
session based read cache ensures that subsequent calls to read the same configuration result only into exactly one
read request to the configuration engine.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadjustConfigurationModel(ConfigModel config, String productCode, boolean overviewOnly) protected ConfigModelafterConfigCreated(ConfigModel config, ConfigurationRetrievalOptions retrievalOptions) protected ConfigModelafterDefaultConfigCreated(ConfigModel config) protected voidcacheConfig(ConfigModel config) intGet the number of errors (conflict, not filled mandatory fields), as it is set at the cart itemprotected voidcheckReadAllowed(String configId) protected voidcheckReleaseAllowed(String configId) protected voidcheckUpdateAllowed(ConfigModel model) protected voidcleanUpAfterEngineError(String configId) intcountNumberOfIncompleteCstics(InstanceModel rootInstance) Returns the number of incomplete csticsprotected intprotected intintcountNumberOfSolvableConflicts(ConfigModel configModel) Returns the number of inconsistent cstics (solvable conflicts)createConfigurationForVariant(String baseProductCode, String variantProductCode) Based on the hybris product code, the configuration engine will provide a configuration for the requested product variant.createConfigurationFromExternal(KBKey kbKey, String externalConfiguration) Creates a configuration from the external string representation (which contains the configuration in XML format)createConfigurationFromExternal(KBKey kbKey, String externalConfiguration, String cartEntryKey) Creates a configuration from the external string representation (which contains the configuration in XML format) and links it immediately with the given cart entry keycreateConfigurationFromExternal(KBKey kbKey, String externalConfiguration, String cartEntryKey, ConfigurationRetrievalOptions retrievalOptions) Creates a configuration from the external string representation (which contains the configuration in XML format) and links it immediately with the given cart entry key/** Create aConfigModelbased on aConfigurationfor the provided product code.createDefaultConfiguration(KBKey kbKey) Based on the hybris product code, provided via theKBKey.productCode, the configuration engine will provide a default configuration for the requested product.protected static voidextractKbKey(String productCode, String externalConfig) Extracts the KBKey from the external configurationprotected ConfigurationAssignmentResolverStrategyprotected ConfigurationLifecycleStrategyprotected ConfigurationModelCacheStrategyprotected ConfigurationProductUtilprotected ConfigurationProviderprotected CPQConfigurableCheckerprotected static ReentrantLockprotected static intprotected ProductConfigurationAccessControlServiceprotected ProviderFactoryprotected TrackingRecorderintgetTotalNumberOfIssues(ConfigModel configModel) Returns the total number of issues (number of solvable conflicts + number of incomplete cstics)booleanhasKbForDate(String productCode, Date kbDate) Checks whether a kb version exists for a given product and dateprotected booleanisChangeableVariant(String variantCode) protected booleanisEnrichModelWithGroupRequired(String currentGroup, boolean overviewOnly, ConfigModel configModel) booleanisKbVersionValid(KBKey kbKey) Checks whether kb version exists and is valid for specified dateprotected booleanprotected booleanprotected booleanisRelatedObjectReadOnly(String configId, ConfigurationRetrievalOptions retrievalOptions) voidreleaseSession(String configId) Releases the configuration sessions identified by the provided ID and all associated resources.voidreleaseSession(String configId, boolean keepModel) Releases the configuration sessions identified by the provided ID and all associated resources.protected voidremoveConfigAttributesFromCache(String configId) retrieveConfigurationModel(String configId) Deprecated, for removal: This API element is subject to removal in a future version.retrieveConfigurationModel(String configId, String currentGroup) Reads the entire configuration without domain values, except for the given groupId, in contrast toProductConfigurationService.retrieveConfigurationModel(String)which reads all domain values for all groups.protected ConfigModelretrieveConfigurationModel(String configId, String currentGroup, boolean overviewOnly) protected ConfigModelretrieveConfigurationModelFromConfigurationEngine(String configId, ConfigurationRetrievalOptions options) protected ConfigModelretrieveConfigurationModelFromConfigurationEngine(String configId, String groupId, boolean overviewOnly, ConfigurationRetrievalOptions options) protected ConfigModelretrieveConfigurationModelFromConfigurationEngineScenarioBased(String configId, String currentGroup, boolean overviewOnly, ConfigurationRetrievalOptions options) retrieveConfigurationOverview(String configId) Reads entire configuration without domain values.protected ConfigurationRetrievalOptionsretrieveCorrectPricingDate(String configId) retrieveExternalConfiguration(String configId) Retrieve the actual configuration model for the requestedconfigIdin a XML format.protected ProductConfigurationRelatedObjectTyperetrieveRelatedObjectType(String configId, ConfigurationRetrievalOptions retrievalOptions) voidsetAbstractOrderEntryLinkStrategy(ConfigurationAbstractOrderEntryLinkStrategy configurationAbstractOrderEntryLinkStrategy) voidsetAssignmentResolverStrategy(ConfigurationAssignmentResolverStrategy assignmentResolverStrategy) voidsetConfigLifecycleStrategy(ConfigurationLifecycleStrategy configLifecycleStrategy) voidsetConfigModelCacheStrategy(ConfigurationModelCacheStrategy configModelCacheStrategy) voidsetConfigurationProductUtil(ConfigurationProductUtil configurationProductUtil) voidsetCpqConfigurableChecker(CPQConfigurableChecker cpqConfigurableChecker) static voidsetMaxLocksPerMap(int maxLocksPerMap) A configuration provider lock ensures, that there are no concurrent requests send to the configuration engine for the same configuration session.
We might not always get informed when a configuration session is released, hence we do not rely on this.voidsetProductConfigurationAccessControlService(ProductConfigurationAccessControlService productConfigurationAccessControlService) voidsetProviderFactory(ProviderFactory providerFactory) voidsetReadDomainValuesOnDemand(boolean readDomainValuesOnDemand) voidsetRecorder(TrackingRecorder recorder) voidupdateConfiguration(ConfigModel model) Update the configuration model within the configuration engine.protected voidupdateKbKeyForVariants(ConfigModel configModel, String baseProductCode, String variantCode) protected voidupdateKbKeyWithProductCode(ConfigModel configModel, String productCode)
-
Field Details
-
NOT_ALLOWED_TO_UPDATE_CONFIGURATION
- See Also:
-
NOT_ALLOWED_TO_READ_CONFIGURATION
- See Also:
-
NOT_ALLOWED_TO_RELEASE_CONFIGURATION
- See Also:
-
DEBUG_CONFIG_WITH_ID
- See Also:
-
RETRIEVED_FROM_CACHE
- See Also:
-
RETRIEVING_CONFIGURATION_FAILED
- See Also:
-
DEFAULT_MAX_LOCKS_PER_MAP
public static final int DEFAULT_MAX_LOCKS_PER_MAP- See Also:
-
MAP_INITIAL_CAPACITY_CALCULATE_DIVISOR
public static final double MAP_INITIAL_CAPACITY_CALCULATE_DIVISOR- See Also:
-
-
Constructor Details
-
ProductConfigurationServiceImpl
public ProductConfigurationServiceImpl()
-
-
Method Details
-
createDefaultConfiguration
Description copied from interface:ProductConfigurationServiceBased on the hybris product code, provided via theKBKey.productCode, the configuration engine will provide a default configuration for the requested product.- Specified by:
createDefaultConfigurationin interfaceProductConfigurationService- Parameters:
kbKey- The product code for the configurable product- Returns:
- The configurable product with default configuration
-
updateConfiguration
Description copied from interface:ProductConfigurationServiceUpdate the configuration model within the configuration engine.- Specified by:
updateConfigurationin interfaceProductConfigurationService- Parameters:
model- Updated model
-
checkUpdateAllowed
-
checkReadAllowed
-
retrieveConfigurationModel
@Deprecated(since="2211", forRemoval=true) public ConfigModel retrieveConfigurationModel(String configId) Deprecated, for removal: This API element is subject to removal in a future version.since 2211 - useProductConfigurationService.retrieveConfigurationModel(String, String)insteadDescription copied from interface:ProductConfigurationServiceRetrieve the actual configuration model for the requestedconfigIdin theConfigModelformat.- Specified by:
retrieveConfigurationModelin interfaceProductConfigurationService- Parameters:
configId- Unique configuration ID- Returns:
- The actual configuration
-
isRelatedObjectReadOnly
protected boolean isRelatedObjectReadOnly(String configId, ConfigurationRetrievalOptions retrievalOptions) -
retrieveRelatedObjectType
protected ProductConfigurationRelatedObjectType retrieveRelatedObjectType(String configId, ConfigurationRetrievalOptions retrievalOptions) -
retrieveCorrectPricingDate
-
retrieveConfigurationModelFromConfigurationEngine
protected ConfigModel retrieveConfigurationModelFromConfigurationEngine(String configId, ConfigurationRetrievalOptions options) -
updateKbKeyForVariants
protected void updateKbKeyForVariants(ConfigModel configModel, String baseProductCode, String variantCode) -
isChangeableVariant
-
updateKbKeyWithProductCode
-
cleanUpAfterEngineError
-
retrieveExternalConfiguration
Description copied from interface:ProductConfigurationServiceRetrieve the actual configuration model for the requestedconfigIdin a XML format.- Specified by:
retrieveExternalConfigurationin interfaceProductConfigurationService- Parameters:
configId- Unique configuration ID- Returns:
- The actual configuration as XML string
-
setProviderFactory
- Parameters:
providerFactory- inject factory to access the providers
-
setMaxLocksPerMap
public static void setMaxLocksPerMap(int maxLocksPerMap) A configuration provider lock ensures, that there are no concurrent requests send to the configuration engine for the same configuration session.
We might not always get informed when a configuration session is released, hence we do not rely on this. Instead we just keep a maximum number of locks and release the oldest locks, when there are to many. The maximum number can be configured by this setter.
A look can be re-created in case it had already been deleted. The number should be high enough, so that locks do not get deleted while some concurrent threads are still using the lock, as this could cause concurrency issue. The maximum number heavily depends on the number of concurrent threads expected. Default is 1024.- Parameters:
maxLocksPerMap- sets the maximum number of Configuration Provider Locks kept.
-
getMaxLocksPerMap
protected static int getMaxLocksPerMap() -
getLock
-
ensureThatLockMapIsNotTooBig
protected static void ensureThatLockMapIsNotTooBig() -
afterDefaultConfigCreated
-
afterConfigCreated
protected ConfigModel afterConfigCreated(ConfigModel config, ConfigurationRetrievalOptions retrievalOptions) -
createConfigurationFromExternal
Description copied from interface:ProductConfigurationServiceCreates a configuration from the external string representation (which contains the configuration in XML format)- Specified by:
createConfigurationFromExternalin interfaceProductConfigurationService- Parameters:
kbKey- Key attributes needed to create a modelexternalConfiguration- Configuration as XML string- Returns:
- Configuration model
-
createConfigurationFromExternal
public ConfigModel createConfigurationFromExternal(KBKey kbKey, String externalConfiguration, String cartEntryKey) Description copied from interface:ProductConfigurationServiceCreates a configuration from the external string representation (which contains the configuration in XML format) and links it immediately with the given cart entry key- Specified by:
createConfigurationFromExternalin interfaceProductConfigurationService- Parameters:
kbKey- Key attributes needed to create a modelexternalConfiguration- Configuration as XML stringcartEntryKey- cartEntryKey this config belongs to- Returns:
- Configuration model
-
createConfigurationFromExternal
public ConfigModel createConfigurationFromExternal(KBKey kbKey, String externalConfiguration, String cartEntryKey, ConfigurationRetrievalOptions retrievalOptions) Description copied from interface:ProductConfigurationServiceCreates a configuration from the external string representation (which contains the configuration in XML format) and links it immediately with the given cart entry key- Specified by:
createConfigurationFromExternalin interfaceProductConfigurationService- Parameters:
kbKey- Key attributes needed to create a modelexternalConfiguration- Configuration as XML stringcartEntryKey- cartEntryKey this config belongs toretrievalOptions- options to modify behavior- Returns:
- Configuration model
-
createConfigurationFromExternalSource
Description copied from interface:ProductConfigurationService/** Create aConfigModelbased on aConfigurationfor the provided product code.- Specified by:
createConfigurationFromExternalSourcein interfaceProductConfigurationService- Parameters:
extConfig- Configuration in a data structure- Returns:
- Configuration model
-
releaseSession
Description copied from interface:ProductConfigurationServiceReleases the configuration sessions identified by the provided ID and all associated resources. Accessing the session afterwards is not possible anymore.- Specified by:
releaseSessionin interfaceProductConfigurationService- Parameters:
configId- session id
-
releaseSession
Description copied from interface:ProductConfigurationServiceReleases the configuration sessions identified by the provided ID and all associated resources. Accessing the session afterwards is not possible anymore.- Specified by:
releaseSessionin interfaceProductConfigurationService- Parameters:
configId- session idkeepModel- signifies whether config model should be kept despite releasing session
-
checkReleaseAllowed
-
removeConfigAttributesFromCache
-
cacheConfig
-
getProviderFactory
-
getConfigLifecycleStrategy
-
setConfigLifecycleStrategy
-
getConfigModelCacheStrategy
-
setConfigModelCacheStrategy
-
getAbstractOrderEntryLinkStrategy
-
setAbstractOrderEntryLinkStrategy
public void setAbstractOrderEntryLinkStrategy(ConfigurationAbstractOrderEntryLinkStrategy configurationAbstractOrderEntryLinkStrategy) -
calculateNumberOfIncompleteCsticsAndSolvableConflicts
Description copied from interface:ProductConfigurationServiceGet the number of errors (conflict, not filled mandatory fields), as it is set at the cart item- Specified by:
calculateNumberOfIncompleteCsticsAndSolvableConflictsin interfaceProductConfigurationService- Parameters:
configId- id of the configuration- Returns:
- Total number of errors
-
countNumberOfIncompleteCstics
Description copied from interface:ProductConfigurationServiceReturns the number of incomplete cstics- Specified by:
countNumberOfIncompleteCsticsin interfaceProductConfigurationService- Parameters:
rootInstance- InstanceModel- Returns:
- number of incomplete cstics
-
countNumberOfIncompleteVisibleCstics
-
countNumberOfNotConsistentCstics
-
countNumberOfSolvableConflicts
Description copied from interface:ProductConfigurationServiceReturns the number of inconsistent cstics (solvable conflicts)- Specified by:
countNumberOfSolvableConflictsin interfaceProductConfigurationService- Parameters:
configModel- ConfigModel- Returns:
- number of inconsistent cstics
-
createConfigurationForVariant
Description copied from interface:ProductConfigurationServiceBased on the hybris product code, the configuration engine will provide a configuration for the requested product variant.- Specified by:
createConfigurationForVariantin interfaceProductConfigurationService- Parameters:
baseProductCode- The product code for the configurable base productvariantProductCode- The product code for the specific product variant- Returns:
- The configurable product with default configuration
-
getRecorder
-
setRecorder
- Parameters:
recorder- inject the CPQ tracking recorder for tracking CPQ events
-
hasKbForDate
Description copied from interface:ProductConfigurationServiceChecks whether a kb version exists for a given product and date- Specified by:
hasKbForDatein interfaceProductConfigurationService- Parameters:
productCode- product codekbDate- date of the knowledgebase- Returns:
- true if KB version for the date exists
-
isKbVersionValid
Description copied from interface:ProductConfigurationServiceChecks whether kb version exists and is valid for specified date- Specified by:
isKbVersionValidin interfaceProductConfigurationService- Parameters:
kbKey- knowledgebase key- Returns:
- true if KB version exists and is valid
-
getConfigurationProvider
-
getTotalNumberOfIssues
Description copied from interface:ProductConfigurationServiceReturns the total number of issues (number of solvable conflicts + number of incomplete cstics)- Specified by:
getTotalNumberOfIssuesin interfaceProductConfigurationService- Parameters:
configModel- configuration model- Returns:
- total number of issues
-
extractKbKey
Description copied from interface:ProductConfigurationServiceExtracts the KBKey from the external configuration- Specified by:
extractKbKeyin interfaceProductConfigurationService- Parameters:
productCode- product codeexternalConfig- external config- Returns:
- returns the kBKey of the given external config
-
setProductConfigurationAccessControlService
public void setProductConfigurationAccessControlService(ProductConfigurationAccessControlService productConfigurationAccessControlService) - Parameters:
productConfigurationAccessControlService-
-
getProductConfigurationAccessControlService
-
getAssignmentResolverStrategy
-
setAssignmentResolverStrategy
public void setAssignmentResolverStrategy(ConfigurationAssignmentResolverStrategy assignmentResolverStrategy) -
getCpqConfigurableChecker
-
setCpqConfigurableChecker
-
getConfigurationProductUtil
-
setConfigurationProductUtil
-
retrieveConfigurationModelFromConfigurationEngine
protected ConfigModel retrieveConfigurationModelFromConfigurationEngine(String configId, String groupId, boolean overviewOnly, ConfigurationRetrievalOptions options) -
retrieveConfigurationModel
Description copied from interface:ProductConfigurationServiceReads the entire configuration without domain values, except for the given groupId, in contrast toProductConfigurationService.retrieveConfigurationModel(String)which reads all domain values for all groups. Hence this method will execute faster.- Specified by:
retrieveConfigurationModelin interfaceProductConfigurationService- Parameters:
configId- runtime configuration idcurrentGroup- for which domain values are calculated and fetched- Returns:
- config model without domain values, except for the given groupId
-
retrieveConfigurationModel
protected ConfigModel retrieveConfigurationModel(String configId, String currentGroup, boolean overviewOnly) -
retrieveConfigurationOverview
Description copied from interface:ProductConfigurationServiceReads entire configuration without domain values. So this call can be used when the actual data of the configuration is required, without offering to change it.- Specified by:
retrieveConfigurationOverviewin interfaceProductConfigurationService- Parameters:
configId- runtime configuration id- Returns:
- entire config model without domain values
-
isReadDomainValuesOnDemand
protected boolean isReadDomainValuesOnDemand()- Returns:
- the readDomainValuesOnDemand
-
setReadDomainValuesOnDemand
public void setReadDomainValuesOnDemand(boolean readDomainValuesOnDemand) - Parameters:
readDomainValuesOnDemand- the readDomainValuesOnDemand to set
-
adjustConfigurationModel
protected void adjustConfigurationModel(ConfigModel config, String productCode, boolean overviewOnly) -
retrieveConfigurationModelFromConfigurationEngineScenarioBased
protected ConfigModel retrieveConfigurationModelFromConfigurationEngineScenarioBased(String configId, String currentGroup, boolean overviewOnly, ConfigurationRetrievalOptions options) -
isReadDomainValuesOnDemandSupported
protected boolean isReadDomainValuesOnDemandSupported() -
isEnrichModelWithGroupRequired
protected boolean isEnrichModelWithGroupRequired(String currentGroup, boolean overviewOnly, ConfigModel configModel)
-
ProductConfigurationService.retrieveConfigurationModel(String, String)instead