Search in sources :

Example 96 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class QTI21AssessmentRunController method doCancelAssessment.

private void doCancelAssessment(UserRequest ureq) {
    if (displayContainerController != null) {
        displayContainerController.deactivate(ureq);
    } else {
        getWindowControl().pop();
    }
    removeHistory(ureq);
    if (courseNode instanceof IQTESTCourseNode) {
        ((IQTESTCourseNode) courseNode).updateCurrentCompletion(userCourseEnv, getIdentity(), null, null, Role.user);
    }
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("test", -1l);
    addToHistory(ureq, ores, null);
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) OLATResourceable(org.olat.core.id.OLATResourceable)

Example 97 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class ProjectBrokerManagerImpl method enrollProjectParticipant.

@Override
public boolean enrollProjectParticipant(final Identity identity, final Project project, final ProjectBrokerModuleConfiguration moduleConfig, final int nbrSelectedProjects, final boolean isParticipantInAnyProject) {
    final boolean debug = isLogDebugEnabled();
    OLATResourceable projectOres = OresHelper.createOLATResourceableInstance(Project.class, project.getKey());
    logDebug("enrollProjectParticipant: start identity=" + identity + "  project=" + project);
    Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectOres, new SyncerCallback<Boolean>() {

        @Override
        public Boolean execute() {
            if (existsProject(project.getKey())) {
                // For cluster-safe : reload project object here another node might have changed this in the meantime
                Project reloadedProject = (Project) dbInstance.loadObject(project, true);
                if (debug) {
                    logDebug("enrollProjectParticipant: project.getMaxMembers()=" + reloadedProject.getMaxMembers());
                    logDebug("enrollProjectParticipant: project.getSelectedPlaces()=" + reloadedProject.getSelectedPlaces());
                }
                if (canBeProjectSelectedBy(identity, reloadedProject, moduleConfig, nbrSelectedProjects, isParticipantInAnyProject)) {
                    if (moduleConfig.isAcceptSelectionManually()) {
                        securityManager.addIdentityToSecurityGroup(identity, reloadedProject.getCandidateGroup());
                        logAudit("ProjectBroker: Add as candidate identity=" + identity + " to project=" + reloadedProject);
                        if (debug) {
                            logDebug("ProjectBroker: Add as candidate reloadedProject=" + reloadedProject + "  CandidateGroup=" + reloadedProject.getCandidateGroup());
                        }
                    } else {
                        businessGroupRelationDao.addRole(identity, reloadedProject.getProjectGroup(), GroupRoles.participant.name());
                        logAudit("ProjectBroker: Add as participant identity=" + identity + " to project=" + reloadedProject);
                        if (debug) {
                            logDebug("ProjectBroker: Add as participant reloadedProject=" + reloadedProject + "  ParticipantGroup=" + reloadedProject.getProjectGroup());
                        }
                        if ((reloadedProject.getMaxMembers() != Project.MAX_MEMBERS_UNLIMITED) && (reloadedProject.getSelectedPlaces() >= reloadedProject.getMaxMembers())) {
                            reloadedProject.setState(Project.STATE_ASSIGNED);
                            updateProjectAndInvalidateCache(reloadedProject);
                        }
                    }
                    return Boolean.TRUE;
                } else {
                    if (debug) {
                        logDebug("ProjectBroker: project-group was full for identity=" + identity + " , project=" + reloadedProject);
                    }
                    return Boolean.FALSE;
                }
            } else {
                // project no longer exist
                return Boolean.FALSE;
            }
        }
    });
    // end of doInSync
    return result.booleanValue();
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) OLATResourceable(org.olat.core.id.OLATResourceable)

Example 98 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class ProjectBrokerManagerImpl method setProjectState.

@Override
public void setProjectState(final Project project, final String state) {
    final Long projectBrokerId = project.getProjectBroker().getKey();
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        @Override
        public void execute() {
            // For cluster-safe : reload project object here another node might have changed this in the meantime
            Project reloadedProject = (Project) dbInstance.loadObject(project, true);
            reloadedProject.setState(state);
            updateProjectAndInvalidateCache(reloadedProject);
        }
    });
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Example 99 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class MessageListController method addMessageToCurrentMessagesAndVC.

