Package org.olat.group.context

Examples of org.olat.group.context.BGContext


      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);
      BusinessGroup g4 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g4", null, null, null, null/* enableWaitinglist */, null/* enableAutoCloseRanks */, c2);
      // members
      secm.addIdentityToSecurityGroup(id1, g3.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id1, g4.getPartipiciantGroup());
      secm.addIdentityToSecurityGroup(id3, g4.getPartipiciantGroup());
      // rights
      rm.addBGRight(CourseRights.RIGHT_ARCHIVING, g3);
      rm.addBGRight(CourseRights.RIGHT_COURSEEDITOR, g3);
      rm.addBGRight(CourseRights.RIGHT_ARCHIVING, g4);
      rm.addBGRight(CourseRights.RIGHT_GROUPMANAGEMENT, g4);
     
      DBFactory.getInstance().closeSession(); // simulate user clicks
     
      // test groups
      CourseGroupManager gm = PersistingCourseGroupManager.getInstance(course1);
      assertTrue(gm.isIdentityInLearningGroup(id1, g1.getName()));
      assertTrue(gm.isIdentityInLearningGroup(id1, g2.getName()));
      assertFalse(gm.isIdentityInLearningGroup(id1, g3.getName())); // not a learning group
      assertFalse(gm.isIdentityInLearningGroup(id1, g4.getName())); // not a learning group

      assertTrue(gm.isIdentityInLearningGroup(id2, g1.getName()));
      assertTrue(gm.isIdentityInLearningGroup(id2, g2.getName()));
      assertFalse(gm.isIdentityInLearningGroup(id2, g3.getName())); // not a learning group
      assertFalse(gm.isIdentityInLearningGroup(id2, g4.getName())); // not a learning group

      DBFactory.getInstance().closeSession();
      assertTrue(gm.isIdentityInLearningGroup(id3, g1.getName()));
      assertFalse(gm.isIdentityInLearningGroup(id3, g2.getName()));
      assertFalse(gm.isIdentityInLearningGroup(id3, g3.getName())); // not a learning group
      assertFalse(gm.isIdentityInLearningGroup(id3, g4.getName())); // not a learning group

      assertTrue(gm.isIdentityInLearningGroup(id1, g1.getName(), c1.getName()));
      assertFalse(gm.isIdentityInLearningGroup(id1, g1.getName(), c2.getName()));
      assertTrue(gm.isIdentityInLearningGroup(id3, g1.getName(), c1.getName()));
      assertFalse(gm.isIdentityInLearningGroup(id3, g1.getName(), c2.getName()));
     
      // test areas
      DBFactory.getInstance().closeSession();
      assertTrue(gm.isIdentityInLearningArea(id1, a1.getName()));
      assertTrue(gm.isIdentityInLearningArea(id1, a2.getName()));
      assertTrue(gm.isIdentityInLearningArea(id1, a3.getName()));

      assertTrue(gm.isIdentityInLearningArea(id2, a1.getName()));
      assertTrue(gm.isIdentityInLearningArea(id2, a2.getName()));
      assertTrue(gm.isIdentityInLearningArea(id2, a3.getName()));

      DBFactory.getInstance().closeSession();
      assertTrue(gm.isIdentityInLearningArea(id3, a1.getName()));
      assertTrue(gm.isIdentityInLearningArea(id3, a2.getName()));
      assertFalse(gm.isIdentityInLearningArea(id3, a3.getName()));

      DBFactory.getInstance().closeSession();
      assertTrue(gm.getLearningAreasOfGroupFromAllContexts(g1.getName()).size() == 2);
      assertTrue(gm.getLearningAreasOfGroupFromAllContexts(g2.getName()).size() == 2);
     
      // test rights
      DBFactory.getInstance().closeSession();
      assertTrue(gm.hasRight(id1, CourseRights.RIGHT_ARCHIVING));
      assertTrue(gm.hasRight(id1, CourseRights.RIGHT_COURSEEDITOR));
      assertTrue(gm.hasRight(id1, CourseRights.RIGHT_GROUPMANAGEMENT));
      assertFalse(gm.hasRight(id1, CourseRights.RIGHT_ASSESSMENT));
      assertTrue(gm.hasRight(id1, CourseRights.RIGHT_COURSEEDITOR, c2.getName()));
      assertFalse(gm.hasRight(id1, CourseRights.RIGHT_COURSEEDITOR, c1.getName()));
      assertFalse(gm.hasRight(id2, CourseRights.RIGHT_COURSEEDITOR));
     
      // test context
      DBFactory.getInstance().closeSession();
      assertTrue(gm.isIdentityInGroupContext(id1,c1.getName()));
      assertTrue(gm.isIdentityInGroupContext(id1,c2.getName()));
      assertTrue(gm.isIdentityInGroupContext(id2,c1.getName()));
      assertFalse(gm.isIdentityInGroupContext(id2,c2.getName()));
      assertTrue(gm.isIdentityInGroupContext(id3,c1.getName()));
      assertTrue(gm.isIdentityInGroupContext(id3,c2.getName()));
  }
