use of org.activityinfo.server.database.hibernate.entity.SiteHistory in project activityinfo by bedatadriven.
the class ActivityDigestModelBuilder method findLastEdit.
@VisibleForTesting
@SuppressWarnings("unchecked")
SiteHistory findLastEdit(Database database) {
Query query = entityManager.get().createQuery("select h from SiteHistory h " + "where h.site.activity.database = :database " + "order by h.timeCreated desc");
query.setParameter("database", database);
query.setMaxResults(1);
List<SiteHistory> list = query.getResultList();
return (list != null && list.size() == 1) ? list.get(0) : null;
}
use of org.activityinfo.server.database.hibernate.entity.SiteHistory in project activityinfo by bedatadriven.
the class GeoDigestRenderer method renderSites.
private void renderSites(StringBuilder html, DatabaseModel databaseModel, Collection<Integer> siteIds) {
if (!siteIds.isEmpty()) {
for (Integer siteId : siteIds) {
SiteResult siteResult = dispatcher.execute(GetSites.byId(siteId));
SiteDTO siteDTO = siteResult.getData().get(0);
ActivityDTO activityDTO = databaseModel.getModel().getSchemaDTO().getActivityById(siteDTO.getActivityId());
// Check to see if this activity is visible to the user...
if (activityDTO != null) {
List<SiteHistory> histories = findSiteHistory(siteId, databaseModel.getModel().getUserDigest().getFrom());
for (SiteHistory history : histories) {
html.append("<span class='geo-site' style='margin-left:10px;'>• ");
html.append(I18N.MESSAGES.geoDigestSiteMsg(history.getUser().getEmail(), history.getUser().getName(), activityDTO.getName(), siteDTO.getLocationName()));
Date targetDate = databaseModel.getModel().getUserDigest().getDate();
Date creationDate = new Date(history.getTimeCreated());
if (DateCalc.isOnToday(targetDate, creationDate)) {
html.append(I18N.MESSAGES.geoDigestSiteMsgDateToday(creationDate));
} else if (DateCalc.isOnYesterday(targetDate, creationDate)) {
html.append(I18N.MESSAGES.geoDigestSiteMsgDateYesterday(creationDate));
} else {
html.append(I18N.MESSAGES.geoDigestSiteMsgDateOther(creationDate));
}
html.append("</span><br>");
}
}
}
}
}
Aggregations