Search in sources :

Example 91 with DBQuery

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

Example 92 with DBQuery

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;
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery) Publisher(org.olat.core.commons.services.notifications.Publisher)

Example 93 with DBQuery

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;
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery) Property(org.olat.properties.Property)

Example 94 with DBQuery

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;
}
Also used : InfoMessage(org.olat.commons.info.InfoMessage) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 95 with DBQuery

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;
}
Also used : 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