use of org.activityinfo.server.report.output.TempStorage in project activityinfo by bedatadriven.
the class ChartRendererJC method renderToUrl.
public String renderToUrl(PivotChartReportElement element, boolean includeTitle, StorageProvider istorageProvider, int width, int height, int dpi) throws IOException {
try {
Chart chart = createChart(element, includeTitle, width, height, dpi);
TempStorage storage = istorageProvider.allocateTemporaryFile(null, "activityinfo.jpg");
JPEGEncoder.encode(chart, 0.75f, storage.getOutputStream());
return storage.getUrl();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of org.activityinfo.server.report.output.TempStorage 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());
TempStorage storage = storageProvider.allocateTemporaryFile(renderer.getMimeType(), cmd.getFilename() + renderer.getFileSuffix());
LOGGER.fine("Rendering element: " + cmd + "\nURL: " + storage.getUrl());
try {
generator.generateElement(user, cmd.getElement(), new Filter(), new DateRange());
renderer.render(cmd.getElement(), storage.getOutputStream());
} finally {
try {
storage.getOutputStream().close();
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Exception while closing storage: " + e.getMessage(), e);
}
}
return new UrlResult(storage.getUrl());
} catch (Exception e) {
throw new RuntimeException("Exception generating export", e);
}
}
Aggregations