Search in sources :

Example 16 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project openolat by klemens.

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 17 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project openolat by klemens.

the class BusinessGroupServiceImpl method moveIdentityFromWaitingListToParticipant.

@Override
public BusinessGroupAddResponse moveIdentityFromWaitingListToParticipant(Identity ureqIdentity, List<Identity> identities, BusinessGroup currBusinessGroup, MailPackage mailing) {
    Roles ureqRoles = securityManager.getRoles(ureqIdentity);
    BusinessGroupAddResponse response = new BusinessGroupAddResponse();
    List<BusinessGroupModifiedEvent.Deferred> events = new ArrayList<BusinessGroupModifiedEvent.Deferred>();
    currBusinessGroup = businessGroupDAO.loadForUpdate(currBusinessGroup);
    for (Identity identity : identities) {
        // check if identity is already in participant
        if (!businessGroupRelationDAO.hasRole(identity, currBusinessGroup, GroupRoles.participant.name())) {
            // Identity is not in participant-list => move identity from waiting-list to participant-list
            addParticipant(ureqIdentity, ureqRoles, identity, currBusinessGroup, mailing, events);
            removeFromWaitingList(ureqIdentity, identity, currBusinessGroup, mailing, events);
            response.getAddedIdentities().add(identity);
        // notification mail is handled in controller
        } else {
            if (businessGroupRelationDAO.hasRole(identity, currBusinessGroup, GroupRoles.waiting.name())) {
                removeFromWaitingList(ureqIdentity, identity, currBusinessGroup, mailing, events);
            }
            response.getIdentitiesAlreadyInGroup().add(identity);
        }
    }
    dbInstance.commit();
    BusinessGroupModifiedEvent.fireDeferredEvents(events);
    return response;
}
Also used : ArrayList(java.util.ArrayList) GroupRoles(org.olat.basesecurity.GroupRoles) Roles(org.olat.core.id.Roles) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse) Identity(org.olat.core.id.Identity) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 18 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project openolat by klemens.

the class BusinessGroupServiceImpl method addParticipants.

@Override
public BusinessGroupAddResponse addParticipants(Identity ureqIdentity, Roles ureqRoles, List<Identity> addIdentities, BusinessGroup group, MailPackage mailing) {
    BusinessGroupAddResponse response = new BusinessGroupAddResponse();
    List<BusinessGroupModifiedEvent.Deferred> events = new ArrayList<BusinessGroupModifiedEvent.Deferred>();
    BusinessGroup currBusinessGroup = businessGroupDAO.loadForUpdate(group);
    for (final Identity identity : addIdentities) {
        if (securityManager.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_GUESTONLY)) {
            response.getIdentitiesWithoutPermission().add(identity);
        } else if (addParticipant(ureqIdentity, ureqRoles, identity, currBusinessGroup, mailing, events)) {
            response.getAddedIdentities().add(identity);
        } else {
            response.getIdentitiesAlreadyInGroup().add(identity);
        }
    }
    dbInstance.commit();
    BusinessGroupModifiedEvent.fireDeferredEvents(events);
    return response;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse) Identity(org.olat.core.id.Identity) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 19 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project openolat by klemens.

the class BusinessGroupServiceImpl method addOwners.

@Override
public BusinessGroupAddResponse addOwners(Identity ureqIdentity, Roles ureqRoles, List<Identity> addIdentities, BusinessGroup group, MailPackage mailing) {
    BusinessGroupAddResponse response = new BusinessGroupAddResponse();
    List<BusinessGroupModifiedEvent.Deferred> events = new ArrayList<BusinessGroupModifiedEvent.Deferred>();
    for (Identity identity : addIdentities) {
        // reload business group
        group = loadBusinessGroup(group);
        if (securityManager.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_GUESTONLY)) {
            response.getIdentitiesWithoutPermission().add(identity);
        } else if (addOwner(ureqIdentity, ureqRoles, identity, group, mailing, events)) {
            response.getAddedIdentities().add(identity);
        } else {
            response.getIdentitiesAlreadyInGroup().add(identity);
        }
    }
    dbInstance.commit();
    BusinessGroupModifiedEvent.fireDeferredEvents(events);
    return response;
}
Also used : ArrayList(java.util.ArrayList) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse) Identity(org.olat.core.id.Identity) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 20 with BusinessGroupAddResponse

use of org.olat.group.BusinessGroupAddResponse in project openolat by klemens.

the class BusinessGroupServiceImpl method addToWaitingList.

@Override
public BusinessGroupAddResponse addToWaitingList(Identity ureqIdentity, List<Identity> addIdentities, BusinessGroup group, MailPackage mailing) {
    BusinessGroupAddResponse response = new BusinessGroupAddResponse();
    // reload business group
    BusinessGroup currBusinessGroup = businessGroupDAO.loadForUpdate(group);
    List<BusinessGroupModifiedEvent.Deferred> events = new ArrayList<BusinessGroupModifiedEvent.Deferred>();
    for (final Identity identity : addIdentities) {
        if (securityManager.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_GUESTONLY)) {
            response.getIdentitiesWithoutPermission().add(identity);
        } else // Check if identity is already in group. make a db query in case
        // someone in another workflow already added this user to this group. if
        // found, add user to model
        {
            List<String> roles = businessGroupRelationDAO.getRoles(identity, currBusinessGroup);
            if (roles.contains(GroupRoles.waiting.name()) || roles.contains(GroupRoles.participant.name())) {
                response.getIdentitiesAlreadyInGroup().add(identity);
            } else {
                // identity has permission and is not already in group => add it
                internalAddToWaitingList(ureqIdentity, identity, currBusinessGroup, mailing, events);
                response.getAddedIdentities().add(identity);
            }
        }
    }
    dbInstance.commit();
    BusinessGroupModifiedEvent.fireDeferredEvents(events);
    return response;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse) Identity(org.olat.core.id.Identity) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

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