Search in sources :

Example 11 with PagePart

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

the class PageDAOTest method persistPart.

@Test
public void persistPart() {
    Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, null, null);
    dbInstance.commitAndCloseSession();
    HTMLPart htmlPart = new HTMLPart();
    PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, htmlPart);
    dbInstance.commitAndCloseSession();
    TitlePart titlePart = new TitlePart();
    reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
    pageDao.persistPart(reloadedBody, titlePart, 0);
    dbInstance.commitAndCloseSession();
    // reload
    List<PagePart> reloadedPageParts = pageDao.getParts(reloadedBody);
    Assert.assertNotNull(reloadedPageParts);
    Assert.assertEquals(2, reloadedPageParts.size());
    Assert.assertEquals(titlePart, reloadedPageParts.get(0));
    Assert.assertEquals(htmlPart, reloadedPageParts.get(1));
}
Also used : PagePart(org.olat.modules.portfolio.PagePart) HTMLPart(org.olat.modules.portfolio.model.HTMLPart) TitlePart(org.olat.modules.portfolio.model.TitlePart) Page(org.olat.modules.portfolio.Page) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Example 12 with PagePart

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

the class PageDAO method moveDownPart.

public void moveDownPart(PageBody body, PagePart part) {
    body.getParts().size();
    int index = body.getParts().indexOf(part);
    if (index >= 0 && index + 1 < body.getParts().size()) {
        PagePart reloadedPart = body.getParts().remove(index);
        body.getParts().add(index + 1, reloadedPart);
        ((PageBodyImpl) body).setLastModified(new Date());
        dbInstance.getCurrentEntityManager().merge(body);
    }
}
Also used : PagePart(org.olat.modules.portfolio.PagePart) PageBodyImpl(org.olat.modules.portfolio.model.PageBodyImpl) Date(java.util.Date)

Aggregations

PagePart (org.olat.modules.portfolio.PagePart)12 Date (java.util.Date)6 Test (org.junit.Test)6 Page (org.olat.modules.portfolio.Page)6 PageBody (org.olat.modules.portfolio.PageBody)6 HTMLPart (org.olat.modules.portfolio.model.HTMLPart)6 PageBodyImpl (org.olat.modules.portfolio.model.PageBodyImpl)6 TitlePart (org.olat.modules.portfolio.model.TitlePart)4 Section (org.olat.modules.portfolio.Section)2 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)2 SpacerPart (org.olat.modules.portfolio.model.SpacerPart)2