Search in sources :

Example 1 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.

the class ReturnboxFullAccessCallback method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == dropboxFolderRunController) {
        if (event instanceof FolderEvent) {
            FolderEvent folderEvent = (FolderEvent) event;
            if (folderEvent.getCommand().equals(FolderEvent.DELETE_EVENT)) {
                UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
                // log entry for this file
                Identity coach = ureq.getIdentity();
                Identity student = userCourseEnv.getIdentityEnvironment().getIdentity();
                am.appendToUserNodeLog(node, coach, student, "FILE DELETED: " + folderEvent.getFilename());
            }
        }
    } else if (source == returnboxFolderRunController) {
        if (event instanceof FolderEvent) {
            FolderEvent folderEvent = (FolderEvent) event;
            if (folderEvent.getCommand().equals(FolderEvent.UPLOAD_EVENT) || folderEvent.getCommand().equals(FolderEvent.NEW_FILE_EVENT)) {
                UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
                // log entry for this file
                Identity coach = ureq.getIdentity();
                Identity student = userCourseEnv.getIdentityEnvironment().getIdentity();
                if (node instanceof AssessableCourseNode) {
                    AssessableCourseNode acn = (AssessableCourseNode) node;
                    AssessmentEvaluation eval = acn.getUserScoreEvaluation(userCourseEnv);
                    if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
                        eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
                        acn.updateUserScoreEvaluation(eval, userCourseEnv, coach, false, Role.coach);
                    }
                }
                am.appendToUserNodeLog(node, coach, student, "FILE UPLOADED: " + folderEvent.getFilename());
                String toMail = UserManager.getInstance().getUserDisplayEmail(student, ureq.getLocale());
                OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseNode.class, Long.valueOf(node.getIdent()));
                ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ores);
                BusinessControl bc = BusinessControlFactory.getInstance().createBusinessControl(ce, getWindowControl().getBusinessControl());
                String link = BusinessControlFactory.getInstance().getAsURIString(bc, true);
                log.debug("DEBUG : Returnbox notification email with link=" + link);
                String subject = translate("returnbox.email.subject");
                String body = translate("returnbox.email.body", new String[] { userCourseEnv.getCourseEnvironment().getCourseTitle(), node.getShortTitle(), folderEvent.getFilename(), link });
                MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
                MailBundle bundle = new MailBundle();
                bundle.setContext(context);
                bundle.setToId(student);
                bundle.setContent(subject, body);
                MailerResult result = CoreSpringFactory.getImpl(MailManager.class).sendMessage(bundle);
                if (result.getReturnCode() > 0) {
                    am.appendToUserNodeLog(node, coach, student, "MAIL SEND FAILED TO:" + toMail + "; MailReturnCode: " + result.getReturnCode());
                    log.warn("Could not send email 'returnbox notification' to " + student + "with email=" + toMail);
                } else {
                    log.info("Send email 'returnbox notification' to " + student + "with email=" + toMail);
                }
            }
        } else if (FolderCommand.FOLDERCOMMAND_FINISHED == event) {
            if (node instanceof AssessableCourseNode) {
                AssessableCourseNode acn = (AssessableCourseNode) node;
                AssessmentEvaluation eval = acn.getUserScoreEvaluation(userCourseEnv);
                if (eval == null) {
                    eval = AssessmentEvaluation.EMPTY_EVAL;
                }
                if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
                    eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
                    acn.updateUserScoreEvaluation(eval, userCourseEnv, getIdentity(), false, Role.coach);
                    fireEvent(ureq, Event.CHANGED_EVENT);
                }
            }
        }
    } else if (source == statusForm) {
        if (event == Event.DONE_EVENT) {
            // get identity not from request (this would be an author)
            StatusManager.getInstance().saveStatusFormData(statusForm, node, userCourseEnv);
        }
    } else if (source == dialogBoxController) {
        if (DialogBoxUIFactory.isYesEvent(event) && assignedTask != null) {
            // cancel task assignment, and show "no task assigned to user"
            removeAssignedTask(userCourseEnv, userCourseEnv.getIdentityEnvironment().getIdentity());
            // update UI
            myContent.contextPut("assignedtask", null);
        }
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) OLATResourceable(org.olat.core.id.OLATResourceable) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) BusinessControl(org.olat.core.id.context.BusinessControl) ContextEntry(org.olat.core.id.context.ContextEntry) UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle)

Example 2 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.

the class SearchResourceContext method getResourceUrl.

/**
 * @return Returns the resourcePath.
 */
