Search in sources :

Example 1 with PageUserInformations

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

the class PortfolioServiceImpl method getPageUserInfos.

@Override
public PageUserInformations getPageUserInfos(Page page, Identity identity, PageUserStatus defaultStatus) {
    PageUserInformations infos = pageUserInfosDao.getPageUserInfos(page, identity);
    if (infos == null) {
        PageStatus status = page.getPageStatus();
        PageUserStatus userStatus = defaultStatus;
        if (status == null || status == PageStatus.draft) {
            userStatus = PageUserStatus.incoming;
        } else if (status == PageStatus.closed || status == PageStatus.deleted) {
            userStatus = PageUserStatus.done;
        }
        infos = pageUserInfosDao.create(userStatus, page, identity);
    }
    return infos;
}
Also used : PageStatus(org.olat.modules.portfolio.PageStatus) PageUserStatus(org.olat.modules.portfolio.PageUserStatus) PageUserInformations(org.olat.modules.portfolio.PageUserInformations)

Example 2 with PageUserInformations

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

the class TableOfContentController method loadPagesModel.

private void loadPagesModel(Map<Long, SectionRow> sectionMap) {
    boolean showUserInfos = secCallback.canPageUserInfosStatus();
    mainVC.contextPut("userInfos", Boolean.valueOf(showUserInfos));
    Map<Long, PageUserInformations> userInfosToPages = new HashMap<>();
    if (showUserInfos) {
        List<PageUserInformations> userInfos = portfolioService.getPageUserInfos(binder, getIdentity());
        for (PageUserInformations userInfo : userInfos) {
            userInfosToPages.put(userInfo.getPage().getKey(), userInfo);
        }
        mainVC.contextPut("userInfosRenderer", new SharedPageStatusCellRenderer(getTranslator()));
    }
    Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfComments(binder);
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Page page : pages) {
        Section section = page.getSection();
        if (section != null && sectionMap.containsKey(section.getKey())) {
            boolean viewElement = secCallback.canViewElement(page);
            boolean viewTitleElement = secCallback.canViewTitleOfElement(page);
            if (viewElement || viewTitleElement) {
                SectionRow sectionRow = sectionMap.get(section.getKey());
                PageRow pageRow = forgePageRow(page, numberOfCommentsMap, viewElement);
                sectionRow.getPages().add(pageRow);
                if (showUserInfos) {
                    PageUserInformations userInfos = userInfosToPages.get(pageRow.getPage().getKey());
                    if (userInfos != null) {
                        pageRow.setUserInfosStatus(userInfos.getStatus());
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) PageUserInformations(org.olat.modules.portfolio.PageUserInformations)

Example 3 with PageUserInformations

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

the class TableOfContentController method loadPagesModel.

private void loadPagesModel(Map<Long, SectionRow> sectionMap) {
    boolean showUserInfos = secCallback.canPageUserInfosStatus();
    mainVC.contextPut("userInfos", Boolean.valueOf(showUserInfos));
    Map<Long, PageUserInformations> userInfosToPages = new HashMap<>();
    if (showUserInfos) {
        List<PageUserInformations> userInfos = portfolioService.getPageUserInfos(binder, getIdentity());
        for (PageUserInformations userInfo : userInfos) {
            userInfosToPages.put(userInfo.getPage().getKey(), userInfo);
        }
        mainVC.contextPut("userInfosRenderer", new SharedPageStatusCellRenderer(getTranslator()));
    }
    Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfComments(binder);
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Page page : pages) {
        Section section = page.getSection();
        if (section != null && sectionMap.containsKey(section.getKey())) {
            boolean viewElement = secCallback.canViewElement(page);
            boolean viewTitleElement = secCallback.canViewTitleOfElement(page);
            if (viewElement || viewTitleElement) {
                SectionRow sectionRow = sectionMap.get(section.getKey());
                PageRow pageRow = forgePageRow(page, numberOfCommentsMap, viewElement);
                sectionRow.getPages().add(pageRow);
                if (showUserInfos) {
                    PageUserInformations userInfos = userInfosToPages.get(pageRow.getPage().getKey());
                    if (userInfos != null) {
                        pageRow.setUserInfosStatus(userInfos.getStatus());
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) PageUserInformations(org.olat.modules.portfolio.PageUserInformations)

Example 4 with PageUserInformations

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

the class SharedPagesController method toggleBookmark.

private void toggleBookmark(SharedPageRow row) {
    Page page = portfolioService.getPageByKey(row.getPageKey());
    PageUserInformations infos = portfolioService.getPageUserInfos(page, getIdentity(), PageUserStatus.incoming);
    infos.setMark(!infos.isMark());
    infos = portfolioService.updatePageUserInfos(infos);
    if (searchParams.isBookmarkOnly() && !infos.isMark()) {
        List<SharedPageRow> rows = model.getObjects();
        rows.remove(row);
        model.setObjects(rows);
        tableEl.reset(false, false, true);
    } else {
        row.getBookmarkLink().setIconLeftCSS(infos.isMark() ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
    }
}
Also used : PageUserInformations(org.olat.modules.portfolio.PageUserInformations) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page)

Example 5 with PageUserInformations

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

the class PageUserInfosDAOTest method createPageUserInfos.

@Test
public void createPageUserInfos() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("pui-1");
    BinderImpl binder = binderDao.createAndPersist("Binder pui1", "A binder with a page for infos", null, null);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    Page page = pageDao.createAndPersist("New page", "A brand new page.", null, null, true, section, null);
    dbInstance.commitAndCloseSession();
    PageUserInformations infos = pageUserInfosDao.create(PageUserStatus.incoming, page, coach);
    Assert.assertNotNull(infos);
    Assert.assertEquals(coach, infos.getIdentity());
    Assert.assertEquals(page, infos.getPage());
    Assert.assertEquals(PageUserStatus.incoming, infos.getStatus());
    Assert.assertFalse(infos.isMark());
    dbInstance.commit();
}
Also used : PageUserInformations(org.olat.modules.portfolio.PageUserInformations) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Aggregations

PageUserInformations (org.olat.modules.portfolio.PageUserInformations)20 Page (org.olat.modules.portfolio.Page)18 Section (org.olat.modules.portfolio.Section)16 Identity (org.olat.core.id.Identity)14 Test (org.junit.Test)12 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)12 HashMap (java.util.HashMap)4 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 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 BaseFullWebappPopupLayoutFactory (org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayoutFactory)2 SortKey (org.olat.core.commons.persistence.SortKey)2 UserRequest (org.olat.core.gui.UserRequest)2 Component (org.olat.core.gui.components.Component)2 Dropdown (org.olat.core.gui.components.dropdown.Dropdown)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2