Search in sources :

Example 56 with DBQuery

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

the class EPArtefactManager method isArtefactClosed.

protected boolean isArtefactClosed(AbstractArtefact artefact) {
    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.root rootStructure").append(" where link.artefact=:artefact and rootStructure.status='closed'");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setEntity("artefact", artefact);
    Number count = (Number) query.uniqueResult();
    return count.intValue() > 0;
}
Also used : EPStructureToArtefactLink(org.olat.portfolio.model.structel.EPStructureToArtefactLink) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 57 with DBQuery

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

the class EPStructureManager method loadMapShortByResourceId.

/**
 * @param olatResourceable cannot be null
 * @return The structure element or null if not found
 */
public EPMapShort loadMapShortByResourceId(Long resourceableId) {
    StringBuilder sb = new StringBuilder();
    sb.append("select element from ").append(EPMapShort.class.getName()).append(" element").append(" inner join fetch element.olatResource resource").append(" where resource.resId=:resourceId and resource.resName in ('EPDefaultMap','EPStructuredMap','EPStructuredMapTemplate')");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setLong("resourceId", resourceableId);
    @SuppressWarnings("unchecked") List<EPMapShort> resources = query.list();
    // if not found, it is an empty list
    if (resources.isEmpty())
        return null;
    return resources.get(0);
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery) EPMapShort(org.olat.portfolio.model.structel.EPMapShort)

Example 58 with DBQuery

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

the class OLATUpgrade_7_1_1 method loadMapChildrenByInternalFK.

// helper to get child not by link, but internal direct link to root-element
private List<PortfolioStructure> loadMapChildrenByInternalFK(PortfolioStructure linkedChildStruct, PortfolioStructure root) {
    if (root == null)
        return null;
    StringBuilder sb = new StringBuilder();
    sb.append("select stEl from ").append(EPStructureElement.class.getName()).append(" stEl");
    // sb.append(" where stEl.root=:rootEl and stEl.structureElSource=:sourceEl"); // filtered by filterLinkedStructs()
    sb.append(" where stEl.root=:rootEl");
    DBQuery query = DBFactory.getInstance().createQuery(sb.toString());
    query.setEntity("rootEl", root);
    // query.setLong("sourceEl", ((EPStructureElement)linkedChildStruct).getStructureElSource());
    @SuppressWarnings("unchecked") List<PortfolioStructure> resources = query.list();
    return resources;
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 59 with DBQuery

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

the class OLATUpgrade_7_1_1 method queryEntries.

public List<RepositoryEntryUpgrade> queryEntries(int firstResult) {
    StringBuilder sb = new StringBuilder();
    sb.append("select v from ").append(RepositoryEntryUpgrade.class.getName()).append(" v inner join fetch v.olatResource as res order by v.key asc");
    DBQuery dbquery = DBFactory.getInstance().createQuery(sb.toString());
    dbquery.setFirstResult(firstResult);
    dbquery.setMaxResults(REPO_ENTRIES_BATCH_SIZE);
    @SuppressWarnings("unchecked") List<RepositoryEntryUpgrade> entries = dbquery.list();
    return entries;
}
Also used : RepositoryEntryUpgrade(org.olat.upgrade.model.RepositoryEntryUpgrade) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 60 with DBQuery

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

the class OLATUpgrade_7_1_1 method getGroupsOfBGContext.

private List<BusinessGroupUpgrade> getGroupsOfBGContext(BGContextImpl bgContext) {
    String q = "select bg from org.olat.upgrade.model.BusinessGroupImpl bg where bg.groupContextKey = :contextKey";
    DBQuery query = DBFactory.getInstance().createQuery(q);
    query.setLong("contextKey", bgContext.getKey());
    @SuppressWarnings("unchecked") List<BusinessGroupUpgrade> groups = query.list();
    return groups;
}
Also used : BusinessGroupUpgrade(org.olat.upgrade.model.BusinessGroupUpgrade) 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