use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class TaggingManagerImpl method getTagsAsString.
@Override
public List<String> getTagsAsString(Identity identity, OLATResourceable ores, String subPath, String businessPath) {
if (ores.getResourceableId() == null || ores.getResourceableTypeName() == null) {
// this ores seems not yet to be persisted, therefore has no key and as a result no tags!
return null;
}
StringBuilder sb = new StringBuilder();
sb.append("select tag.tag from ").append(TagImpl.class.getName()).append(" tag where tag.resId=:resId and tag.resName=:resName");
if (subPath != null) {
sb.append(" and tag.subPath=:subPath");
}
if (identity != null) {
sb.append(" and tag.author=:author");
}
if (businessPath != null) {
sb.append(" and tag.businessPath=:businessPath");
}
sb.append(" group by tag.tag");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setLong("resId", ores.getResourceableId());
query.setString("resName", ores.getResourceableTypeName());
if (subPath != null) {
query.setString("subPath", subPath);
}
if (identity != null) {
query.setEntity("author", identity);
}
if (businessPath != null) {
query.setString("businessPath", businessPath);
}
@SuppressWarnings("unchecked") List<String> tags = query.list();
return tags;
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
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 SimpleTagProposalManager method proposeTagsForInputText.
@Override
public List<String> proposeTagsForInputText(String referenceText, boolean onlyExisting) {
List<String> tokens = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(referenceText, " \t\n\r\f.,;:-!?");
for (; tokenizer.hasMoreTokens(); ) {
String next = tokenizer.nextToken().trim();
next = next.replace(" ", "");
if (!tokens.contains(next) && StringHelper.containsNonWhitespace(next) && next.length() > 3)
tokens.add(next);
if (tokens.size() == 500) {
break;
}
}
if (onlyExisting) {
StringBuilder sb = new StringBuilder();
sb.append("select tag.tag from ").append(TagImpl.class.getName()).append(" tag where tag.tag in (:tokens) group by tag.tag");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setParameterList("tokens", tokens);
@SuppressWarnings("unchecked") List<String> currentTags = query.list();
return currentTags;
} else {
return tokens;
}
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class BaseSecurityManager method countIdentitiesByPowerSearch.
@Override
public int countIdentitiesByPowerSearch(SearchIdentityParams params) {
DBQuery dbq = createIdentitiesByPowerQuery(params, true);
Number count = (Number) dbq.uniqueResult();
return count.intValue();
}
Aggregations