Search in sources :

Example 1 with SectionStatus

use of org.olat.modules.portfolio.SectionStatus in project OpenOLAT by OpenOLAT.

the class SharedWithMeQueries method searchSharedBindersTwo.

private void searchSharedBindersTwo(Identity member, List<AssessedBinder> binders) {
    StringBuilder sb = new StringBuilder(2048);
    sb.append("select binder.key,").append("  section.key, section.status, section.title, section.pos, section.endDate,").append("  page.key, page.status, page.lastModified, page.lastPublicationDate,").append("  body.lastModified, max(parts.lastModified), infos.recentLaunch").append(" from pfbinder as binder").append(" inner join binder.sections as section").append(" inner join section.pages as page").append(" inner join page.body as body").append(" left join body.parts as parts").append(" left join pfbinderuserinfos as infos on (infos.binder.key=binder.key and infos.identity.key=:identityKey)").append(" where exists (select membership.key from bgroupmember as membership").append("   where membership.group.key=binder.baseGroup.key and membership.identity.key=:identityKey and membership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("')").append(" ) or exists (select sectionMembership.key from bgroupmember as sectionMembership").append("   where sectionMembership.group.key=section.baseGroup.key and sectionMembership.identity.key=:identityKey and sectionMembership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("')").append(" ) or exists (select page.key from pfpage as coachedPage").append("   inner join coachedPage.baseGroup as pageGroup").append("   inner join pageGroup.members as pageMembership on (pageMembership.identity.key=:identityKey and pageMembership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("'))").append("   where coachedPage.key=page.key").append(" ) group by binder.key, section.key, section.status, section.title, section.pos, section.endDate,").append("    page.key, page.status, page.lastModified, page.lastPublicationDate, body.lastModified, infos.recentLaunch");
    Date now = new Date();
    List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("identityKey", member.getKey()).getResultList();
    if (objects.size() > 0) {
        Set<Long> sectionKeys = new HashSet<>();
        Map<Long, AssessedBinder> keyToBinder = binders.stream().collect(Collectors.toMap(b -> b.getBinderKey(), b -> b));
        for (Object[] object : objects) {
            int pos = 0;
            Long binderKey = (Long) object[pos++];
            AssessedBinder binder = keyToBinder.get(binderKey);
            if (binder == null) {
                continue;
            }
            Long sectionKey = (Long) object[pos++];
            String sectionStatus = (String) object[pos++];
            String sectionTitle = (String) object[pos++];
            Number sectionPosNumber = (Number) object[pos++];
            Date sectionEndDate = (Date) object[pos++];
            ;
            Long pageKey = (Long) object[pos++];
            String pageStatus = (String) object[pos++];
            Date pageLastModified = (Date) object[pos++];
            Date pageLastPublication = (Date) object[pos++];
            Date bodyLastModified = (Date) object[pos++];
            Date partLastModified = (Date) object[pos++];
            Date recentLaunch = (Date) object[pos++];
            Date lastModified = pageLastModified;
            if (lastModified == null || (lastModified != null && partLastModified != null && partLastModified.after(lastModified))) {
                lastModified = partLastModified;
            }
            if (lastModified == null || (lastModified != null && bodyLastModified != null && bodyLastModified.after(lastModified))) {
                lastModified = bodyLastModified;
            }
            if (lastModified != null && (binder.getLastModified() == null || binder.getLastModified().before(lastModified))) {
                binder.setLastModified(lastModified);
            }
            if (binder.getRecentLaunch() == null) {
                binder.setRecentLaunch(recentLaunch);
            }
            if (pageKey != null && pageStatus == null) {
                binder.incrementNumOfDraftPages();
            } else if (StringHelper.containsNonWhitespace(pageStatus)) {
                PageStatus status = PageStatus.valueOf(pageStatus);
                if (PageStatus.isClosed(status, sectionEndDate, now)) {
                    binder.incrementNumOfClosedPages();
                } else if (PageStatus.draft.name().equals(pageStatus)) {
                    binder.incrementNumOfDraftPages();
                } else if (PageStatus.inRevision.name().equals(pageStatus)) {
                    binder.incrementNumOfInRevisionPages();
                }
            }
            if (recentLaunch == null && pageLastPublication != null) {
                binder.incrementNumOfNewlyPublishedPages();
            } else if (recentLaunch != null && pageLastPublication != null && recentLaunch.before(pageLastPublication)) {
                binder.incrementNumOfNewlyPublishedPages();
            }
            if (!sectionKeys.contains(sectionKey)) {
                SectionStatus status = SectionStatus.notStarted;
                if (StringHelper.containsNonWhitespace(sectionStatus)) {
                    status = SectionStatus.valueOf(sectionStatus);
                }
                if (status == SectionStatus.notStarted || status == SectionStatus.inProgress) {
                    binder.setNumOfOpenSections(binder.getNumOfOpenSections() + 1);
                }
                if (status == SectionStatus.inProgress || status == SectionStatus.submitted || status == SectionStatus.closed) {
                    if (binder.getSections() == null) {
                        binder.setSections(new ArrayList<>());
                    }
                    int sectionPos = sectionPosNumber == null ? -1 : sectionPosNumber.intValue();
                    binder.getSections().add(new AssessedBinderSection(sectionKey, sectionTitle, sectionPos));
                    sectionKeys.add(sectionKey);
                }
            }
        }
    }
}
Also used : PersistenceHelper.makeFuzzyQueryString(org.olat.core.commons.persistence.PersistenceHelper.makeFuzzyQueryString) SearchSharePagesParameters(org.olat.modules.portfolio.model.SearchSharePagesParameters) AssessedBinderSection(org.olat.modules.portfolio.model.AssessedBinderSection) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) TypedQuery(javax.persistence.TypedQuery) ArrayList(java.util.ArrayList) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) HashSet(java.util.HashSet) BigDecimal(java.math.BigDecimal) Service(org.springframework.stereotype.Service) Map(java.util.Map) SectionStatus(org.olat.modules.portfolio.SectionStatus) StringHelper(org.olat.core.util.StringHelper) PersistenceHelper.appendFuzzyLike(org.olat.core.commons.persistence.PersistenceHelper.appendFuzzyLike) PageUserStatus(org.olat.modules.portfolio.PageUserStatus) Set(java.util.Set) BinderStatus(org.olat.modules.portfolio.BinderStatus) Collectors(java.util.stream.Collectors) List(java.util.List) DB(org.olat.core.commons.persistence.DB) Identity(org.olat.core.id.Identity) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) PortfolioRoles(org.olat.modules.portfolio.PortfolioRoles) PageStatus(org.olat.modules.portfolio.PageStatus) PageStatus(org.olat.modules.portfolio.PageStatus) SectionStatus(org.olat.modules.portfolio.SectionStatus) AssessedBinderSection(org.olat.modules.portfolio.model.AssessedBinderSection) PersistenceHelper.makeFuzzyQueryString(org.olat.core.commons.persistence.PersistenceHelper.makeFuzzyQueryString) Date(java.util.Date) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) HashSet(java.util.HashSet)

