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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations