Search in sources :

Example 91 with Page

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

the class DeletedPageListController 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<Page> pages = portfolioService.searchDeletedPages(getIdentity(), searchString);
    List<PortfolioElementRow> rows = new ArrayList<>(pages.size());
    for (Page page : pages) {
        rows.add(forgePageRow(ureq, page, null, null, categorizedElementMap, numberOfCommentsMap, true));
    }
    // clean up the posters
    disposeRows();
    model.setObjects(rows);
    tableEl.reset();
    tableEl.reloadData();
    deleteButton.setVisible(tableEl.getRendererType() == FlexiTableRendererType.classic && model.getRowCount() > 0);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Category(org.olat.modules.portfolio.Category) OLATResourceable(org.olat.core.id.OLATResourceable) HashMap(java.util.HashMap) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) ArrayList(java.util.ArrayList) List(java.util.List)

Example 92 with Page

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

the class BinderPageListController method loadModel.

@Override
protected void loadModel(UserRequest ureq, String searchString) {
    if (StringHelper.containsNonWhitespace(binder.getSummary())) {
        summaryComp.setText(binder.getSummary());
        flc.getFormItemComponent().put("summary", summaryCtrl.getInitialComponent());
    } else {
        flc.getFormItemComponent().remove("summary");
    }
    List<Section> sections = portfolioService.getSections(binder);
    List<CategoryToElement> categorizedElements = portfolioService.getCategorizedSectionsAndPages(binder);
    Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
    Map<Section, Set<String>> sectionAggregatedCategoriesMap = 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());
    }
    // comments
    Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfComments(binder);
    // assessment sections
    List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
    Map<Section, AssessmentSection> sectionToAssessmentSectionMap = assessmentSections.stream().collect(Collectors.toMap(as -> as.getSection(), as -> as));
    List<PortfolioElementRow> rows = new ArrayList<>();
    // assignments
    List<Assignment> assignments = portfolioService.getAssignments(binder, searchString);
    Map<Section, List<Assignment>> sectionToAssignmentMap = new HashMap<>();
    for (Assignment assignment : assignments) {
        List<Assignment> assignmentList;
        Section section = assignment.getSection();
        if (sectionToAssignmentMap.containsKey(section)) {
            assignmentList = sectionToAssignmentMap.get(section);
        } else {
            assignmentList = new ArrayList<>();
            sectionToAssignmentMap.put(section, assignmentList);
        }
        assignmentList.add(assignment);
    }
    for (Assignment assignment : assignments) {
        Section section = assignment.getSection();
        if (assignment.getPage() == null && secCallback.canViewPendingAssignments(section)) {
            List<Assignment> sectionAssignments = sectionToAssignmentMap.get(section);
            PortfolioElementRow row = forgePendingAssignmentRow(assignment, section, sectionAssignments);
            rows.add(row);
            if (secCallback.canAddPage(section)) {
                FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
                newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
                newEntryButton.setUserObject(row);
                row.setNewEntryLink(newEntryButton);
            }
        }
    }
    boolean userInfos = secCallback.canPageUserInfosStatus();
    Map<Long, PageUserInformations> userInfosToPage = new HashMap<>();
    rowVC.contextPut("userInfos", Boolean.valueOf(userInfos));
    if (userInfos) {
        rowVC.contextPut("userInfosRenderer", new SharedPageStatusCellRenderer(getTranslator()));
        List<PageUserInformations> userInfoList = portfolioService.getPageUserInfos(binder, getIdentity());
        for (PageUserInformations userInfo : userInfoList) {
            userInfosToPage.put(userInfo.getPage().getKey(), userInfo);
        }
    }
    List<Page> pages = portfolioService.getPages(binder, searchString);
    for (Page page : pages) {
        boolean viewElement = secCallback.canViewElement(page);
        boolean viewTitleElement = viewElement || secCallback.canViewTitleOfElement(page);
        if (!viewTitleElement) {
            continue;
        }
        Section section = page.getSection();
        PortfolioElementRow pageRow = forgePageRow(ureq, page, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), categorizedElementMap, numberOfCommentsMap, viewElement);
        rows.add(pageRow);
        if (secCallback.canAddPage(section)) {
            FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
            newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
            newEntryButton.setUserObject(pageRow);
            pageRow.setNewEntryLink(newEntryButton);
        }
        if (secCallback.canNewAssignment() && section != null) {
            FormLink newAssignmentButton = uifactory.addFormLink("new.assignment." + (++counter), "new.assignment", "create.new.assignment", null, flc, Link.BUTTON);
            newAssignmentButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_assignment");
            newAssignmentButton.setUserObject(pageRow);
            pageRow.setNewAssignmentLink(newAssignmentButton);
        }
        if (userInfos) {
            PageUserInformations infos = userInfosToPage.get(page.getKey());
            if (infos != null) {
                pageRow.setUserInfosStatus(infos.getStatus());
            }
        }
        if (section != null) {
            Set<String> categories = sectionAggregatedCategoriesMap.get(section);
            if (categories == null) {
                categories = new HashSet<>();
                sectionAggregatedCategoriesMap.put(section, categories);
            }
            if (pageRow.getPageCategories() != null && pageRow.getPageCategories().size() > 0) {
                categories.addAll(pageRow.getPageCategories());
            }
            pageRow.setSectionCategories(categories);
        }
    }
    // sections without pages
    if (!StringHelper.containsNonWhitespace(searchString)) {
        for (Section section : sections) {
            if (!secCallback.canViewElement(section)) {
                continue;
            }
            PortfolioElementRow sectionRow = forgeSectionRow(section, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), categorizedElementMap);
            rows.add(sectionRow);
            if (secCallback.canAddPage(section)) {
                FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
                newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
                newEntryButton.setUserObject(sectionRow);
                sectionRow.setNewEntryLink(newEntryButton);
            }
            if (secCallback.canNewAssignment() && section != null) {
                FormLink newAssignmentButton = uifactory.addFormLink("new.assignment." + (++counter), "new.assignment", "create.new.assignment", null, flc, Link.BUTTON);
                newAssignmentButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_assignment");
                newAssignmentButton.setUserObject(sectionRow);
                sectionRow.setNewAssignmentLink(newAssignmentButton);
            }
        }
    }
    if (newSectionButton != null && rows.isEmpty()) {
        flc.add("create.new.section", newSectionButton);
    } else if (newSectionButton != null) {
        flc.remove(newSectionButton);
    }
    if (newEntryLink != null && !newEntryLink.isVisible()) {
        newEntryLink.setVisible(rows.size() > 0);
        stackPanel.setDirty(true);
    }
    if (newAssignmentLink != null && !newAssignmentLink.isVisible()) {
        newAssignmentLink.setVisible(rows.size() > 0);
        stackPanel.setDirty(true);
    }
    // clean up the posters
    disposeRows();
    model.setObjects(rows);
    if (filteringSection != null) {
        doFilterSection(filteringSection);
    } else {
        tableEl.reloadData();
        updateTimeline();
    }
}
Also used : Autowired(org.springframework.beans.factory.annotation.Autowired) PageUserInformations(org.olat.modules.portfolio.PageUserInformations) TextFactory(org.olat.core.gui.components.text.TextFactory) MediaResource(org.olat.core.gui.media.MediaResource) OLATResourceable(org.olat.core.id.OLATResourceable) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration) Category(org.olat.modules.portfolio.Category) Assignment(org.olat.modules.portfolio.Assignment) Map(java.util.Map) SortKey(org.olat.core.commons.persistence.SortKey) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) TimelinePoint(org.olat.modules.portfolio.ui.component.TimelinePoint) Dropdown(org.olat.core.gui.components.dropdown.Dropdown) WindowControl(org.olat.core.gui.control.WindowControl) FlexiTableRendererType(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRendererType) Set(java.util.Set) Component(org.olat.core.gui.components.Component) LinkFactory(org.olat.core.gui.components.link.LinkFactory) Collectors(java.util.stream.Collectors) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) List(java.util.List) ExportBinderAsCPResource(org.olat.modules.portfolio.ui.export.ExportBinderAsCPResource) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Align(org.olat.core.gui.components.stack.TooledStackedPanel.Align) Identity(org.olat.core.id.Identity) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) LinkPopupSettings(org.olat.core.gui.components.link.LinkPopupSettings) ExtendedMediaRenderingHints(org.olat.modules.portfolio.model.ExtendedMediaRenderingHints) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) Section(org.olat.modules.portfolio.Section) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) HashMap(java.util.HashMap) PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Event(org.olat.core.gui.control.Event) TextComponent(org.olat.core.gui.components.text.TextComponent) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) ContextEntry(org.olat.core.id.context.ContextEntry) ExportBinderAsPDFResource(org.olat.modules.portfolio.ui.export.ExportBinderAsPDFResource) StringHelper(org.olat.core.util.StringHelper) StateEntry(org.olat.core.id.context.StateEntry) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) FlexiTableRenderEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRenderEvent) Link(org.olat.core.gui.components.link.Link) Controller(org.olat.core.gui.control.Controller) CodeHelper(org.olat.core.util.CodeHelper) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserManager(org.olat.user.UserManager) BaseFullWebappPopupLayoutFactory(org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayoutFactory) ToggleBoxController(org.olat.core.gui.control.generic.spacesaver.ToggleBoxController) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) PortfolioRoles(org.olat.modules.portfolio.PortfolioRoles) UserRequest(org.olat.core.gui.UserRequest) Binder(org.olat.modules.portfolio.Binder) PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Set(java.util.Set) HashSet(java.util.HashSet) Category(org.olat.modules.portfolio.Category) OLATResourceable(org.olat.core.id.OLATResourceable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Assignment(org.olat.modules.portfolio.Assignment) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) List(java.util.List) ArrayList(java.util.ArrayList) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) PageUserInformations(org.olat.modules.portfolio.PageUserInformations) AssessmentSection(org.olat.modules.portfolio.AssessmentSection)

