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;
}
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;
}
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;
}
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();
}
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();
}
Aggregations