Search in sources :

Example 1 with DatabaseModel

use of org.activityinfo.server.digest.geo.GeoDigestModel.DatabaseModel in project activityinfo by bedatadriven.

the class GeoDigestRenderer method renderDatabases.

private void renderDatabases(StringBuilder html, GeoDigestModel model) throws IOException {
    html.append("<div class='geo-data' style='margin-top:20px'>");
    Collection<DatabaseModel> databases = model.getDatabases();
    for (DatabaseModel database : databases) {
        if (database.isRenderable()) {
            renderDatabase(html, database);
        }
    }
    html.append("</div>");
}
Also used : DatabaseModel(org.activityinfo.server.digest.geo.GeoDigestModel.DatabaseModel)

Example 2 with DatabaseModel

use of org.activityinfo.server.digest.geo.GeoDigestModel.DatabaseModel in project activityinfo by bedatadriven.

the class GeoDigestModelBuilder method createDatabaseModel.

private void createDatabaseModel(GeoDigestModel model, Database database) throws IOException {
    DatabaseModel databaseModel = new DatabaseModel(model, database);
    List<Integer> siteIds = findSiteIds(database, model.getUserDigest().getFrom());
    LOGGER.finest("rendering geo digest for user " + model.getUserDigest().getUser().getId() + " and database " + database.getId() + " - found " + siteIds.size() + " site(s) that were edited since " + DateFormatter.formatDateTime(model.getUserDigest().getFrom()));
    if (!siteIds.isEmpty()) {
        MapReportElement reportModel = new MapReportElement();
        reportModel.setMaximumZoomLevel(9);
        BubbleMapLayer layer = createLayer(siteIds);
        reportModel.setLayers(layer);
        MapContent content = dispatcher.execute(new GenerateElement<MapContent>(reportModel));
        databaseModel.setContent(content);
        if (!content.getMarkers().isEmpty()) {
            reportModel.setContent(content);
            GeneratedResource storage = storageProvider.create("image/png", "map.png");
            try (OutputStream outputStream = storage.openOutputStream()) {
                imageMapRenderer.render(reportModel, outputStream);
            }
            databaseModel.setUrl(storage.getDownloadUri());
        }
    }
}
Also used : MapReportElement(org.activityinfo.legacy.shared.reports.model.MapReportElement) DatabaseModel(org.activityinfo.server.digest.geo.GeoDigestModel.DatabaseModel) MapContent(org.activityinfo.legacy.shared.reports.content.MapContent) OutputStream(java.io.OutputStream) BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) GeneratedResource(org.activityinfo.server.generated.GeneratedResource)

Aggregations

DatabaseModel (org.activityinfo.server.digest.geo.GeoDigestModel.DatabaseModel)2 OutputStream (java.io.OutputStream)1 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)1 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)1 BubbleMapLayer (org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer)1 GeneratedResource (org.activityinfo.server.generated.GeneratedResource)1