Search in sources :

Example 6 with IdmNotificationAttachmentFilter

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())));
}
Also used : IdmNotificationAttachmentDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationAttachmentDto) NotificationManager(eu.bcvsolutions.idm.core.notification.api.service.NotificationManager) IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmNotificationConfigurationService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationConfigurationService) Lists(com.google.common.collect.Lists) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) NotificationConfigurationDto(eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmNotificationAttachmentFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationAttachmentFilter) NotificationLevel(eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) UUID(java.util.UUID) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) IdmNotificationTemplateService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationTemplateService) IdmEmailLog(eu.bcvsolutions.idm.core.notification.entity.IdmEmailLog) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) IdmNotificationAttachmentService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationAttachmentService) IdmNotificationAttachmentDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationAttachmentDto) IdmNotificationAttachmentFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationAttachmentFilter) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) Test(org.junit.Test)

Example 7 with IdmNotificationAttachmentFilter

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);
    }
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) IdmNotificationAttachmentFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationAttachmentFilter) UUID(java.util.UUID) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdmNotificationAttachmentFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationAttachmentFilter)7 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 IdmNotificationAttachmentDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationAttachmentDto)6 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)6 Test (org.junit.Test)6 Lists (com.google.common.collect.Lists)5 IdmAttachmentDto (eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto)5 AttachmentManager (eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager)5 DefaultAttachmentManagerIntegrationTest (eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest)5 NotificationLevel (eu.bcvsolutions.idm.core.notification.api.domain.NotificationLevel)5 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)5 IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)5 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)5 IdmNotificationAttachmentService (eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationAttachmentService)5 IdmNotificationConfigurationService (eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationConfigurationService)5 IdmNotificationLogService (eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService)5 IdmNotificationTemplateService (eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationTemplateService)5 NotificationManager (eu.bcvsolutions.idm.core.notification.api.service.NotificationManager)5 IdmEmailLog (eu.bcvsolutions.idm.core.notification.entity.IdmEmailLog)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5