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.String
DEBUG_CONFIG_WITH_ID
static java.lang.String
NOT_ALLOWED_TO_READ_CONFIGURATION
static java.lang.String
NOT_ALLOWED_TO_RELEASE_CONFIGURATION
static java.lang.String
NOT_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 ConfigModel
afterConfigCreated(ConfigModel config, ConfigurationRetrievalOptions retrievalOptions)
protected ConfigModel
afterDefaultConfigCreated(ConfigModel config)
protected void
cacheConfig(ConfigModel config)
int
calculateNumberOfIncompleteCsticsAndSolvableConflicts(java.lang.String configId)
Get the number of errors (conflict, not filled mandatory fields), as it is set at the cart itemprotected void
checkReadAllowed(java.lang.String configId)
protected void
checkReleaseAllowed(java.lang.String configId)
protected void
checkUpdateAllowed(ConfigModel model)
protected void
cleanUpAfterEngineError(java.lang.String configId)
protected int
countNumberOfIncompleteCstics(InstanceModel rootInstance)
protected int
countNumberOfIncompleteVisibleCstics(CsticModel cstic)
protected int
countNumberOfNotConsistentCstics(InstanceModel instance)
protected int
countNumberOfSolvableConflicts(ConfigModel configModel)
ConfigModel
createConfigurationForVariant(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.ConfigModel
createConfigurationFromExternal(KBKey kbKey, java.lang.String externalConfiguration)
Creates a configuration from the external string representation (which contains the configuration in XML format)ConfigModel
createConfigurationFromExternal(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 keyConfigModel
createConfigurationFromExternal(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 keyConfigModel
createConfigurationFromExternalSource(Configuration extConfig)
/** Create aConfigModel
based on aConfiguration
for the provided product code.ConfigModel
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 void
ensureThatLockMapIsNotTooBig()
KBKey
extractKbKey(java.lang.String productCode, java.lang.String externalConfig)
Extracts the KBKey from the external configurationprotected ConfigurationAbstractOrderEntryLinkStrategy
getAbstractOrderEntryLinkStrategy()
protected ConfigurationAssignmentResolverStrategy
getAssignmentResolverStrategy()
protected ConfigurationLifecycleStrategy
getConfigLifecycleStrategy()
protected ConfigurationModelCacheStrategy
getConfigModelCacheStrategy()
protected ProductConfigurationOrderIntegrationService
getConfigurationPricingOrderIntegrationService()
protected ConfigurationProductUtil
getConfigurationProductUtil()
protected ConfigurationProvider
getConfigurationProvider()
protected CPQConfigurableChecker
getCpqConfigurableChecker()
protected static java.lang.Object
getLock(java.lang.String configId)
protected static int
getMaxLocksPerMap()
protected ProductConfigurationAccessControlService
getProductConfigurationAccessControlService()
protected ProductConfigurationPricingStrategy
getProductConfigurationPricingStrategy()
protected ProviderFactory
getProviderFactory()
protected TrackingRecorder
getRecorder()
int
getTotalNumberOfIssues(ConfigModel configModel)
Returns the total number of issues (number of solvable conflicts + number of incomplete cstics)boolean
hasKbForDate(java.lang.String productCode, java.util.Date kbDate)
Checks whether a kb version exists for a given product and dateboolean
hasKbForVersion(KBKey kbKey, java.lang.String externalConfig)
Deprecated, for removal: This API element is subject to removal in a future version.since 18.08protected boolean
isChangeableVariant(java.lang.String variantCode)
boolean
isKbVersionValid(KBKey kbKey)
Checks whether kb version exists and is valid for specified dateprotected boolean
isRelatedObjectReadOnly(java.lang.String configId, ConfigurationRetrievalOptions retrievalOptions)
void
releaseSession(java.lang.String configId)
Releases the configuration sessions identified by the provided ID and all associated resources.void
releaseSession(java.lang.String configId, boolean keepModel)
Releases the configuration sessions identified by the provided ID and all associated resources.protected void
removeConfigAttributesFromCache(java.lang.String configId)
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)
insteadConfigModel
retrieveConfigurationModel(java.lang.String configId)
Retrieve the actual configuration model for the requestedconfigId
in theConfigModel
format.protected ConfigModel
retrieveConfigurationModelFromConfigurationEngine(java.lang.String configId, ConfigurationRetrievalOptions options)
protected ConfigurationRetrievalOptions
retrieveCorrectPricingDate(java.lang.String configId)
java.lang.String
retrieveExternalConfiguration(java.lang.String configId)
Retrieve the actual configuration model for the requestedconfigId
in a XML format.protected ProductConfigurationRelatedObjectType
retrieveRelatedObjectType(java.lang.String configId, ConfigurationRetrievalOptions retrievalOptions)
void
setAbstractOrderEntryLinkStrategy(ConfigurationAbstractOrderEntryLinkStrategy configurationAbstractOrderEntryLinkStrategy)
void
setAssignmentResolverStrategy(ConfigurationAssignmentResolverStrategy assignmentResolverStrategy)
void
setConfigLifecycleStrategy(ConfigurationLifecycleStrategy configLifecycleStrategy)
void
setConfigModelCacheStrategy(ConfigurationModelCacheStrategy configModelCacheStrategy)
void
setConfigurationPricingOrderIntegrationService(ProductConfigurationOrderIntegrationService configurationPricingOrderIntegrationService)
void
setConfigurationProductUtil(ConfigurationProductUtil configurationProductUtil)
void
setCpqConfigurableChecker(CPQConfigurableChecker cpqConfigurableChecker)
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.void
setProductConfigurationAccessControlService(ProductConfigurationAccessControlService productConfigurationAccessControlService)
void
setProductConfigurationPricingStrategy(ProductConfigurationPricingStrategy productConfigurationPricingStrategy)
void
setProviderFactory(ProviderFactory providerFactory)
void
setRecorder(TrackingRecorder recorder)
void
updateConfiguration(ConfigModel model)
Update the configuration model within the configuration engine.protected void
updateKbKeyForVariants(ConfigModel configModel, java.lang.String baseProductCode, java.lang.String variantCode)
protected void
updateKbKeyWithProductCode(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:ProductConfigurationService
Based on the hybris product code, provided via theKBKey.productCode
, the configuration engine will provide a default configuration for the requested product.- Specified by:
createDefaultConfiguration
in 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:ProductConfigurationService
Update the configuration model within the configuration engine.- Specified by:
updateConfiguration
in 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:ProductConfigurationService
Retrieve the actual configuration model for the requestedconfigId
in theConfigModel
format.- Specified by:
retrieveConfigurationModel
in 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:ProductConfigurationService
Retrieve the actual configuration model for the requestedconfigId
in a XML format.- Specified by:
retrieveExternalConfiguration
in 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:ProductConfigurationService
Creates a configuration from the external string representation (which contains the configuration in XML format)- Specified by:
createConfigurationFromExternal
in 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:ProductConfigurationService
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- Specified by:
createConfigurationFromExternal
in 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:ProductConfigurationService
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- Specified by:
createConfigurationFromExternal
in 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 aConfigModel
based on aConfiguration
for the provided product code.- Specified by:
createConfigurationFromExternalSource
in interfaceProductConfigurationService
- Parameters:
extConfig
- Configuration in a data structure- Returns:
- Configuration model
-
releaseSession
public void releaseSession(java.lang.String configId)
Description copied from interface:ProductConfigurationService
Releases the configuration sessions identified by the provided ID and all associated resources. Accessing the session afterwards is not possible anymore.- Specified by:
releaseSession
in interfaceProductConfigurationService
- Parameters:
configId
- session id
-
releaseSession
public void releaseSession(java.lang.String configId, boolean keepModel)
Description copied from interface:ProductConfigurationService
Releases the configuration sessions identified by the provided ID and all associated resources. Accessing the session afterwards is not possible anymore.- Specified by:
releaseSession
in 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:ProductConfigurationService
Get the number of errors (conflict, not filled mandatory fields), as it is set at the cart item- Specified by:
calculateNumberOfIncompleteCsticsAndSolvableConflicts
in 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:ProductConfigurationService
Based on the hybris product code, the configuration engine will provide a configuration for the requested product variant.- Specified by:
createConfigurationForVariant
in 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:ProductConfigurationService
Checks whether a kb version exists for a given product and date- Specified by:
hasKbForDate
in 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:ProductConfigurationService
Checks whether kb version exists and is valid for specified date- Specified by:
isKbVersionValid
in 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:ProductConfigurationService
Checks whether kb version specified in the external config still exists- Specified by:
hasKbForVersion
in 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:ProductConfigurationService
Returns the total number of issues (number of solvable conflicts + number of incomplete cstics)- Specified by:
getTotalNumberOfIssues
in 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:ProductConfigurationService
Extracts the KBKey from the external configuration- Specified by:
extractKbKey
in 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)
-
-