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