Search in sources :

Example 86 with DBQuery

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;
}
Also used : EPCommentNotification(org.olat.portfolio.model.notification.EPCommentNotification) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 87 with DBQuery

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;
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery) EPArtefactNotification(org.olat.portfolio.model.notification.EPArtefactNotification)

Example 88 with DBQuery

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;
}
Also used : EPStructureElementNotification(org.olat.portfolio.model.notification.EPStructureElementNotification) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 89 with DBQuery

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);
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) DBQuery(org.olat.core.commons.persistence.DBQuery) OLATResource(org.olat.resource.OLATResource)

Example 90 with DBQuery

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();
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) DBQuery(org.olat.core.commons.persistence.DBQuery)

Aggregations

DBQuery (org.olat.core.commons.persistence.DBQuery)108 EPStructureToArtefactLink (org.olat.portfolio.model.structel.EPStructureToArtefactLink)12 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)10 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)10 Calendar (java.util.Calendar)8 IdentityImpl (org.olat.basesecurity.IdentityImpl)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 DB (org.olat.core.commons.persistence.DB)4 Publisher (org.olat.core.commons.services.notifications.Publisher)4 Tag (org.olat.core.commons.services.tagging.model.Tag)4 Identity (org.olat.core.id.Identity)4 EPStructureToStructureLink (org.olat.portfolio.model.structel.EPStructureToStructureLink)4 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)4 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)4 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 StringTokenizer (java.util.StringTokenizer)2