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);
}
}
}
}
}
}
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>");
}
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;'> </th>");
html.append("<th style='width:").append(IA_DBS_CONTENTCELL_WIDTH).append("px;'> </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>");
}
}
Aggregations