use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPArtefactManager method getArtefactPoolForUser.
protected List<AbstractArtefact> getArtefactPoolForUser(Identity ident) {
long start = System.currentTimeMillis();
StringBuilder sb = new StringBuilder();
sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where author=:author");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setEntity("author", ident);
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
if (artefacts.isEmpty())
return null;
long duration = System.currentTimeMillis() - start;
if (isLogDebugEnabled())
logDebug("loading the full artefact pool took " + duration + "ms");
return artefacts;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
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;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPStructureManager method loadStructureChildren.
/**
* @param structure
* @param firstResult
* @param maxResults
* @return
*/
protected List<PortfolioStructure> loadStructureChildren(PortfolioStructure structure, int firstResult, int maxResults) {
if (structure == null)
throw new NullPointerException();
StringBuilder sb = new StringBuilder();
sb.append("select link.child from ").append(EPStructureToStructureLink.class.getName()).append(" link").append(" where link.parent=:structureEl order by link.order");
DBQuery query = dbInstance.createQuery(sb.toString());
if (firstResult > 0) {
query.setFirstResult(firstResult);
}
if (maxResults > 0) {
query.setMaxResults(maxResults);
}
query.setEntity("structureEl", structure);
@SuppressWarnings("unchecked") List<PortfolioStructure> resources = query.list();
return resources;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPStructureManager method countArtefactsRecursively.
/**
* Count all artefacts (links) in a map
*/
protected int countArtefactsRecursively(PortfolioStructure structure) {
// return countArtefactsRecursively(structure, 0);
StringBuilder sb = new StringBuilder();
sb.append("select count(link) from ").append(EPStructureToArtefactLink.class.getName()).append(" link").append(" inner join link.structureElement structure ").append(" inner join structure.rootMap root").append(" where root=:structureEl");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setEntity("structureEl", structure);
Number count = (Number) query.uniqueResult();
return count.intValue();
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
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();
}
Aggregations