Search in sources :

Example 16 with BGAreaReference

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

the class KeyAndNameConverter method convertExpressionKeyToKey.

public static String convertExpressionKeyToKey(String expression, CourseEnvironmentMapper envMapper) {
    for (String groupMethod : groupMethods) {
        for (BusinessGroupReference group : envMapper.getGroups()) {
            String strToMatch = groupMethod + "(\"" + group.getOriginalKey() + "\")";
            String replacement = groupMethod + "(\"" + group.getKey() + "\")";
            expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
        }
    }
    for (BGAreaReference area : envMapper.getAreas()) {
        String strToMatch = areaMethod + "(\"" + area.getOriginalKey() + "\")";
        String replacement = areaMethod + "(\"" + area.getKey() + "\")";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    for (BusinessGroupReference group : envMapper.getGroups()) {
        String strToMatch = "\"" + group.getOriginalKey() + "\"";
        String replacement = "\"" + group.getKey() + "\"";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    for (BGAreaReference area : envMapper.getAreas()) {
        String strToMatch = "\"" + area.getOriginalKey() + "\"";
        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 17 with BGAreaReference

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

the class PersistingCourseGroupManager method getBusinessGroupEnvironment.

/**
 * This operation load all business groups and areas. Use with caution, costly!
 * @param resource
 * @param fGroupExportXML
 * @return
 */
public CourseEnvironmentMapper getBusinessGroupEnvironment() {
    CourseEnvironmentMapper env = new CourseEnvironmentMapper();
    List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, getCourseEntry(), 0, -1);
    for (BusinessGroup group : groups) {
        env.getGroups().add(new BusinessGroupReference(group));
    }
    List<BGArea> areas = areaManager.findBGAreasInContext(getCourseResource());
    for (BGArea area : areas) {
        env.getAreas().add(new BGAreaReference(area));
    }
    return env;
}
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 18 with BGAreaReference

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

the class KeyAndNameConverterTest method convertAreaKeyToName.

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

Example 19 with BGAreaReference

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

the class KeyAndNameConverter method convertExpressionKeyToKey.

public static String convertExpressionKeyToKey(String expression, CourseEnvironmentMapper envMapper) {
    for (String groupMethod : groupMethods) {
        for (BusinessGroupReference group : envMapper.getGroups()) {
            String strToMatch = groupMethod + "(\"" + group.getOriginalKey() + "\")";
            String replacement = groupMethod + "(\"" + group.getKey() + "\")";
            expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
        }
    }
    for (BGAreaReference area : envMapper.getAreas()) {
        String strToMatch = areaMethod + "(\"" + area.getOriginalKey() + "\")";
        String replacement = areaMethod + "(\"" + area.getKey() + "\")";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    for (BusinessGroupReference group : envMapper.getGroups()) {
        String strToMatch = "\"" + group.getOriginalKey() + "\"";
        String replacement = "\"" + group.getKey() + "\"";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    for (BGAreaReference area : envMapper.getAreas()) {
        String strToMatch = "\"" + area.getOriginalKey() + "\"";
        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 20 with BGAreaReference

use of org.olat.group.model.BGAreaReference 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)

Aggregations

BGAreaReference (org.olat.group.model.BGAreaReference)28 BusinessGroupReference (org.olat.group.model.BusinessGroupReference)20 BGArea (org.olat.group.area.BGArea)18 CourseEnvironmentMapper (org.olat.course.export.CourseEnvironmentMapper)16 Test (org.junit.Test)12 BusinessGroup (org.olat.group.BusinessGroup)6 HashSet (java.util.HashSet)4 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 AssertException (org.olat.core.logging.AssertException)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 BusinessGroupEnvironment (org.olat.group.model.BusinessGroupEnvironment)2