use of eu.bcvsolutions.idm.core.model.entity.IdmRoleRequest_ in project CzechIdMng by bcvsolutions.
the class RoleRequestNotificationProcessor method sendNotification.
/**
* Send notification to applicant and implementer
*
* @param request
*/
private void sendNotification(IdmRoleRequestDto request) {
UUID requestId = request.getId();
Assert.notNull(requestId, "Role request has to persisted before notification is sent.");
boolean sendNotificationToApplicant = configurationService.getBooleanValue(WorkflowConfig.SEND_NOTIFICATION_TO_APPLICANT_CONFIGURATION_PROPERTY, true);
boolean sendNotificationToImplementer = configurationService.getBooleanValue(WorkflowConfig.SEND_NOTIFICATION_TO_IMPLEMENTER_CONFIGURATION_PROPERTY, false);
// Transform created date
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(ConfigurationService.DEFAULT_APP_DATETIME_FORMAT);
String from = request.getCreated().format(dateFormat);
List<IdmConceptRoleRequestDto> concepts = conceptRoleRequestService.findAllByRoleRequest(request.getId());
Set<IdmConceptRoleRequestDto> addedRoles = //
concepts.stream().filter(//
concept -> ConceptRoleRequestOperation.ADD == concept.getOperation()).collect(//
Collectors.toSet());
Set<IdmConceptRoleRequestDto> changedRoles = //
concepts.stream().filter(//
concept -> ConceptRoleRequestOperation.UPDATE == concept.getOperation()).collect(//
Collectors.toSet());
Set<IdmConceptRoleRequestDto> removedRoles = //
concepts.stream().filter(//
concept -> ConceptRoleRequestOperation.REMOVE == concept.getOperation()).collect(//
Collectors.toSet());
IdmIdentityDto applicantIdentity = DtoUtils.getEmbedded(request, IdmRoleRequest_.applicant.getName(), IdmIdentityDto.class);
IdmIdentityDto implementerIdentity = identityService.get(request.getCreatorId());
if (implementerIdentity.equals(applicantIdentity)) {
// implementer and applicant is same identity
if (sendNotificationToImplementer || sendNotificationToApplicant) {
send(CoreModuleDescriptor.TOPIC_REQUEST_REALIZED_IMPLEMENTER, request, from, addedRoles, changedRoles, removedRoles, applicantIdentity, implementerIdentity);
}
} else {
// Send notification to applicant
if (sendNotificationToApplicant) {
send(CoreModuleDescriptor.TOPIC_REQUEST_REALIZED_APPLICANT, request, from, addedRoles, changedRoles, removedRoles, applicantIdentity, applicantIdentity);
}
// Send notification to implementer
if (sendNotificationToImplementer) {
send(CoreModuleDescriptor.TOPIC_REQUEST_REALIZED_IMPLEMENTER, request, from, addedRoles, changedRoles, removedRoles, applicantIdentity, implementerIdentity);
}
}
}
Aggregations