Search in sources :

Example 1 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project OpenOLAT by OpenOLAT.

the class FolderCallback 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 urequest, Controller source, Event event) {
    if (source == projectBrokerConditionController) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionProjectBroker(projectBrokerConditionController.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == dialogBoxController) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            // ok: open task folder
            String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(CourseFactory.loadCourse(courseId), node);
            OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
            OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
            namedFolder.setLocalSecurityCallback(new FolderCallback(relPath, false));
            removeAsListenerAndDispose(frc);
            frc = new FolderRunController(namedFolder, false, urequest, getWindowControl());
            listenTo(frc);
            removeAsListenerAndDispose(cmc);
            cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc.getInitialComponent());
            listenTo(cmc);
            cmc.activate();
            fireEvent(urequest, Event.CHANGED_EVENT);
        }
    } else if (source == scoringController) {
        if (event == Event.CANCELLED_EVENT) {
            if (hasLogEntries) {
                scoringController.setDisplayOnly(true);
            }
            editScoring.contextPut("isOverwriting", new Boolean(false));
            return;
        } else if (event == Event.DONE_EVENT) {
            scoringController.updateModuleConfiguration(config);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == modulesForm) {
        boolean onoff = event.getCommand().endsWith("true");
        if (event.getCommand().startsWith("dropbox")) {
            config.set(ProjectBrokerCourseNode.CONF_DROPBOX_ENABLED, onoff);
        } else if (event.getCommand().startsWith("returnbox")) {
            config.set(ProjectBrokerCourseNode.CONF_RETURNBOX_ENABLED, onoff);
        }
        fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        return;
    } else if (source == accountManagerGroupController) {
        if (event instanceof IdentitiesAddEvent) {
            IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
            BusinessGroupAddResponse response = businessGroupService.addParticipants(urequest.getIdentity(), urequest.getUserSession().getRoles(), identitiesAddedEvent.getAddIdentities(), accountManagerGroup, null);
            identitiesAddedEvent.setIdentitiesAddedEvent(response.getAddedIdentities());
            identitiesAddedEvent.setIdentitiesWithoutPermission(response.getIdentitiesWithoutPermission());
            identitiesAddedEvent.setIdentitiesAlreadyInGroup(response.getIdentitiesAlreadyInGroup());
            getLogger().info("Add users as account-managers");
            fireEvent(urequest, Event.CHANGED_EVENT);
        } else if (event instanceof IdentitiesRemoveEvent) {
            businessGroupService.removeParticipants(urequest.getIdentity(), ((IdentitiesRemoveEvent) event).getRemovedIdentities(), accountManagerGroup, null);
            getLogger().info("Remove users as account-managers");
            fireEvent(urequest, Event.CHANGED_EVENT);
        }
    } else if (source == optionsForm) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            projectBrokerModuleConfiguration.setNbrParticipantsPerTopic(optionsForm.getNnbrOfAttendees());
            if (projectBrokerModuleConfiguration.isAcceptSelectionManually() && !optionsForm.getSelectionAccept()) {
                // change 'Accept manually' to 'Accept automatically' => enroll all candidates
                projectGroupManager.acceptAllCandidates(projectBrokerId, urequest.getIdentity(), projectBrokerModuleConfiguration.isAutoSignOut(), optionsForm.getSelectionAccept());
            }
            projectBrokerModuleConfiguration.setAcceptSelectionManaually(optionsForm.getSelectionAccept());
            projectBrokerModuleConfiguration.setSelectionAutoSignOut(optionsForm.getSelectionAutoSignOut());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == customfieldsForm || source == projectEventForm) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (event == NodeEditController.NODECONFIG_CHANGED_EVENT) {
        getLogger().debug("NODECONFIG_CHANGED_node.shortTitle=" + node.getShortTitle());
        String groupName = translate("account.manager.groupname", node.getShortTitle());
        String groupDescription = translate("account.manager.groupdescription", node.getShortTitle());
        accountManagerGroup = projectGroupManager.updateAccountManagerGroupName(getIdentity(), groupName, groupDescription, accountManagerGroup);
    } else if (source == dropboxForm) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            config.set(ProjectBrokerCourseNode.CONF_DROPBOX_ENABLEMAIL, dropboxForm.mailEnabled());
            config.set(ProjectBrokerCourseNode.CONF_DROPBOX_CONFIRMATION, dropboxForm.getConfirmation());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
            return;
        }
    } else {
        getLogger().warn("Can not handle event in ProjectBrokerCourseEditorController source=" + source + " " + event.toString());
    }
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse)

