Search in sources :

Example 1 with CollaborationToolsFactory

use of org.olat.collaboration.CollaborationToolsFactory in project OpenOLAT by OpenOLAT.

the class CourseCalendarController method addCalendars.

private void addCalendars(List<BusinessGroup> groups, boolean isOwner, LinkProvider linkProvider, List<KalendarRenderWrapper> calendars) {
    CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
    for (BusinessGroup bGroup : groups) {
        CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
        if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR))
            continue;
        KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
        groupCalendarWrapper.setPrivateEventsVisible(true);
        // set calendar access
        int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
        Long lCalAccess = collabTools.lookupCalendarAccess();
        if (lCalAccess != null)
            iCalAccess = lCalAccess.intValue();
        if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
            groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
        } else {
            groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
        }
        CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(groupCalendarWrapper.getKalendar(), getIdentity());
        if (config != null) {
            groupCalendarWrapper.setConfiguration(config);
        }
        groupCalendarWrapper.setLinkProvider(linkProvider);
        calendars.add(groupCalendarWrapper);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) CollaborationToolsFactory(org.olat.collaboration.CollaborationToolsFactory)

Example 2 with CollaborationToolsFactory

use of org.olat.collaboration.CollaborationToolsFactory in project openolat by klemens.

the class BusinessGroupServiceImpl method copyBusinessGroup.

@Override
public BusinessGroup copyBusinessGroup(Identity identity, BusinessGroup sourceBusinessGroup, String targetName, String targetDescription, Integer targetMin, Integer targetMax, boolean copyAreas, boolean copyCollabToolConfig, boolean copyRights, boolean copyOwners, boolean copyParticipants, boolean copyMemberVisibility, boolean copyWaitingList, boolean copyRelations) {
    // 1. create group, set waitingListEnabled, enableAutoCloseRanks like source business-group
    BusinessGroup newGroup = createBusinessGroup(null, targetName, targetDescription, targetMin, targetMax, sourceBusinessGroup.getWaitingListEnabled(), sourceBusinessGroup.getAutoCloseRanksEnabled(), null);
    // return immediately with null value to indicate an already take groupname
    if (newGroup == null) {
        return null;
    }
    // 2. copy tools
    if (copyCollabToolConfig) {
        CollaborationToolsFactory toolsF = CollaborationToolsFactory.getInstance();
        // get collab tools from original group and the new group
        CollaborationTools oldTools = toolsF.getOrCreateCollaborationTools(sourceBusinessGroup);
        CollaborationTools newTools = toolsF.getOrCreateCollaborationTools(newGroup);
        // copy the collab tools settings
        String[] availableTools = CollaborationToolsFactory.getInstance().getAvailableTools().clone();
        for (int i = 0; i < availableTools.length; i++) {
            String tool = availableTools[i];
            newTools.setToolEnabled(tool, oldTools.isToolEnabled(tool));
        }
        String oldNews = oldTools.lookupNews();
        newTools.saveNews(oldNews);
    }
    // 3. copy member visibility
    if (copyMemberVisibility) {
        newGroup.setOwnersVisibleIntern(sourceBusinessGroup.isOwnersVisibleIntern());
        newGroup.setOwnersVisiblePublic(sourceBusinessGroup.isOwnersVisiblePublic());
        newGroup.setParticipantsVisibleIntern(sourceBusinessGroup.isParticipantsVisibleIntern());
        newGroup.setParticipantsVisiblePublic(sourceBusinessGroup.isParticipantsVisiblePublic());
        newGroup.setWaitingListVisibleIntern(sourceBusinessGroup.isWaitingListVisibleIntern());
        newGroup.setWaitingListVisiblePublic(sourceBusinessGroup.isWaitingListVisiblePublic());
        newGroup.setDownloadMembersLists(sourceBusinessGroup.isDownloadMembersLists());
    }
    // 4. copy areas
    if (copyAreas) {
        List<BGArea> areas = areaManager.findBGAreasOfBusinessGroup(sourceBusinessGroup);
        for (BGArea area : areas) {
            // reference target group to source groups areas
            areaManager.addBGToBGArea(newGroup, area);
        }
    }
    // 5. copy owners
    if (copyOwners) {
        List<Identity> owners = businessGroupRelationDAO.getMembers(sourceBusinessGroup, GroupRoles.coach.name());
        if (owners.isEmpty()) {
            businessGroupRelationDAO.addRole(identity, newGroup, GroupRoles.coach.name());
        } else {
            for (Identity owner : owners) {
                businessGroupRelationDAO.addRole(owner, newGroup, GroupRoles.coach.name());
            }
        }
    } else {
        businessGroupRelationDAO.addRole(identity, newGroup, GroupRoles.coach.name());
    }
    // 6. copy participants
    if (copyParticipants) {
        List<Identity> participants = businessGroupRelationDAO.getMembers(sourceBusinessGroup, GroupRoles.participant.name());
        for (Identity participant : participants) {
            businessGroupRelationDAO.addRole(participant, newGroup, GroupRoles.participant.name());
        }
    }
    // 7. copy rights
    if (copyRights) {
        List<String> participantRights = rightManager.findBGRights(sourceBusinessGroup, BGRightsRole.participant);
        for (String sourceRight : participantRights) {
            rightManager.addBGRight(sourceRight, newGroup, BGRightsRole.participant);
        }
        List<String> tutorRights = rightManager.findBGRights(sourceBusinessGroup, BGRightsRole.tutor);
        for (String sourceRight : tutorRights) {
            rightManager.addBGRight(sourceRight, newGroup, BGRightsRole.tutor);
        }
    }
    // 8. copy waiting-lisz
    if (copyWaitingList) {
        List<Identity> waitingList = getMembers(sourceBusinessGroup, GroupRoles.waiting.name());
        for (Identity waiting : waitingList) {
            businessGroupRelationDAO.addRole(waiting, newGroup, GroupRoles.waiting.name());
        }
    }
    // 9. copy relations
    if (copyRelations) {
        List<RepositoryEntry> resources = businessGroupRelationDAO.findRepositoryEntries(Collections.singletonList(sourceBusinessGroup), 0, -1);
        addResourcesTo(Collections.singletonList(newGroup), resources);
    }
    return newGroup;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) BGArea(org.olat.group.area.BGArea) CollaborationTools(org.olat.collaboration.CollaborationTools) Identity(org.olat.core.id.Identity) CollaborationToolsFactory(org.olat.collaboration.CollaborationToolsFactory)

