Examples of BGContextManager


Examples of org.olat.group.context.BGContextManager

    }
  }

  /** BGContextManagerImpl:createAndPersistBGContext * */
  public void testCreateAndPersistBGContext() {
    BGContextManager bgcm = BGContextManagerImpl.getInstance();
    BGContext c1 = bgcm.createAndPersistBGContext("c1name", "c1desc", BusinessGroup.TYPE_LEARNINGROUP, null, true);
    assertNotNull(c1);
    BGContext c2 = bgcm.createAndPersistBGContext("c2name", "c2desc", BusinessGroup.TYPE_LEARNINGROUP, id1, false);
    assertNotNull(c2);
    try {
      bgcm.createAndPersistBGContext("name", "desc", null, id2, false);
      fail("context groupType can not be null");
    } catch (AssertException e) {
      // expected exception
      assertTrue(true);
    }
    try {
      bgcm.createAndPersistBGContext(null, "desc", BusinessGroup.TYPE_LEARNINGROUP, id2, false);
      fail("context name can not be null");
    } catch (AssertException e) {
      // expected exception
      assertTrue(true);
    }
View Full Code Here

Examples of org.olat.group.context.BGContextManager

    }
  }

  /** BGContextManagerImpl:deleteBGContext() * */
  public void testDeleteBGContext() {
    BGContextManager bgcm = BGContextManagerImpl.getInstance();
    BGContext c1 = bgcm.createAndPersistBGContext("c1name", "c1desc", BusinessGroup.TYPE_LEARNINGROUP, null, true);
    BGContext c2 = bgcm.createAndPersistBGContext("c2name", "c2desc", BusinessGroup.TYPE_RIGHTGROUP, id1, false);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
   
    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);
    BusinessGroup g3 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g3", null, new Integer(0),
        new Integer(10), false, false, c2);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    Manager secm = ManagerFactory.getManager();
    secm.addIdentityToSecurityGroup(id1, g1.getPartipiciantGroup());
    secm.addIdentityToSecurityGroup(id1, g1.getOwnerGroup());
    secm.addIdentityToSecurityGroup(id2, g1.getPartipiciantGroup());
    secm.addIdentityToSecurityGroup(id3, g1.getOwnerGroup());
    secm.addIdentityToSecurityGroup(id4, g2.getPartipiciantGroup());
    secm.addIdentityToSecurityGroup(id4, g1.getOwnerGroup());
    secm.addIdentityToSecurityGroup(id1, g3.getPartipiciantGroup());
    secm.addIdentityToSecurityGroup(id2, g3.getPartipiciantGroup());

    BGRightManagerImpl rm = BGRightManagerImpl.getInstance();
    rm.addBGRight(CourseRights.RIGHT_ARCHIVING, g3);
    rm.addBGRight(CourseRights.RIGHT_COURSEEDITOR, g3);
    DBFactory.getInstance().closeSession(); // simulate user clicks
   
    assertTrue(rm.hasBGRight(CourseRights.RIGHT_ARCHIVING, id1, c2));
    assertFalse(rm.hasBGRight(CourseRights.RIGHT_GROUPMANAGEMENT, id1, c2));
    assertTrue(rm.hasBGRight(CourseRights.RIGHT_ARCHIVING, id2, c2));
    assertFalse(rm.hasBGRight(CourseRights.RIGHT_ARCHIVING, id3, c2));

    DBFactory.getInstance().closeSession(); // simulate user clicks
    BGAreaManager am = BGAreaManagerImpl.getInstance();
    BGArea a1 = am.createAndPersistBGAreaIfNotExists("a1-delete", "desca1", c1);
    BGArea a2 = am.createAndPersistBGAreaIfNotExists("a2-delete", null, c1);
    BGArea a3 = am.createAndPersistBGAreaIfNotExists("a3-delete", "desca3", c1);
    BGArea a4 = am.createAndPersistBGAreaIfNotExists("a4-delete", "desca4", c1);
    am.addBGToBGArea(g1, a1);
    am.addBGToBGArea(g2, a1);
    am.addBGToBGArea(g1, a2);
    am.addBGToBGArea(g2, a3);
    am.addBGToBGArea(g1, a4);
    DBFactory.getInstance().closeSession(); // simulate user clicks

    // test isIdentityInBGArea
    assertTrue(am.isIdentityInBGArea(id1, "a1-delete", c1));
    assertTrue(am.isIdentityInBGArea(id1, "a2-delete", c1));
    assertFalse(am.isIdentityInBGArea(id1, "a3-delete", c1)); // not in group g2
    assertTrue(am.isIdentityInBGArea(id1, "a4-delete", c1));
    assertFalse(am.isIdentityInBGArea(id1, "xx", c1)); // wrong area name
    assertFalse(am.isIdentityInBGArea(id1, "a1-delete", c2)); // wrong context
    assertTrue(am.isIdentityInBGArea(id2, "a1-delete", c1));
    assertTrue(am.isIdentityInBGArea(id2, "a2-delete", c1));
    assertFalse(am.isIdentityInBGArea(id2, "a3-delete", c1)); // not in group g2
    assertTrue(am.isIdentityInBGArea(id2, "a4-delete", c1));
    assertTrue(am.isIdentityInBGArea(id3, "a1-delete", c1));
    assertTrue(am.isIdentityInBGArea(id3, "a2-delete", c1));
    assertFalse(am.isIdentityInBGArea(id3, "a3-delete", c1)); // not in group g2
    assertTrue(am.isIdentityInBGArea(id3, "a4-delete", c1));
    assertTrue(am.isIdentityInBGArea(id4, "a1-delete", c1));
    assertTrue(am.isIdentityInBGArea(id4, "a2-delete", c1));
    assertTrue(am.isIdentityInBGArea(id4, "a3-delete", c1));
    assertTrue(am.isIdentityInBGArea(id4, "a4-delete", c1));

    DBFactory.getInstance().closeSession(); // simulate user clicks
    assertTrue(am.findBGAreasOfBusinessGroup(g1).size() == 3);
    assertTrue(am.findBGAreasOfBusinessGroup(g2).size() == 2);
    assertTrue(am.findBGAreasOfBusinessGroup(g3).size() == 0);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    assertTrue(am.findBGAreasOfBGContext(c1).size() == 4);
    assertTrue(am.findBGAreasOfBGContext(c2).size() == 0);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    assertTrue(am.findBusinessGroupsOfArea(a1).size() == 2);
    assertTrue(am.findBusinessGroupsOfArea(a2).size() == 1);
    assertTrue(am.findBusinessGroupsOfArea(a3).size() == 1);
    assertTrue(am.findBusinessGroupsOfArea(a4).size() == 1);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    assertTrue(am.countBGAreasOfBGContext(c1) == 4);
    assertTrue(am.countBGAreasOfBGContext(c2) == 0);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    assertTrue(am.findBusinessGroupsOfAreaAttendedBy(id1, "a1-delete", c1).size() == 1);
    assertTrue(am.findBusinessGroupsOfAreaAttendedBy(id1, "a2-delete", c1).size() == 1);
    assertTrue(am.findBusinessGroupsOfAreaAttendedBy(id1, "a3-delete", c1).size() == 0);
    assertTrue(am.findBusinessGroupsOfAreaAttendedBy(id1, "a4-delete", c1).size() == 1);
    assertTrue(am.findBusinessGroupsOfAreaAttendedBy(id4, "a1-delete", c1).size() == 1);
    assertTrue(am.findBusinessGroupsOfAreaAttendedBy(id4, "a2-delete", c1).size() == 0);
    assertTrue(am.findBusinessGroupsOfAreaAttendedBy(id4, "a3-delete", c1).size() == 1);
    assertTrue(am.findBusinessGroupsOfAreaAttendedBy(id4, "a4-delete", c1).size() == 0);

    bgcm.deleteBGContext(c1);
    // assertNull(DB.getInstance().findObject(BGContextImpl.class,
    // c1.getKey()));

    bgcm.deleteBGContext(c2);
    // assertNull(DB.getInstance().findObject(BGContextImpl.class,
    // c2.getKey()));

    assertTrue(am.findBGAreasOfBGContext(c1).size() == 0);
    assertNull(am.findBGArea("a1-delete", c1));
