Search in sources :

Example 21 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project OpenOLAT by OpenOLAT.

the class KeyAndNameConverter method convertExpressionNameToKey.

public static String convertExpressionNameToKey(String expression, CourseEnvironmentMapper envMapper) {
    for (String groupMethod : groupMethods) {
        for (BusinessGroupReference group : envMapper.getGroups()) {
            String strToMatch = groupMethod + "(\"" + group.getOriginalName() + "\")";
            String replacement = groupMethod + "(\"" + group.getKey() + "\")";
            expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
        }
    }
    for (BGAreaReference area : envMapper.getAreas()) {
        String strToMatch = areaMethod + "(\"" + area.getOriginalName() + "\")";
        String replacement = areaMethod + "(\"" + area.getKey() + "\")";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    // fallback for special case where there is blank between the ( and "
    for (BusinessGroupReference group : envMapper.getGroups()) {
        String strToMatch = "\"" + group.getOriginalName() + "\"";
        String replacement = "\"" + group.getKey() + "\"";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    for (BGAreaReference area : envMapper.getAreas()) {
        String strToMatch = "\"" + area.getOriginalName() + "\"";
        String replacement = "\"" + area.getKey() + "\"";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    return expression;
}
Also used : BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGAreaReference(org.olat.group.model.BGAreaReference)

Example 22 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project OpenOLAT by OpenOLAT.

the class CourseEnvironmentMapper method toGroupKeyFromOriginalNames.

public List<Long> toGroupKeyFromOriginalNames(String groupNames) {
    if (!StringHelper.containsNonWhitespace(groupNames))
        return null;
    String[] groupNameArr = groupNames.split(",");
    List<Long> groupKeyList = new ArrayList<Long>();
    for (String groupName : groupNameArr) {
        groupName = groupName.trim();
        for (BusinessGroupReference group : groups) {
            if (groupName.equalsIgnoreCase(group.getOriginalName())) {
                groupKeyList.add(group.getKey());
                break;
            }
        }
    }
    return groupKeyList;
}
Also used : BusinessGroupReference(org.olat.group.model.BusinessGroupReference) ArrayList(java.util.ArrayList)

Example 23 with BusinessGroupReference

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

the class OLATUpgrade_8_2_0 method getCourseEnvironmentMapper.

private CourseEnvironmentMapper getCourseEnvironmentMapper(RepositoryEntry courseResource) {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, courseResource, 0, -1);
    for (BusinessGroup group : groups) {
        envMapper.getGroups().add(new BusinessGroupReference(group));
    }
    List<BGArea> areas = areaManager.findBGAreasInContext(courseResource.getOlatResource());
    for (BGArea area : areas) {
        envMapper.getAreas().add(new BGAreaReference(area));
    }
    return envMapper;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGArea(org.olat.group.area.BGArea) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper)

Example 24 with BusinessGroupReference

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

the class KeyAndNameConverterTest method convertGroupAndAreaNameToKey_sameName.

/**
 * Test with same name for area and group
 */
@Test
public void convertGroupAndAreaNameToKey_sameName() {
    CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
    BGArea newArea = new MockArea(567l, "Test 1");
    BGAreaReference areaRef = new BGAreaReference(newArea, 345l, "Test 1");
    envMapper.getAreas().add(areaRef);
    MockBusinessGroup newGroup = new MockBusinessGroup(568l, "Test 1");
    BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, 346l, "Test 1");
    envMapper.getGroups().add(bgRef);
    String convertedExp = convertExpressionNameToKey("inLearningArea(\"Test 1\") & inLearningGroup(\"Test 1\")", envMapper);
    Assert.assertEquals("inLearningArea(\"567\") & inLearningGroup(\"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 25 with BusinessGroupReference

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

the class KeyAndNameConverterTest method convertBusinessGroupKeyToName.

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

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