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());
}
}
}
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;
}
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;
}
Aggregations