Class AbstractDomainEventService
java.lang.Object
es.kukenan.smartfi.microservice.communication.service.messaging.AbstractDomainEventService
- Direct Known Subclasses:
FirmEventService,NotificationCreatedEventService,NotificationService,NotificationSettingService,OnboardingDomainEventService,SecurityGatewayEventService,TransferSuccessfulService,UserContractDocumentEventService,UserPasswordResetEventService
This abstract class owns the logic that is in common for all domain events processing. It should be extended by any domain event handling service.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSome notifications configured to be send - as destination - to the CAT may be required in a context that a real user does not exist - at least yet -.static final StringThe language to use when searching templates for messages destined to CAT virtual user.static final StringThe CAT user identifier prefix.private CompanyRepositorySpring repository with the methods to access theCompanydatabase table.private EventRepositorySpring repository with the methods to access theEventdatabase table.private MessagesRepositorySpring repository with the methods to access theEventdatabase table.protected NotificationSenderServiceCommon notifications service.private UsersRepositorySpring repository with the methods to access theUserdatabase table. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected UsercreateVirtualUserForCatDestination(int companyId) Create a user with the information in the event.protected StringeventTypeDescriptor(es.kukenan.smartfi.events.common.AbstractEvent<?> event) Get the full event descriptor used to search the related messages.findMessages(String eventTypeName, Company company) Finds the messages for a given event type id.protected UserfindRealUser(String userId, int companyId) Find a user.protected UserfindRealUserFromOnboarding(String userId) Find a user.private UserfindUser(es.kukenan.smartfi.events.common.AbstractEvent event) Finds a user affected by the event.protected voidhandleGenericNotificationEvent(es.kukenan.smartfi.events.common.AbstractEvent event, Map<String, Object> variables) Send the messages corresponding to the given onboarding event.protected voidhandleGenericNotificationEvent(es.kukenan.smartfi.events.common.AbstractEvent event, Map<String, Object> variables, Boolean ignorePrimaryChannel) Send the messages corresponding to the given onboarding event.toMessageSpecialProperties(List<Message> messages, Boolean ignorePrimaryChannel) Create a MessageSpecialProperties list from Message list.
-
Field Details
-
CAT_DESTINATION_PREFIX
Some notifications configured to be send - as destination - to the CAT may be required in a context that a real user does not exist - at least yet -. This will be the case when we receive anEventwith the next prefix in theuserId. Due to the database model - that requires the user in the event to exist - if we do not handle this special case message delivering will fail.- See Also:
-
CAT_USER
The CAT user identifier prefix. THe company ID must be added as suffix.- See Also:
-
CAT_LANG
The language to use when searching templates for messages destined to CAT virtual user.- See Also:
-
companyRepository
Spring repository with the methods to access theCompanydatabase table. -
eventRepository
Spring repository with the methods to access theEventdatabase table. -
usersRepository
Spring repository with the methods to access theUserdatabase table. -
messagesRepository
Spring repository with the methods to access theEventdatabase table. -
notificationService
Common notifications service.
-
-
Constructor Details
-
AbstractDomainEventService
public AbstractDomainEventService()
-
-
Method Details
-
handleGenericNotificationEvent
protected void handleGenericNotificationEvent(es.kukenan.smartfi.events.common.AbstractEvent event, Map<String, Object> variables) Send the messages corresponding to the given onboarding event.- Parameters:
event- the event.variables- additional variables that the mail template will be able to use. This argument is mandatory and must be modifiable.
-
handleGenericNotificationEvent
protected void handleGenericNotificationEvent(es.kukenan.smartfi.events.common.AbstractEvent event, Map<String, Object> variables, Boolean ignorePrimaryChannel) Send the messages corresponding to the given onboarding event.- Parameters:
event- the event.variables- additional variables that the mail template will be able to use. This argument is mandatory and must be modifiable.ignorePrimaryChannel- indicates if the primary channel should be ignored.
-
toMessageSpecialProperties
public List<MessagesRequest.MessageSpecialProperties> toMessageSpecialProperties(List<Message> messages, Boolean ignorePrimaryChannel) Create a MessageSpecialProperties list from Message list.- Parameters:
messages- listignorePrimaryChannel- indicates if the primary channel should be ignored for the message- Returns:
- MessageSpecialProperties list
-
findMessages
Finds the messages for a given event type id.- Parameters:
eventTypeName- the event type identifier.company- the company the message must been have designed for.- Returns:
- the user found.
InvalidCallExceptionif the event type is not registered or user is found.
-
findUser
Finds a user affected by the event.- Parameters:
event- the event.- Returns:
- the user found.
UnexpectedExceptionif there is no user information or the user does not exist.
-
createVirtualUserForCatDestination
Create a user with the information in the event. The ID will be set to match the virtual CAT user so notifications will be able to be stored.- Parameters:
companyId- the user company, must be consistent.- Returns:
- a virtual user.
-
findRealUser
Find a user.- Parameters:
userId- the user id, required and the user must exist.companyId- the user company, must be consistent.- Returns:
- the user found.
UnexpectedExceptionif the user does not exist or does not belong to the given company.
-
findRealUserFromOnboarding
Find a user.- Parameters:
userId- the user id, required and the user must exist.- Returns:
- the user found.
UnexpectedExceptionif the user does not exist or does not belong to the given company.
-
eventTypeDescriptor
Get the full event descriptor used to search the related messages.- Parameters:
event- the domain event.- Returns:
- the full event type descriptor.
-