Search in sources :

Example 11 with MarkResourceStat

use of org.olat.core.commons.services.mark.MarkResourceStat in project openolat by klemens.

the class MarkManagerImpl method getStats.

@Override
public List<MarkResourceStat> getStats(OLATResourceable ores, List<String> subPaths, Identity identity) {
    if (subPaths == null || subPaths.isEmpty()) {
        // these stats are optimized
        if (identity == null) {
            return getStats(ores);
        } else {
            return getStats(ores, identity);
        }
    } else {
        StringBuilder sb = new StringBuilder();
        sb.append("select count(mark.resSubPath), mark.resSubPath from ").append(MarkImpl.class.getName()).append(" mark where ").append("mark.resId=:resId and mark.resName=:resName and mark.resSubPath in (:resSubPath)");
        if (identity != null) {
            sb.append(" and mark.creator=:creator");
        }
        sb.append(" group by mark.resSubPath");
        TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("resName", ores.getResourceableTypeName()).setParameter("resId", ores.getResourceableId()).setParameter("resSubPath", subPaths);
        if (identity != null) {
            query.setParameter("creator", identity);
        }
        List<Object[]> rawStats = query.getResultList();
        List<MarkResourceStat> stats = new ArrayList<MarkResourceStat>(rawStats.size());
        for (Object[] rawStat : rawStats) {
            stats.add(new MarkResourceStat(ores, (String) rawStat[1], ((Number) rawStat[0]).intValue()));
        }
        return stats;
    }
}
Also used : MarkResourceStat(org.olat.core.commons.services.mark.MarkResourceStat) ArrayList(java.util.ArrayList)

Example 12 with MarkResourceStat

use of org.olat.core.commons.services.mark.MarkResourceStat in project openolat by klemens.

the class MarkManagerImpl method getStats.

private List<MarkResourceStat> getStats(OLATResourceable ores) {
    StringBuilder sb = new StringBuilder();
    sb.append("select count(mark.resSubPath), mark.resSubPath from ").append(MarkImpl.class.getName()).append(" mark where ").append("mark.resId=:resId and mark.resName=:resName").append(" group by mark.resSubPath");
    List<Object[]> rawStats = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("resName", ores.getResourceableTypeName()).setParameter("resId", ores.getResourceableId()).getResultList();
    List<MarkResourceStat> stats = new ArrayList<MarkResourceStat>(rawStats.size());
    for (Object[] rawStat : rawStats) {
        stats.add(new MarkResourceStat(ores, (String) rawStat[1], ((Number) rawStat[0]).intValue()));
    }
    return stats;
}
Also used : MarkResourceStat(org.olat.core.commons.services.mark.MarkResourceStat) ArrayList(java.util.ArrayList)

Aggregations

MarkResourceStat (org.olat.core.commons.services.mark.MarkResourceStat)12 ArrayList (java.util.ArrayList)10 Mark (org.olat.core.commons.services.mark.Mark)6 HashMap (java.util.HashMap)4 Component (org.olat.core.gui.components.Component)2 Link (org.olat.core.gui.components.link.Link)2 LinkPopupSettings (org.olat.core.gui.components.link.LinkPopupSettings)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 DialogBoxController (org.olat.core.gui.control.generic.modal.DialogBoxController)2 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSItemMetaFilter (org.olat.core.util.vfs.filters.VFSItemMetaFilter)2 MessageLight (org.olat.modules.fo.MessageLight)2 MediaCollectorComponent (org.olat.modules.portfolio.ui.component.MediaCollectorComponent)2 DisplayPortraitController (org.olat.user.DisplayPortraitController)2