Example 2 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project OpenOLAT by OpenOLAT.

the class ProjectGroupController method handleCandidateGroupEvent.

private void handleCandidateGroupEvent(UserRequest urequest, Event event) {
    if (event instanceof IdentitiesAddEvent) {
        IdentitiesAddEvent identitiesAddEvent = (IdentitiesAddEvent) event;
        List<Identity> addedIdentities = projectGroupManager.addCandidates(identitiesAddEvent.getAddIdentities(), project);
        identitiesAddEvent.setIdentitiesAddedEvent(addedIdentities);
        fireEvent(urequest, Event.CHANGED_EVENT);
    } else if (event instanceof IdentitiesRemoveEvent) {
        projectGroupManager.removeCandidates(((IdentitiesRemoveEvent) event).getRemovedIdentities(), project);
        fireEvent(urequest, Event.CHANGED_EVENT);
    } else if (event instanceof IdentitiesMoveEvent) {
        final IdentitiesMoveEvent identitiesMoveEvent = (IdentitiesMoveEvent) event;
        // OLAT-6342: check identity not in group first!
        List<Identity> moveIdents = identitiesMoveEvent.getChosenIdentities();
        BusinessGroupAddResponse response = projectGroupManager.acceptCandidates(moveIdents, project, urequest.getIdentity(), projectBrokerModuleConfiguration.isAutoSignOut(), projectBrokerModuleConfiguration.isAcceptSelectionManually());
        identitiesMoveEvent.setMovedIdentities(response.getAddedIdentities());
        identitiesMoveEvent.setNotMovedIdentities(response.getIdentitiesAlreadyInGroup());
        // send mail for all of them
        MailTemplate mailTemplate = identitiesMoveEvent.getMailTemplate();
        if (mailTemplate != null) {
            MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
            String metaId = UUID.randomUUID().toString().replace("-", "");
            MailerResult result = new MailerResult();
            MailBundle[] bundles = mailManager.makeMailBundles(context, identitiesMoveEvent.getMovedIdentities(), mailTemplate, null, metaId, result);
            result.append(mailManager.sendMessage(bundles));
            if (mailTemplate.getCpfrom()) {
                MailBundle ccBundle = mailManager.makeMailBundle(context, urequest.getIdentity(), mailTemplate, null, metaId, result);
                result.append(mailManager.sendMessage(ccBundle));
            }
            MailHelper.printErrorsAndWarnings(result, getWindowControl(), urequest.getUserSession().getRoles().isOLATAdmin(), urequest.getLocale());
        }
        fireEvent(urequest, Event.CHANGED_EVENT);
        // Participant and waiting-list were changed => reload both
        projectMemberController.reloadData();
        // Do only reload data in case of IdentitiesMoveEvent (IdentitiesAddEvent and reload data resulting in doublicate values)
        projectCandidatesController.reloadData();
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) MailTemplate(org.olat.core.util.mail.MailTemplate) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle) IdentitiesMoveEvent(org.olat.admin.securitygroup.gui.IdentitiesMoveEvent)

Example 3 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project OpenOLAT by OpenOLAT.

the class ProjectGroupController method handleProjectMemberGroupEvent.

private void handleProjectMemberGroupEvent(UserRequest urequest, Event event) {
    if (event instanceof IdentitiesAddEvent) {
        IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
        BusinessGroupAddResponse response = businessGroupService.addParticipants(urequest.getIdentity(), urequest.getUserSession().getRoles(), identitiesAddedEvent.getAddIdentities(), project.getProjectGroup(), null);
        identitiesAddedEvent.setIdentitiesAddedEvent(response.getAddedIdentities());
        identitiesAddedEvent.setIdentitiesWithoutPermission(response.getIdentitiesWithoutPermission());
        identitiesAddedEvent.setIdentitiesAlreadyInGroup(response.getIdentitiesAlreadyInGroup());
        getLogger().info("Add users as project-members");
        fireEvent(urequest, Event.CHANGED_EVENT);
    } else if (event instanceof IdentitiesRemoveEvent) {
        businessGroupService.removeParticipants(urequest.getIdentity(), ((IdentitiesRemoveEvent) event).getRemovedIdentities(), project.getProjectGroup(), null);
        getLogger().info("Remove users as account-managers");
        fireEvent(urequest, Event.CHANGED_EVENT);
    }
}
Also used : IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse)

