Class JpaNotificationStateService
- java.lang.Object
-
- com.broadleafcommerce.common.messaging.notification.DefaultNotificationStateService
-
- com.broadleafcommerce.data.tracking.jpa.messaging.notification.JpaNotificationStateService
-
- All Implemented Interfaces:
com.broadleafcommerce.common.messaging.notification.NotificationStateService,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class JpaNotificationStateService extends com.broadleafcommerce.common.messaging.notification.DefaultNotificationStateService implements org.springframework.context.ApplicationContextAwareThe implementation for theJpaNotificationState.- Author:
- Dima Myroniuk (dmyroniuk)
-
-
Constructor Summary
Constructors Constructor Description JpaNotificationStateService(com.broadleafcommerce.common.extension.TypeFactory typeFactory, NotificationStateValueUpdater repository, com.broadleafcommerce.common.extension.data.DataRouteReference reference, List<org.springframework.orm.jpa.EntityManagerFactoryInfo> factories, org.springframework.boot.autoconfigure.cache.CacheProperties cacheProperties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JpaNotificationStateServiceget()com.broadleafcommerce.common.messaging.notification.domain.NotificationStategetOrInitializeNotificationState(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, String name)List<com.broadleafcommerce.common.messaging.notification.domain.NotificationState>readFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware)Given aNotificationStateAwareimplementing entity instance, retrieve the list ofNotificationStateinstances associated.voidsaveFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, javax.persistence.EntityManager em)Persist all theNotificationStateinstances built up in the entity'sNotificationStateAware.getNotificationStates()related list.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
-
-
Constructor Detail
-
JpaNotificationStateService
public JpaNotificationStateService(com.broadleafcommerce.common.extension.TypeFactory typeFactory, NotificationStateValueUpdater repository, com.broadleafcommerce.common.extension.data.DataRouteReference reference, List<org.springframework.orm.jpa.EntityManagerFactoryInfo> factories, org.springframework.boot.autoconfigure.cache.CacheProperties cacheProperties)
-
-
Method Detail
-
get
public static JpaNotificationStateService get()
-
setApplicationContext
public void setApplicationContext(@NonNull org.springframework.context.ApplicationContext applicationContext)- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
getOrInitializeNotificationState
public com.broadleafcommerce.common.messaging.notification.domain.NotificationState getOrInitializeNotificationState(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, String name)- Specified by:
getOrInitializeNotificationStatein interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateService- Overrides:
getOrInitializeNotificationStatein classcom.broadleafcommerce.common.messaging.notification.DefaultNotificationStateService
-
readFrom
public List<com.broadleafcommerce.common.messaging.notification.domain.NotificationState> readFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware)
Given aNotificationStateAwareimplementing entity instance, retrieve the list ofNotificationStateinstances associated. This is necessary in Jpa, since these instances are managed separately from the entity itself.- Parameters:
stateAware- The entity instance that may be related to one or moreNotificationStateinstances.- Returns:
- The list of resolved
NotificationStateinstances.
-
saveFrom
public void saveFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, javax.persistence.EntityManager em)Persist all theNotificationStateinstances built up in the entity'sNotificationStateAware.getNotificationStates()related list. This list is generally manipulated during various mapping operations during the lifecycle of a service call. Since notification state instances are managed separately from the entity itself, calling here is required to have those notification states be persisted. This method is generally called fromJpaTrackableRepository.save(Trackable, ContextInfo), or in save overrides in customized repositories that deal withNotificationStateAwareimplementing domain classes. This method also requires a valid entity manager instance be passed from the calling repository instance (either JpaTrackableRepository or custom repository fragment) in order to guarantee matching data route and transaction behavior, if applicable. SeeJpaDataRoutefor more information.- Parameters:
stateAware- The entity to review for anyNotificationStateinstances to persist.em- The entity manager to use for the persistence.
-
-