public String getResourceUrl() {
    BusinessControl bControl = myBusinessControl == null ? parentBusinessControl : myBusinessControl;
    String resourceUrl = BusinessControlFactory.getInstance().getAsString(bControl);
    if (filePath != null) {
        // It is a file resource => Append file path
        StringBuilder buf = new StringBuilder(resourceUrl);
        buf.append(FILEPATH_PREFIX).append(filePath).append(ENDTAG);
        resourceUrl = buf.toString();
    }
    return resourceUrl;
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl)

Example 3 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.

the class EventsModel method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == showAllLink) {
        // activate homes tab in top navigation and active calendar menu item
        String resourceUrl = "[HomeSite:" + ureq.getIdentity().getKey() + "][calendar:0]";
        BusinessControl bc = BusinessControlFactory.getInstance().createFromString(resourceUrl);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
        NewControllerFactory.getInstance().launch(ureq, bwControl);
    } else if (event == ComponentUtil.VALIDATE_EVENT && dirty) {
        List<KalendarEvent> events = getMatchingEvents(ureq, getWindowControl());
        tableController.setTableDataModel(new EventsModel(events));
    }
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl) ArrayList(java.util.ArrayList) List(java.util.List) WindowControl(org.olat.core.gui.control.WindowControl)

Example 4 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.

the class SearchControllerFactory method createSearchController.

@Override
public SearchInputController createSearchController(UserRequest ureq, WindowControl wControl) {
    String resourceUrl = null;
    BusinessControl bc = wControl.getBusinessControl();
    if (bc != null) {
        resourceUrl = bc.getAsString();
    }
    return new ResultsSearchController(ureq, wControl, resourceUrl);
}
Also used : BusinessControl(org.olat.core.id.context.BusinessControl)

Example 5 with BusinessControl

use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.

the class BlogArtefactHandler method prefillBlogArtefact.

private void prefillBlogArtefact(AbstractArtefact artefact, Feed feed, Item item) {
    VFSContainer itemContainer = FeedManager.getInstance().getItemContainer(item);
    artefact.setFileSourceContainer(itemContainer);
    artefact.setTitle(item.getTitle());
    artefact.setDescription(item.getDescription());
    VFSLeaf itemXml = (VFSLeaf) itemContainer.resolve(BlogArtefact.BLOG_FILE_NAME);
    if (itemXml != null) {
        InputStream in = itemXml.getInputStream();
        String xml = FileUtils.load(in, "UTF-8");
        artefact.setFulltextContent(xml);
        FileUtils.closeSafely(in);
    }
    String origBPath = artefact.getBusinessPath();
    String artSource = "";
    BusinessControl bc = BusinessControlFactory.getInstance().createFromString(origBPath);
    if (origBPath.contains(CourseNode.class.getSimpleName())) {
        // blog-post from inside a course, rebuild "course-name - feed-name"
        OLATResourceable ores = bc.popLauncherContextEntry().getOLATResourceable();
        RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(ores.getResourceableId());
        artSource = repoEntry.getDisplayname();
        if (feed != null) {
            artSource += " - " + feed.getTitle();
        }
    } else if (origBPath.contains(RepositoryEntry.class.getSimpleName())) {
        // blog-post from blog-LR, only get name itself
        if (feed != null) {
            artSource = feed.getTitle();
        }
    } else {
        // collecting a post from live-blog, [Identity:xy]
        if (feed != null) {
            artSource = feed.getTitle();
        }
    }
    artefact.setSource(artSource);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OLATResourceable(org.olat.core.id.OLATResourceable) InputStream(java.io.InputStream) VFSContainer(org.olat.core.util.vfs.VFSContainer) BusinessControl(org.olat.core.id.context.BusinessControl) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

BusinessControl (org.olat.core.id.context.BusinessControl)80 WindowControl (org.olat.core.gui.control.WindowControl)56 OLATResourceable (org.olat.core.id.OLATResourceable)24 ContextEntry (org.olat.core.id.context.ContextEntry)22 RepositoryEntry (org.olat.repository.RepositoryEntry)16 ArrayList (java.util.ArrayList)14 Controller (org.olat.core.gui.control.Controller)8 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)6 Window (org.olat.core.gui.components.Window)6 HistoryPoint (org.olat.core.id.context.HistoryPoint)6 CourseNode (org.olat.course.nodes.CourseNode)6 Date (java.util.Date)4 UserRequest (org.olat.core.gui.UserRequest)4 DTab (org.olat.core.gui.control.generic.dtabs.DTab)4 DTabs (org.olat.core.gui.control.generic.dtabs.DTabs)4 Identity (org.olat.core.id.Identity)4 Roles (org.olat.core.id.Roles)4 BusinessControlFactory (org.olat.core.id.context.BusinessControlFactory)4 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)4 IOException (java.io.IOException)3