Search in sources :

Example 1 with CategoryToElement

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

the class CategoryDAOTest method getCategorizedSectionsAndPages.

@Test
public void getCategorizedSectionsAndPages() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-1");
    Binder binder = portfolioService.createNewBinder("Binder about Verne", "A binder with a single page", null, author);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    dbInstance.commitAndCloseSession();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page = pageDao.createAndPersist("Jules Verne", "Deux ans de vacances", null, null, true, reloadedSection, null);
    dbInstance.commitAndCloseSession();
    List<String> categoriesSection = new ArrayList<>();
    categoriesSection.add("Jules");
    categoriesSection.add("Verne");
    portfolioService.updateCategories(section, categoriesSection);
    List<String> categoriesPage = new ArrayList<>();
    categoriesPage.add("Aventure");
    categoriesPage.add("Vacances");
    portfolioService.updateCategories(page, categoriesPage);
    dbInstance.commitAndCloseSession();
    // load by section
    List<CategoryToElement> categories = categoryDao.getCategorizedSectionAndPages(section);
    Assert.assertNotNull(categories);
    Assert.assertEquals(4, categories.size());
    // load by binder
    List<CategoryToElement> categoriesByBinder = categoryDao.getCategorizedSectionsAndPages(binder);
    Assert.assertNotNull(categoriesByBinder);
    Assert.assertEquals(4, categoriesByBinder.size());
}
Also used : Binder(org.olat.modules.portfolio.Binder) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 2 with CategoryToElement

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

the class CategoryDAOTest method getCategorizedOwnedPages.

@Test
public void getCategorizedOwnedPages() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-1");
    Binder binder = portfolioService.createNewBinder("Binder p2", "A binder with 2 page", null, author);
    Section section = binderDao.createSection("Section", "First section", null, null, binder);
    dbInstance.commitAndCloseSession();
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Page page1 = pageDao.createAndPersist("Jules Verne", "Cing semaine en ballon", null, null, true, reloadedSection, null);
    Page page2 = pageDao.createAndPersist("J. Verne", "Une ville flottante", null, null, true, reloadedSection, null);
    Page page3 = pageDao.createAndPersist("Verne", "Les Tribulations d'un Chinois en Chine", null, null, true, reloadedSection, null);
    dbInstance.commitAndCloseSession();
    List<String> categories1 = new ArrayList<>();
    categories1.add("Jules");
    categories1.add("Verne");
    categories1.add("Aventure");
    categories1.add("Voyage");
    portfolioService.updateCategories(page1, categories1);
    List<String> categories2 = new ArrayList<>();
    categories2.add("Jules");
    categories2.add("Verne");
    categories2.add("Anticipation");
    categories2.add("Technologie");
    portfolioService.updateCategories(page2, categories2);
    List<String> categories3 = new ArrayList<>();
    categories3.add("Jules");
    categories3.add("Verne");
    categories3.add("Aventure");
    categories3.add("Chine");
    portfolioService.updateCategories(page3, categories3);
    dbInstance.commitAndCloseSession();
    List<CategoryToElement> categories = categoryDao.getCategorizedOwnedPages(author);
    Assert.assertNotNull(categories);
    Assert.assertEquals(12, categories.size());
}
Also used : Binder(org.olat.modules.portfolio.Binder) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Example 3 with CategoryToElement

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

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 4 with CategoryToElement

use of org.olat.modules.portfolio.CategoryToElement 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();
}
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) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Section(org.olat.modules.portfolio.Section) Assignment(org.olat.modules.portfolio.Assignment) ArrayList(java.util.ArrayList) List(java.util.List) TimelinePoint(org.olat.modules.portfolio.ui.component.TimelinePoint)

Example 5 with CategoryToElement

use of org.olat.modules.portfolio.CategoryToElement 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)

Aggregations

ArrayList (java.util.ArrayList)10 CategoryToElement (org.olat.modules.portfolio.CategoryToElement)10 Page (org.olat.modules.portfolio.Page)10 Section (org.olat.modules.portfolio.Section)8 HashMap (java.util.HashMap)6 List (java.util.List)6 Identity (org.olat.core.id.Identity)6 OLATResourceable (org.olat.core.id.OLATResourceable)6 Binder (org.olat.modules.portfolio.Binder)6 Category (org.olat.modules.portfolio.Category)6 PortfolioElementRow (org.olat.modules.portfolio.ui.model.PortfolioElementRow)6 Test (org.junit.Test)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 Assignment (org.olat.modules.portfolio.Assignment)4 TimelinePoint (org.olat.modules.portfolio.ui.component.TimelinePoint)4 HashSet (java.util.HashSet)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