Examples of BGAreaManager


Examples of org.olat.group.area.BGAreaManager

    if (context == null) return; // nothing to do... says Florian.
    Dom4jConfiguration root = new Dom4jConfiguration(EXPORT_KEY_ROOT);

    // export areas
    MutableConfiguration confAreas = root.addChild(EXPORT_KEY_AREA_COLLECTION);
    BGAreaManager am = BGAreaManagerImpl.getInstance();
    List areas = am.findBGAreasOfBGContext(context);
    for (Iterator iter = areas.iterator(); iter.hasNext();) {
      BGArea area = (BGArea) iter.next();
      MutableConfiguration newArea = confAreas.addChild(EXPORT_KEY_AREA);
      newArea.addAttribute(EXPORT_ATTR_NAME, area.getName());
      newArea.addChild(EXPORT_KEY_DESCRIPTION, area.getDescription());
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

      throw new OLATRuntimeException("Error importing group config.", ce);
    }
    if (!groupConfig.getName().equals(EXPORT_KEY_ROOT)) throw new AssertException("Invalid group export file. Root does not match.");

    // get areas
    BGAreaManager am = BGAreaManagerImpl.getInstance();
    Configuration confAreas = groupConfig.getChild(EXPORT_KEY_AREA_COLLECTION);
    if (confAreas != null) {
      List areas = confAreas.getChildren(EXPORT_KEY_AREA);
      for (Iterator iter = areas.iterator(); iter.hasNext();) {
        Configuration area = (Configuration) iter.next();
        String areaName = area.getAttribute(EXPORT_ATTR_NAME);
        String areaDesc = area.getChildValue(EXPORT_KEY_DESCRIPTION);
        am.createAndPersistBGAreaIfNotExists(areaName, areaDesc, context);
      }
    }

    // TODO fg: import group rights

    // get groups
    Configuration confGroups = groupConfig.getChild(EXPORT_KEY_GROUP_COLLECTION);
    if (confGroups != null) {
      BusinessGroupManager gm = BusinessGroupManagerImpl.getInstance();
      List groups = confGroups.getChildren(EXPORT_KEY_GROUP);
      for (Iterator iter = groups.iterator(); iter.hasNext();) {
        // create group
        Configuration group = (Configuration) iter.next();
        String groupName = group.getAttribute(EXPORT_ATTR_NAME);
        String groupDesc = group.getChildValue(EXPORT_KEY_DESCRIPTION);

        // get min/max participants
        Integer groupMinParticipants = null;
        String sMinParticipants = group.getAttribute(EXPORT_ATTR_MIN_PARTICIPATS);
        if (sMinParticipants != null) groupMinParticipants = new Integer(sMinParticipants);
        Integer groupMaxParticipants = null;
        String sMaxParticipants = group.getAttribute(EXPORT_ATTR_MAX_PARTICIPATS);
        if (sMaxParticipants != null) groupMaxParticipants = new Integer(sMaxParticipants);

        // waiting list configuration
        String waitingListConfig = group.getAttribute(EXPORT_ATTR_WAITING_LIST);
        Boolean waitingList = null;
        if (waitingListConfig == null) {
          waitingList = Boolean.FALSE;
        } else {
          waitingList = Boolean.valueOf(waitingListConfig);
        }
        String enableAutoCloseRanksConfig = group.getAttribute(EXPORT_ATTR_AUTO_CLOSE_RANKS);
        Boolean enableAutoCloseRanks = null;
        if (enableAutoCloseRanksConfig == null) {
          enableAutoCloseRanks = Boolean.FALSE;
        } else {
          enableAutoCloseRanks = Boolean.valueOf(enableAutoCloseRanksConfig);
        }
       
        BusinessGroup newGroup = gm.createAndPersistBusinessGroup(context.getGroupType(), null, groupName, groupDesc, groupMinParticipants,
            groupMaxParticipants, waitingList, enableAutoCloseRanks, context);

        // get tools config
        Configuration toolsConfig = group.getChild(EXPORT_KEY_COLLABTOOLS);
        CollaborationTools ct = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(newGroup);
        for (int i = 0; i < CollaborationTools.TOOLS.length; i++) {
          String sTool = toolsConfig.getAttribute(CollaborationTools.TOOLS[i]);
          if (sTool != null) ct.setToolEnabled(CollaborationTools.TOOLS[i], sTool.equals("true") ? true : false);
        }
        if(group.getAttribute(EXPORT_KEY_CALENDAR_ACCESS)!=null) {
          Long calendarAccess = Long.valueOf(group.getAttribute(EXPORT_KEY_CALENDAR_ACCESS));
          ct.saveCalendarAccess(calendarAccess);         
        }
        if(group.getAttribute(EXPORT_KEY_NEWS)!=null) {
          String info = group.getAttribute(EXPORT_KEY_NEWS);
          ct.saveNews(info);        
        }

        // get memberships
        List memberships = group.getChildren(EXPORT_KEY_AREA_RELATION);
        for (Iterator iterator = memberships.iterator(); iterator.hasNext();) {
          Configuration areaRelation = (Configuration) iterator.next();
          BGArea area = am.findBGArea(areaRelation.getValue(), context);
          if (area == null) throw new AssertException("Group-Area-Relationship in export, but area was not created during import.");
          am.addBGToBGArea(newGroup, area);
        }
       
        //get properties
        boolean showOwners = true;
        boolean showParticipants = true;
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

  /**
   * @see org.olat.group.context.BGContextManager#copyAndAddBGContextToResource(java.lang.String,
   *      org.olat.resource.OLATResource, org.olat.group.context.BGContext)
   */
  public BGContext copyAndAddBGContextToResource(String contextName, OLATResource resource, BGContext originalBgContext) {
    BGAreaManager areaManager = BGAreaManagerImpl.getInstance();
    BusinessGroupManager groupManager = BusinessGroupManagerImpl.getInstance();
    if (!originalBgContext.isDefaultContext()) { throw new AssertException("Can only copy default contexts"); }

    // 1. Copy context as default context. Owner group of original context will
    // not be
    // copied since this is a default context
    BGContext targetContext = createAndAddBGContextToResource(contextName, resource, originalBgContext.getGroupType(), null, true);
    // 2. Copy areas
    Map areas = areaManager.copyBGAreasOfBGContext(originalBgContext, targetContext);
    // 3. Copy Groups
    // only group configuration will be copied, no group members are copied
    List origGroups = getGroupsOfBGContext(originalBgContext);
    Iterator iter = origGroups.iterator();
    while (iter.hasNext()) {
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

   * @see org.olat.group.context.BGContextManager#deleteBGContext(org.olat.group.context.BGContext)
   */
  public void deleteBGContext(BGContext bgContext) {
    bgContext = (BGContext) DBFactory.getInstance().loadObject(bgContext);
    BusinessGroupManager bgManager = BusinessGroupManagerImpl.getInstance();
    BGAreaManager areaManager = BGAreaManagerImpl.getInstance();
    // 1) Delete all groups from group context
    List groups = getGroupsOfBGContext(bgContext);
    bgManager.deleteBusinessGroups(groups);
    // 2) Delete all group areas
    List areas = areaManager.findBGAreasOfBGContext(bgContext);
    for (Iterator iter = areas.iterator(); iter.hasNext();) {
      BGArea area = (BGArea) iter.next();
      areaManager.deleteBGArea(area);
    }
    // 3) Delete group to resource relations
    List referencingResources = findOLATResourcesForBGContext(bgContext);
    for (Iterator iter = referencingResources.iterator(); iter.hasNext();) {
      OLATResource refRes = (OLATResource) iter.next();
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

  public void testHasRightIsInMethods() {
      BGContextManager cm = BGContextManagerImpl.getInstance();
      BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
      Manager secm = ManagerFactory.getManager();
      BGRightManager rm = BGRightManagerImpl.getInstance();
      BGAreaManager am = BGAreaManagerImpl.getInstance();
     
      // 1) context one: learning groups
      BGContext c1 = cm.createAndAddBGContextToResource("c1name", course1, BusinessGroup.TYPE_LEARNINGROUP, id1, true);
      // create groups without waitinglist
      BusinessGroup g1 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g1", null, new Integer(0), new Integer(10), false, false, c1);
      BusinessGroup g2 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g2", null, new Integer(0), new Integer(10), false, false, c1);
      // members
      secm.addIdentityToSecurityGroup(id1, g2.getOwnerGroup());
      secm.addIdentityToSecurityGroup(id1, g1.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id2, g1.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id2, g2.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id3, g1.getOwnerGroup());
      // areas
      BGArea a1 = am.createAndPersistBGAreaIfNotExists("a1", "desca1",c1);
      BGArea a2 = am.createAndPersistBGAreaIfNotExists("a2", null, c1);
      BGArea a3 = am.createAndPersistBGAreaIfNotExists("a3", null, c1);
      am.addBGToBGArea(g1, a1);   
      am.addBGToBGArea(g2, a1);
      am.addBGToBGArea(g1, a2)
      am.addBGToBGArea(g2, a3);
     
      // 2) context two: right groups
      BGContext c2 = cm.createAndAddBGContextToResource("c2name", course1, BusinessGroup.TYPE_RIGHTGROUP, id2, true);
      // groups
      BusinessGroup g3 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g3", null, null, null, null/* enableWaitinglist */, null/* enableAutoCloseRanks */, c2);
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

      BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(newGroup);
      bgpm.copyConfigurationFromGroup(sourceBusinessGroup);
    }
    // 4. copy areas
    if (copyAreas) {
      BGAreaManager areaManager = BGAreaManagerImpl.getInstance();
      List areas = areaManager.findBGAreasOfBusinessGroup(sourceBusinessGroup);
      Iterator iterator = areas.iterator();
      while (iterator.hasNext()) {
        BGArea area = (BGArea) iterator.next();
        if (areaLookupMap == null) {
          // reference target group to source groups areas
          areaManager.addBGToBGArea(newGroup, area);
        } else {
          // reference target group to mapped group areas
          BGArea mappedArea = (BGArea) areaLookupMap.get(area);
          areaManager.addBGToBGArea(newGroup, mappedArea);
        }
      }
    }
    // 5. copy owners
    if (copyOwners) {
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

  /**
   * @see org.olat.course.groupsandrights.CourseGroupManager#isIdentityInLearningArea(org.olat.core.id.Identity,
   *      java.lang.String, java.lang.String)
   */
  public boolean isIdentityInLearningArea(Identity identity, String areaName, String groupContextName) {
    BGAreaManager areaManager = BGAreaManagerImpl.getInstance();
    Iterator iter = learningGroupContexts.iterator();
    while (iter.hasNext()) {
      BGContext context = (BGContext) iter.next();
      if (groupContextName == null || context.getName().equals(groupContextName)) {
        boolean inArea = areaManager.isIdentityInBGArea(identity, areaName, context);
        if (inArea) return true; // finished
      }
    }
    return false;
  }
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

  /**
   * @see org.olat.course.groupsandrights.CourseGroupManager#getAllAreasFromAllContexts()
   */
  public List getAllAreasFromAllContexts() {
    List allAreas = new ArrayList();
    BGAreaManager areaManager = BGAreaManagerImpl.getInstance();
    Iterator iterator = learningGroupContexts.iterator();
    while (iterator.hasNext()) {
      BGContext bgContext = (BGContext) iterator.next();
      List contextAreas = areaManager.findBGAreasOfBGContext(bgContext);
      allAreas.addAll(contextAreas);
    }
    return allAreas;

  }
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

  /**
   * @see org.olat.course.groupsandrights.CourseGroupManager#getLearningGroupsInAreaFromAllContexts(java.lang.String)
   */
  public List getLearningGroupsInAreaFromAllContexts(String areaName) {
    List groups = new ArrayList();
    BGAreaManager areaManager = BGAreaManagerImpl.getInstance();
    Iterator iterator = learningGroupContexts.iterator();
    while (iterator.hasNext()) {
      BGContext bgContext = (BGContext) iterator.next();
      BGArea area = areaManager.findBGArea(areaName, bgContext);
      if (area != null) {
        List areaGroups = areaManager.findBusinessGroupsOfArea(area);
        groups.addAll(areaGroups);
      }
    }
    return groups;
  }
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

  /**
   * @see org.olat.course.groupsandrights.CourseGroupManager#getLearningAreasOfGroupFromAllContexts(java.lang.String)
   */
  public List getLearningAreasOfGroupFromAllContexts(String groupName) {
    List areas = new ArrayList();
    BGAreaManager areaManager = BGAreaManagerImpl.getInstance();
    BGContextManager contextManager = BGContextManagerImpl.getInstance();
    Iterator iterator = learningGroupContexts.iterator();
    while (iterator.hasNext()) {
      BGContext bgContext = (BGContext) iterator.next();
      BusinessGroup group = contextManager.findGroupOfBGContext(groupName, bgContext);
      if (group != null) {
        List groupAreas = areaManager.findBGAreasOfBusinessGroup(group);
        areas.addAll(groupAreas);
      }
    }
    return areas;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.