Examples of BGAreaManager


Examples of org.olat.group.area.BGAreaManager

  /**
   * @see org.olat.course.groupsandrights.CourseGroupManager#getParticipatingLearningGroupsInAreaFromAllContexts(org.olat.core.id.Identity,
   *      java.lang.String)
   */
  public List getParticipatingLearningGroupsInAreaFromAllContexts(Identity identity, String areaName) {
    BGAreaManager areaManager = BGAreaManagerImpl.getInstance();
    List groups = new ArrayList();
    Iterator iter = learningGroupContexts.iterator();
    while (iter.hasNext()) {
      BGContext context = (BGContext) iter.next();
      List contextGroups = areaManager.findBusinessGroupsOfAreaAttendedBy(identity, areaName, context);
      groups.addAll(contextGroups);
    }
    return groups;
  }
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

      DB db = DBFactory.getInstance();
      String q = "select area from org.olat.group.area.BGAreaImpl area ";
      DBQuery query = db.createQuery(q);
      List<BGArea> areas = query.list();
      if (log.isDebug()) log.info("Migrating " + areas.size() + " BG areas.");
      BGAreaManager bgM = BGAreaManagerImpl.getInstance();
      int bgcounter = 0;

      for (BGArea area : areas) {
        try{
          String oldDesc = area.getDescription();
          if (StringHelper.containsNonWhitespace(oldDesc)) {
            String newDesc = migrateStringSavely(oldDesc);
            area.setDescription(newDesc);
            bgM.updateBGArea(area);
            bgcounter++;
          }
          DBFactory.getInstance().intermediateCommit();
        } catch (Exception e) {
          log.error("Error during Migration: "+e, e);
View Full Code Here

Examples of org.olat.group.area.BGAreaManager

    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.area.BGAreaManager

    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));
    assertTrue(am.findBGAreasOfBusinessGroup(g1).size() == 0);
    assertTrue(am.findBGAreasOfBGContext(c2).size() == 0);
    assertNull(am.findBGArea("a2-delete", c1));
    assertTrue(am.findBusinessGroupsOfArea(a1).size() == 0);
    assertTrue(am.findBusinessGroupsOfArea(a2).size() == 0);
    assertFalse(rm.hasBGRight(CourseRights.RIGHT_ARCHIVING, id1, c2));
    assertFalse(rm.hasBGRight(CourseRights.RIGHT_GROUPMANAGEMENT, id1, c2));
    assertFalse(rm.hasBGRight(CourseRights.RIGHT_ARCHIVING, id2, c2));
    assertFalse(rm.hasBGRight(CourseRights.RIGHT_ARCHIVING, id3, c2));
  }
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.