Search in sources :

Example 1 with PageImpl

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

Example 2 with PageImpl

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

Example 3 with PageImpl

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;
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) PageStatus(org.olat.modules.portfolio.PageStatus) 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) SectionImpl(org.olat.modules.portfolio.model.SectionImpl) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl)

Example 4 with PageImpl

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;
}
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 5 with PageImpl

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

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