use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPNotificationManager method getCommentNotifications.
private List<EPCommentNotification> getCommentNotifications(List<Long> mapKey, Date compareDate) {
if (mapKey == null || mapKey.isEmpty()) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select notification from ").append(EPCommentNotification.class.getName()).append(" as notification").append(" inner join fetch notification.author").append(" where notification.creationDate>=:currentDate and notification.mapKey in (:mapKey)");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setDate("currentDate", compareDate);
query.setParameterList("mapKey", mapKey);
@SuppressWarnings("unchecked") List<EPCommentNotification> notifications = query.list();
return notifications;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPNotificationManager method getArtefactNotifications.
private List<EPArtefactNotification> getArtefactNotifications(List<Long> mapKey, Date compareDate) {
if (mapKey == null || mapKey.isEmpty()) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select notification from ").append(EPArtefactNotification.class.getName()).append(" as notification").append(" inner join fetch notification.author").append(" where notification.creationDate>=:currentDate and (notification.key in (:mapKey) or notification.rootMapKey in (:mapKey))");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setDate("currentDate", compareDate);
query.setParameterList("mapKey", mapKey);
@SuppressWarnings("unchecked") List<EPArtefactNotification> notifications = query.list();
return notifications;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPNotificationManager method getPageNotifications.
private List<EPStructureElementNotification> getPageNotifications(Long mapKey, Date compareDate) {
StringBuilder sb = new StringBuilder();
sb.append("select notification from ").append(EPStructureElementNotification.class.getName()).append(" as notification");
sb.append(" where notification.creationDate>=:currentDate and (notification.key=:mapKey or notification.rootMapKey=:mapKey)");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setDate("currentDate", compareDate);
query.setLong("mapKey", mapKey);
@SuppressWarnings("unchecked") List<EPStructureElementNotification> notifications = query.list();
return notifications;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPStructureManager method loadOlatResourceFromStructureElByKey.
public OLATResource loadOlatResourceFromStructureElByKey(Long key) {
if (key == null)
throw new NullPointerException();
StringBuilder sb = new StringBuilder();
sb.append("select element.olatResource from ").append(EPStructureElement.class.getName()).append(" element").append(" where element.key=:key or element.olatResource.resId=:key ");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setLong("key", key);
@SuppressWarnings("unchecked") List<OLATResource> resources = query.list();
// if not found, it is an empty list
if (resources.isEmpty())
return null;
return resources.get(0);
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class OLATUpgrade_7_1_1 method countPortfolioTemplates.
private int countPortfolioTemplates() {
StringBuilder sb = new StringBuilder();
sb.append("select count(stEl) from ").append(EPStructureElement.class.getName()).append(" stEl");
sb.append(" where stEl.class in (" + EPStructuredMapTemplate.class.getName() + ")");
DBQuery query = DBFactory.getInstance().createQuery(sb.toString());
Number count = (Number) query.uniqueResult();
return count.intValue();
}
Aggregations