Search in sources :

Example 1 with RptReportFilter

use of eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter in project CzechIdMng by bcvsolutions.

the class ReportDeleteBulkActionIntegrationTest method processBulkActionByFilter.

@Test
public void processBulkActionByFilter() {
    List<RptReportDto> reports = createReports(5);
    RptReportFilter filter = new RptReportFilter();
    filter.setId(reports.get(2).getId());
    List<RptReportDto> checkReports = service.find(filter, null).getContent();
    Assert.assertEquals(1, checkReports.size());
    IdmBulkActionDto bulkAction = findBulkAction(RptReport.class, ReportDeleteBulkAction.NAME);
    bulkAction.setTransformedFilter(filter);
    bulkAction.setFilter(toMap(filter));
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    Assert.assertNull(service.get(reports.get(2)));
    Assert.assertNotNull(service.get(reports.get(1)));
    Assert.assertNotNull(service.get(reports.get(3)));
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) RptReportFilter(eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 2 with RptReportFilter

use of eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter in project CzechIdMng by bcvsolutions.

the class DefaultRptReportManagerIntegrationTest method testRerunReportWithFilter.

@Test
@SuppressWarnings("rawtypes")
public void testRerunReportWithFilter() throws IOException {
    RptReportDto report = new RptReportDto();
    report.setExecutorName(TestFilterReportExecutor.REPORT_NAME);
    IdmFormDto filter = new IdmFormDto();
    TestFilterReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestFilterReportExecutor.class);
    IdmFormDefinitionDto definition = testReportExecutor.getFormDefinition();
    IdmFormValueDto usernameOne = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentity_.username.getName()));
    usernameOne.setValue(TestReportExecutor.identities.get(0).getUsername());
    filter.getValues().add(usernameOne);
    IdmFormValueDto usernameTwo = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentity_.username.getName()));
    usernameTwo.setValue(getHelper().createName());
    filter.getValues().add(usernameTwo);
    filter.setFormDefinition(definition.getId());
    report.setFilter(filter);
    // 
    report = manager.generate(report);
    final UUID reportId = report.getId();
    Assert.assertNotNull(reportId);
    Assert.assertNotNull(report.getData());
    InputStream is = attachmentManager.getAttachmentData(report.getData());
    try {
        Assert.assertEquals(mapper.writeValueAsString(Lists.newArrayList(TestReportExecutor.identities.get(0))), IOUtils.toString(is));
    } finally {
        IOUtils.closeQuietly(is);
    }
    // 
    // filter is propaged to LRT properly
    report = reportService.get(reportId);
    Assert.assertNotNull(report.getLongRunningTask());
    IdmLongRunningTaskDto longRunningTask = taskManager.getLongRunningTask(report.getLongRunningTask());
    List propertyValue = (List) longRunningTask.getTaskProperties().get(IdmIdentity_.username.getName());
    Assert.assertNotNull(propertyValue);
    Assert.assertTrue(propertyValue.contains(TestReportExecutor.identities.get(0).getUsername()));
    Assert.assertTrue(propertyValue.contains(usernameTwo.getValue()));
    // 
    // rerun long running task
    LongRunningFutureTask<?> recover = taskManager.recover(longRunningTask.getId());
    UUID recoveredTask = recover.getExecutor().getLongRunningTaskId();
    Assert.assertNotNull(recoveredTask);
    Assert.assertNotEquals(longRunningTask.getId(), recoveredTask);
    longRunningTask = taskManager.getLongRunningTask(recoveredTask);
    Assert.assertEquals(OperationState.EXECUTED, longRunningTask.getResultState());
    propertyValue = (List) longRunningTask.getTaskProperties().get(IdmIdentity_.username.getName());
    Assert.assertNotNull(propertyValue);
    Assert.assertTrue(propertyValue.contains(TestReportExecutor.identities.get(0).getUsername()));
    Assert.assertTrue(propertyValue.contains(usernameTwo.getValue()));
    // 
    RptReportFilter reportFilter = new RptReportFilter();
    reportFilter.setLongRunningTaskId(recoveredTask);
    List<RptReportDto> recoveredReports = reportService.find(reportFilter, null).getContent();
    Assert.assertEquals(1, recoveredReports.size());
    RptReportDto recoveredReport = recoveredReports.get(0);
    Assert.assertEquals(OperationState.EXECUTED, recoveredReport.getResult().getState());
    // recoveredReport.getFilter().
    IdmFormInstanceDto reportProperties = new IdmFormInstanceDto(recoveredReport, testFilterReportExecutor.getFormDefinition(), recoveredReport.getFilter());
    List<Serializable> persistentValues = reportProperties.toPersistentValues(IdmIdentity_.username.getName());
    Assert.assertEquals(2, persistentValues.size());
    Assert.assertTrue(persistentValues.contains(TestReportExecutor.identities.get(0).getUsername()));
    Assert.assertTrue(persistentValues.contains(usernameTwo.getValue()));
    // 
    reportService.delete(report);
    reportService.delete(recoveredReport);
    attachmentManager.deleteAttachments(report);
    attachmentManager.deleteAttachments(recoveredReport);
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) Serializable(java.io.Serializable) InputStream(java.io.InputStream) RptReportFilter(eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) List(java.util.List) UUID(java.util.UUID) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 3 with RptReportFilter

use of eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter in project CzechIdMng by bcvsolutions.

the class RptReportController method toFilter.

@Override
protected RptReportFilter toFilter(MultiValueMap<String, Object> parameters) {
    RptReportFilter filter = new RptReportFilter(parameters);
    // 
    filter.setFrom(getParameterConverter().toDateTime(parameters, "from"));
    filter.setTill(getParameterConverter().toDateTime(parameters, "till"));
    // 
    return filter;
}
Also used : RptReportFilter(eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter)

Example 4 with RptReportFilter

use of eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter in project CzechIdMng by bcvsolutions.

the class RptLongRunningTaskDeleteProcessor method process.

@Override
public EventResult<IdmLongRunningTaskDto> process(EntityEvent<IdmLongRunningTaskDto> event) {
    IdmLongRunningTaskDto lrt = event.getContent();
    Assert.notNull(lrt.getId(), "Long running task identifier is required.");
    // 
    RptReportFilter filter = new RptReportFilter();
    filter.setLongRunningTaskId(lrt.getId());
    service.find(filter, null).forEach(report -> {
        report.setLongRunningTask(null);
        // 
        service.save(report);
    });
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) RptReportFilter(eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult)

Example 5 with RptReportFilter

use of eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter in project CzechIdMng by bcvsolutions.

the class DefaultRptReportManagerIntegrationTest method testScheduleReport.

@Test
@SuppressWarnings("unchecked")
public void testScheduleReport() throws Exception {
    String testPropagateParameterValue = getHelper().createName();
    Task task = new Task();
    task.setInstanceId(configurationService.getInstanceId());
    task.setTaskType((Class<? extends SchedulableTaskExecutor<?>>) AutowireHelper.getTargetClass(testFilterReportExecutor));
    task.setDescription("test report");
    task.getParameters().put(IdmIdentity_.username.getName(), testPropagateParameterValue);
    // 
    task = schedulerManager.createTask(task);
    // 
    ObserveLongRunningTaskEndProcessor.listenTask(task.getId());
    // 
    SimpleTaskTrigger trigger = new SimpleTaskTrigger();
    trigger.setTaskId(task.getId());
    trigger.setFireTime(ZonedDateTime.now());
    schedulerManager.createTrigger(task.getId(), trigger);
    // 
    ObserveLongRunningTaskEndProcessor.waitForEnd(task.getId());
    // 
    assertEquals(OperationState.EXECUTED, ObserveLongRunningTaskEndProcessor.getResult(task.getId()).getState());
    // 
    // find report by LRT task
    RptReportFilter reportFilter = new RptReportFilter();
    IdmLongRunningTaskDto lrt = ObserveLongRunningTaskEndProcessor.getLongRunningTask(task.getId());
    Assert.assertEquals(testPropagateParameterValue, lrt.getTaskProperties().get(IdmIdentity_.username.getName()));
    reportFilter.setLongRunningTaskId(ObserveLongRunningTaskEndProcessor.getLongRunningTask(task.getId()).getId());
    // 
    getHelper().waitForResult(res -> {
        return reportService.count(reportFilter) == 0;
    });
    // 
    List<RptReportDto> reports = reportService.find(reportFilter, null).getContent();
    Assert.assertEquals(1, reports.size());
    IdmFormInstanceDto formInstance = new IdmFormInstanceDto(reports.get(0), testFilterReportExecutor.getFormDefinition(), reports.get(0).getFilter());
    Assert.assertEquals(testPropagateParameterValue, formInstance.toSinglePersistentValue(IdmIdentity_.username.getName()));
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) Task(eu.bcvsolutions.idm.core.scheduler.api.dto.Task) LongRunningFutureTask(eu.bcvsolutions.idm.core.scheduler.api.dto.LongRunningFutureTask) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) RptReportFilter(eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) SimpleTaskTrigger(eu.bcvsolutions.idm.core.scheduler.api.dto.SimpleTaskTrigger) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

RptReportFilter (eu.bcvsolutions.idm.rpt.api.dto.filter.RptReportFilter)6 RptReportDto (eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)4 Test (org.junit.Test)4 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)3 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)3 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)2 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)2 UUID (java.util.UUID)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)1 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)1 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)1 LongRunningFutureTask (eu.bcvsolutions.idm.core.scheduler.api.dto.LongRunningFutureTask)1 SimpleTaskTrigger (eu.bcvsolutions.idm.core.scheduler.api.dto.SimpleTaskTrigger)1 Task (eu.bcvsolutions.idm.core.scheduler.api.dto.Task)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1