Class ProductConfigurationServiceImpl
- java.lang.Object
-
- de.hybris.platform.sap.productconfig.services.impl.ProductConfigurationServiceImpl
-
- All Implemented Interfaces:
ProductConfigurationService
- Direct Known Subclasses:
ProductConfigurationRuleAwareServiceImpl
public class ProductConfigurationServiceImpl extends java.lang.Object implements ProductConfigurationService
Default implementation of theProductConfigurationService.
This implementation will synchronize access to theConfigurationProvider, 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.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringDEBUG_CONFIG_WITH_IDstatic java.lang.StringNOT_ALLOWED_TO_READ_CONFIGURATIONstatic java.lang.StringNOT_ALLOWED_TO_RELEASE_CONFIGURATIONstatic java.lang.StringNOT_ALLOWED_TO_UPDATE_CONFIGURATION
-
Constructor Summary
Constructors Constructor Description ProductConfigurationServiceImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected ConfigModelafterConfigCreated(ConfigModel config, ConfigurationRetrievalOptions retrievalOptions)protected ConfigModelafterDefaultConfigCreated(ConfigModel config)protected voidcacheConfig(ConfigModel config)intcalculateNumberOfIncompleteCsticsAndSolvableConflicts(java.lang.String configId)Get the number of errors (conflict, not filled mandatory fields), as it is set at the cart itemprotected voidcheckReadAllowed(java.lang.String configId)protected voidcheckReleaseAllowed(java.lang.String configId)protected voidcheckUpdateAllowed(ConfigModel model)protected voidcleanUpAfterEngineError(java.lang.String configId)protected intcountNumberOfIncompleteCstics(InstanceModel rootInstance)protected intcountNumberOfIncompleteVisibleCstics(CsticModel cstic)protected intcountNumberOfNotConsistentCstics(InstanceModel instance)protected intcountNumberOfSolvableConflicts(ConfigModel configModel)ConfigModelcreateConfigurationForVariant(java.lang.String baseProductCode, java.lang.String variantProductCode)Based on the hybris product code, the configuration engine will provide a configuration for the requested product variant.ConfigModelcreateConfigurationFromExternal(KBKey kbKey, java.lang.String externalConfiguration)Creates a configuration from the external string representation (which contains the configuration in XML format)ConfigModelcreateConfigurationFromExternal(KBKey kbKey, java.lang.String externalConfiguration, java.lang.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 keyConfigModelcreateConfigurationFromExternal(KBKey kbKey, java.lang.String externalConfiguration, java.lang.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 keyConfigModelcreateConfigurationFromExternalSource(Configuration extConfig)/** Create aConfigModelbased on aConfigurationfor the provided product code.ConfigModelcreateDefaultConfiguration(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 voidensureThatLockMapIsNotTooBig()KBKeyextractKbKey(java.lang.String productCode, java.lang.String externalConfig)Extracts the KBKey from the external configurationprotected ConfigurationAbstractOrderEntryLinkStrategygetAbstractOrderEntryLinkStrategy()protected ConfigurationAssignmentResolverStrategygetAssignmentResolverStrategy()protected ConfigurationLifecycleStrategygetConfigLifecycleStrategy()protected ConfigurationModelCacheStrategygetConfigModelCacheStrategy()protected ProductConfigurationOrderIntegrationServicegetConfigurationPricingOrderIntegrationService()protected ConfigurationProductUtilgetConfigurationProductUtil()protected ConfigurationProvidergetConfigurationProvider()protected CPQConfigurableCheckergetCpqConfigurableChecker()protected static java.lang.ObjectgetLock(java.lang.String configId)protected static intgetMaxLocksPerMap()protected ProductConfigurationAccessControlServicegetProductConfigurationAccessControlService()protected ProductConfigurationPricingStrategygetProductConfigurationPricingStrategy()protected ProviderFactorygetProviderFactory()protected TrackingRecordergetRecorder()intgetTotalNumberOfIssues(ConfigModel configModel)Returns the total number of issues (number of solvable conflicts + number of incomplete cstics)booleanhasKbForDate(java.lang.String productCode, java.util.Date kbDate)Checks whether a kb version exists for a given product and datebooleanhasKbForVersion(KBKey kbKey, java.lang.String externalConfig)Deprecated, for removal: This API element is subject to removal in a future version.since 18.08protected booleanisChangeableVariant(java.lang.String variantCode)booleanisKbVersionValid(KBKey kbKey)Checks whether kb version exists and is valid for specified dateprotected booleanisRelatedObjectReadOnly(java.lang.String configId, ConfigurationRetrievalOptions retrievalOptions)voidreleaseSession(java.lang.String configId)Releases the configuration sessions identified by the provided ID and all associated resources.voidreleaseSession(java.lang.String configId, boolean keepModel)Releases the configuration sessions identified by the provided ID and all associated resources.protected voidremoveConfigAttributesFromCache(java.lang.String configId)protected voidremoveConfigAttributesSessionFromCache(java.lang.String configId)Deprecated, for removal: This API element is subject to removal in a future version.since 18.11.0 - callremoveConfigAttributesFromCache(java.lang.String)insteadConfigModelretrieveConfigurationModel(java.lang.String configId)Retrieve the actual configuration model for the requestedconfigIdin theConfigModelformat.protected ConfigModelretrieveConfigurationModelFromConfigurationEngine(java.lang.String configId, ConfigurationRetrievalOptions options)protected ConfigurationRetrievalOptionsretrieveCorrectPricingDate(java.lang.String configId)java.lang.StringretrieveExternalConfiguration(java.lang.String configId)Retrieve the actual configuration model for the requestedconfigIdin a XML format.protected ProductConfigurationRelatedObjectTyperetrieveRelatedObjectType(java.lang.String configId, ConfigurationRetrievalOptions retrievalOptions)voidsetAbstractOrderEntryLinkStrategy(ConfigurationAbstractOrderEntryLinkStrategy configurationAbstractOrderEntryLinkStrategy)voidsetAssignmentResolverStrategy(ConfigurationAssignmentResolverStrategy assignmentResolverStrategy)voidsetConfigLifecycleStrategy(ConfigurationLifecycleStrategy configLifecycleStrategy)voidsetConfigModelCacheStrategy(ConfigurationModelCacheStrategy configModelCacheStrategy)voidsetConfigurationPricingOrderIntegrationService(ProductConfigurationOrderIntegrationService configurationPricingOrderIntegrationService)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)voidsetProductConfigurationPricingStrategy(ProductConfigurationPricingStrategy productConfigurationPricingStrategy)voidsetProviderFactory(ProviderFactory providerFactory)voidsetRecorder(TrackingRecorder recorder)voidupdateConfiguration(ConfigModel model)Update the configuration model within the configuration engine.protected voidupdateKbKeyForVariants(ConfigModel configModel, java.lang.String baseProductCode, java.lang.String variantCode)protected voidupdateKbKeyWithProductCode(ConfigModel configModel, java.lang.String productCode)
-
-
-
Field Detail
-
NOT_ALLOWED_TO_UPDATE_CONFIGURATION
public static final java.lang.String NOT_ALLOWED_TO_UPDATE_CONFIGURATION
- See Also:
- Constant Field Values
-
NOT_ALLOWED_TO_READ_CONFIGURATION
public static final java.lang.String NOT_ALLOWED_TO_READ_CONFIGURATION
- See Also:
- Constant Field Values
-
NOT_ALLOWED_TO_RELEASE_CONFIGURATION
public static final java.lang.String NOT_ALLOWED_TO_RELEASE_CONFIGURATION
- See Also:
- Constant Field Values
-
DEBUG_CONFIG_WITH_ID
protected static final java.lang.String DEBUG_CONFIG_WITH_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
createDefaultConfiguration
public ConfigModel createDefaultConfiguration(KBKey kbKey)
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
public void updateConfiguration(ConfigModel model)
Description copied from interface:ProductConfigurationServiceUpdate the configuration model within the configuration engine.- Specified by:
updateConfigurationin interfaceProductConfigurationService- Parameters:
model- Updated model
-
checkUpdateAllowed
protected void checkUpdateAllowed(ConfigModel model)
-
checkReadAllowed
protected void checkReadAllowed(java.lang.String configId)
-
retrieveConfigurationModel
public ConfigModel retrieveConfigurationModel(java.lang.String configId)
Description 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(java.lang.String configId, ConfigurationRetrievalOptions retrievalOptions)
-
retrieveRelatedObjectType
protected ProductConfigurationRelatedObjectType retrieveRelatedObjectType(java.lang.String configId, ConfigurationRetrievalOptions retrievalOptions)
-
retrieveCorrectPricingDate
protected ConfigurationRetrievalOptions retrieveCorrectPricingDate(java.lang.String configId)
-
retrieveConfigurationModelFromConfigurationEngine
protected ConfigModel retrieveConfigurationModelFromConfigurationEngine(java.lang.String configId, ConfigurationRetrievalOptions options)
-
updateKbKeyForVariants
protected void updateKbKeyForVariants(ConfigModel configModel, java.lang.String baseProductCode, java.lang.String variantCode)
-
isChangeableVariant
protected boolean isChangeableVariant(java.lang.String variantCode)
-
updateKbKeyWithProductCode
protected void updateKbKeyWithProductCode(ConfigModel configModel, java.lang.String productCode)
-
cleanUpAfterEngineError
protected void cleanUpAfterEngineError(java.lang.String configId)
-
retrieveExternalConfiguration
public java.lang.String retrieveExternalConfiguration(java.lang.String configId)
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
public void setProviderFactory(ProviderFactory providerFactory)
- 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
protected static java.lang.Object getLock(java.lang.String configId)
-
ensureThatLockMapIsNotTooBig
protected static void ensureThatLockMapIsNotTooBig()
-
afterDefaultConfigCreated
protected ConfigModel afterDefaultConfigCreated(ConfigModel config)
-
afterConfigCreated
protected ConfigModel afterConfigCreated(ConfigModel config, ConfigurationRetrievalOptions retrievalOptions)
-
createConfigurationFromExternal
public ConfigModel createConfigurationFromExternal(KBKey kbKey, java.lang.String externalConfiguration)
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, java.lang.String externalConfiguration, java.lang.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, java.lang.String externalConfiguration, java.lang.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
public ConfigModel createConfigurationFromExternalSource(Configuration extConfig)
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
public void releaseSession(java.lang.String configId)
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
public void releaseSession(java.lang.String configId, boolean keepModel)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
protected void checkReleaseAllowed(java.lang.String configId)
-
removeConfigAttributesFromCache
protected void removeConfigAttributesFromCache(java.lang.String configId)
-
removeConfigAttributesSessionFromCache
@Deprecated(since="1811", forRemoval=true) protected void removeConfigAttributesSessionFromCache(java.lang.String configId)Deprecated, for removal: This API element is subject to removal in a future version.since 18.11.0 - callremoveConfigAttributesFromCache(java.lang.String)instead
-
cacheConfig
protected void cacheConfig(ConfigModel config)
-
getProviderFactory
protected ProviderFactory getProviderFactory()
-
getConfigLifecycleStrategy
protected ConfigurationLifecycleStrategy getConfigLifecycleStrategy()
-
setConfigLifecycleStrategy
public void setConfigLifecycleStrategy(ConfigurationLifecycleStrategy configLifecycleStrategy)
-
getConfigModelCacheStrategy
protected ConfigurationModelCacheStrategy getConfigModelCacheStrategy()
-
setConfigModelCacheStrategy
public void setConfigModelCacheStrategy(ConfigurationModelCacheStrategy configModelCacheStrategy)
-
getAbstractOrderEntryLinkStrategy
protected ConfigurationAbstractOrderEntryLinkStrategy getAbstractOrderEntryLinkStrategy()
-
setAbstractOrderEntryLinkStrategy
public void setAbstractOrderEntryLinkStrategy(ConfigurationAbstractOrderEntryLinkStrategy configurationAbstractOrderEntryLinkStrategy)
-
calculateNumberOfIncompleteCsticsAndSolvableConflicts
public int calculateNumberOfIncompleteCsticsAndSolvableConflicts(java.lang.String configId)
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
protected int countNumberOfIncompleteCstics(InstanceModel rootInstance)
-
countNumberOfIncompleteVisibleCstics
protected int countNumberOfIncompleteVisibleCstics(CsticModel cstic)
-
countNumberOfNotConsistentCstics
protected int countNumberOfNotConsistentCstics(InstanceModel instance)
-
countNumberOfSolvableConflicts
protected int countNumberOfSolvableConflicts(ConfigModel configModel)
-
createConfigurationForVariant
public ConfigModel createConfigurationForVariant(java.lang.String baseProductCode, java.lang.String variantProductCode)
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
protected TrackingRecorder getRecorder()
-
setRecorder
public void setRecorder(TrackingRecorder recorder)
- Parameters:
recorder- inject the CPQ tracking recorder for tracking CPQ events
-
hasKbForDate
public boolean hasKbForDate(java.lang.String productCode, java.util.Date kbDate)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
public boolean isKbVersionValid(KBKey kbKey)
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
-
hasKbForVersion
@Deprecated(since="1808", forRemoval=true) public boolean hasKbForVersion(KBKey kbKey, java.lang.String externalConfig)Deprecated, for removal: This API element is subject to removal in a future version.since 18.08Description copied from interface:ProductConfigurationServiceChecks whether kb version specified in the external config still exists- Specified by:
hasKbForVersionin interfaceProductConfigurationService- Parameters:
kbKey- knowledgebase key which is used to extract product codeexternalConfig- external configuration- Returns:
- true if KB version specified in the external config exists
-
getConfigurationPricingOrderIntegrationService
protected ProductConfigurationOrderIntegrationService getConfigurationPricingOrderIntegrationService()
-
getConfigurationProvider
protected ConfigurationProvider getConfigurationProvider()
-
setConfigurationPricingOrderIntegrationService
public void setConfigurationPricingOrderIntegrationService(ProductConfigurationOrderIntegrationService configurationPricingOrderIntegrationService)
- Parameters:
configurationPricingOrderIntegrationService- the configurationPricingOrderIntegrationService to set
-
getTotalNumberOfIssues
public int getTotalNumberOfIssues(ConfigModel configModel)
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
-
getProductConfigurationPricingStrategy
protected ProductConfigurationPricingStrategy getProductConfigurationPricingStrategy()
-
setProductConfigurationPricingStrategy
public void setProductConfigurationPricingStrategy(ProductConfigurationPricingStrategy productConfigurationPricingStrategy)
- Parameters:
productConfigurationPricingStrategy- the productConfigurationPricingStrategy to set
-
extractKbKey
public KBKey extractKbKey(java.lang.String productCode, java.lang.String externalConfig)
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
protected ProductConfigurationAccessControlService getProductConfigurationAccessControlService()
-
getAssignmentResolverStrategy
protected ConfigurationAssignmentResolverStrategy getAssignmentResolverStrategy()
-
setAssignmentResolverStrategy
public void setAssignmentResolverStrategy(ConfigurationAssignmentResolverStrategy assignmentResolverStrategy)
-
getCpqConfigurableChecker
protected CPQConfigurableChecker getCpqConfigurableChecker()
-
setCpqConfigurableChecker
public void setCpqConfigurableChecker(CPQConfigurableChecker cpqConfigurableChecker)
-
getConfigurationProductUtil
protected ConfigurationProductUtil getConfigurationProductUtil()
-
setConfigurationProductUtil
public void setConfigurationProductUtil(ConfigurationProductUtil configurationProductUtil)
-
-