Search in sources :

Example 1 with BusinessGroup

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);
            }
        }
    }
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 2 with BusinessGroup

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());
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroup(org.olat.group.BusinessGroup)

Example 3 with BusinessGroup

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;
    }
}
Also used : AccessControlModule(org.olat.resource.accesscontrol.AccessControlModule) BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) ACService(org.olat.resource.accesscontrol.ACService) OLATResource(org.olat.resource.OLATResource) Date(java.util.Date)

Example 4 with BusinessGroup

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");
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext) Document(org.apache.lucene.document.Document) GroupDocument(org.olat.search.service.document.GroupDocument) IOException(java.io.IOException)

Example 5 with BusinessGroup

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.");
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) BusinessGroup(org.olat.group.BusinessGroup) SearchResourceContext(org.olat.search.service.SearchResourceContext) WikiPage(org.olat.modules.wiki.WikiPage) CollaborationTools(org.olat.collaboration.CollaborationTools) Wiki(org.olat.modules.wiki.Wiki) WikiPageDocument(org.olat.search.service.document.WikiPageDocument) Document(org.apache.lucene.document.Document)

Aggregations

BusinessGroup (org.olat.group.BusinessGroup)1034 Test (org.junit.Test)536 Identity (org.olat.core.id.Identity)536 RepositoryEntry (org.olat.repository.RepositoryEntry)324 ArrayList (java.util.ArrayList)224 BusinessGroupService (org.olat.group.BusinessGroupService)116 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)84 BGArea (org.olat.group.area.BGArea)70 CollaborationTools (org.olat.collaboration.CollaborationTools)58 OLATResource (org.olat.resource.OLATResource)56 Date (java.util.Date)54 HashSet (java.util.HashSet)50 File (java.io.File)46 Path (javax.ws.rs.Path)42 Group (org.olat.basesecurity.Group)42 HashMap (java.util.HashMap)38 Roles (org.olat.core.id.Roles)38 BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)38 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)38 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)38