View Full Code Here

Examples of org.olat.group.context.BGContextManager

    assertFalse(rm.hasBGRight(CourseRights.RIGHT_ARCHIVING, id3, c2));
  }

  /** BGContextManagerImpl:copyBGContext() * */
  public void testCopyBGContext() {
    BGContextManager bgcm = BGContextManagerImpl.getInstance();
    BGContext c1 = bgcm.createAndPersistBGContext("c1name", "c1desc", BusinessGroup.TYPE_LEARNINGROUP, null, true);
    BGContext c2 = bgcm.createAndPersistBGContext("c2name", "c2desc", BusinessGroup.TYPE_RIGHTGROUP, id1, false);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
    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);
    BusinessGroup g3 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g3", null, new Integer(0),
        new Integer(10), false, false, c2);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    Manager secm = ManagerFactory.getManager();
    secm.addIdentityToSecurityGroup(id1, g1.getPartipiciantGroup());
    secm.addIdentityToSecurityGroup(id1, g1.getOwnerGroup());
    secm.addIdentityToSecurityGroup(id2, g1.getPartipiciantGroup());
    secm.addIdentityToSecurityGroup(id3, g1.getOwnerGroup());
    secm.addIdentityToSecurityGroup(id1, g3.getPartipiciantGroup());
    secm.addIdentityToSecurityGroup(id2, g3.getPartipiciantGroup());

    DBFactory.getInstance().closeSession(); // simulate user clicks
    BGRightManagerImpl rm = BGRightManagerImpl.getInstance();
    rm.addBGRight(CourseRights.RIGHT_ARCHIVING, g3);
    rm.addBGRight(CourseRights.RIGHT_COURSEEDITOR, g3);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    BGAreaManager am = BGAreaManagerImpl.getInstance();
    BGArea a1 = am.createAndPersistBGAreaIfNotExists("a1-copy", "desca1", c1);
    BGArea a2 = am.createAndPersistBGAreaIfNotExists("a2-copy", null, c1);
    am.addBGToBGArea(g1, a1);
    am.addBGToBGArea(g2, a1);
    am.addBGToBGArea(g1, a2);
    DBFactory.getInstance().closeSession(); // simulate user clicks

    BGContext c1copy = bgcm.copyAndAddBGContextToResource(c1.getName(), course1, c1);
    DBFactory.getInstance().closeSession(); // simulate user clicks
    try {
      bgcm.copyAndAddBGContextToResource(c2.getName(), course1, c2);
      fail("expecting exeption");
    } catch (AssertException e) {
      // ok, passed
    }
    DBFactory.getInstance().closeSession(); // simulate user clicks

    assertTrue(am.findBGAreasOfBGContext(c1copy).size() == 2);
    assertNotNull(am.findBGArea("a1-copy", c1));
    assertNotNull(am.findBGArea("a2-copy", c1));
    assertNotNull(bgcm.findGroupOfBGContext(g1.getName(), c1copy));
    assertNotNull(bgcm.findGroupOfBGContext(g2.getName(), c1copy));
    assertTrue(bgcm.getGroupsOfBGContext(c1copy).size() == 2);
  }
