use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class GTACoachedParticipantListController method collectIdentities.
private void collectIdentities(Consumer<Identity> participantCollector) {
Set<Identity> duplicateKiller = new HashSet<>();
CourseGroupManager cgm = coachCourseEnv.getCourseEnvironment().getCourseGroupManager();
boolean admin = coachCourseEnv.isAdmin();
List<BusinessGroup> coachedGroups = admin ? cgm.getAllBusinessGroups() : coachCourseEnv.getCoachedGroups();
List<Identity> participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
for (Identity participant : participants) {
if (!duplicateKiller.contains(participant)) {
participantCollector.accept(participant);
duplicateKiller.add(participant);
}
}
RepositoryEntry re = coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
boolean repoTutor = admin || (coachedGroups.isEmpty() && repositoryService.hasRole(getIdentity(), re, GroupRoles.coach.name()));
if (repoTutor) {
List<Identity> courseParticipants = repositoryService.getMembers(re, GroupRoles.participant.name());
for (Identity participant : courseParticipants) {
if (!duplicateKiller.contains(participant)) {
participantCollector.accept(participant);
duplicateKiller.add(participant);
}
}
}
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class RunMainController method loadUserCourseEnvironment.
private UserCourseEnvironmentImpl loadUserCourseEnvironment(UserRequest ureq, RepositoryEntrySecurity reSecurity) {
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
List<BusinessGroup> coachedGroups;
if (reSecurity.isGroupCoach()) {
coachedGroups = cgm.getOwnedBusinessGroups(ureq.getIdentity());
} else {
coachedGroups = Collections.emptyList();
}
List<BusinessGroup> participatedGroups;
if (reSecurity.isGroupParticipant()) {
participatedGroups = cgm.getParticipatingBusinessGroups(ureq.getIdentity());
} else {
participatedGroups = Collections.emptyList();
}
List<BusinessGroup> waitingLists;
if (reSecurity.isGroupWaiting()) {
waitingLists = cgm.getWaitingListGroups(ureq.getIdentity());
} else {
waitingLists = Collections.emptyList();
}
return new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment(), getWindowControl(), coachedGroups, participatedGroups, waitingLists, reSecurity.isCourseCoach() || reSecurity.isGroupCoach(), reSecurity.isEntryAdmin(), reSecurity.isCourseParticipant() || reSecurity.isGroupParticipant(), reSecurity.isReadOnly());
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class GroupIndexer method checkAccess.
@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
if (roles.isGuestOnly()) {
return false;
}
Long key = contextEntry.getOLATResourceable().getResourceableId();
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup group = bgs.loadBusinessGroup(key);
if (group == null || roles.isGuestOnly()) {
return false;
}
boolean inGroup = bgs.isIdentityInBusinessGroup(identity, group);
if (inGroup) {
return super.checkAccess(contextEntry, businessControl, identity, roles) && super.checkAccess(businessControl, identity, roles);
} else {
AccessControlModule acModule = (AccessControlModule) CoreSpringFactory.getBean("acModule");
if (acModule.isEnabled()) {
ACService acService = CoreSpringFactory.getImpl(ACService.class);
OLATResource resource = group.getResource();
if (acService.isResourceAccessControled(resource, new Date())) {
return super.checkAccess(contextEntry, businessControl, identity, roles) && super.checkAccess(businessControl, identity, roles);
}
}
return false;
}
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class GroupIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
long startTime = System.currentTimeMillis();
final BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
List<BusinessGroup> groupList = bgs.loadAllBusinessGroups();
if (isLogDebugEnabled())
logDebug("GroupIndexer groupList.size=" + groupList.size());
// committing here to make sure the loadBusinessGroup below does actually
// reload from the database and not only use the session cache
// (see org.hibernate.Session.get():
// If the instance, or a proxy for the instance, is already associated with the session, return that instance or proxy.)
DBFactory.getInstance().commitAndCloseSession();
// loop over all groups
for (BusinessGroup businessGroup : groupList) {
try {
// reload the businessGroup here before indexing it to make sure it has not been deleted in the meantime
BusinessGroup reloadedBusinessGroup = bgs.loadBusinessGroup(businessGroup);
if (reloadedBusinessGroup == null) {
logInfo("doIndex: businessGroup was deleted while we were indexing. The deleted businessGroup was: " + businessGroup);
continue;
}
businessGroup = reloadedBusinessGroup;
if (isLogDebugEnabled())
logDebug("Index BusinessGroup=" + businessGroup);
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
searchResourceContext.setBusinessControlFor(businessGroup);
Document document = GroupDocument.createDocument(searchResourceContext, businessGroup);
indexWriter.addDocument(document);
// Do index child
super.doIndex(searchResourceContext, businessGroup, indexWriter);
} catch (Exception ex) {
logError("Exception indexing group=" + businessGroup, ex);
DBFactory.getInstance().rollbackAndCloseSession();
} catch (Error err) {
logError("Error indexing group=" + businessGroup, err);
DBFactory.getInstance().rollbackAndCloseSession();
}
DBFactory.getInstance().commitAndCloseSession();
}
long indexTime = System.currentTimeMillis() - startTime;
if (isLogDebugEnabled())
logDebug("GroupIndexer finished in " + indexTime + " ms");
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class GroupWikiIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!(businessObj instanceof BusinessGroup))
throw new AssertException("businessObj must be BusinessGroup");
BusinessGroup businessGroup = (BusinessGroup) businessObj;
// Index Group Wiki
if (isLogDebugEnabled())
logDebug("Analyse Wiki for Group=" + businessGroup);
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI)) {
try {
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(businessGroup);
// loop over all wiki pages
List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
for (WikiPage wikiPage : wikiPageList) {
SearchResourceContext wikiResourceContext = new SearchResourceContext(parentResourceContext);
wikiResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLWIKI);
wikiResourceContext.setDocumentType(TYPE);
wikiResourceContext.setFilePath(wikiPage.getPageName());
Document document = WikiPageDocument.createDocument(wikiResourceContext, wikiPage);
indexWriter.addDocument(document);
}
} catch (NullPointerException nex) {
logWarn("NullPointerException in GroupWikiIndexer.doIndex.", nex);
}
} else {
if (isLogDebugEnabled())
logDebug("Group=" + businessGroup + " has no Wiki.");
}
}
Aggregations