private void addMessageToCurrentMessagesAndVC(UserRequest ureq, MessageLight m, MessageView messageView, Map<String, Mark> marks, Map<String, MarkResourceStat> stats, Map<String, Long> artefactStats, Set<Long> readSet) {
    // all values belonging to a message are stored in this map
    // these values can be accessed in velocity. make sure you clean up
    // everything
    // you create here in disposeCurrentMessages()!
    String keyString = m.getKey().toString();
    if (readSet == null || readSet.contains(m.getKey())) {
        messageView.setNewMessage(false);
    } else {
        // mark now as read
        markRead(m);
        messageView.setNewMessage(true);
    }
    // add some data now
    messageView.setFormattedCreationDate(formatter.formatDateAndTime(m.getCreationDate()));
    messageView.setFormattedLastModified(formatter.formatDateAndTime(m.getLastModified()));
    Identity creator = m.getCreator();
    Identity modifier = m.getModifier();
    if (modifier != null) {
        messageView.setModified(true);
        if (modifier.equals(creator) && StringHelper.containsNonWhitespace(m.getPseudonym())) {
            messageView.setModifierPseudonym(m.getPseudonym());
        } else {
            messageView.setModifierFirstName(modifier.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()));
            messageView.setModifierLastName(modifier.getUser().getProperty(UserConstants.LASTNAME, getLocale()));
        }
    } else {
        messageView.setModified(false);
    }
    boolean userIsMsgCreator = false;
    // keeps the first 15 chars
    if (creator != null) {
        userIsMsgCreator = getIdentity().equals(creator);
        if (!StringHelper.containsNonWhitespace(m.getPseudonym())) {
            messageView.setCreatorFirstname(Formatter.truncate(creator.getUser().getProperty(UserConstants.FIRSTNAME, getLocale()), 18));
            messageView.setCreatorLastname(Formatter.truncate(creator.getUser().getProperty(UserConstants.LASTNAME, getLocale()), 18));
        }
    }
    // message attachments
    VFSContainer msgContainer = forumManager.getMessageContainer(forum.getKey(), m.getKey());
    messageView.setMessageContainer(msgContainer);
    List<VFSItem> attachments = new ArrayList<VFSItem>(msgContainer.getItems(new VFSItemMetaFilter()));
    messageView.setAttachments(attachments);
    // number of children and modify/delete permissions
    int numOfChildren = messageView.getNumOfChildren();
    messageView.setAuthor(userIsMsgCreator);
    boolean threadTop = m.getThreadtop() == null;
    messageView.setThreadTop(threadTop);
    boolean isThreadClosed;
    if (threadTop) {
        isThreadClosed = Status.getStatus(m.getStatusCode()).isClosed();
    } else {
        if (thread == null) {
            isThreadClosed = Status.getStatus(m.getThreadtop().getStatusCode()).isClosed();
        } else {
            isThreadClosed = Status.getStatus(thread.getStatusCode()).isClosed();
        }
    }
    messageView.setClosed(isThreadClosed);
    if (!guestOnly && !m.isGuest() && creator != null && !StringHelper.containsNonWhitespace(m.getPseudonym())) {
        // add portrait to map for later disposal and key for rendering in velocity
        DisplayPortraitController portrait = new DisplayPortraitController(ureq, getWindowControl(), creator, true, true, false, true);
        messageView.setPortrait(portrait);
        mainVC.put("portrait_".concat(keyString), portrait.getInitialComponent());
        // Add link with username that is clickable
        String creatorFullName = StringHelper.escapeHtml(UserManager.getInstance().getUserDisplayName(creator));
        Link visitingCardLink = LinkFactory.createCustomLink("vc_".concat(keyString), "vc", creatorFullName, Link.LINK_CUSTOM_CSS + Link.NONTRANSLATED, mainVC, this);
        visitingCardLink.setUserObject(creator);
        LinkPopupSettings settings = new LinkPopupSettings(800, 600, "_blank");
        visitingCardLink.setPopup(settings);
    }
    if (!isThreadClosed) {
        if ((numOfChildren == 0 && userIsMsgCreator && foCallback.mayDeleteOwnMessage()) || foCallback.mayDeleteMessageAsModerator()) {
            Link deleteLink = LinkFactory.createCustomLink("dl_".concat(keyString), "dl", "msg.delete", Link.BUTTON_SMALL, mainVC, this);
            deleteLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
            deleteLink.setUserObject(messageView);
        }
        if ((numOfChildren == 0 && userIsMsgCreator && foCallback.mayEditOwnMessage()) || foCallback.mayEditMessageAsModerator()) {
            Link editLink = LinkFactory.createCustomLink("ed_".concat(keyString), "ed", "msg.update", Link.BUTTON_SMALL, mainVC, this);
            editLink.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
            editLink.setUserObject(messageView);
        }
        if (foCallback.mayReplyMessage()) {
            Link quoteLink = LinkFactory.createCustomLink("qt_".concat(keyString), "qt", "msg.quote", Link.BUTTON_SMALL, mainVC, this);
            quoteLink.setElementCssClass("o_sel_forum_reply_quoted");
            quoteLink.setIconLeftCSS("o_icon o_icon-fw o_icon_reply_with_quote");
            quoteLink.setUserObject(messageView);
            Link replyLink = LinkFactory.createCustomLink("rp_".concat(keyString), "rp", "msg.reply", Link.BUTTON_SMALL, mainVC, this);
            replyLink.setElementCssClass("o_sel_forum_reply");
            replyLink.setIconLeftCSS("o_icon o_icon-fw o_icon_reply");
            replyLink.setUserObject(messageView);
        }
        if (foCallback.mayEditMessageAsModerator()) {
            if (!threadTop) {
                Link splitLink = LinkFactory.createCustomLink("split_".concat(keyString), "split", "msg.split", Link.LINK, mainVC, this);
                splitLink.setIconLeftCSS("o_icon o_icon-fw o_icon_split");
                splitLink.setUserObject(messageView);
                Link moveLink = LinkFactory.createCustomLink("move_".concat(keyString), "move", "msg.move", Link.LINK, mainVC, this);
                moveLink.setIconLeftCSS("o_icon o_icon-fw o_icon_move");
                moveLink.setUserObject(messageView);
            }
            Link exileLink = LinkFactory.createCustomLink("exile_".concat(keyString), "exile", "msg.exile", Link.LINK, mainVC, this);
            exileLink.setIconLeftCSS("o_icon o_icon-fw o_forum_status_thread_icon");
            exileLink.setUserObject(messageView);
        }
    }
    Mark currentMark = marks.get(keyString);
    MarkResourceStat stat = stats.get(keyString);
    if (!guestOnly) {
        String businessPath = currentMark == null ? getWindowControl().getBusinessControl().getAsString() + "[Message:" + m.getKey() + "]" : currentMark.getBusinessPath();
        Controller markCtrl = markingService.getMarkController(ureq, getWindowControl(), currentMark, stat, forumOres, keyString, businessPath);
        mainVC.put("mark_".concat(keyString), markCtrl.getInitialComponent());
    }
    if (userIsMsgCreator && !StringHelper.containsNonWhitespace(m.getPseudonym())) {
        OLATResourceable messageOres = OresHelper.createOLATResourceableInstance("Forum", m.getKey());
        String businessPath = BusinessControlFactory.getInstance().getAsString(getWindowControl().getBusinessControl()) + "[Message:" + m.getKey() + "]";
        Long artefact = artefactStats.get(businessPath);
        int numOfArtefact = artefact == null ? 0 : artefact.intValue();
        if (portfolioModule.isEnabled()) {
            String collectorId = "eportfolio_" + keyString;
            Component collectorCmp = new MediaCollectorComponent(collectorId, getWindowControl(), m, forumMediaHandler, businessPath);
            mainVC.put(collectorId, collectorCmp);
        } else {
            Controller ePFCollCtrl = EPUIFactory.createArtefactCollectWizzardController(ureq, getWindowControl(), numOfArtefact, messageOres, businessPath);
            if (ePFCollCtrl != null) {
                messageView.setArtefact(ePFCollCtrl);
                mainVC.put("eportfolio_" + keyString, ePFCollCtrl.getInitialComponent());
            }
        }
    }
}
Also used : VFSItemMetaFilter(org.olat.core.util.vfs.filters.VFSItemMetaFilter) DisplayPortraitController(org.olat.user.DisplayPortraitController) MarkResourceStat(org.olat.core.commons.services.mark.MarkResourceStat) MediaCollectorComponent(org.olat.modules.portfolio.ui.component.MediaCollectorComponent) OLATResourceable(org.olat.core.id.OLATResourceable) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) Mark(org.olat.core.commons.services.mark.Mark) DisplayPortraitController(org.olat.user.DisplayPortraitController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) BasicController(org.olat.core.gui.control.controller.BasicController) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) UserInfoMainController(org.olat.user.UserInfoMainController) Controller(org.olat.core.gui.control.Controller) LinkPopupSettings(org.olat.core.gui.components.link.LinkPopupSettings) Identity(org.olat.core.id.Identity) Component(org.olat.core.gui.components.Component) MediaCollectorComponent(org.olat.modules.portfolio.ui.component.MediaCollectorComponent) Link(org.olat.core.gui.components.link.Link)