View Full Code Here

Examples of org.olat.group.context.BGContextManager

    assertTrue(bgcm.getGroupsOfBGContext(c1copy).size() == 2);
  }

  /** BGContextManagerImpl:deleteBGContext() * */
  public void testBGRights() {
    BGContextManager bgcm = BGContextManagerImpl.getInstance();
    BGContext c1 = bgcm.createAndPersistBGContext("c1name", "c1desc", BusinessGroup.TYPE_RIGHTGROUP, null, true);
    BGContext c2 = bgcm.createAndPersistBGContext("c2name", "c2desc", BusinessGroup.TYPE_RIGHTGROUP, id1, false);

    BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
    BusinessGroup g1 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g1", null, null, null, false, false, c1);
    BusinessGroup g2 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g2", null, null, null, false, false, c1);
    BusinessGroup g3 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g3", null, null, null, false, false, c2);
View Full Code Here

Examples of org.olat.group.context.BGContextManager

    assertTrue(rm.findBGRights(g2).size() == 0);
  }

  /** BGContextManagerImpl:getGroupsOfBGContext and countGroupsOfBGContext* */
  public void testGroupsOfBGContext() {
    BGContextManager bgcm = BGContextManagerImpl.getInstance();
    BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
    BGContext c1 = bgcm.createAndPersistBGContext("c1name", "c1desc", BusinessGroup.TYPE_LEARNINGROUP, null, true);
    BGContext c2 = bgcm.createAndPersistBGContext("c2name", "c2desc", BusinessGroup.TYPE_LEARNINGROUP, id1, false);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    assertTrue(bgcm.getGroupsOfBGContext(c1).size() == 0);
    assertTrue(bgcm.countGroupsOfBGContext(c1) == 0);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    BusinessGroup g1 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g1", null, new Integer(0),
        new Integer(10), false, false, c1);
    assertNotNull(g1);
    BusinessGroup g2 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g2", null, new Integer(0),
        new Integer(10), false, false, c1);
    assertNotNull(g2);
    BusinessGroup g3 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g3", null, new Integer(0),
        new Integer(10), false, false, c2);
    assertNotNull(g3);

    BusinessGroup g2douplicate = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g2", null, new Integer(0),
        new Integer(10), false, false, c1);
    assertNull(g2douplicate); // name douplicate names allowed per group context

    BusinessGroup g4 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g2", null, new Integer(0),
        new Integer(10), false, false, c2);
    assertNotNull(g4); // name douplicate in other context allowed

    DBFactory.getInstance().closeSession(); // simulate user clicks
    assertTrue(bgcm.getGroupsOfBGContext(c1).size() == 2);
    assertTrue(bgcm.countGroupsOfBGContext(c1) == 2);
  }