Example 93 with Page

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

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);
}
Also used : HashMap(java.util.HashMap) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) AccessRights(org.olat.modules.portfolio.model.AccessRights) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Link(org.olat.core.gui.components.link.Link)

Example 94 with Page

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

the class TableOfContentController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty()) {
        return;
    }
    String resName = entries.get(0).getOLATResourceable().getResourceableTypeName();
    if ("Page".equalsIgnoreCase(resName) || "Entry".equalsIgnoreCase(resName)) {
        Long pageKey = entries.get(0).getOLATResourceable().getResourceableId();
        Page page = portfolioService.getPageByKey(pageKey);
        if (page != null && page.getSection() != null && binder.equals(page.getSection().getBinder())) {
            Activateable2 activateable = doOpenPage(ureq, page);
            if (activateable != null) {
                List<ContextEntry> subEntries = entries.subList(1, entries.size());
                activateable.activate(ureq, subEntries, entries.get(0).getTransientState());
            }
        }
    } else if ("Section".equalsIgnoreCase(resName)) {
        Long sectionKey = entries.get(0).getOLATResourceable().getResourceableId();
        Section section = portfolioService.getSection(new SectionRefImpl(sectionKey));
        if (section != null && binder.equals(section.getBinder())) {
            doOpenSection(ureq, section);
        }
    }
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SectionRefImpl(org.olat.modules.portfolio.model.SectionRefImpl) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 95 with Page

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

