use of org.olat.modules.portfolio.model.PageImpl in project OpenOLAT by OpenOLAT.
the class PageDAO method createAndPersist.
/**
* @param title
* @param summary
* @param section If the section is null, the page is floating.
* @param body If the body is null, a new one is create.
* @return
*/
public Page createAndPersist(String title, String summary, String imagePath, PageImageAlign align, boolean editable, Section section, PageBody body) {
PageImpl page = new PageImpl();
page.setCreationDate(new Date());
page.setLastModified(page.getCreationDate());
page.setTitle(title);
page.setSummary(summary);
page.setImagePath(imagePath);
page.setImageAlignment(align);
page.setEditable(editable);
page.setBaseGroup(groupDao.createGroup());
if (body == null) {
page.setBody(createAndPersistPageBody());
} else {
page.setBody(body);
}
if (section != null) {
page.setSection(section);
section.getPages().add(page);
dbInstance.getCurrentEntityManager().persist(page);
dbInstance.getCurrentEntityManager().merge(section);
} else {
dbInstance.getCurrentEntityManager().persist(page);
}
return page;
}
use of org.olat.modules.portfolio.model.PageImpl in project OpenOLAT by OpenOLAT.
the class PageDAO method removePage.
public Page removePage(Page page) {
PageImpl reloadedPage = (PageImpl) loadByKey(page.getKey());
Section section = reloadedPage.getSection();
if (section != null) {
section.getPages().remove(reloadedPage);
}
reloadedPage.setLastModified(new Date());
reloadedPage.setSection(null);
reloadedPage.setPageStatus(PageStatus.deleted);
unlinkAssignment(page);
if (section != null) {
dbInstance.getCurrentEntityManager().merge(section);
}
return dbInstance.getCurrentEntityManager().merge(reloadedPage);
}
use of org.olat.modules.portfolio.model.PageImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method changeSectionStatus.
@Override
public Section changeSectionStatus(Section section, SectionStatus status, Identity coach) {
PageStatus newPageStatus;
if (status == SectionStatus.closed) {
newPageStatus = PageStatus.closed;
} else {
newPageStatus = PageStatus.inRevision;
}
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
List<Page> pages = reloadedSection.getPages();
for (Page page : pages) {
if (page != null) {
((PageImpl) page).setPageStatus(newPageStatus);
pageDao.updatePage(page);
if (newPageStatus == PageStatus.closed) {
// set user informations to done
pageUserInfosDao.updateStatus(page, PageUserStatus.done);
}
}
}
((SectionImpl) reloadedSection).setSectionStatus(status);
reloadedSection = binderDao.updateSection(reloadedSection);
return reloadedSection;
}
use of org.olat.modules.portfolio.model.PageImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method updatePage.
@Override
public Page updatePage(Page page, SectionRef newParentSection) {
Page updatedPage;
if (newParentSection == null) {
updatedPage = pageDao.updatePage(page);
} else {
Section currentSection = null;
if (page.getSection() != null) {
currentSection = binderDao.loadSectionByKey(page.getSection().getKey());
currentSection.getPages().remove(page);
}
Section newParent = binderDao.loadSectionByKey(newParentSection.getKey());
((PageImpl) page).setSection(newParent);
newParent.getPages().add(page);
updatedPage = pageDao.updatePage(page);
if (currentSection != null) {
binderDao.updateSection(currentSection);
}
binderDao.updateSection(newParent);
}
return updatedPage;
}
use of org.olat.modules.portfolio.model.PageImpl in project OpenOLAT by OpenOLAT.
the class BinderDAO method syncMovedAssignment.
private void syncMovedAssignment(SectionImpl currentSection, SectionImpl newSection, Assignment assignment) {
currentSection.getAssignments().size();
newSection.getAssignments().size();
currentSection.getAssignments().remove(assignment);
((AssignmentImpl) assignment).setSection(newSection);
assignment = dbInstance.getCurrentEntityManager().merge(assignment);
newSection.getAssignments().add(assignment);
Page page = assignment.getPage();
if (page != null) {
currentSection.getPages().remove(page);
newSection.getPages().add(page);
((PageImpl) page).setSection(newSection);
dbInstance.getCurrentEntityManager().merge(page);
}
}
Aggregations