Search in sources :

Example 11 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project OpenOLAT by OpenOLAT.

the class ConfirmMoveBinderToTrashController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    StringBuilder names = new StringBuilder();
    int numOfPages = 0;
    int numOfSections = 0;
    int numOfComments = 0;
    for (BinderStatistics stat : stats) {
        if (names.length() > 0)
            names.append(", ");
        names.append(StringHelper.escapeHtml(stat.getTitle()));
        numOfPages += stat.getNumOfPages();
        numOfSections += stat.getNumOfSections();
        numOfComments += stat.getNumOfComments();
    }
    String[] args = new String[] { names.toString(), Integer.toString(numOfSections), Integer.toString(numOfPages), Integer.toString(numOfComments) };
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("msg", translate("delete.binder.warning", args));
        layoutCont.contextPut("dangerCssClass", "o_warning");
    }
    String[] onValues = new String[] { translate("trash.binder.acknowledge") };
    acknowledgeEl = uifactory.addCheckboxesHorizontal("acknowledge", "delete.binder.acknowledge", formLayout, onKeys, onValues);
    uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    uifactory.addFormSubmitButton("delete", "delete.binder", formLayout);
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics)

Example 12 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project OpenOLAT by OpenOLAT.

the class ConfirmDeleteBinderController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    StringBuilder names = new StringBuilder();
    int numOfPages = 0;
    int numOfSections = 0;
    int numOfComments = 0;
    for (BinderStatistics stat : stats) {
        if (names.length() > 0)
            names.append(", ");
        names.append(StringHelper.escapeHtml(stat.getTitle()));
        numOfPages += stat.getNumOfPages();
        numOfSections += stat.getNumOfSections();
        numOfComments += stat.getNumOfComments();
    }
    String[] args = new String[] { names.toString(), Integer.toString(numOfSections), Integer.toString(numOfPages), Integer.toString(numOfComments) };
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("msg", translate("delete.binder.warning", args));
        layoutCont.contextPut("dangerCssClass", "o_error");
    }
    String[] onValues = new String[] { translate("delete.binder.acknowledge") };
    acknowledgeEl = uifactory.addCheckboxesHorizontal("acknowledge", "confirmation", formLayout, onKeys, onValues);
    String[] on2Values = new String[] { translate("delete.binder.acknowledge.2") };
    acknowledge2El = uifactory.addCheckboxesHorizontal("acknowledge2", "confirmation", formLayout, onKeys, on2Values);
    uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    uifactory.addFormSubmitButton("delete", "delete.binder", formLayout);
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics)

Example 13 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project OpenOLAT by OpenOLAT.

the class DeletedBinderController method loadModel.

@Override
protected void loadModel() {
    List<BinderStatistics> binderRows = portfolioService.searchOwnedDeletedBinders(getIdentity());
    List<BinderRow> rows = new ArrayList<>(binderRows.size());
    for (BinderStatistics binderRow : binderRows) {
        rows.add(forgePortfolioRow(binderRow));
    }
    model.setObjects(rows);
    tableEl.reset();
    tableEl.reloadData();
}
Also used : BinderRow(org.olat.modules.portfolio.ui.model.BinderRow) ArrayList(java.util.ArrayList) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics)

Example 14 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project OpenOLAT by OpenOLAT.

the class BinderDAO method searchOwnedBinders.

/**
 * The same type of query is user for the categories
 * @param owner
 * @return
 */
