use of org.olat.modules.portfolio.model.SectionImpl in project openolat by klemens.
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 klemens.
the class BinderDAO method syncMovingAssignments.
private void syncMovingAssignments(SectionImpl templateSection, SectionImpl currentSection, Map<Section, Section> templateToSectionsMap) {
List<Assignment> templateAssignments = new ArrayList<>(templateSection.getAssignments());
for (Iterator<Assignment> currentAssignmentIt = currentSection.getAssignments().iterator(); currentAssignmentIt.hasNext(); ) {
if (currentAssignmentIt.next() == null) {
currentAssignmentIt.remove();
}
}
List<Assignment> currentAssignments = new ArrayList<>(currentSection.getAssignments());
for (int i = 0; i < currentAssignments.size(); i++) {
Assignment currentAssignment = currentAssignments.get(i);
if (currentAssignment == null) {
currentSection.getAssignments().remove(i);
} else {
Assignment refAssignment = currentAssignment.getTemplateReference();
if (refAssignment != null && !templateAssignments.contains(refAssignment) && !refAssignment.getSection().equals(templateSection) && templateToSectionsMap.containsKey(refAssignment.getSection())) {
// really moved
templateAssignments.remove(refAssignment);
SectionImpl newSection = (SectionImpl) templateToSectionsMap.get(refAssignment.getSection());
syncMovedAssignment(currentSection, newSection, currentAssignment);
}
}
}
}
use of org.olat.modules.portfolio.model.SectionImpl in project openolat by klemens.
the class BinderDAO method createInternalSection.
private SectionImpl createInternalSection(Binder binder, Section templateSection) {
SectionImpl section = new SectionImpl();
section.setCreationDate(new Date());
section.setLastModified(section.getCreationDate());
section.setBaseGroup(groupDao.createGroup());
section.setTitle(templateSection.getTitle());
section.setDescription(templateSection.getDescription());
section.setBeginDate(templateSection.getBeginDate());
section.setEndDate(templateSection.getEndDate());
section.setOverrideBeginEndDates(false);
section.setStatus(SectionStatus.notStarted.name());
section.setBinder(binder);
section.setTemplateReference(templateSection);
return section;
}
use of org.olat.modules.portfolio.model.SectionImpl in project openolat by klemens.
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 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);
}
Aggregations