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