Example 100 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class MessageListController method doExportForumItem.

private void doExportForumItem(UserRequest ureq, MessageView messageToMove) {
    if (foCallback.mayEditMessageAsModerator()) {
        StepRunnerCallback finish = new FinishCallback();
        Translator trans = Util.createPackageTranslator(Step_1_SelectCourse.class, getLocale());
        Step start = new Step_1_SelectCourse(ureq);
        Message message = forumManager.getMessageById(messageToMove.getKey());
        String wizardTitle = trans.translate("title.wizard.movethread", new String[] { message.getTitle() });
        exportCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, wizardTitle, "o_sel_bulk_assessment_wizard");
        StepsRunContext runContext = exportCtrl.getRunContext();
        // can be threadtop message
        runContext.put(SendMailStepForm.MESSAGE_TO_MOVE, message);
        // starting thread
        runContext.put(SendMailStepForm.START_THREADTOP, message.getThreadtop() == null ? message : message.getThreadtop());
        // get start course
        PropertyManager propertyManager = PropertyManager.getInstance();
        Long forumResourceableId = forum.getResourceableId();
        Property forumproperty = propertyManager.getPropertyByLongValue(forumResourceableId, FOCourseNode.FORUM_KEY);
        if (forumproperty != null) {
            Long resourcetypeId = forumproperty.getResourceTypeId();
            String resourcetypeName = forumproperty.getResourceTypeName();
            OLATResourceable olatResourceable = olatManager.findResourceable(resourcetypeId, resourcetypeName);
            RepositoryEntry startCourse = repositoryManager.lookupRepositoryEntry(olatResourceable, false);
            if (startCourse != null) {
                runContext.put(SendMailStepForm.START_COURSE, startCourse);
            }
        }
        listenTo(exportCtrl);
        getWindowControl().pushAsModalDialog(exportCtrl.getInitialComponent());
    } else {
        showWarning("may.not.move.message");
    }
}
Also used : ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) OLATResourceable(org.olat.core.id.OLATResourceable) PropertyManager(org.olat.properties.PropertyManager) Step(org.olat.core.gui.control.generic.wizard.Step) RepositoryEntry(org.olat.repository.RepositoryEntry) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) Step_1_SelectCourse(org.olat.modules.fo.export.Step_1_SelectCourse) Translator(org.olat.core.gui.translator.Translator) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Property(org.olat.properties.Property) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) FinishCallback(org.olat.modules.fo.export.FinishCallback)

Aggregations

OLATResourceable (org.olat.core.id.OLATResourceable)924 WindowControl (org.olat.core.gui.control.WindowControl)304 Test (org.junit.Test)158 Identity (org.olat.core.id.Identity)154 RepositoryEntry (org.olat.repository.RepositoryEntry)130 ContextEntry (org.olat.core.id.context.ContextEntry)82 ArrayList (java.util.ArrayList)68 OLATResource (org.olat.resource.OLATResource)60 Controller (org.olat.core.gui.control.Controller)48 Date (java.util.Date)46 AssertException (org.olat.core.logging.AssertException)32 StateSite (org.olat.core.id.context.StateSite)30 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)30 ICourse (org.olat.course.ICourse)30 CourseNode (org.olat.course.nodes.CourseNode)28 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)28 BusinessControl (org.olat.core.id.context.BusinessControl)24 BusinessGroup (org.olat.group.BusinessGroup)24 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)22 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)22