use of org.olat.modules.portfolio.model.SectionImpl in project openolat by klemens.
the class PortfolioServiceImpl method internalCopyTransientBinder.
private Binder internalCopyTransientBinder(Binder transientBinder, RepositoryEntry entry, String imagePath, boolean copy) {
Binder binder = binderDao.createAndPersist(transientBinder.getTitle(), transientBinder.getSummary(), imagePath, entry);
// copy sections
for (Section transientSection : ((BinderImpl) transientBinder).getSections()) {
SectionImpl section = binderDao.createSection(transientSection.getTitle(), transientSection.getDescription(), transientSection.getBeginDate(), transientSection.getEndDate(), binder);
List<Assignment> transientAssignments = ((SectionImpl) transientSection).getAssignments();
for (Assignment transientAssignment : transientAssignments) {
if (transientAssignment != null) {
File newStorage = portfolioFileStorage.generateAssignmentSubDirectory();
String storage = portfolioFileStorage.getRelativePath(newStorage);
assignmentDao.createAssignment(transientAssignment.getTitle(), transientAssignment.getSummary(), transientAssignment.getContent(), storage, transientAssignment.getAssignmentType(), transientAssignment.getAssignmentStatus(), section, transientAssignment.isOnlyAutoEvaluation(), transientAssignment.isReviewerSeeAutoEvaluation(), transientAssignment.isAnonymousExternalEvaluation(), transientAssignment.getFormEntry());
// copy attachments
File templateDirectory = portfolioFileStorage.getAssignmentDirectory(transientAssignment);
if (copy && templateDirectory != null) {
FileUtils.copyDirContentsToDir(templateDirectory, newStorage, false, "Assignment attachments");
}
}
}
}
return binder;
}
use of org.olat.modules.portfolio.model.SectionImpl in project openolat by klemens.
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 klemens.
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;
}
use of org.olat.modules.portfolio.model.SectionImpl in project openolat by klemens.
the class BinderDAO method syncWithTemplate.
public Binder syncWithTemplate(BinderImpl template, BinderImpl binder, AtomicBoolean changes) {
binder.setImagePath(template.getImagePath());
binder.setSummary(template.getSummary());
List<Section> templateSections = template.getSections();
Map<Assignment, Section> assignmentTemplateToSectionTemplatesMap = new HashMap<>();
for (Section templateSection : templateSections) {
for (Assignment assignment : templateSection.getAssignments()) {
assignmentTemplateToSectionTemplatesMap.put(assignment, templateSection);
}
}
List<Section> currentSections = binder.getSections();
List<Section> leadingSections = new ArrayList<>(binder.getSections());
Map<Section, Section> templateToSectionsMap = new HashMap<>();
for (Section currentSection : currentSections) {
Section templateRef = currentSection.getTemplateReference();
if (templateRef != null) {
templateToSectionsMap.put(templateRef, currentSection);
}
}
currentSections.clear();
for (int i = 0; i < templateSections.size(); i++) {
SectionImpl templateSection = (SectionImpl) templateSections.get(i);
SectionImpl currentSection = (SectionImpl) templateToSectionsMap.get(templateSection);
if (currentSection != null) {
leadingSections.remove(currentSection);
currentSections.add(currentSection);
syncSectionMetadata(templateSection, currentSection);
templateToSectionsMap.put(templateSection, currentSection);
} else {
SectionImpl section = createInternalSection(binder, templateSection);
currentSections.add(section);
dbInstance.getCurrentEntityManager().persist(section);
templateToSectionsMap.put(templateSection, section);
}
}
currentSections.addAll(leadingSections);
// sync moving assignments
for (int i = 0; i < templateSections.size(); i++) {
SectionImpl templateSection = (SectionImpl) templateSections.get(i);
SectionImpl currentSection = (SectionImpl) templateToSectionsMap.get(templateSection);
syncMovingAssignments(templateSection, currentSection, templateToSectionsMap);
}
// sync assignments
for (int i = 0; i < templateSections.size(); i++) {
SectionImpl templateSection = (SectionImpl) templateSections.get(i);
SectionImpl currentSection = (SectionImpl) templateToSectionsMap.get(templateSection);
syncAssignments(templateSection, currentSection);
}
// update all sections
for (int i = 0; i < templateSections.size(); i++) {
SectionImpl templateSection = (SectionImpl) templateSections.get(i);
SectionImpl currentSection = (SectionImpl) templateToSectionsMap.get(templateSection);
currentSection = dbInstance.getCurrentEntityManager().merge(currentSection);
}
binder = dbInstance.getCurrentEntityManager().merge(binder);
changes.set(true);
return binder;
}
use of org.olat.modules.portfolio.model.SectionImpl in project openolat by klemens.
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;
}
Aggregations