View Full Code Here

Examples of org.olat.group.context.BGContextManager

    assertTrue(bgcm.countGroupsOfBGContext(c1) == 2);
  }

  /** BGContext2ResourceManager tests */
  public void testFindContextMethods() {
    BGContextManager cm = BGContextManagerImpl.getInstance();
    BGContext c1 = cm.createAndAddBGContextToResource("c1name", course1, BusinessGroup.TYPE_LEARNINGROUP, null, true);
    cm.createAndAddBGContextToResource("c2name", course1, BusinessGroup.TYPE_LEARNINGROUP, id1, false);
    cm.createAndAddBGContextToResource("c3name", course1, BusinessGroup.TYPE_RIGHTGROUP, id2, false);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    assertTrue(cm.findBGContextsForResource(course1, true, true).size() == 3);
    assertTrue(cm.findBGContextsForResource(course1, true, false).size() == 1);
    assertTrue(cm.findBGContextsForResource(course1, false, true).size() == 2);
    assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_LEARNINGROUP, true, true).size() == 2);
    assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_RIGHTGROUP, true, true).size() == 1);

    assertTrue(cm.findBGContextsForIdentity(id1, true, true).size() == 1);
    assertTrue(cm.findBGContextsForIdentity(id1, true, false).size() == 0);
    assertTrue(cm.findBGContextsForIdentity(id1, false, true).size() == 1);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    cm.removeBGContextFromResource(c1, course1);
    assertTrue(cm.findBGContextsForResource(course1, true, true).size() == 2);
    assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_LEARNINGROUP, true, true).size() == 1);
    assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_RIGHTGROUP, true, true).size() == 1);

    DBFactory.getInstance().closeSession(); // simulate user clicks
    // cm.removeAllBGContextsFromResource(course1);
    CourseGroupManager cgm = PersistingCourseGroupManager.getInstance(course1);
    cgm.deleteCourseGroupmanagement();
    assertTrue(cm.findBGContextsForResource(course1, true, true).size() == 0);
    assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_LEARNINGROUP, true, true).size() == 0);
    assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_RIGHTGROUP, true, true).size() == 0);
  }
