Search in sources :

Example 46 with DBQuery

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

the class TaggingManagerImpl method getUserTagsAsString.

@Override
public List<String> getUserTagsAsString(Identity identity) {
    if (identity == null)
        return Collections.emptyList();
    StringBuilder sb = new StringBuilder();
    sb.append("select tag.tag from ").append(TagImpl.class.getName()).append(" tag where tag.author=:author").append(" group by tag.tag").append(" order by count(tag.key) DESC");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setEntity("author", identity);
    @SuppressWarnings("unchecked") List<String> tags = query.list();
    return tags;
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 47 with DBQuery

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

the class TaggingManagerImpl method getUserTagsWithFrequency.

@Override
public List<Map<String, Integer>> getUserTagsWithFrequency(Identity identity) {
    if (identity == null)
        return null;
    StringBuilder sb = new StringBuilder();
    sb.append("select new map ( tag.tag as tag, count(*) as nr ) from ").append(TagImpl.class.getName()).append(" tag where tag.author=:author and tag.tag=tag.tag ").append("Group by tag.tag order by count(*) DESC, tag.tag ASC");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setEntity("author", identity);
    @SuppressWarnings("unchecked") List<Map<String, Integer>> tags = query.list();
    return tags;
}
Also used : TagImpl(org.olat.core.commons.services.tagging.model.TagImpl) DBQuery(org.olat.core.commons.persistence.DBQuery) Map(java.util.Map)

Example 48 with DBQuery

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

the class EPStructureManager method loadStructureChildren.

/**
 * @param structure
 * @param firstResult
 * @param maxResults
 * @return
 */
protected List<PortfolioStructure> loadStructureChildren(PortfolioStructure structure, int firstResult, int maxResults) {
    if (structure == null)
        throw new NullPointerException();
    StringBuilder sb = new StringBuilder();
    sb.append("select link.child from ").append(EPStructureToStructureLink.class.getName()).append(" link").append(" where link.parent=:structureEl order by link.order");
    DBQuery query = dbInstance.createQuery(sb.toString());
    if (firstResult > 0) {
        query.setFirstResult(firstResult);
    }
    if (maxResults > 0) {
        query.setMaxResults(maxResults);
    }
    query.setEntity("structureEl", structure);
    @SuppressWarnings("unchecked") List<PortfolioStructure> resources = query.list();
    return resources;
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPStructureToStructureLink(org.olat.portfolio.model.structel.EPStructureToStructureLink) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 49 with DBQuery

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

the class EPStructureManager method countArtefactsRecursively.

/**
 * Count all artefacts (links) in a map
 */
protected int countArtefactsRecursively(PortfolioStructure structure) {
    // return countArtefactsRecursively(structure, 0);
    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.rootMap root").append(" where root=:structureEl");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setEntity("structureEl", structure);
    Number count = (Number) query.uniqueResult();
    return count.intValue();
}
Also used : EPStructureToArtefactLink(org.olat.portfolio.model.structel.EPStructureToArtefactLink) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 50 with DBQuery

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

the class EPStructureManager method countArtefacts.

/**
 * Return the number of artefacts hold by a structure element
 * @param structure
 * @return
 */
public int countArtefacts(PortfolioStructure structure) {
    StringBuilder sb = new StringBuilder();
    sb.append("select count(link) from ").append(EPStructureToArtefactLink.class.getName()).append(" link").append(" where link.structureElement=:structureEl");
    DBQuery query = dbInstance.createQuery(sb.toString());
    query.setEntity("structureEl", structure);
    Number count = (Number) query.uniqueResult();
    return count.intValue();
}
Also used : EPStructureToArtefactLink(org.olat.portfolio.model.structel.EPStructureToArtefactLink) 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