public List<BinderStatistics> searchOwnedBinders(IdentityRef owner, boolean deleted) {
    StringBuilder sb = new StringBuilder(1024);
    sb.append("select binder.key, binder.title, binder.imagePath, binder.lastModified, binder.status,").append(" binderEntry.displayname,").append(" (select count(section.key) from pfsection as section").append("   where section.binder.key=binder.key").append(" ) as numOfSections,").append(" (select count(page.key) from pfpage as page, pfsection as pageSection").append("   where pageSection.binder.key=binder.key and page.section.key=pageSection.key").append(" ) as numOfPages,").append(" (select count(comment.key) from usercomment as comment, pfpage as page, pfsection as pageSection").append("   where pageSection.binder.key=binder.key and page.section.key=pageSection.key and comment.resId=page.key and comment.resName='Page'").append(" ) as numOfComments").append(" from pfbinder as binder").append(" left join binder.baseGroup as baseGroup").append(" left join baseGroup.members as membership").append(" left join binder.entry binderEntry").append(" where binder.olatResource is null and membership.identity.key=:identityKey and membership.role=:role");
    if (deleted) {
        sb.append(" and binder.status='").append(BinderStatus.deleted.name()).append("'");
    } else {
        sb.append(" and (binder.status is null or binder.status='").append(BinderStatus.open.name()).append("')");
    }
    List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("identityKey", owner.getKey()).setParameter("role", PortfolioRoles.owner.name()).getResultList();
    List<BinderStatistics> rows = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        int pos = 0;
        Long key = (Long) object[pos++];
        String title = (String) object[pos++];
        String imagePath = (String) object[pos++];
        Date lastModified = (Date) object[pos++];
        String status = (String) object[pos++];
        String repoEntryName = (String) object[pos++];
        int numOfSections = ((Number) object[pos++]).intValue();
        int numOfPages = ((Number) object[pos++]).intValue();
        int numOfComments = ((Number) object[pos++]).intValue();
        rows.add(new BinderStatistics(key, title, imagePath, lastModified, numOfSections, numOfPages, status, repoEntryName, numOfComments));
    }
    return rows;
}
Also used : ArrayList(java.util.ArrayList) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics) Date(java.util.Date)

Example 15 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project OpenOLAT by OpenOLAT.

the class BinderDAO method getBinderStatistics.

/**
 * The same type of query is user for the categories
 * @param owner
 * @return
 */
public BinderStatistics getBinderStatistics(BinderRef binder) {
    StringBuilder sb = new StringBuilder();
    sb.append("select binder.key, binder.title, binder.imagePath, binder.lastModified, binder.status,").append(" binderEntry.displayname,").append(" (select count(section.key) from pfsection as section").append("   where section.binder.key=binder.key").append(" ) as numOfSections,").append(" (select count(page.key) from pfpage as page, pfsection as pageSection").append("   where pageSection.binder.key=binder.key and page.section.key=pageSection.key").append(" ) as numOfPages,").append(" (select count(comment.key) from usercomment as comment, pfpage as page, pfsection as pageSection").append("   where pageSection.binder.key=binder.key and page.section.key=pageSection.key and comment.resId=page.key and comment.resName='Page'").append(" ) as numOfComments").append(" from pfbinder as binder").append(" left join binder.entry binderEntry").append(" where binder.key=:binderKey");
    List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey()).getResultList();
    if (objects.size() >= 1) {
        int pos = 0;
        Object[] object = objects.get(0);
        Long key = (Long) object[pos++];
        String title = (String) object[pos++];
        String imagePath = (String) object[pos++];
        Date lastModified = (Date) object[pos++];
        String status = (String) object[pos++];
        String repoEntryName = (String) object[pos++];
        int numOfSections = ((Number) object[pos++]).intValue();
        int numOfPages = ((Number) object[pos++]).intValue();
        int numOfComments = ((Number) object[pos++]).intValue();
        return new BinderStatistics(key, title, imagePath, lastModified, numOfSections, numOfPages, status, repoEntryName, numOfComments);
    }
    return null;
}
Also used : BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics) Date(java.util.Date)

Aggregations

BinderStatistics (org.olat.modules.portfolio.model.BinderStatistics)20 ArrayList (java.util.ArrayList)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 BinderRow (org.olat.modules.portfolio.ui.model.BinderRow)6 Date (java.util.Date)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 Test (org.junit.Test)2 Identity (org.olat.core.id.Identity)2 Binder (org.olat.modules.portfolio.Binder)2 Section (org.olat.modules.portfolio.Section)2 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)2