use of org.olat.modules.reminder.model.ReminderInfos in project openolat by klemens.
the class ReminderDAO method getReminderInfos.
public List<ReminderInfos> getReminderInfos(RepositoryEntryRef entry) {
StringBuilder sb = new StringBuilder();
sb.append("select rem.key, rem.description, rem.sendTime, rem.creationDate, rem.lastModified, rem.creator.key,").append(" (select count(sentrem.key) from sentreminder sentrem").append(" where sentrem.reminder.key=rem.key").append(" ) as numOfRemindersSent ").append(" from reminder rem").append(" where rem.entry.key=:entryKey");
List<Object[]> results = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("entryKey", entry.getKey()).getResultList();
List<ReminderInfos> infos = new ArrayList<>(results.size());
for (Object[] result : results) {
Long key = (Long) result[0];
String desc = (String) result[1];
String sendTime = (String) result[2];
Date creationDate = (Date) result[3];
Date lastModified = (Date) result[4];
Long creatorKey = (Long) result[5];
String creator = userManager.getUserDisplayName(creatorKey);
int numOfRemindersSent = 0;
if (result[6] != null) {
numOfRemindersSent = ((Number) result[6]).intValue();
}
infos.add(new ReminderInfos(key, creationDate, lastModified, desc, sendTime, creatorKey, creator, numOfRemindersSent));
}
return infos;
}
Aggregations