Example 2 with SectionStatus

use of org.olat.modules.portfolio.SectionStatus in project OpenOLAT by OpenOLAT.

the class StatusCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
    if (cellValue instanceof PageStatus) {
        PageStatus status = (PageStatus) cellValue;
        String tip = translator.translate(status.i18nKey());
        target.append("<i class='o_icon ").append(status.cssClass()).append(" o_icon-fw' title='").append(tip).append("'> </i>");
    } else if (cellValue instanceof SectionStatus) {
        SectionStatus status = (SectionStatus) cellValue;
        String tip = translator.translate(status.i18nKey());
        target.append("<i class='o_icon ").append(status.cssClass()).append(" o_icon-fw' title='").append(tip).append("'> </i>");
    }
}
Also used : PageStatus(org.olat.modules.portfolio.PageStatus) SectionStatus(org.olat.modules.portfolio.SectionStatus)

Example 3 with SectionStatus

use of org.olat.modules.portfolio.SectionStatus in project openolat by klemens.

the class PortfolioServiceImpl method changePageStatus.

@Override
public Page changePageStatus(Page page, PageStatus status, Identity identity, Role by) {
    PageStatus currentStatus = page.getPageStatus();
    Page reloadedPage = pageDao.loadByKey(page.getKey());
    ((PageImpl) reloadedPage).setPageStatus(status);
    if (status == PageStatus.published) {
        Date now = new Date();
        if (reloadedPage.getInitialPublicationDate() == null) {
            ((PageImpl) reloadedPage).setInitialPublicationDate(now);
        }
        ((PageImpl) reloadedPage).setLastPublicationDate(now);
        Section section = reloadedPage.getSection();
        // auto update the status of the evaluation form of the authors of the binder
        changeAssignmentStatus(page, section, EvaluationFormSessionStatus.done);
        if (section != null) {
            SectionStatus sectionStatus = section.getSectionStatus();
            if (currentStatus == PageStatus.closed) {
                if (sectionStatus == SectionStatus.closed) {
                    ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                    binderDao.updateSection(section);
                }
            } else if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
                ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                binderDao.updateSection(section);
            }
        }
    } else if (status == PageStatus.inRevision) {
        Section section = reloadedPage.getSection();
        changeAssignmentStatus(page, section, EvaluationFormSessionStatus.inProgress);
        if (section != null) {
            SectionStatus sectionStatus = section.getSectionStatus();
            if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
                if (sectionStatus == SectionStatus.closed) {
                    ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                    binderDao.updateSection(section);
                }
            }
        }
        pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.inProcess, PageUserStatus.done);
    } else if (status == PageStatus.closed) {
        // set user informations to done
        pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.done);
    }
    if (reloadedPage.getSection() != null && reloadedPage.getSection().getBinder() != null) {
        Binder binder = reloadedPage.getSection().getBinder();
        updateAssessmentEntryLastModification(binder, identity, by);
    }
    return pageDao.updatePage(reloadedPage);
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PageStatus(org.olat.modules.portfolio.PageStatus) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) SectionStatus(org.olat.modules.portfolio.SectionStatus) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SectionImpl(org.olat.modules.portfolio.model.SectionImpl) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) Date(java.util.Date)

