Search in sources :

Example 66 with DBQuery

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;
}
Also used : DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 67 with DBQuery

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;
}
Also used : TagImpl(org.olat.core.commons.services.tagging.model.TagImpl) DBQuery(org.olat.core.commons.persistence.DBQuery) Map(java.util.Map)

Example 68 with DBQuery

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;
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 69 with DBQuery

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;
}
Also used : InfoMessage(org.olat.commons.info.InfoMessage) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 70 with DBQuery

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();
}
Also used : 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