use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto in project CzechIdMng by bcvsolutions.
the class DefaultConsoleNotificationSender method createLogForSend.
/**
* Create email log for send, this record is not persist.
*
* @param notification
* @param showGuardedString
* @return
*/
private IdmConsoleLogDto createLogForSend(IdmNotificationDto notification, boolean showGuardedString) {
Assert.notNull(notification);
Assert.notNull(notification.getMessage());
//
IdmConsoleLogDto notificationLog = new IdmConsoleLogDto();
notificationLog.setSent(new DateTime());
notificationLog.setParent(notification.getId());
// clone message
notificationLog.setMessage(getMessage(notification, showGuardedString));
// clone recipients - real recipient is console
notification.getRecipients().forEach(recipient -> {
notificationLog.getRecipients().add(new IdmNotificationRecipientDto(notificationLog.getId(), recipient.getIdentityRecipient(), IdmConsoleLog.NOTIFICATION_TYPE));
});
// clone from - resolve real email
notificationLog.setIdentitySender(notification.getIdentitySender());
return notificationLog;
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto in project CzechIdMng by bcvsolutions.
the class DefaultNotificationManager method createLog.
/**
* Persists new notification record from given notification.
* Input notification type is leaved unchanged - is needed for another processing (routing).
*
* @param notification
* @return
*/
private IdmNotificationLogDto createLog(IdmNotificationDto notification) {
Assert.notNull(notification);
Assert.notNull(notification.getMessage());
// IdmNotificationLog
if (notification instanceof IdmNotificationLogDto) {
notification.setSent(new DateTime());
IdmNotificationLogDto notificationLog = notificationLogService.save((IdmNotificationLogDto) notification);
// set previous type - is needed for choose correct notification sender
notificationLog.setType(notification.getType());
return notificationLog;
}
// we need to clone notification
IdmNotificationLogDto notificationLog = new IdmNotificationLogDto();
notificationLog.setType(notification.getType());
notificationLog.setSent(new DateTime());
// clone message
notificationLog.setMessage(cloneMessage(notification));
// clone recipients
for (IdmNotificationRecipientDto recipient : notification.getRecipients()) {
notificationLog.getRecipients().add(cloneRecipient(notificationLog, recipient, recipient.getRealRecipient()));
}
notificationLog.setIdentitySender(notification.getIdentitySender());
notificationLog = notificationLogService.save(notificationLog);
// set previous type - is needed for choose correct notification sender
notificationLog.setType(notification.getType());
return notificationLog;
}
Aggregations