Search in sources :

Example 26 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project openolat by klemens.

the class KeyAndNameConverterTest method convertGroupAndAreaKeyToName_sameKey.

@Test
public void convertGroupAndAreaKeyToName_sameKey() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    BGArea newArea = new MockArea(567l, "Area 1");
    BGAreaReference areaRef = new BGAreaReference(newArea, null, null);
    envMapper.getAreas().add(areaRef);
    MockBusinessGroup newGroup = new MockBusinessGroup(567l, "Group 1");
    BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, null, null);
    envMapper.getGroups().add(bgRef);
    String convertedExp = convertExpressionKeyToName("inLearningArea(\"567\") & isLearningGroupFull(\"567\")", envMapper);
    Assert.assertEquals("inLearningArea(\"Area 1\") & isLearningGroupFull(\"Group 1\")", convertedExp);
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) Test(org.junit.Test)

Example 27 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project openolat by klemens.

the class KeyAndNameConverterTest method convertBusinessGroupNameToKey.

@Test
public void convertBusinessGroupNameToKey() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    MockBusinessGroup newGroup = new MockBusinessGroup(567l, "Group 1");
    BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, 345l, "Group 1");
    envMapper.getGroups().add(bgRef);
    String convertedExp = convertExpressionNameToKey("inLearningGroup(\"Group 1\")", envMapper);
    Assert.assertEquals("inLearningGroup(\"567\")", convertedExp);
}
Also used : BusinessGroupReference(org.olat.group.model.BusinessGroupReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) Test(org.junit.Test)

Example 28 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project openolat by klemens.

the class KeyAndNameConverterTest method convertBusinessGroupKeyToKey.

@Test
public void convertBusinessGroupKeyToKey() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    MockBusinessGroup newGroup = new MockBusinessGroup(567l, "Group 1");
    BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, 345l, "Group 1");
    envMapper.getGroups().add(bgRef);
    String convertedExp = convertExpressionKeyToKey("inRightGroup(\"345\")", envMapper);
    Assert.assertEquals("inRightGroup(\"567\")", convertedExp);
}
Also used : BusinessGroupReference(org.olat.group.model.BusinessGroupReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) Test(org.junit.Test)

Example 29 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project openolat by klemens.

the class KeyAndNameConverterTest method convertGroupAndAreaKeyToKey_sameKey.

@Test
public void convertGroupAndAreaKeyToKey_sameKey() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    BGArea newArea = new MockArea(567l, "Area 1");
    BGAreaReference areaRef = new BGAreaReference(newArea, 345l, "Area 1");
    envMapper.getAreas().add(areaRef);
    MockBusinessGroup newGroup = new MockBusinessGroup(568l, "Group 1");
    BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, 345l, "Group 1");
    envMapper.getGroups().add(bgRef);
    String convertedExp = convertExpressionKeyToKey("inLearningArea(\"345\") & inRightGroup(\"345\")", envMapper);
    Assert.assertEquals("inLearningArea(\"567\") & inRightGroup(\"568\")", convertedExp);
}
Also used : BGArea(org.olat.group.area.BGArea) BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper) Test(org.junit.Test)

Example 30 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project openolat by klemens.

the class CourseEnvironmentMapper method avoidDuplicateNames.

public void avoidDuplicateNames() {
    Set<String> names = new HashSet<String>();
    for (BusinessGroupReference ref : getGroups()) {
        if (names.contains(ref.getName())) {
            String newName = generateName(ref.getName(), names);
            names.add(newName);
            ref.setName(newName);
        } else {
            names.add(ref.getName());
        }
    }
    names.clear();
    for (BGAreaReference ref : getAreas()) {
        if (names.contains(ref.getName())) {
            String newName = generateName(ref.getName(), names);
            names.add(newName);
            ref.setName(newName);
        } else {
            names.add(ref.getName());
        }
    }
}
Also used : BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGAreaReference(org.olat.group.model.BGAreaReference) HashSet(java.util.HashSet)

Aggregations

BusinessGroupReference (org.olat.group.model.BusinessGroupReference)32 BGAreaReference (org.olat.group.model.BGAreaReference)20 CourseEnvironmentMapper (org.olat.course.export.CourseEnvironmentMapper)16 Test (org.junit.Test)12 BGArea (org.olat.group.area.BGArea)12 BusinessGroup (org.olat.group.BusinessGroup)8 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 AssertException (org.olat.core.logging.AssertException)4 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)4 XStream (com.thoughtworks.xstream.XStream)2 File (java.io.File)2 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 Identity (org.olat.core.id.Identity)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 Project (org.olat.course.nodes.projectbroker.datamodel.Project)2