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