Search in sources :

Example 21 with DBQuery

use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.

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 22 with DBQuery

use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.

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 23 with DBQuery

use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.

the class EPNotificationManager method getRatingNotifications.

private List<EPRatingNotification> getRatingNotifications(List<Long> mapKey, Date compareDate) {
    if (mapKey == null || mapKey.isEmpty()) {
        return Collections.emptyList();
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select notification from ").append(EPRatingNotification.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<EPRatingNotification> notifications = query.list();
    return notifications;
}
Also used : EPRatingNotification(org.olat.portfolio.model.notification.EPRatingNotification) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 24 with DBQuery

use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.

the class RepositoryManager method countByTypeLimitAccess.

/**
 * Count by type, limit by role accessability.
 * @param restrictedType
 * @param roles
 * @return Number of repo entries
 */
public int countByTypeLimitAccess(String restrictedType, int restrictedAccess) {
    StringBuilder query = new StringBuilder(400);
    query.append("select count(*) from" + " org.olat.repository.RepositoryEntry v, " + " org.olat.resource.OLATResourceImpl res " + " where v.olatResource = res and res.resName= :restrictedType and v.access >= :restrictedAccess ");
    DBQuery dbquery = dbInstance.createQuery(query.toString());
    dbquery.setString("restrictedType", restrictedType);
    dbquery.setInteger("restrictedAccess", restrictedAccess);
    dbquery.setCacheable(true);
    return ((Long) dbquery.list().get(0)).intValue();
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 25 with DBQuery

use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_7_1_1 method getStructuredMapsLinkedToTemplate.

private List<PortfolioStructure> getStructuredMapsLinkedToTemplate(PortfolioStructure template) {
    StringBuilder sb = new StringBuilder();
    sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" map").append(" where map.structuredMapSource=:template");
    DBQuery query = DBFactory.getInstance().createQuery(sb.toString());
    query.setEntity("template", template);
    @SuppressWarnings("unchecked") List<PortfolioStructure> maps = query.list();
    return maps;
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) 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