use of org.olat.modules.portfolio.PageStatus in project openolat by klemens.
the class PageMetadataController method syncUserInfosStatus.
private void syncUserInfosStatus() {
PageStatus status = page.getPageStatus();
PageUserStatus userStatus = pageUserInfos.getStatus();
if ((status == PageStatus.inRevision || status == PageStatus.published) && (userStatus == null || userStatus == PageUserStatus.incoming)) {
pageUserInfos.setStatus(PageUserStatus.inProcess);
} else if ((status == PageStatus.closed || status == PageStatus.deleted) && (userStatus != PageUserStatus.done)) {
pageUserInfos.setStatus(PageUserStatus.done);
}
pageUserInfos.setRecentLaunch(new Date());
pageUserInfos = portfolioService.updatePageUserInfos(pageUserInfos);
}
use of org.olat.modules.portfolio.PageStatus in project openolat by klemens.
the class EvaluationFormHandler method getControllerForAssignment.
private Controller getControllerForAssignment(UserRequest ureq, WindowControl wControl, PageBody body, Assignment assignment, boolean onePage) {
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
// find the evaluation form
RepositoryEntry re = assignment.getFormEntry();
Page page = assignment.getPage();
PageStatus pageStatus = page.getPageStatus();
Controller ctrl = null;
List<AccessRights> accessRights = portfolioService.getAccessRights(page);
boolean anonym = assignment.isAnonymousExternalEvaluation();
if (pageStatus == null || pageStatus == PageStatus.draft) {
if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, false, false);
}
} else if (assignment.isOnlyAutoEvaluation()) {
// only the auto evaluation is shown
if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
boolean readOnly = (pageStatus == PageStatus.published) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted);
ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, false);
} else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
Identity owner = getOwner(accessRights);
ctrl = new EvaluationFormController(ureq, wControl, owner, body, re, true, false);
} else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
if (assignment.isReviewerSeeAutoEvaluation()) {
Identity owner = getOwner(accessRights);
ctrl = new EvaluationFormController(ureq, wControl, owner, body, re, true, false);
}
}
} else {
if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
boolean readOnly = (pageStatus == PageStatus.published) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
Identity owner = getOwner(accessRights);
List<Identity> coachesAndReviewers = getCoachesAndReviewers(accessRights);
if (coachesAndReviewers.size() > 0) {
ctrl = new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, false, readOnly, onePage, anonym);
} else {
ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, false);
}
} else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
Identity owner = getOwner(accessRights);
List<Identity> coachesAndReviewers = getCoachesAndReviewers(accessRights);
boolean readOnly = (pageStatus == PageStatus.draft) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
ctrl = new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, false, readOnly, onePage, anonym);
} else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
boolean readOnly = (pageStatus == PageStatus.draft) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
if (assignment.isReviewerSeeAutoEvaluation()) {
Identity owner = getOwner(accessRights);
List<Identity> reviewers = Collections.singletonList(ureq.getIdentity());
ctrl = new MultiEvaluationFormController(ureq, wControl, owner, reviewers, body, re, true, readOnly, onePage, anonym);
} else {
ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, !readOnly);
}
}
}
return ctrl;
}
use of org.olat.modules.portfolio.PageStatus 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;
}
use of org.olat.modules.portfolio.PageStatus in project openolat by klemens.
the class SharedWithMeQueries method searchSharedBindersTwo.
private void searchSharedBindersTwo(Identity member, List<AssessedBinder> binders) {
StringBuilder sb = new StringBuilder(2048);
sb.append("select binder.key,").append(" section.key, section.status, section.title, section.pos, section.endDate,").append(" page.key, page.status, page.lastModified, page.lastPublicationDate,").append(" body.lastModified, max(parts.lastModified), infos.recentLaunch").append(" from pfbinder as binder").append(" inner join binder.sections as section").append(" inner join section.pages as page").append(" inner join page.body as body").append(" left join body.parts as parts").append(" left join pfbinderuserinfos as infos on (infos.binder.key=binder.key and infos.identity.key=:identityKey)").append(" where exists (select membership.key from bgroupmember as membership").append(" where membership.group.key=binder.baseGroup.key and membership.identity.key=:identityKey and membership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("')").append(" ) or exists (select sectionMembership.key from bgroupmember as sectionMembership").append(" where sectionMembership.group.key=section.baseGroup.key and sectionMembership.identity.key=:identityKey and sectionMembership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("')").append(" ) or exists (select page.key from pfpage as coachedPage").append(" inner join coachedPage.baseGroup as pageGroup").append(" inner join pageGroup.members as pageMembership on (pageMembership.identity.key=:identityKey and pageMembership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("'))").append(" where coachedPage.key=page.key").append(" ) group by binder.key, section.key, section.status, section.title, section.pos, section.endDate,").append(" page.key, page.status, page.lastModified, page.lastPublicationDate, body.lastModified, infos.recentLaunch");
Date now = new Date();
List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("identityKey", member.getKey()).getResultList();
if (objects.size() > 0) {
Set<Long> sectionKeys = new HashSet<>();
Map<Long, AssessedBinder> keyToBinder = binders.stream().collect(Collectors.toMap(b -> b.getBinderKey(), b -> b));
for (Object[] object : objects) {
int pos = 0;
Long binderKey = (Long) object[pos++];
AssessedBinder binder = keyToBinder.get(binderKey);
if (binder == null) {
continue;
}
Long sectionKey = (Long) object[pos++];
String sectionStatus = (String) object[pos++];
String sectionTitle = (String) object[pos++];
Number sectionPosNumber = (Number) object[pos++];
Date sectionEndDate = (Date) object[pos++];
;
Long pageKey = (Long) object[pos++];
String pageStatus = (String) object[pos++];
Date pageLastModified = (Date) object[pos++];
Date pageLastPublication = (Date) object[pos++];
Date bodyLastModified = (Date) object[pos++];
Date partLastModified = (Date) object[pos++];
Date recentLaunch = (Date) object[pos++];
Date lastModified = pageLastModified;
if (lastModified == null || (lastModified != null && partLastModified != null && partLastModified.after(lastModified))) {
lastModified = partLastModified;
}
if (lastModified == null || (lastModified != null && bodyLastModified != null && bodyLastModified.after(lastModified))) {
lastModified = bodyLastModified;
}
if (lastModified != null && (binder.getLastModified() == null || binder.getLastModified().before(lastModified))) {
binder.setLastModified(lastModified);
}
if (binder.getRecentLaunch() == null) {
binder.setRecentLaunch(recentLaunch);
}
if (pageKey != null && pageStatus == null) {
binder.incrementNumOfDraftPages();
} else if (StringHelper.containsNonWhitespace(pageStatus)) {
PageStatus status = PageStatus.valueOf(pageStatus);
if (PageStatus.isClosed(status, sectionEndDate, now)) {
binder.incrementNumOfClosedPages();
} else if (PageStatus.draft.name().equals(pageStatus)) {
binder.incrementNumOfDraftPages();
} else if (PageStatus.inRevision.name().equals(pageStatus)) {
binder.incrementNumOfInRevisionPages();
}
}
if (recentLaunch == null && pageLastPublication != null) {
binder.incrementNumOfNewlyPublishedPages();
} else if (recentLaunch != null && pageLastPublication != null && recentLaunch.before(pageLastPublication)) {
binder.incrementNumOfNewlyPublishedPages();
}
if (!sectionKeys.contains(sectionKey)) {
SectionStatus status = SectionStatus.notStarted;
if (StringHelper.containsNonWhitespace(sectionStatus)) {
status = SectionStatus.valueOf(sectionStatus);
}
if (status == SectionStatus.notStarted || status == SectionStatus.inProgress) {
binder.setNumOfOpenSections(binder.getNumOfOpenSections() + 1);
}
if (status == SectionStatus.inProgress || status == SectionStatus.submitted || status == SectionStatus.closed) {
if (binder.getSections() == null) {
binder.setSections(new ArrayList<>());
}
int sectionPos = sectionPosNumber == null ? -1 : sectionPosNumber.intValue();
binder.getSections().add(new AssessedBinderSection(sectionKey, sectionTitle, sectionPos));
sectionKeys.add(sectionKey);
}
}
}
}
}
use of org.olat.modules.portfolio.PageStatus in project openolat by klemens.
the class SharedWithMeQueries method searchSharedPagesEntries.
public List<AssessedPage> searchSharedPagesEntries(Identity member, SearchSharePagesParameters params) {
StringBuilder sb = new StringBuilder(2048);
sb.append("select binder.key,").append(" section.key, section.endDate,").append(" page.key, page.title, page.status, page.lastModified,").append(" body.lastModified,").append(" (select max(part.lastModified) from pfpagepart as part").append(" where part.body.key=body.key").append(" ) as partLastModified,").append(" uinfos.userStatus, uinfos.mark,").append(" owner").append(" from pfbinder as binder").append(" inner join binder.baseGroup as baseGroup").append(" inner join baseGroup.members as ownership on (ownership.role='").append(PortfolioRoles.owner.name()).append("')").append(" inner join ownership.identity as owner").append(" inner join fetch owner.user as owneruser").append(" inner join binder.sections as section").append(" inner join section.pages as page").append(" inner join page.body as body").append(params.isBookmarkOnly() ? " inner" : " left").append(" join pfpageuserinfos as uinfos on (uinfos.page.key=page.key and uinfos.identity.key=:identityKey)").append(" where ");
if (params.isBookmarkOnly()) {
sb.append(" uinfos.mark=true and");
}
String searchString = params.getSearchString();
if (StringHelper.containsNonWhitespace(searchString)) {
searchString = makeFuzzyQueryString(searchString);
sb.append(" (");
appendFuzzyLike(sb, "page.title", "searchString", dbInstance.getDbVendor());
sb.append(") and");
}
if (params.getExcludedPageStatus() != null && !params.getExcludedPageStatus().isEmpty()) {
sb.append(" (page.status is null or page.status not in (:excludedPageStatus)) and");
}
if (params.getExcludedPageUserStatus() != null && !params.getExcludedPageUserStatus().isEmpty()) {
sb.append(" (uinfos.userStatus is null or uinfos.userStatus not in (:excludedPageUserStatus)) and");
}
sb.append(" (exists (select membership.key from bgroupmember as membership").append(" where membership.group.key=binder.baseGroup.key and membership.identity.key=:identityKey and membership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("')").append(" ) or exists (select sectionMembership.key from bgroupmember as sectionMembership").append(" where sectionMembership.group.key=section.baseGroup.key and sectionMembership.identity.key=:identityKey and sectionMembership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("')").append(" ) or exists (select page.key from pfpage as coachedPage").append(" inner join coachedPage.baseGroup as pageGroup").append(" inner join pageGroup.members as pageMembership on (pageMembership.identity.key=:identityKey and pageMembership.role in ('").append(PortfolioRoles.coach.name()).append("','").append(PortfolioRoles.reviewer.name()).append("'))").append(" where coachedPage.key=page.key").append(" ))");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("identityKey", member.getKey());
if (StringHelper.containsNonWhitespace(searchString)) {
query.setParameter("searchString", searchString.toLowerCase());
}
if (params.getExcludedPageStatus() != null && !params.getExcludedPageStatus().isEmpty()) {
List<String> excludedPageStatus = params.getExcludedPageStatus().stream().map(s -> s.name()).collect(Collectors.toList());
query.setParameter("excludedPageStatus", excludedPageStatus);
}
if (params.getExcludedPageUserStatus() != null && !params.getExcludedPageUserStatus().isEmpty()) {
List<String> excludedPageUserStatus = params.getExcludedPageUserStatus().stream().map(s -> s.name()).collect(Collectors.toList());
query.setParameter("excludedPageUserStatus", excludedPageUserStatus);
}
List<Object[]> objects = query.getResultList();
List<AssessedPage> items = new ArrayList<>(objects.size());
for (Object[] object : objects) {
int pos = 0;
Long binderKey = (Long) object[pos++];
// Section key
pos++;
Date sectionDate = (Date) object[pos++];
Long pageKey = (Long) object[pos++];
String pageTitle = (String) object[pos++];
PageStatus pageStatus = PageStatus.valueOfOrNull((String) object[pos++]);
Date pageLastModified = (Date) object[pos++];
Date bodyLastModified = (Date) object[pos++];
Date partLastModified = (Date) object[pos++];
PageUserStatus userStatus = PageUserStatus.valueOfWithDefault((String) object[pos++]);
Boolean mark = (Boolean) object[pos++];
Identity owner = (Identity) object[pos++];
Date lastModified = pageLastModified;
if (lastModified == null || (lastModified != null && partLastModified != null && partLastModified.after(lastModified))) {
lastModified = partLastModified;
}
if (lastModified == null || (lastModified != null && bodyLastModified != null && bodyLastModified.after(lastModified))) {
lastModified = bodyLastModified;
}
items.add(new AssessedPage(binderKey, sectionDate, pageKey, pageTitle, pageStatus, lastModified, mark, userStatus, owner));
}
return items;
}
Aggregations