use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class BinderDAOTest method createBinderWithSection_2steps.
@Test
public void createBinderWithSection_2steps() {
String title = "Binder 2";
String summary = "Binder with one section.";
Binder binder = binderDao.createAndPersist(title, summary, null, null);
dbInstance.commitAndCloseSession();
String section1Title = "First section";
String section1Desc = "My first section.";
binder = binderDao.loadByKey(binder.getKey());
Section section1 = binderDao.createSection(section1Title, section1Desc, null, null, binder);
dbInstance.commitAndCloseSession();
String section2Title = "Second section";
String section2Desc = "My second section.";
binder = binderDao.loadByKey(binder.getKey());
Section section2 = binderDao.createSection(section2Title, section2Desc, null, null, binder);
dbInstance.commitAndCloseSession();
Binder reloadedBinder = binderDao.loadByKey(binder.getKey());
List<Section> sections = ((BinderImpl) reloadedBinder).getSections();
Assert.assertNotNull(sections);
Assert.assertEquals(2, sections.size());
Assert.assertEquals(section1, sections.get(0));
Assert.assertEquals(section2, sections.get(1));
}
use of org.olat.modules.portfolio.Section 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.Section 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.Section in project OpenOLAT by OpenOLAT.
the class PageDAOTest method loadPageByBody.
@Test
public void loadPageByBody() {
BinderImpl binder = binderDao.createAndPersist("Binder body", "A binder with a page and a page body", null, null);
Section section = binderDao.createSection("Section", "Body section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with body.", null, null, true, reloadedSection, null);
dbInstance.commitAndCloseSession();
Page reloadedPage = pageDao.loadByBody(page.getBody());
Assert.assertNotNull(reloadedPage);
Assert.assertEquals(page, reloadedPage);
}
use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class PageDAOTest method getLastPage.
@Test
public void getLastPage() {
// an owned binder
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("Page 1", "A page with content.", null, null, true, reloadedSection, null);
sleep(1500);
Page page2 = pageDao.createAndPersist("Page 2", "A page with content.", null, null, true, reloadedSection, null);
sleep(1500);
Page page3 = portfolioService.appendNewPage(author, "Page 3", "A page with content.", null, null, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(page1);
// reload
Page lastBinderPage = pageDao.getLastPage(author, true);
Assert.assertNotNull(lastBinderPage);
Assert.assertEquals(page2, lastBinderPage);
// reload
Page lastFloatingPage = pageDao.getLastPage(author, false);
Assert.assertNotNull(lastFloatingPage);
Assert.assertEquals(page3, lastFloatingPage);
}
Aggregations