use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class EPStructureManager method loadPortfolioRepositoryEntryByMapKey.
/**
* Load the repository entry of a template with the map key
* @param key The template key
* @return The repository entry
*/
public RepositoryEntry loadPortfolioRepositoryEntryByMapKey(Long key) {
if (key == null)
throw new NullPointerException();
StringBuilder sb = new StringBuilder();
sb.append("select repo from ").append(RepositoryEntry.class.getName()).append(" repo").append(" where repo.olatResource in (select map.olatResource from ").append(EPStructuredMapTemplate.class.getName()).append(" map where map.key=:key").append(")");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setLong("key", key);
@SuppressWarnings("unchecked") List<RepositoryEntry> entries = query.list();
// if not found, it is an empty list
if (entries.isEmpty())
return null;
return entries.get(0);
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class EPStructureManager method getStructureElements.
protected List<PortfolioStructure> getStructureElements(int firstResult, int maxResults, ElementType... types) {
StringBuilder sb = new StringBuilder();
sb.append("select stEl from ").append(EPStructureElement.class.getName()).append(" stEl");
sb.append(" where type(stEl) in (");
boolean first = true;
for (ElementType type : types) {
if (first)
first = false;
else
sb.append(",");
sb.append(getImplementation(type).getName());
}
sb.append(")");
DBQuery query = dbInstance.createQuery(sb.toString());
if (firstResult > 0) {
query.setFirstResult(firstResult);
}
if (maxResults > 0) {
query.setMaxResults(maxResults);
}
@SuppressWarnings("unchecked") List<PortfolioStructure> pStructs = query.list();
return pStructs;
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class EPStructureManager method getOpenStructuredMapAfterDeadline.
protected List<PortfolioStructureMap> getOpenStructuredMapAfterDeadline() {
StringBuilder sb = new StringBuilder();
sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" as map");
sb.append(" where (map.status is null or not(map.status = 'closed'))").append(" and map.deadLine<:currentDate");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setDate("currentDate", new Date());
@SuppressWarnings("unchecked") List<PortfolioStructureMap> maps = query.list();
return maps;
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class EPArtefactManager method loadArtefactsByBusinessPath.
protected List<AbstractArtefact> loadArtefactsByBusinessPath(String businessPath, Identity author) {
if (!StringHelper.containsNonWhitespace(businessPath))
return null;
StringBuilder sb = new StringBuilder();
sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where artefact.businessPath=:bpath");
if (author != null) {
sb.append(" and artefact.author=:ident");
}
DBQuery query = dbInstance.createQuery(sb.toString());
query.setString("bpath", businessPath);
if (author != null) {
query.setEntity("ident", author);
}
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
// if not found, it is an empty list
if (artefacts.isEmpty())
return null;
return artefacts;
}
Aggregations