use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class BinderOnePageController method loadMetadataAndComponents.
private void loadMetadataAndComponents(UserRequest ureq, BinderRef binderRef) {
Binder binder = portfolioService.getBinderByKey(binderRef.getKey());
// load metadata
List<Identity> owners = portfolioService.getMembers(binder, PortfolioRoles.owner.name());
StringBuilder ownerSb = new StringBuilder();
for (Identity owner : owners) {
if (ownerSb.length() > 0)
ownerSb.append(", ");
ownerSb.append(userManager.getUserDisplayName(owner));
}
mainVC.contextPut("owners", ownerSb.toString());
mainVC.contextPut("binderTitle", binder.getTitle());
mainVC.contextPut("binderKey", binder.getKey());
// load pages
List<Section> sections = portfolioService.getSections(binder);
List<Page> pages = portfolioService.getPages(binder, null);
for (Section section : sections) {
loadSection(section);
for (Page page : pages) {
if (section.equals(page.getSection())) {
loadPage(ureq, page);
}
}
}
}
use of org.olat.modules.portfolio.Section 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);
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class PortfolioNotificationsHandler method getSectionNotifications.
public List<SubscriptionListItem> getSectionNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
StringBuilder sb = new StringBuilder();
sb.append("select section").append(" from pfsection as section").append(" inner join fetch section.binder as binder").append(" where binder.key=:binderKey and section.lastModified>=:compareDate");
List<Section> sections = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Section.class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
Set<Long> uniqueSectionKeys = new HashSet<>();
Set<Long> uniqueCreateSectionKeys = new HashSet<>();
List<SubscriptionListItem> items = new ArrayList<>(sections.size());
for (Section section : sections) {
// section
Long sectionKey = section.getKey();
String sectionTitle = section.getTitle();
Date sectionCreationDate = section.getCreationDate();
Date sectionLastModified = section.getLastModified();
if (secCallback.canViewElement(section)) {
if (isSameDay(sectionCreationDate, sectionLastModified)) {
if (!uniqueCreateSectionKeys.contains(sectionKey)) {
uniqueCreateSectionKeys.add(sectionKey);
SubscriptionListItem item = sectionCreateItem(sectionKey, sectionTitle, sectionCreationDate, rootBusinessPath, translator);
items.add(item);
}
} else if (!uniqueSectionKeys.contains(sectionKey)) {
uniqueSectionKeys.add(sectionKey);
SubscriptionListItem item = sectionModifiedItem(sectionKey, sectionTitle, sectionLastModified, rootBusinessPath, translator);
items.add(item);
}
}
}
return items;
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class PortfolioServiceImpl method startAssignment.
@Override
public Assignment startAssignment(Long assignmentKey, Identity author) {
Assignment reloadedAssignment = assignmentDao.loadAssignmentByKey(assignmentKey);
if (reloadedAssignment.getPage() == null) {
Section section = reloadedAssignment.getSection();
if (reloadedAssignment.getAssignmentType() == AssignmentType.essay || reloadedAssignment.getAssignmentType() == AssignmentType.document) {
Page page = appendNewPage(author, reloadedAssignment.getTitle(), reloadedAssignment.getSummary(), null, null, section);
reloadedAssignment = assignmentDao.startEssayAssignment(reloadedAssignment, page, author);
} else if (reloadedAssignment.getAssignmentType() == AssignmentType.form) {
RepositoryEntry formEntry = reloadedAssignment.getFormEntry();
Page page = appendNewPage(author, reloadedAssignment.getTitle(), reloadedAssignment.getSummary(), null, false, null, section);
reloadedAssignment = assignmentDao.startFormAssignment(reloadedAssignment, page, author);
// create the session for the assignee
evaluationFormSessionDao.createSessionForPortfolio(author, page.getBody(), formEntry);
}
}
dbInstance.commit();
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_ASSIGNMENT_STARTED, getClass(), LoggingResourceable.wrap(reloadedAssignment.getSection()), LoggingResourceable.wrap(reloadedAssignment));
return reloadedAssignment;
}
use of org.olat.modules.portfolio.Section 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;
}
Aggregations