View Full Code Here


  /**
   * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int)
   */
  public Object getValueAt(int row, int col) {
    BGContext context = (BGContext) objects.get(row);
    switch (col) {
      case 0:
        String name = DefaultContextTranslationHelper.translateIfDefaultContextName(context, trans);
        name = StringEscapeUtils.escapeHtml(name).toString();
        return name;
      case 1:
        String description = context.getDescription();
        description = FilterFactory.getHtmlTagsFilter().filter(description);
        description = Formatter.truncate(description, 256);
        return description;
      case 2:
        if (showType) return trans.translate(context.getGroupType());
        else return new Boolean(context.isDefaultContext());
      case 3:
        return new Boolean(context.isDefaultContext());
      default:
        return "ERROR";
    }
  }
View Full Code Here

          doContextDeleteConfirm(ureq);
        }
      }
    } else if (source == this.newContextController) {
      if (event == Event.DONE_EVENT) {
        BGContext newContext = doContextCreate(ureq);
        if (newContext == null) {
          throw new AssertException("Could not create new BGContext - unknown reason");
        } else {
          this.currentGroupContext = newContext;
          doContextEdit(ureq);
View Full Code Here

  public void addBGRight(String bgRight, BusinessGroup rightGroup) {
    if (bgRight.indexOf(BG_RIGHT_PREFIX) == -1) throw new AssertException("Groups rights must start with prefix '" + BG_RIGHT_PREFIX
        + "', but given right is ::" + bgRight);
    if (BusinessGroup.TYPE_RIGHTGROUP.equals(rightGroup.getType())) {
      Manager secm = ManagerFactory.getManager();
      BGContext context = rightGroup.getGroupContext();
      secm.createAndPersistPolicy(rightGroup.getPartipiciantGroup(), bgRight, context);
    } else {
      throw new AssertException("Only right groups can have bg rights, but type was ::" + rightGroup.getType());
    }
  }
View Full Code Here

   *      org.olat.group.BusinessGroup)
   */
  public void removeBGRight(String bgRight, BusinessGroup rightGroup) {
    if (BusinessGroup.TYPE_RIGHTGROUP.equals(rightGroup.getType())) {
      Manager secm = ManagerFactory.getManager();
      BGContext context = rightGroup.getGroupContext();
      secm.deletePolicy(rightGroup.getPartipiciantGroup(), bgRight, context);
    } else {
      throw new AssertException("Only right groups can have bg rights, but type was ::" + rightGroup.getType());
    }
  }
View Full Code Here

  private BusinessGroup doCopyGroup(String newGroupName, Integer max) {
    BusinessGroupManager groupManager = BusinessGroupManagerImpl.getInstance();
    // reload original group to prevent context proxy problems
    this.originalGroup = groupManager.loadBusinessGroup(this.originalGroup);
    BGContext bgContext = this.originalGroup.getGroupContext();
    boolean copyAreas = (flags.isEnabled(BGConfigFlags.AREAS) && copyForm.isCopyAreas());

    BusinessGroup newGroup = groupManager.copyBusinessGroup(this.originalGroup, newGroupName, this.originalGroup.getDescription(), null, max, bgContext, null, copyAreas,
        copyForm.isCopyTools(), copyForm.isCopyRights(), copyForm.isCopyOwners(), copyForm.isCopyParticipants(), copyForm
            .isCopyMembersVisibility(), copyForm.isCopyWaitingList());
View Full Code Here

        log.warn("ProjectBroker: Account-manager does no longer exist, create a new one");
      }
    }
    if (groupKey == null) {
      log.debug("No group for project-broker exist => create a new one");
      BGContext context = createGroupContext(course);
     
      accountManagerGroup = BusinessGroupManagerImpl.getInstance().createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, identity, groupName, groupDescription, null, null, false, false, context);
      int i = 2;
      while (accountManagerGroup == null) {
        // group with this name exist already, try another name
View Full Code Here

  // PROJECT GROUP MANAGEMENT
  ////////////////////////////
  public BusinessGroup createProjectGroupFor(Long projectBrokerId, Identity identity, String groupName, String groupDescription, Long courseId) {
    List<Project> projects = ProjectBrokerManagerFactory.getProjectBrokerManager().getProjectListBy(projectBrokerId);

    BGContext context = createGroupContext(CourseFactory.loadCourse(courseId));
    // TODO: groupNbr no longer used => remove for 6.4
    int groupNbr = projects.size() + 1;
    log.debug("createProjectGroupFor groupName=" + groupName);
    BusinessGroup projectGroup = BusinessGroupManagerImpl.getInstance().createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, identity, groupName, groupDescription, null, null, false, false, context);
    // projectGroup could be null when a group with name already exists
View Full Code Here

  ///////////////////
  private BGContext createGroupContext(ICourse course) {
    List<BGContext> groupContexts = course.getCourseEnvironment().getCourseGroupManager().getLearningGroupContexts();
    log.debug("createGroupContext groupContexts.size=" + groupContexts.size());
    for (Iterator<BGContext> iterator = groupContexts.iterator(); iterator.hasNext();) {
      BGContext iterContext = iterator.next();
      log.debug("createGroupContext loop iterContext=" + iterContext);
      if (iterContext.isDefaultContext()) {
        log.debug("createGroupContext default groupContexts=" + iterContext);
        return iterContext;
      }
    }
    // found no default context
    String defaultContextName = CourseGroupManager.DEFAULT_NAME_LC_PREFIX + course.getCourseTitle();
    if (groupContexts.size() == 0) {
      log.debug("no group context exists, create a new default defaultContextName=" + defaultContextName);
    } else {
      log.debug("Found no default group context, create a new default defaultContextName=" + defaultContextName);
    }
    // no context exists => create a new default context
    OLATResource courseResource = OLATResourceManager.getInstance().findOrPersistResourceable(course);
    BGContext context = BGContextManagerImpl.getInstance().createAndAddBGContextToResource(defaultContextName, courseResource, BusinessGroup.TYPE_LEARNINGROUP, null, true);
    return context;
  }
View Full Code Here

      cmc.addControllerListener(this);
      cmc.activate();

    } else if (source == createGroupsLink) {
      // no groups in group management -> directly show group create dialog
      BGContext bgContext = getDefaultBGContext();
      String[] csvGroupName = easyGroupTE.isEmpty() ? new String[0] : easyGroupTE.getValue().split(",");
      // determine if bulkmode or not
      if (groupCreateCntrllr != null) groupCreateCntrllr.dispose();
      boolean bulkMode = csvGroupName.length > 1;
      groupCreateCntrllr = BGControllerFactory.getInstance().createNewBGController(ureq, getWindowControl(), true,
          bgContext, bulkMode, easyGroupTE.getValue());
      groupCreateCntrllr.addControllerListener(this);

      //the main form gets overlayed -> hence do not mark as dirty
      //otherwise clicking any link in the overlay results in a
      //alert box -> "you have unsaved form data"
      //one has to listen for cmc closing events and then reactivate
      //dirty setting!! TODO:pb: find a better solution as this is error prone
      this.flc.getRootForm().setDirtyMarking(false);
      if (cmc != null) cmc.dispose();
      cmc = new CloseableModalController(getWindowControl(), "close", groupCreateCntrllr.getInitialComponent());
      cmc.addControllerListener(this);
      cmc.activate();

    } else if (source == chooseAreasLink) {
      if (areaChooseC != null) areaChooseC.dispose();

      // already areas -> choose areas
      if (areaChooseC != null) areaChooseC.dispose();
      areaChooseC = new GroupOrAreaSelectionController(1, getWindowControl(), ureq, "area", cev.getCourseGroupManager(),
          easyAreaTE.getValue());
      areaChooseC.addControllerListener(this);
     
      //the main form gets overlayed -> hence do not mark as dirty
      //otherwise clicking any link in the overlay results in a
      //alert box -> "you have unsaved form data"
      //one has to listen for cmc closing events and then reactivate
      //dirty setting!! TODO:pb: find a better solution as this is error prone
      this.flc.getRootForm().setDirtyMarking(false);
      if (cmc != null) cmc.dispose();
      cmc = new CloseableModalController(getWindowControl(), "close", areaChooseC.getInitialComponent(), true, getTranslator().translate("popupchooseareas"));
      cmc.addControllerListener(this);
      cmc.activate();

    } else if (source == createAreasLink) {
      // no areas -> directly show creation dialog
      BGContext bgContext = getDefaultBGContext();
      if (areaCreateCntrllr != null) areaCreateCntrllr.dispose();
      String[] csvAreaName = easyAreaTE.isEmpty() ? new String[0] : easyAreaTE.getValue().split(",");
      // determine if bulkmode or not
      boolean bulkMode = csvAreaName.length > 1;
      areaCreateCntrllr = BGControllerFactory.getInstance().createNewAreaController(ureq, getWindowControl(),
          bgContext, bulkMode, easyAreaTE.getValue());
      areaCreateCntrllr.addControllerListener(this);

      //the main form gets overlayed -> hence do not mark as dirty
      //otherwise clicking any link in the overlay results in a
      //alert box -> "you have unsaved form data"
      //one has to listen for cmc closing events and then reactivate
      //dirty setting!! TODO:pb: find a better solution as this is error prone
      this.flc.getRootForm().setDirtyMarking(false);
      if (cmc != null) cmc.dispose();
      cmc = new CloseableModalController(getWindowControl(), "close", areaCreateCntrllr.getInitialComponent());
      cmc.addControllerListener(this);
      cmc.activate();

    } else if (source == fixGroupError) {
      /*
       * user wants to fix problem with fixing group error link e.g. create one
       * or more group at once.
       */
      BGContext bgContext = getDefaultBGContext();
      if (groupCreateCntrllr != null) groupCreateCntrllr.dispose();
      String[] csvGroupName = (String[]) fixGroupError.getUserObject();
      // determine if bulkmode or not
      boolean bulkMode = csvGroupName.length > 1;
      groupCreateCntrllr = BGControllerFactory.getInstance().createNewBGController(ureq, getWindowControl(), true,
          bgContext, bulkMode, csvGroupName[0]);
      groupCreateCntrllr.addControllerListener(this);
     
      //the main form gets overlayed -> hence do not mark as dirty
      //otherwise clicking any link in the overlay results in a
      //alert box -> "you have unsaved form data"
      //one has to listen for cmc closing events and then reactivate
      //dirty setting!! TODO:pb: find a better solution as this is error prone
      this.flc.getRootForm().setDirtyMarking(false);
      if (cmc != null) cmc.dispose();
      cmc = new CloseableModalController(getWindowControl(), "close", groupCreateCntrllr.getInitialComponent());
      cmc.addControllerListener(this);
      cmc.activate();
    } else if (source == fixAreaError) {
      /*
       * user wants to fix problem with fixing area error link e.g. create one
       * or more areas at once.
       */
      BGContext bgContext = getDefaultBGContext();
      if (areaCreateCntrllr != null) areaCreateCntrllr.dispose();
      String[] csvAreaName = (String[]) fixAreaError.getUserObject();
      // determine if bulkmode or not
      boolean bulkMode = csvAreaName.length > 1;
      areaCreateCntrllr = BGControllerFactory.getInstance().createNewAreaController(ureq, getWindowControl(),
View Full Code Here

TOP

Related Classes of org.olat.group.context.BGContext

Copyright © 2018 www.massapicom. 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.