use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
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;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class OLATUpgrade_8_1_0 method getAssessmentPublishers.
private List<Publisher> getAssessmentPublishers() {
StringBuilder sb = new StringBuilder();
sb.append("select pub from notipublisher pub where pub.resName='AssessmentManager' and type='AssessmentManager'");
DBQuery query = dbInstance.createQuery(sb.toString());
@SuppressWarnings("unchecked") List<Publisher> res = query.list();
return res;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class OLATUpgrade_8_1_0 method getEfficiencyStatement.
private List<Property> getEfficiencyStatement(int firstResult) {
StringBuilder query = new StringBuilder();
query.append("select p from ").append(Property.class.getName()).append(" as p ");
query.append(" where p.category='efficiencyStatement' order by p.key");
DBQuery dbQuery = dbInstance.createQuery(query.toString());
dbQuery.setFirstResult(firstResult);
dbQuery.setMaxResults(REPO_ENTRIES_BATCH_SIZE);
@SuppressWarnings("unchecked") List<Property> props = dbQuery.list();
return props;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class InfoMessageManagerImpl method loadInfoMessageByResource.
@Override
public List<InfoMessage> loadInfoMessageByResource(OLATResourceable ores, String subPath, String businessPath, Date after, Date before, int firstResult, int maxResults) {
DBQuery query = queryInfoMessageByResource(ores, subPath, businessPath, after, before, false);
if (firstResult >= 0) {
query.setFirstResult(firstResult);
}
if (maxResults > 0) {
query.setMaxResults(maxResults);
}
@SuppressWarnings("unchecked") List<InfoMessage> msgs = query.list();
return msgs;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class InfoMessageManagerImpl method queryInfoMessageByResource.
private DBQuery queryInfoMessageByResource(OLATResourceable ores, String subPath, String businessPath, Date after, Date before, boolean count) {
StringBuilder sb = new StringBuilder();
sb.append("select ");
if (count)
sb.append("count(msg.key)");
else
sb.append("msg");
sb.append(" from ").append(InfoMessageImpl.class.getName()).append(" msg");
if (!count) {
sb.append(" left join fetch msg.author author").append(" left join fetch author.user").append(" left join fetch msg.modifier modifier").append(" left join fetch modifier.user");
}
if (ores != null) {
appendAnd(sb, "msg.resId=:resId and msg.resName=:resName ");
}
if (StringHelper.containsNonWhitespace(subPath)) {
appendAnd(sb, "msg.resSubPath=:subPath");
}
if (StringHelper.containsNonWhitespace(businessPath)) {
appendAnd(sb, "msg.businessPath=:businessPath");
}
if (after != null) {
appendAnd(sb, "msg.creationDate>=:after");
}
if (before != null) {
appendAnd(sb, "msg.creationDate<=:before");
}
if (!count) {
sb.append(" order by msg.creationDate desc");
}
DBQuery query = dbInstance.createQuery(sb.toString());
if (ores != null) {
query.setLong("resId", ores.getResourceableId());
query.setString("resName", ores.getResourceableTypeName());
}
if (StringHelper.containsNonWhitespace(subPath)) {
query.setString("subPath", subPath);
}
if (StringHelper.containsNonWhitespace(businessPath)) {
query.setString("businessPath", normalizeBusinessPath(businessPath));
}
if (after != null) {
query.setTimestamp("after", after);
}
if (before != null) {
query.setTimestamp("before", before);
}
return query;
}
Aggregations