Search in sources :

Example 6 with PageImpl

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);
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) Section(org.olat.modules.portfolio.Section) Date(java.util.Date)

Example 7 with PageImpl

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;
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 8 with PageImpl

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);
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PageStatus(org.olat.modules.portfolio.PageStatus) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) SectionStatus(org.olat.modules.portfolio.SectionStatus) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SectionImpl(org.olat.modules.portfolio.model.SectionImpl) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) Date(java.util.Date)

Example 9 with PageImpl

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);
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PageStatus(org.olat.modules.portfolio.PageStatus) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) SectionStatus(org.olat.modules.portfolio.SectionStatus) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SectionImpl(org.olat.modules.portfolio.model.SectionImpl) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl) Date(java.util.Date)

Example 10 with PageImpl

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;
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) Date(java.util.Date)

Aggregations

PageImpl (org.olat.modules.portfolio.model.PageImpl)12 Page (org.olat.modules.portfolio.Page)8 Section (org.olat.modules.portfolio.Section)8 Date (java.util.Date)6 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)6 AssessedPage (org.olat.modules.portfolio.model.AssessedPage)6 PageStatus (org.olat.modules.portfolio.PageStatus)4 AssessmentSectionImpl (org.olat.modules.portfolio.model.AssessmentSectionImpl)4 SectionImpl (org.olat.modules.portfolio.model.SectionImpl)4 Binder (org.olat.modules.portfolio.Binder)2 SectionStatus (org.olat.modules.portfolio.SectionStatus)2 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)2 AssignmentImpl (org.olat.modules.portfolio.model.AssignmentImpl)2 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)2