use of eu.bcvsolutions.idm.rpt.api.dto.RptReportDto in project CzechIdMng by bcvsolutions.
the class IdentityReportExecutorIntegrationTest method testDisabledIdentity.
@Test
@Transactional
public void testDisabledIdentity() throws IOException {
// prepare test identities
IdmIdentityDto identityOne = helper.createIdentity();
IdmIdentityDto identityDisabled = helper.createIdentity();
identityService.disable(identityDisabled.getId());
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto disabled = new IdmFormValueDto(definition.getMappedAttributeByCode(IdmIdentityFilter.PARAMETER_DISABLED));
disabled.setValue(false);
filter.getValues().add(disabled);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<IdmIdentityDto> identityRoles = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<IdmIdentityDto>>() {
});
//
// test
Assert.assertTrue(identityRoles.stream().anyMatch(i -> i.equals(identityOne)));
Assert.assertFalse(identityRoles.stream().anyMatch(i -> i.equals(identityDisabled)));
//
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.rpt.api.dto.RptReportDto in project CzechIdMng by bcvsolutions.
the class AbstractReportExecutor method process.
@Override
public RptReportDto process() {
if (event != null) {
// generate report
return generate(event.getContent());
}
// event is empty - publish new event and stop current LRT process (event has to be initialized at first)
if (getLongRunningTaskId() != null) {
IdmLongRunningTaskDto task = getLongRunningTaskService().get(getLongRunningTaskId());
if (task != null) {
task.setRunning(false);
getLongRunningTaskService().save(task);
}
}
// executed from scheduler => we propagate new event for creating report
RptReportDto report = new RptReportDto();
report.setExecutorName(getName());
report.setLongRunningTask(getLongRunningTaskId());
reportManager.generate(report);
return report;
}
use of eu.bcvsolutions.idm.rpt.api.dto.RptReportDto in project CzechIdMng by bcvsolutions.
the class ReportGenerateEndProcessor method process.
@Override
public EventResult<RptReportDto> process(EntityEvent<RptReportDto> event) {
RptReportDto report = event.getContent();
report = reportService.saveInternal(report);
event.setContent(report);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.rpt.api.dto.RptReportDto in project CzechIdMng by bcvsolutions.
the class ReportGenerateEndSendNotificationProcessor method process.
@Override
public EventResult<RptReportDto> process(EntityEvent<RptReportDto> event) {
RptReportDto report = event.getContent();
// TODO: can be improved by some configuration (specially for LRT)
if (report.getCreatorId() != null && report.getResult() != null) {
boolean success = report.getResult().getState() == OperationState.EXECUTED;
notificationManager.send(success ? RptModuleDescriptor.TOPIC_REPORT_GENERATE_SUCCESS : RptModuleDescriptor.TOPIC_REPORT_GENERATE_FAILED, new IdmMessageDto.Builder(success ? NotificationLevel.SUCCESS : NotificationLevel.WARNING).addParameter("url", configurationService.getFrontendUrl(String.format("report/reports?id=%s", report.getId()))).addParameter("report", report).setModel(new DefaultResultModel(success ? RptResultCode.REPORT_GENERATE_SUCCESS : RptResultCode.REPORT_GENERATE_FAILED, ImmutableMap.of("reportName", report.getName()))).build(), identityService.get(report.getCreatorId()));
}
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.rpt.api.dto.RptReportDto in project CzechIdMng by bcvsolutions.
the class RptReportController method renderReport.
@ResponseBody
@RequestMapping(value = "/{backendId}/render", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> renderReport(@ApiParam(value = "Report's uuid identifier.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Renderer's identifier.", required = true) @RequestParam(required = true, name = "renderer") @NotNull String rendererName) {
//
RptReportDto report = getDto(backendId);
if (report == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
try {
RptRenderedReportDto result = reportManager.render(report, rendererName);
InputStream is = result.getRenderedReport();
//
String reportName = report.getExecutorName() + "-" + report.getCreated().toString("yyyyMMddHHmmss");
return ResponseEntity.ok().contentLength(is.available()).contentType(result.getRenderer().getFormat()).header(HttpHeaders.CONTENT_DISPOSITION, String.format("attachment; filename=\"%s.%s\"", reportName, result.getRenderer().getExtension())).body(new InputStreamResource(is));
} catch (Exception ex) {
throw new ResultCodeException(CoreResultCode.INTERNAL_SERVER_ERROR, ex);
}
}
Aggregations