Search in sources :

Example 26 with BGAreaReference

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

Example 27 with BGAreaReference

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

the class CourseEnvironmentMapper method toAreaKeyFromOriginalNames.

public List<Long> toAreaKeyFromOriginalNames(String areaNames) {
    if (!StringHelper.containsNonWhitespace(areaNames))
        return null;
    String[] areaNameArr = areaNames.split(",");
    List<Long> areaKeyList = new ArrayList<Long>();
    for (String areaName : areaNameArr) {
        areaName = areaName.trim();
        for (BGAreaReference area : areas) {
            if (areaName.equalsIgnoreCase(area.getOriginalName())) {
                areaKeyList.add(area.getKey());
                break;
            }
        }
    }
    return areaKeyList;
}
Also used : ArrayList(java.util.ArrayList) BGAreaReference(org.olat.group.model.BGAreaReference)

Example 28 with BGAreaReference

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

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