Example 4 with SectionStatus

use of org.olat.modules.portfolio.SectionStatus in project openolat by klemens.

the class SectionStatusCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
    if (cellValue instanceof SectionStatus) {
        SectionStatus status = (SectionStatus) cellValue;
        target.append("<i class='o_icon o_icon-fw ").append(status.cssClass()).append("'> </i> ").append(translator.translate(status.i18nKey()));
    }
}
Also used : SectionStatus(org.olat.modules.portfolio.SectionStatus)

Example 5 with SectionStatus

use of org.olat.modules.portfolio.SectionStatus in project OpenOLAT by OpenOLAT.

the class SectionStatusCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
    if (cellValue instanceof SectionStatus) {
        SectionStatus status = (SectionStatus) cellValue;
        target.append("<i class='o_icon o_icon-fw ").append(status.cssClass()).append("'> </i> ").append(translator.translate(status.i18nKey()));
    }
}
Also used : SectionStatus(org.olat.modules.portfolio.SectionStatus)

Aggregations

SectionStatus (org.olat.modules.portfolio.SectionStatus)8 PageStatus (org.olat.modules.portfolio.PageStatus)6 Date (java.util.Date)4 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)4 AssessedPage (org.olat.modules.portfolio.model.AssessedPage)4 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 TypedQuery (javax.persistence.TypedQuery)2 DB (org.olat.core.commons.persistence.DB)2 PersistenceHelper.appendFuzzyLike (org.olat.core.commons.persistence.PersistenceHelper.appendFuzzyLike)2 PersistenceHelper.makeFuzzyQueryString (org.olat.core.commons.persistence.PersistenceHelper.makeFuzzyQueryString)2 Identity (org.olat.core.id.Identity)2 StringHelper (org.olat.core.util.StringHelper)2 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)2 Binder (org.olat.modules.portfolio.Binder)2