Class DefaultCommerceConsentService
- java.lang.Object
-
- de.hybris.platform.commerceservices.consent.impl.DefaultCommerceConsentService
-
- All Implemented Interfaces:
CommerceConsentService
public class DefaultCommerceConsentService extends java.lang.Object implements CommerceConsentService
Default implementation ofCommerceConsentService
-
-
Constructor Summary
Constructors Constructor Description DefaultCommerceConsentService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ConsentModel
createConsentModel(CustomerModel customer, ConsentTemplateModel consentTemplate)
ConsentModel
getActiveConsent(CustomerModel customer, ConsentTemplateModel consentTemplate)
Finds the latest consent for the specified customer and consent template.ConsentModel
getConsent(java.lang.String consentCode)
Finds the consent for the specifiedconsentCode
protected ConsentDao
getConsentDao()
ConsentTemplateModel
getConsentTemplate(java.lang.String consentTemplateId, java.lang.Integer consentTemplateVersion, BaseSiteModel baseSite)
Finds the consent template for the suppliedconsentTemplateId
,consentTemplateVersion
andbaseSite
.protected ConsentTemplateDao
getConsentTemplateDao()
java.util.List<ConsentTemplateModel>
getConsentTemplates(BaseSiteModel baseSite)
Finds all the latest versions of consent templates for the givenbaseSite
.protected EventService
getEventService()
ConsentTemplateModel
getLatestConsentTemplate(java.lang.String consentTemplateId, BaseSiteModel baseSite)
Finds the latest version of aConsentTemplate
for the givenconsentTemplateId
andbaseSite
.protected ModelService
getModelService()
protected TimeService
getTimeService()
protected UserService
getUserService()
void
giveConsent(CustomerModel customer, ConsentTemplateModel consentTemplate)
Gives consent for the specified customer and consent template.boolean
hasEffectivelyActiveConsent(CustomerModel customer, ConsentTemplateModel consentTemplate)
Checks if a customer has a consent that has not been withdrawn for the specified consent template.protected AbstractConsentEvent
initializeEvent(AbstractConsentEvent event, ConsentModel consent)
protected boolean
isConsentGiven(ConsentModel consent)
protected boolean
isConsentWithdrawn(ConsentModel consent)
void
setConsentDao(ConsentDao consentDao)
void
setConsentTemplateDao(ConsentTemplateDao consentTemplateDao)
void
setEventService(EventService eventService)
void
setModelService(ModelService modelService)
void
setTimeService(TimeService timeService)
void
setUserService(UserService userService)
void
withdrawConsent(ConsentModel consent)
Withdraws consent for the specified ConsentModel by updating the consentWithdrawnDate.
1.
-
-
-
Method Detail
-
getConsentTemplates
public java.util.List<ConsentTemplateModel> getConsentTemplates(BaseSiteModel baseSite)
Description copied from interface:CommerceConsentService
Finds all the latest versions of consent templates for the givenbaseSite
.- Specified by:
getConsentTemplates
in interfaceCommerceConsentService
- Parameters:
baseSite
- the baseSite to retrieve the consent template for- Returns:
- available consent templates
-
getConsentTemplate
public ConsentTemplateModel getConsentTemplate(java.lang.String consentTemplateId, java.lang.Integer consentTemplateVersion, BaseSiteModel baseSite)
Description copied from interface:CommerceConsentService
Finds the consent template for the suppliedconsentTemplateId
,consentTemplateVersion
andbaseSite
.- Specified by:
getConsentTemplate
in interfaceCommerceConsentService
- Parameters:
consentTemplateId
- the id of the consent templateconsentTemplateVersion
- the version of the consent templatebaseSite
- the baseSite to retrieve the consent template for- Returns:
- the consent template
-
getLatestConsentTemplate
public ConsentTemplateModel getLatestConsentTemplate(java.lang.String consentTemplateId, BaseSiteModel baseSite)
Description copied from interface:CommerceConsentService
Finds the latest version of aConsentTemplate
for the givenconsentTemplateId
andbaseSite
.- Specified by:
getLatestConsentTemplate
in interfaceCommerceConsentService
- Parameters:
consentTemplateId
- the id of the consent templatebaseSite
- the baseSite to retrieve the consent template for.- Returns:
- the consent template
-
getConsent
public ConsentModel getConsent(java.lang.String consentCode)
Description copied from interface:CommerceConsentService
Finds the consent for the specifiedconsentCode
- Specified by:
getConsent
in interfaceCommerceConsentService
- Parameters:
consentCode
- the consent code to get the consent for- Returns:
- the consent
-
getActiveConsent
public ConsentModel getActiveConsent(CustomerModel customer, ConsentTemplateModel consentTemplate)
Description copied from interface:CommerceConsentService
Finds the latest consent for the specified customer and consent template.- Specified by:
getActiveConsent
in interfaceCommerceConsentService
- Parameters:
customer
- the customer to get the consent forconsentTemplate
- the consent template to get the consent for- Returns:
- the consent if found, otherwise null
-
hasEffectivelyActiveConsent
public boolean hasEffectivelyActiveConsent(CustomerModel customer, ConsentTemplateModel consentTemplate)
Description copied from interface:CommerceConsentService
Checks if a customer has a consent that has not been withdrawn for the specified consent template.- Specified by:
hasEffectivelyActiveConsent
in interfaceCommerceConsentService
- Parameters:
customer
- the customer to check the consent forconsentTemplate
- the consent template to check the consent for- Returns:
- true, if the customer has a consent that has not been withdrawn
-
giveConsent
public void giveConsent(CustomerModel customer, ConsentTemplateModel consentTemplate)
Description copied from interface:CommerceConsentService
Gives consent for the specified customer and consent template. Creates a newConsent
and sets the consentGivenDate.
1. Doesn't create a new consent if the consent is already given and active and throwsCommerceConsentGivenException
- Specified by:
giveConsent
in interfaceCommerceConsentService
- Parameters:
customer
- the customer to give the consent forconsentTemplate
- the consent template to give the consent for
-
withdrawConsent
public void withdrawConsent(ConsentModel consent)
Description copied from interface:CommerceConsentService
Withdraws consent for the specified ConsentModel by updating the consentWithdrawnDate.
1. Doesn't withdraw the consent if its already withdrawn, i.e, IfConsent.consentWithdrawnDate
is already set calling this method will not overwrite the existing value.- Specified by:
withdrawConsent
in interfaceCommerceConsentService
- Parameters:
consent
- the consent to withdraw the consent for
-
isConsentWithdrawn
protected boolean isConsentWithdrawn(ConsentModel consent)
-
isConsentGiven
protected boolean isConsentGiven(ConsentModel consent)
-
createConsentModel
protected ConsentModel createConsentModel(CustomerModel customer, ConsentTemplateModel consentTemplate)
-
initializeEvent
protected AbstractConsentEvent initializeEvent(AbstractConsentEvent event, ConsentModel consent)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getTimeService
protected TimeService getTimeService()
-
setTimeService
public void setTimeService(TimeService timeService)
-
getConsentDao
protected ConsentDao getConsentDao()
-
setConsentDao
public void setConsentDao(ConsentDao consentDao)
-
getConsentTemplateDao
protected ConsentTemplateDao getConsentTemplateDao()
-
setConsentTemplateDao
public void setConsentTemplateDao(ConsentTemplateDao consentTemplateDao)
-
getEventService
protected EventService getEventService()
-
setEventService
public void setEventService(EventService eventService)
-
getUserService
protected UserService getUserService()
-
setUserService
public void setUserService(UserService userService)
-
-