Search in sources :

Example 26 with DBQuery

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

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 27 with DBQuery

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

the class EPStructureManager method getAllReferencesForArtefact.

protected List<PortfolioStructure> getAllReferencesForArtefact(AbstractArtefact artefact) {
    StringBuilder sb = new StringBuilder();
    sb.append("select link.structureElement from ").append(EPStructureToArtefactLink.class.getName()).append(" link").append(" where link.artefact=:artefactEl ");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setEntity("artefactEl", artefact);
    @SuppressWarnings("unchecked") List<PortfolioStructure> pfList = query.list();
    return pfList;
}
Also used : EPStructureToArtefactLink(org.olat.portfolio.model.structel.EPStructureToArtefactLink) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 28 with DBQuery

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

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 29 with DBQuery

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

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

Example 30 with DBQuery

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

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;
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) 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