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;
}
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());
}
}
}
}
}
}
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());
}
}
}
}
}
}
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);
}
}
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();
}
Aggregations