use of org.olat.modules.portfolio.model.SectionImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method deleteAssignment.
@Override
public boolean deleteAssignment(Assignment assignment) {
Assignment reloadedAssignment = assignmentDao.loadAssignmentByKey(assignment.getKey());
Section reloadedSection = reloadedAssignment.getSection();
boolean removed = false;
if (reloadedSection != null) {
removed = ((SectionImpl) reloadedSection).getAssignments().remove(reloadedAssignment);
}
assignmentDao.deleteAssignment(reloadedAssignment);
if (removed) {
binderDao.updateSection(reloadedSection);
}
return true;
}
use of org.olat.modules.portfolio.model.SectionImpl 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.SectionImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method appendNewPage.
private Page appendNewPage(Identity owner, String title, String summary, String imagePath, boolean editable, PageImageAlign align, SectionRef section) {
Section reloadedSection = section == null ? null : binderDao.loadSectionByKey(section.getKey());
if (reloadedSection != null && reloadedSection.getSectionStatus() == SectionStatus.notStarted) {
((SectionImpl) reloadedSection).setSectionStatus(SectionStatus.inProgress);
}
Page page = pageDao.createAndPersist(title, summary, imagePath, align, editable, reloadedSection, null);
groupDao.addMembershipTwoWay(page.getBaseGroup(), owner, PortfolioRoles.owner.name());
return page;
}
use of org.olat.modules.portfolio.model.SectionImpl in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method appendNewSection.
@Override
public SectionRef appendNewSection(String title, String description, Date begin, Date end, BinderRef binder) {
Binder reloadedBinder = binderDao.loadByKey(binder.getKey());
SectionImpl newSection = binderDao.createSection(title, description, begin, end, reloadedBinder);
return new SectionKeyRef(newSection.getKey());
}
use of org.olat.modules.portfolio.model.SectionImpl in project OpenOLAT by OpenOLAT.
the class BinderDAO method createSection.
/**
* Add a section to a binder. The binder must be a fresh reload one
* with the possibility to lazy load the sections.
*
* @param title
* @param description
* @param begin
* @param end
* @param binder
*/
public SectionImpl createSection(String title, String description, Date begin, Date end, Binder binder) {
SectionImpl section = new SectionImpl();
section.setCreationDate(new Date());
section.setLastModified(section.getCreationDate());
section.setBaseGroup(groupDao.createGroup());
section.setTitle(title);
section.setDescription(description);
section.setBeginDate(begin);
section.setEndDate(end);
section.setOverrideBeginEndDates(false);
section.setStatus(SectionStatus.notStarted.name());
// force load of the list
((BinderImpl) binder).getSections().size();
section.setBinder(binder);
((BinderImpl) binder).getSections().add(section);
dbInstance.getCurrentEntityManager().persist(section);
dbInstance.getCurrentEntityManager().merge(binder);
return section;
}
Aggregations