use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationAttachmentFilter in project CzechIdMng by bcvsolutions.
the class IdmNotificationAttachmentControllerTest method testFindByText.
@Test
public void testFindByText() {
IdmNotificationAttachmentDto attachmentOne = createDto();
// other
createDto();
//
IdmNotificationAttachmentFilter filter = new IdmNotificationAttachmentFilter();
filter.setText(attachmentOne.getName());
List<IdmNotificationAttachmentDto> attachments = find(filter);
Assert.assertEquals(1, attachments.size());
Assert.assertTrue(attachments.stream().anyMatch(r -> r.getId().equals(attachmentOne.getId())));
}
use of eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationAttachmentFilter in project CzechIdMng by bcvsolutions.
the class AbstractNotificationLogService method deleteInternal.
@Override
@Transactional
public void deleteInternal(DTO dto) {
Assert.notNull(dto, "Notification is required.");
UUID notificationId = dto.getId();
Assert.notNull(notificationId, "Notification identifier is required.");
//
try {
//
// delete recipients is done by hiberante mapping - see IdmNotification
//
// delete notification attachments
IdmNotificationAttachmentFilter notificationAttachmentFilter = new IdmNotificationAttachmentFilter();
notificationAttachmentFilter.setNotification(notificationId);
notificationAttachmentService.find(notificationAttachmentFilter, null).forEach(notificationAttachmentService::delete);
//
// delete attachments - owned by notification only
attachmentManager.deleteAttachments(dto);
//
// delete child notifications ...
F filter = getFilterClass().getDeclaredConstructor().newInstance();
filter.setParent(notificationId);
find(filter, null).getContent().forEach(this::delete);
//
super.deleteInternal(dto);
} catch (ReflectiveOperationException ex) {
throw new CoreException(String.format("Service [%s] has wrong filter, fix implemented filter class [%s] (add default constructor).", this.getClass(), getFilterClass()), ex);
}
}
Aggregations