use of org.activityinfo.server.report.renderer.Renderer in project activityinfo by bedatadriven.
the class RenderElementHandler method execute.
@Override
public CommandResult execute(RenderElement cmd, User user) throws CommandException {
try {
Renderer renderer = rendererFactory.get(cmd.getFormat());
GeneratedResource storage = storageProvider.create(renderer.getMimeType(), cmd.getFilename() + renderer.getFileSuffix());
LOGGER.fine("Rendering element: " + cmd + "\nURL: " + storage.getDownloadUri());
try (OutputStream out = storage.openOutputStream()) {
generator.generateElement(user, cmd.getElement(), new Filter(), new DateRange());
renderer.render(cmd.getElement(), out);
}
return new UrlResult(storage.getDownloadUri());
} catch (Exception e) {
throw new RuntimeException("Exception generating export", e);
}
}
Aggregations