Example 3 with CollaborationToolsFactory

use of org.olat.collaboration.CollaborationToolsFactory in project OpenOLAT by OpenOLAT.

the class CourseCalendars method addCalendars.

private static void addCalendars(UserRequest ureq, UserCourseEnvironment courseEnv, List<BusinessGroup> groups, boolean isOwner, LinkProvider linkProvider, List<KalendarRenderWrapper> calendars) {
    if (groups == null || groups.isEmpty())
        return;
    CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
    CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
    Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(ureq.getIdentity(), CalendarManager.TYPE_GROUP);
    for (BusinessGroup bGroup : groups) {
        CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
        if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) {
            continue;
        }
        boolean member = courseEnv.isIdentityInCourseGroup(bGroup.getKey());
        KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
        groupCalendarWrapper.setPrivateEventsVisible(member || isOwner);
        // set calendar access
        int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
        Long lCalAccess = collabTools.lookupCalendarAccess();
        if (lCalAccess != null)
            iCalAccess = lCalAccess.intValue();
        if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
            groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
        } else {
            groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
        }
        CalendarUserConfiguration config = configMap.get(groupCalendarWrapper.getCalendarKey());
        if (config != null) {
            groupCalendarWrapper.setConfiguration(config);
        }
        groupCalendarWrapper.setLinkProvider(linkProvider);
        calendars.add(groupCalendarWrapper);
    }
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarKey(org.olat.commons.calendar.model.CalendarKey) BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) CollaborationToolsFactory(org.olat.collaboration.CollaborationToolsFactory)

Example 4 with CollaborationToolsFactory

use of org.olat.collaboration.CollaborationToolsFactory in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceImpl method copyBusinessGroup.

