use of eu.bcvsolutions.idm.rpt.api.dto.RptRenderedReportDto 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);
}
}
use of eu.bcvsolutions.idm.rpt.api.dto.RptRenderedReportDto in project CzechIdMng by bcvsolutions.
the class DefaultReportManager method render.
@Override
public RptRenderedReportDto render(RptReportDto report, String rendererName) {
Assert.notNull(report);
Assert.hasLength(rendererName);
//
ReportRenderer renderer = reportRendererRegistry.getPluginFor(rendererName);
if (renderer == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("reportRenderer", rendererName));
}
//
RptRenderedReportDto result = new RptRenderedReportDto();
result.setInputReport(report);
result.setRenderer(toDto(renderer));
result.setRenderedReport(renderer.render(report));
return result;
}
use of eu.bcvsolutions.idm.rpt.api.dto.RptRenderedReportDto in project CzechIdMng by bcvsolutions.
the class DefaultRptReportManagerIntegrationTest method testRenderReportAsJson.
@Test
public void testRenderReportAsJson() throws IOException {
TestReportExecutor testReportExecutor = context.getAutowireCapableBeanFactory().createBean(TestReportExecutor.class);
RptReportDto report = testReportExecutor.generate(new RptReportDto(UUID.randomUUID()));
RptRenderedReportDto renderedData = manager.render(report, TestReportRenderer.RENDERER_NAME);
//
Assert.assertEquals(mapper.writeValueAsString(TestReportExecutor.identities), IOUtils.toString(renderedData.getRenderedReport()));
}
Aggregations