Search in sources :

Example 1 with DatabaseModel

use of org.activityinfo.server.digest.activity.ActivityDigestModel.DatabaseModel in project activityinfo by bedatadriven.

the class ActivityDigestModelBuilder method createDatabaseModel.

private void createDatabaseModel(ActivityDigestModel model, Database database) {
    SiteHistory lastEdit = findLastEdit(database);
    // only include databases that are known to be edited at least once
    if (lastEdit != null) {
        DatabaseModel databaseModel = new DatabaseModel(model, database, lastEdit);
        List<SiteHistory> ownerHistories = findSiteHistory(databaseModel, database.getOwner());
        ActivityMap ownerActivityMap = new ActivityMap(databaseModel, database.getOwner(), ownerHistories);
        databaseModel.setOwnerActivityMap(ownerActivityMap);
        List<Partner> partners = findPartners(databaseModel);
        LOGGER.finest("building user activity digest for user " + model.getUserDigest().getUser().getId() + " and database " + database.getId() + " - found " + partners.size() + " partner(s)");
        if (!partners.isEmpty()) {
            for (Partner partner : partners) {
                PartnerActivityModel partnerModel = new PartnerActivityModel(databaseModel, partner);
                List<User> partnerUsers = findUsers(partnerModel);
                LOGGER.finest("found users " + partnerUsers + " for partner " + partner.getName());
                if (!partnerUsers.isEmpty()) {
                    for (User partnerUser : partnerUsers) {
                        List<SiteHistory> histories = findSiteHistory(databaseModel, partnerUser);
                        ActivityMap activityMap = new ActivityMap(databaseModel, partnerUser, histories);
                        partnerModel.addActivityMap(activityMap);
                    }
                }
            }
        }
    }
}
Also used : ActivityMap(org.activityinfo.server.digest.activity.ActivityDigestModel.ActivityMap) PartnerActivityModel(org.activityinfo.server.digest.activity.ActivityDigestModel.PartnerActivityModel) DatabaseModel(org.activityinfo.server.digest.activity.ActivityDigestModel.DatabaseModel) User(org.activityinfo.server.database.hibernate.entity.User) SiteHistory(org.activityinfo.server.database.hibernate.entity.SiteHistory) Partner(org.activityinfo.server.database.hibernate.entity.Partner)

Example 2 with DatabaseModel

use of org.activityinfo.server.digest.activity.ActivityDigestModel.DatabaseModel in project activityinfo by bedatadriven.

the class ActivityDigestRenderer method renderActiveDatabases.

private void renderActiveDatabases(StringBuilder html, ActivityDigestModel model) throws IOException {
    html.append("<div class='act-active'>");
    html.append("<table class='act-data' border='0' cellpadding='0' cellspacing='0' style='width:");
    html.append(HEADERCELL_WIDTH + SPACERCELL_WIDTH + (model.getUserDigest().getDays() * GRAPHCELL_WIDTH));
    html.append("px; border-collapse:collapse;'>");
    renderTableHeader(html, model);
    Collection<DatabaseModel> activeDatabases = model.getActiveDatabases();
    for (DatabaseModel activeDatabase : activeDatabases) {
        renderActiveDatabase(html, activeDatabase);
    }
    html.append("</table>");
    html.append("</div>");
}
Also used : DatabaseModel(org.activityinfo.server.digest.activity.ActivityDigestModel.DatabaseModel)

Example 3 with DatabaseModel

use of org.activityinfo.server.digest.activity.ActivityDigestModel.DatabaseModel in project activityinfo by bedatadriven.

the class ActivityDigestRenderer method renderInactiveDatabases.

private void renderInactiveDatabases(StringBuilder html, ActivityDigestModel model) {
    Collection<DatabaseModel> inactiveDatabases = model.getInactiveDatabases();
    if (!inactiveDatabases.isEmpty()) {
        html.append("<div class='act-inactive' style='margin-top:35px;'>");
        html.append(I18N.MESSAGES.activityDigestInactiveDatabases(model.getUserDigest().getDays()));
        html.append("<br>");
        html.append("<table class='act-data' border='0' cellpadding='0' cellspacing='0' ");
        html.append("style='width:").append(IA_DBS_HEADERCELL_WIDTH + IA_DBS_CONTENTCELL_WIDTH).append("px; ");
        html.append("border-collapse:collapse;'>");
        html.append("<tr>");
        html.append("<th style='width:").append(IA_DBS_HEADERCELL_WIDTH).append("px;'>&nbsp;</th>");
        html.append("<th style='width:").append(IA_DBS_CONTENTCELL_WIDTH).append("px;'>&nbsp;</th>");
        html.append("</tr>");
        for (DatabaseModel db : inactiveDatabases) {
            html.append("<tr>");
            html.append("<td class='act-database-header' style='color: #67a639; font-weight:bold'>");
            html.append(db.getName());
            html.append("</td>");
            html.append("<td class='act-lastedit' style='font-style: italic'>");
            html.append(formatLastEdited(db));
            html.append("</td>");
            html.append("</tr>");
        }
        html.append("</table>");
        html.append("</div>");
    }
}
Also used : DatabaseModel(org.activityinfo.server.digest.activity.ActivityDigestModel.DatabaseModel)

Aggregations

DatabaseModel (org.activityinfo.server.digest.activity.ActivityDigestModel.DatabaseModel)3 Partner (org.activityinfo.server.database.hibernate.entity.Partner)1 SiteHistory (org.activityinfo.server.database.hibernate.entity.SiteHistory)1 User (org.activityinfo.server.database.hibernate.entity.User)1 ActivityMap (org.activityinfo.server.digest.activity.ActivityDigestModel.ActivityMap)1 PartnerActivityModel (org.activityinfo.server.digest.activity.ActivityDigestModel.PartnerActivityModel)1