use of org.olat.modules.portfolio.model.PageImpl in project openolat by klemens.
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 klemens.
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 klemens.
the class PortfolioServiceImpl method changePageStatus.
@Override
public Page changePageStatus(Page page, PageStatus status, Identity identity, Role by) {
PageStatus currentStatus = page.getPageStatus();
Page reloadedPage = pageDao.loadByKey(page.getKey());
((PageImpl) reloadedPage).setPageStatus(status);
if (status == PageStatus.published) {
Date now = new Date();
if (reloadedPage.getInitialPublicationDate() == null) {
((PageImpl) reloadedPage).setInitialPublicationDate(now);
}
((PageImpl) reloadedPage).setLastPublicationDate(now);
Section section = reloadedPage.getSection();
// auto update the status of the evaluation form of the authors of the binder
changeAssignmentStatus(page, section, EvaluationFormSessionStatus.done);
if (section != null) {
SectionStatus sectionStatus = section.getSectionStatus();
if (currentStatus == PageStatus.closed) {
if (sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
} else if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
}
} else if (status == PageStatus.inRevision) {
Section section = reloadedPage.getSection();
changeAssignmentStatus(page, section, EvaluationFormSessionStatus.inProgress);
if (section != null) {
SectionStatus sectionStatus = section.getSectionStatus();
if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
if (sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
}
}
pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.inProcess, PageUserStatus.done);
} else if (status == PageStatus.closed) {
// set user informations to done
pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.done);
}
if (reloadedPage.getSection() != null && reloadedPage.getSection().getBinder() != null) {
Binder binder = reloadedPage.getSection().getBinder();
updateAssessmentEntryLastModification(binder, identity, by);
}
return pageDao.updatePage(reloadedPage);
}
use of org.olat.modules.portfolio.model.PageImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method changePageStatus.
@Override
public Page changePageStatus(Page page, PageStatus status, Identity identity, Role by) {
PageStatus currentStatus = page.getPageStatus();
Page reloadedPage = pageDao.loadByKey(page.getKey());
((PageImpl) reloadedPage).setPageStatus(status);
if (status == PageStatus.published) {
Date now = new Date();
if (reloadedPage.getInitialPublicationDate() == null) {
((PageImpl) reloadedPage).setInitialPublicationDate(now);
}
((PageImpl) reloadedPage).setLastPublicationDate(now);
Section section = reloadedPage.getSection();
// auto update the status of the evaluation form of the authors of the binder
changeAssignmentStatus(page, section, EvaluationFormSessionStatus.done);
if (section != null) {
SectionStatus sectionStatus = section.getSectionStatus();
if (currentStatus == PageStatus.closed) {
if (sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
} else if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
}
} else if (status == PageStatus.inRevision) {
Section section = reloadedPage.getSection();
changeAssignmentStatus(page, section, EvaluationFormSessionStatus.inProgress);
if (section != null) {
SectionStatus sectionStatus = section.getSectionStatus();
if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
if (sectionStatus == SectionStatus.closed) {
((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
binderDao.updateSection(section);
}
}
}
pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.inProcess, PageUserStatus.done);
} else if (status == PageStatus.closed) {
// set user informations to done
pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.done);
}
if (reloadedPage.getSection() != null && reloadedPage.getSection().getBinder() != null) {
Binder binder = reloadedPage.getSection().getBinder();
updateAssessmentEntryLastModification(binder, identity, by);
}
return pageDao.updatePage(reloadedPage);
}
use of org.olat.modules.portfolio.model.PageImpl in project openolat by klemens.
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;
}
Aggregations