use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PublishController method reloadData.
public void reloadData() {
binderRow.getChildren().clear();
binderRow.getAccessRights().clear();
List<AccessRights> rights = portfolioService.getAccessRights(binder);
boolean canEditBinderAccessRights = secCallback.canEditAccessRights(binder);
for (AccessRights right : rights) {
if (right.getSectionKey() == null && right.getPageKey() == null) {
if (PortfolioRoles.invitee.equals(right.getRole())) {
// only access
continue;
}
Link editLink = null;
if (canEditBinderAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
}
binderRow.getAccessRights().add(new AccessRightsRow(binder, right, editLink));
}
}
List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
Map<Section, AssessmentSection> sectionToAssessmentSectionMap = new HashMap<>();
for (AssessmentSection assessmentSection : assessmentSections) {
sectionToAssessmentSectionMap.put(assessmentSection.getSection(), assessmentSection);
}
// sections
List<Section> sections = portfolioService.getSections(binder);
Map<Long, PortfolioElementRow> sectionMap = new HashMap<>();
for (Section section : sections) {
boolean canEditSectionAccessRights = secCallback.canEditAccessRights(section);
boolean canViewSectionAccessRights = secCallback.canViewAccessRights(section);
if (canEditSectionAccessRights || canViewSectionAccessRights) {
PortfolioElementRow sectionRow = new PortfolioElementRow(section, sectionToAssessmentSectionMap.get(section));
binderRow.getChildren().add(sectionRow);
sectionMap.put(section.getKey(), sectionRow);
for (AccessRights right : rights) {
if (section.getKey().equals(right.getSectionKey()) && right.getPageKey() == null) {
Link editLink = null;
if (canEditSectionAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
sectionRow.getAccessRights().add(new AccessRightsRow(section, right, editLink));
}
}
}
}
}
// pages
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
boolean canEditPageAccessRights = secCallback.canEditAccessRights(page);
boolean canViewPageAccessRights = secCallback.canViewAccessRights(page);
if (canEditPageAccessRights || canViewPageAccessRights) {
Section section = page.getSection();
PortfolioElementRow sectionRow = sectionMap.get(section.getKey());
if (sectionRow == null) {
logError("Section not found: " + section.getKey() + " of page: " + page.getKey(), null);
continue;
}
PortfolioElementRow pageRow = new PortfolioElementRow(page, null);
sectionRow.getChildren().add(pageRow);
for (AccessRights right : rights) {
if (page.getKey().equals(right.getPageKey())) {
Link editLink = null;
if (canEditPageAccessRights && !PortfolioRoles.owner.equals(right.getRole())) {
String id = "edit_" + (counter++);
editLink = LinkFactory.createLink(id, id, "edit_access", "edit", getTranslator(), mainVC, this, Link.LINK);
pageRow.getAccessRights().add(new AccessRightsRow(page, right, editLink));
}
}
}
}
}
mainVC.setDirty(true);
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PageRunController method doMoveToTrash.
private void doMoveToTrash(UserRequest ureq) {
Page floatingPage = portfolioService.removePage(page);
fireEvent(ureq, new PageRemovedEvent(floatingPage));
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class MyPageListController method loadModel.
@Override
protected void loadModel(UserRequest ureq, String searchString) {
Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfCommentsOnOwnedPage(getIdentity());
List<CategoryToElement> categorizedElements = portfolioService.getCategorizedOwnedPages(getIdentity());
Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
for (CategoryToElement categorizedElement : categorizedElements) {
List<Category> categories = categorizedElementMap.get(categorizedElement.getCategorizedResource());
if (categories == null) {
categories = new ArrayList<>();
categorizedElementMap.put(categorizedElement.getCategorizedResource(), categories);
}
categories.add(categorizedElement.getCategory());
}
List<Assignment> assignments = portfolioService.searchOwnedAssignments(getIdentity());
Map<Page, List<Assignment>> pageToAssignments = new HashMap<>();
for (Assignment assignment : assignments) {
Page page = assignment.getPage();
List<Assignment> assignmentList;
if (pageToAssignments.containsKey(page)) {
assignmentList = pageToAssignments.get(page);
} else {
assignmentList = new ArrayList<>();
pageToAssignments.put(page, assignmentList);
}
assignmentList.add(assignment);
}
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary");
List<Page> pages = portfolioService.searchOwnedPages(getIdentity(), searchString);
List<PortfolioElementRow> rows = new ArrayList<>(pages.size());
List<TimelinePoint> points = new ArrayList<>(pages.size());
for (Page page : pages) {
if (page.getPageStatus() == PageStatus.deleted) {
continue;
}
List<Assignment> assignmentList = pageToAssignments.get(page);
PortfolioElementRow row = forgePageRow(ureq, page, null, assignmentList, categorizedElementMap, numberOfCommentsMap, true);
rows.add(row);
if (page.getSection() != null) {
Section section = page.getSection();
row.setMetaSectionTitle(section.getTitle());
if (section.getBinder() != null) {
row.setMetaBinderTitle(section.getBinder().getTitle());
}
}
row.setNewFloatingEntryLink(newEntryButton);
String s = page.getPageStatus() == null ? "draft" : page.getPageStatus().name();
points.add(new TimelinePoint(page.getKey().toString(), page.getTitle(), page.getCreationDate(), s));
}
timelineEl.setPoints(points);
// clean up the posters
disposeRows();
model.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class TableOfContentController method doOpenPage.
private PageRunController doOpenPage(UserRequest ureq, Page page) {
removeAsListenerAndDispose(pageCtrl);
OLATResourceable pageOres = OresHelper.createOLATResourceableInstance("Entry", page.getKey());
WindowControl swControl = addToHistory(ureq, pageOres, null);
Page reloadedPage = portfolioService.getPageByKey(page.getKey());
boolean openInEditMode = (secCallback.canEditPage(reloadedPage) && (reloadedPage.getPageStatus() == null || reloadedPage.getPageStatus() == PageStatus.draft || reloadedPage.getPageStatus() == PageStatus.inRevision));
pageCtrl = new PageRunController(ureq, swControl, stackPanel, secCallback, reloadedPage, openInEditMode);
listenTo(pageCtrl);
stackPanel.pushController(page.getTitle(), pageCtrl);
return pageCtrl;
}
use of org.olat.modules.portfolio.Page 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());
}
}
}
}
}
}
Aggregations