use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class ScoreAccountingHelper method loadUsers.
/**
* Load all users from all known learning groups into a list
*
* @param courseEnv
* @return The list of identities from this course
*/
public static List<Identity> loadUsers(CourseEnvironment courseEnv) {
CourseGroupManager gm = courseEnv.getCourseGroupManager();
List<BusinessGroup> groups = gm.getAllBusinessGroups();
BusinessGroupService businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
Set<Identity> userSet = new HashSet<>(businessGroupService.getMembers(groups, GroupRoles.participant.name()));
RepositoryEntry re = gm.getCourseEntry();
if (re != null) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
userSet.addAll(repositoryService.getMembers(re, GroupRoles.participant.name()));
}
List<Identity> assessedList = courseEnv.getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(userSet);
if (!assessedList.isEmpty()) {
userSet.addAll(assessedList);
}
return new ArrayList<>(userSet);
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class ProjectBrokerCourseNode method createInstanceForCopy.
/**
* @see org.olat.course.nodes.CourseNode#createInstanceForCopy()
*/
@Override
public CourseNode createInstanceForCopy(boolean isNewTitle, ICourse course, Identity author) {
// create the instance for the copy
CourseNode copyInstance = super.createInstanceForCopy(isNewTitle, course, author);
// get all the different managers
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
ProjectGroupManager projectGroupManager = CoreSpringFactory.getImpl(ProjectGroupManager.class);
ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
// get the pbID from the source pb
Long oldProjectBrokerId = projectBrokerManager.getProjectBrokerId(cpm, this);
// create a new projectBroker for the copyInstance
ProjectBroker newBroker = projectBrokerManager.createAndSaveProjectBroker();
Long projectBrokerId = newBroker.getKey();
projectBrokerManager.saveProjectBrokerId(projectBrokerId, cpm, copyInstance);
// configure the new Project like the old one
// copy the old accountManagergroup to preserve the
// "persons in charge"
Long originalAccountGroupKey = projectGroupManager.getAccountManagerGroupKey(cpm, this);
if (originalAccountGroupKey != null) {
BusinessGroup originalAccountGroup = projectGroupManager.getAccountManagerGroupFor(cpm, this, course, getShortTitle(), getShortTitle(), null);
BusinessGroup newAccountManagerGroup = bgs.copyBusinessGroup(author, originalAccountGroup, originalAccountGroup.getName(), originalAccountGroup.getDescription(), originalAccountGroup.getMinParticipants(), originalAccountGroup.getMaxParticipants(), false, false, true, false, false, true, false, false);
projectGroupManager.saveAccountManagerGroupKey(newAccountManagerGroup.getKey(), cpm, copyInstance);
bgs.addResourceTo(newAccountManagerGroup, course.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
}
if (oldProjectBrokerId != null) {
List<Project> projects = projectBrokerManager.getProjectListBy(oldProjectBrokerId);
for (Project project : projects) {
// create projectGroup
BusinessGroup projectGroup = projectGroupManager.createProjectGroupFor(projectBrokerId, author, project.getTitle(), project.getDescription(), course.getResourceableId());
Project newProject = projectBrokerManager.createAndSaveProjectFor(project.getTitle(), project.getDescription(), projectBrokerId, projectGroup);
// copy all project configurations
newProject.setMailNotificationEnabled(project.isMailNotificationEnabled());
newProject.setMaxMembers(project.getMaxMembers());
for (int i = 0; i < project.getCustomFieldSize(); i++) {
newProject.setCustomFieldValue(i, project.getCustomFieldValue(i));
}
projectGroupManager.setDeselectionAllowed(newProject, project.getProjectGroup().isAllowToLeave());
projectBrokerManager.updateProject(newProject);
// attachment file
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(projectBrokerManager.getAttamchmentRelativeRootPath(project, course.getCourseEnvironment(), this), null);
VFSItem item = rootFolder.resolve(project.getAttachmentFileName());
if (item instanceof VFSLeaf) {
projectBrokerManager.saveAttachedFile(newProject, project.getAttachmentFileName(), (VFSLeaf) item, course.getCourseEnvironment(), copyInstance);
newProject.setAttachedFileName(project.getAttachmentFileName());
projectBrokerManager.updateProject(newProject);
}
}
}
return copyInstance;
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class OpenMeetingsCourseNode method isCoach.
private final boolean isCoach(RepositoryEntry re, Identity identity) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(identity, true, false);
int count = bgs.countBusinessGroups(params, re);
return count > 0;
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class ProjectGroupManagerImpl method updateAccountManagerGroupName.
@Override
public BusinessGroup updateAccountManagerGroupName(Identity ureqIdentity, String groupName, String groupDescription, BusinessGroup accountManagerGroup) {
// group could have been deleted, see FXOLAT-295
if (accountManagerGroup != null) {
BusinessGroupService bgs = businessGroupService;
BusinessGroup reloadedBusinessGroup = bgs.loadBusinessGroup(accountManagerGroup);
return bgs.updateBusinessGroup(ureqIdentity, reloadedBusinessGroup, groupName, groupDescription, reloadedBusinessGroup.getExternalId(), reloadedBusinessGroup.getManagedFlagsString(), reloadedBusinessGroup.getMinParticipants(), reloadedBusinessGroup.getMaxParticipants());
}
return null;
}
use of org.olat.group.BusinessGroupService in project openolat by klemens.
the class ProjectGroupManagerImpl method deleteAccountManagerGroup.
public void deleteAccountManagerGroup(CoursePropertyManager cpm, CourseNode courseNode) {
log.debug("deleteAccountManagerGroup start...");
Property accountManagerGroupProperty = cpm.findCourseNodeProperty(courseNode, null, null, ProjectBrokerCourseNode.CONF_ACCOUNTMANAGER_GROUP_KEY);
if (accountManagerGroupProperty != null) {
Long groupKey = accountManagerGroupProperty.getLongValue();
if (groupKey != null) {
BusinessGroup accountManagerGroup = businessGroupService.loadBusinessGroup(groupKey);
if (accountManagerGroup != null) {
BusinessGroupService bgs = businessGroupService;
bgs.deleteBusinessGroup(accountManagerGroup);
log.audit("ProjectBroker: Deleted accountManagerGroup=" + accountManagerGroup);
} else {
log.debug("deleteAccountManagerGroup: accountManagerGroup=" + accountManagerGroup + " has already been deleted");
}
}
cpm.deleteProperty(accountManagerGroupProperty);
log.debug("deleteAccountManagerGroup: deleted accountManagerGroupProperty=" + accountManagerGroupProperty);
} else {
log.debug("deleteAccountManagerGroup: found no accountManagerGroup-key");
}
}
Aggregations