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)));
}
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);
}
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;
}
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);
}
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()));
}
Aggregations