@Override
public BusinessGroup copyBusinessGroup(Identity identity, BusinessGroup sourceBusinessGroup, String targetName, String targetDescription, Integer targetMin, Integer targetMax, boolean copyAreas, boolean copyCollabToolConfig, boolean copyRights, boolean copyOwners, boolean copyParticipants, boolean copyMemberVisibility, boolean copyWaitingList, boolean copyRelations) {
    // 1. create group, set waitingListEnabled, enableAutoCloseRanks like source business-group
    BusinessGroup newGroup = createBusinessGroup(null, targetName, targetDescription, targetMin, targetMax, sourceBusinessGroup.getWaitingListEnabled(), sourceBusinessGroup.getAutoCloseRanksEnabled(), null);
    // return immediately with null value to indicate an already take groupname
    if (newGroup == null) {
        return null;
    }
    // 2. copy tools
    if (copyCollabToolConfig) {
        CollaborationToolsFactory toolsF = CollaborationToolsFactory.getInstance();
        // get collab tools from original group and the new group
        CollaborationTools oldTools = toolsF.getOrCreateCollaborationTools(sourceBusinessGroup);
        CollaborationTools newTools = toolsF.getOrCreateCollaborationTools(newGroup);
        // copy the collab tools settings
        String[] availableTools = CollaborationToolsFactory.getInstance().getAvailableTools().clone();
        for (int i = 0; i < availableTools.length; i++) {
            String tool = availableTools[i];
            newTools.setToolEnabled(tool, oldTools.isToolEnabled(tool));
        }
        String oldNews = oldTools.lookupNews();
        newTools.saveNews(oldNews);
    }
    // 3. copy member visibility
    if (copyMemberVisibility) {
        newGroup.setOwnersVisibleIntern(sourceBusinessGroup.isOwnersVisibleIntern());
        newGroup.setOwnersVisiblePublic(sourceBusinessGroup.isOwnersVisiblePublic());
        newGroup.setParticipantsVisibleIntern(sourceBusinessGroup.isParticipantsVisibleIntern());
        newGroup.setParticipantsVisiblePublic(sourceBusinessGroup.isParticipantsVisiblePublic());
        newGroup.setWaitingListVisibleIntern(sourceBusinessGroup.isWaitingListVisibleIntern());
        newGroup.setWaitingListVisiblePublic(sourceBusinessGroup.isWaitingListVisiblePublic());
        newGroup.setDownloadMembersLists(sourceBusinessGroup.isDownloadMembersLists());
    }
    // 4. copy areas
    if (copyAreas) {
        List<BGArea> areas = areaManager.findBGAreasOfBusinessGroup(sourceBusinessGroup);
        for (BGArea area : areas) {
            // reference target group to source groups areas
            areaManager.addBGToBGArea(newGroup, area);
        }
    }
    // 5. copy owners
    if (copyOwners) {
        List<Identity> owners = businessGroupRelationDAO.getMembers(sourceBusinessGroup, GroupRoles.coach.name());
        if (owners.isEmpty()) {
            businessGroupRelationDAO.addRole(identity, newGroup, GroupRoles.coach.name());
        } else {
            for (Identity owner : owners) {
                businessGroupRelationDAO.addRole(owner, newGroup, GroupRoles.coach.name());
            }
        }
    } else {
        businessGroupRelationDAO.addRole(identity, newGroup, GroupRoles.coach.name());
    }
    // 6. copy participants
    if (copyParticipants) {
        List<Identity> participants = businessGroupRelationDAO.getMembers(sourceBusinessGroup, GroupRoles.participant.name());
        for (Identity participant : participants) {
            businessGroupRelationDAO.addRole(participant, newGroup, GroupRoles.participant.name());
        }
    }
    // 7. copy rights
    if (copyRights) {
        List<String> participantRights = rightManager.findBGRights(sourceBusinessGroup, BGRightsRole.participant);
        for (String sourceRight : participantRights) {
            rightManager.addBGRight(sourceRight, newGroup, BGRightsRole.participant);
        }
        List<String> tutorRights = rightManager.findBGRights(sourceBusinessGroup, BGRightsRole.tutor);
        for (String sourceRight : tutorRights) {
            rightManager.addBGRight(sourceRight, newGroup, BGRightsRole.tutor);
        }
    }
    // 8. copy waiting-lisz
    if (copyWaitingList) {
        List<Identity> waitingList = getMembers(sourceBusinessGroup, GroupRoles.waiting.name());
        for (Identity waiting : waitingList) {
            businessGroupRelationDAO.addRole(waiting, newGroup, GroupRoles.waiting.name());
        }
    }
    // 9. copy relations
    if (copyRelations) {
        List<RepositoryEntry> resources = businessGroupRelationDAO.findRepositoryEntries(Collections.singletonList(sourceBusinessGroup), 0, -1);
        addResourcesTo(Collections.singletonList(newGroup), resources);
    }
    return newGroup;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) BGArea(org.olat.group.area.BGArea) CollaborationTools(org.olat.collaboration.CollaborationTools) Identity(org.olat.core.id.Identity) CollaborationToolsFactory(org.olat.collaboration.CollaborationToolsFactory)

Example 5 with CollaborationToolsFactory

use of org.olat.collaboration.CollaborationToolsFactory in project openolat by klemens.

the class CourseCalendars method addCalendars.

private static void addCalendars(UserRequest ureq, UserCourseEnvironment courseEnv, List<BusinessGroup> groups, boolean isOwner, LinkProvider linkProvider, List<KalendarRenderWrapper> calendars) {
    if (groups == null || groups.isEmpty())
        return;
    CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
    CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
    Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(ureq.getIdentity(), CalendarManager.TYPE_GROUP);
    for (BusinessGroup bGroup : groups) {
        CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
        if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) {
            continue;
        }
        boolean member = courseEnv.isIdentityInCourseGroup(bGroup.getKey());
        KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
        groupCalendarWrapper.setPrivateEventsVisible(member || isOwner);
        // set calendar access
        int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
        Long lCalAccess = collabTools.lookupCalendarAccess();
        if (lCalAccess != null)
            iCalAccess = lCalAccess.intValue();
        if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
            groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
        } else {
            groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
        }
        CalendarUserConfiguration config = configMap.get(groupCalendarWrapper.getCalendarKey());
        if (config != null) {
            groupCalendarWrapper.setConfiguration(config);
        }
        groupCalendarWrapper.setLinkProvider(linkProvider);
        calendars.add(groupCalendarWrapper);
    }
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarKey(org.olat.commons.calendar.model.CalendarKey) BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) CollaborationToolsFactory(org.olat.collaboration.CollaborationToolsFactory)

Aggregations

CollaborationTools (org.olat.collaboration.CollaborationTools)6 CollaborationToolsFactory (org.olat.collaboration.CollaborationToolsFactory)6 BusinessGroup (org.olat.group.BusinessGroup)6 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)4 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)4 CalendarManager (org.olat.commons.calendar.CalendarManager)2 CalendarKey (org.olat.commons.calendar.model.CalendarKey)2 Identity (org.olat.core.id.Identity)2 BGArea (org.olat.group.area.BGArea)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2