View Full Code Here

Examples of org.olat.group.context.BGContextManager

    assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_LEARNINGROUP, true, true).size() == 0);
    assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_RIGHTGROUP, true, true).size() == 0);
  }
 
  public void testRemoveBGFromArea() {
    BGContextManager cm = BGContextManagerImpl.getInstance();
    BGContext bgContext = cm.createAndAddBGContextToResource("c2name", course1, BusinessGroup.TYPE_LEARNINGROUP, null, true);
    assertEquals( 1,cm.findBGContextsForResource(course1, true, true).size() );
    cm.removeBGContextFromResource(bgContext, course1);
    assertEquals( 0,cm.findBGContextsForResource(course1, true, true).size() );
  }
View Full Code Here

Examples of org.olat.group.context.BGContextManager

  public void testCheckIfNamesExistsInContext() throws Exception {
    suiteIsAborted = true;

    BusinessGroupManagerImpl bgManager = (BusinessGroupManagerImpl)BusinessGroupManagerImpl.getInstance();
    BGContextManager bgContextManager = BGContextManagerImpl.getInstance();
    BGContext ctxA = bgContextManager.createAndPersistBGContext("DefaultA", "Empty", BusinessGroup.TYPE_LEARNINGROUP, id1, true);
    BGContext ctxB = bgContextManager.createAndPersistBGContext("DefaultB", "Empty", BusinessGroup.TYPE_LEARNINGROUP, id1, true);

    String[] namesInCtxA = new String[] { "A-GroupOne", "A-GroupTwo", "A-GroupThree", "A-GroupFour", "A-GroupFive", "A-GroupSix" };
    String[] namesInCtxB = new String[] { "B-GroupAAA", "B-GroupBBB", "B-GroupCCC", "B-GroupDDD", "B-GroupEEE", "B-GroupFFF" };
    BusinessGroup[] ctxAgroups = new BusinessGroup[namesInCtxA.length];
    BusinessGroup[] ctxBgroups = new BusinessGroup[namesInCtxB.length];
View Full Code Here

Examples of org.olat.group.context.BGContextManager

  public void testDeleteBusinessGroupWithoutWaitingGroup() {
    doTestDeleteBusinessGroup(false);
  }

  private void doTestDeleteBusinessGroup(boolean withWaitingList) {
    BGContextManager bgcm = BGContextManagerImpl.getInstance();
    BGContext groupContext = bgcm.createAndPersistBGContext("c1delete", "c1delete", BusinessGroup.TYPE_LEARNINGROUP, null, true);

    BusinessGroup deleteTestGroup = BusinessGroupManagerImpl.getInstance().createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, id1, "deleteTestGroup-1",
        "deleteTestGroup-1", null, null, withWaitingList, true, groupContext);
   
    Long ownerGroupKey = deleteTestGroup.getOwnerGroup().getKey();
View Full Code Here

Examples of org.olat.group.context.BGContextManager

    String bgWithWaitingListName = "Group with WaitingList";
    String bgWithWaitingListDesc = "some short description for Group with WaitingList";
    Boolean enableWaitinglist = new Boolean(true);
    Boolean enableAutoCloseRanks = new Boolean(true);

    BGContextManager bgcm = BGContextManagerImpl.getInstance();
    BGContext groupContext = bgcm.createAndPersistBGContext("c1name", "c1desc", BusinessGroup.TYPE_LEARNINGROUP, null, true);
    System.out.println("testAddToWaitingListAndFireEvent: groupContext=" + groupContext);
    bgWithWaitingList = bgManager.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, id1, bgWithWaitingListName,
        bgWithWaitingListDesc, null, null, enableWaitinglist, enableAutoCloseRanks, groupContext);
    bgWithWaitingList.setMaxParticipants(new Integer(2));
    // create mock objects
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.