Example 4 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project OpenOLAT by OpenOLAT.

the class ProjectGroupController method handleProjectLeaderGroupEvent.

private void handleProjectLeaderGroupEvent(UserRequest urequest, Event event) {
    if (event instanceof IdentitiesAddEvent) {
        IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
        BusinessGroupAddResponse response = businessGroupService.addOwners(urequest.getIdentity(), urequest.getUserSession().getRoles(), identitiesAddedEvent.getAddIdentities(), project.getProjectGroup(), null);
        identitiesAddedEvent.setIdentitiesAddedEvent(response.getAddedIdentities());
        identitiesAddedEvent.setIdentitiesWithoutPermission(response.getIdentitiesWithoutPermission());
        identitiesAddedEvent.setIdentitiesAlreadyInGroup(response.getIdentitiesAlreadyInGroup());
        getLogger().info("Add users as project-leader");
        fireEvent(urequest, Event.CHANGED_EVENT);
    } else if (event instanceof IdentitiesRemoveEvent) {
        businessGroupService.removeOwners(urequest.getIdentity(), ((IdentitiesRemoveEvent) event).getRemovedIdentities(), project.getProjectGroup());
        getLogger().info("Remove users as account-managers");
        fireEvent(urequest, Event.CHANGED_EVENT);
    }
}
Also used : IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse)

Example 5 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project OpenOLAT by OpenOLAT.

the class LearningGroupWebService method addParticipant.

/**
 * Adds a participant to the group.
 * @response.representation.200.doc The user is added as participant of the group
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The business group or the user cannot be found
 * @param groupKey The key of the group
 * @param identityKey The user's id
 * @param request The HTTP request
 * @return
 */
@PUT
@Path("{groupKey}/participants/{identityKey}")
public Response addParticipant(@PathParam("groupKey") Long groupKey, @PathParam("identityKey") Long identityKey, @Context HttpServletRequest request) {
    try {
        if (!isGroupManager(request)) {
            return Response.serverError().status(Status.UNAUTHORIZED).build();
        }
        final UserRequest ureq = RestSecurityHelper.getUserRequest(request);
        final BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
        final BusinessGroup group = bgs.loadBusinessGroup(groupKey);
        final Identity identity = BaseSecurityManager.getInstance().loadIdentityByKey(identityKey, false);
        if (identity == null || group == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        BusinessGroupAddResponse state = bgs.addParticipants(ureq.getIdentity(), ureq.getUserSession().getRoles(), Collections.singletonList(identity), group, null);
        if (state.getAddedIdentities().contains(identity)) {
            return Response.ok().build();
        } else if (state.getIdentitiesAlreadyInGroup().contains(identity)) {
            return Response.ok().status(Status.NOT_MODIFIED).build();
        }
        return Response.serverError().status(Status.PRECONDITION_FAILED).build();
    } catch (Exception e) {
        log.error("Trying to add a participant to a group", e);
        return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse) Identity(org.olat.core.id.Identity) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Aggregations

BusinessGroupAddResponse (org.olat.group.BusinessGroupAddResponse)20 Identity (org.olat.core.id.Identity)14 ArrayList (java.util.ArrayList)8 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)8 IdentitiesRemoveEvent (org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent)8 BusinessGroupModifiedEvent (org.olat.group.ui.edit.BusinessGroupModifiedEvent)8 BusinessGroup (org.olat.group.BusinessGroup)6 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 IdentitiesMoveEvent (org.olat.admin.securitygroup.gui.IdentitiesMoveEvent)2 GroupRoles (org.olat.basesecurity.GroupRoles)2 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)2 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)2 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)2 UserRequest (org.olat.core.gui.UserRequest)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 Roles (org.olat.core.id.Roles)2 MailBundle (org.olat.core.util.mail.MailBundle)2 MailContext (org.olat.core.util.mail.MailContext)2 MailContextImpl (org.olat.core.util.mail.MailContextImpl)2