the class BinderOnePageController method loadMetadataAndComponents.

private void loadMetadataAndComponents(UserRequest ureq, BinderRef binderRef) {
    Binder binder = portfolioService.getBinderByKey(binderRef.getKey());
    // load metadata
    List<Identity> owners = portfolioService.getMembers(binder, PortfolioRoles.owner.name());
    StringBuilder ownerSb = new StringBuilder();
    for (Identity owner : owners) {
        if (ownerSb.length() > 0)
            ownerSb.append(", ");
        ownerSb.append(userManager.getUserDisplayName(owner));
    }
    mainVC.contextPut("owners", ownerSb.toString());
    mainVC.contextPut("binderTitle", binder.getTitle());
    mainVC.contextPut("binderKey", binder.getKey());
    // load pages
    List<Section> sections = portfolioService.getSections(binder);
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Section section : sections) {
        loadSection(section);
        for (Page page : pages) {
            if (section.equals(page.getSection())) {
                loadPage(ureq, page);
            }
        }
    }
}
Also used : Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) AssessmentSection(org.olat.modules.portfolio.AssessmentSection)

Aggregations

Page (org.olat.modules.portfolio.Page)136 Section (org.olat.modules.portfolio.Section)98 Test (org.junit.Test)70 Identity (org.olat.core.id.Identity)64 Binder (org.olat.modules.portfolio.Binder)44 ArrayList (java.util.ArrayList)32 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)32 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)26 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)26 Assignment (org.olat.modules.portfolio.Assignment)24 RepositoryEntry (org.olat.repository.RepositoryEntry)22 HashMap (java.util.HashMap)20 SectionRef (org.olat.modules.portfolio.SectionRef)20 PageUserInformations (org.olat.modules.portfolio.PageUserInformations)18 AssessedPage (org.olat.modules.portfolio.model.AssessedPage)16 PageBody (org.olat.modules.portfolio.PageBody)14 OLATResourceable (org.olat.core.id.OLATResourceable)12 AccessRights (org.olat.modules.portfolio.model.AccessRights)12 CategoryToElement (org.olat.modules.portfolio.CategoryToElement)10 Date (java.util.Date)8