Skip to content
Snippets Groups Projects
Commit 77785aea authored by srosse's avatar srosse
Browse files

OO-2144: fix validation and check if area keys list are null OR empty

parent 03189e57
No related branches found
No related tags found
No related merge requests found
......@@ -247,7 +247,7 @@ public class ENCourseNode extends AbstractAccessableCourseNode {
for (int i = 0; i < areas.length; i++) {
String trimmed = areas[i] != null ?
FilterFactory.getHtmlTagsFilter().filter(areas[i]).trim() : areas[i];
if (!trimmed.equals("") && !cev.existsGroup(trimmed)) {
if (!trimmed.equals("") && !cev.existsArea(trimmed)) {
missingNames.add(trimmed);
}
}
......@@ -404,7 +404,7 @@ public class ENCourseNode extends AbstractAccessableCourseNode {
@SuppressWarnings("unchecked")
List<Long> areaKeys = (List<Long>) mc.get(ENCourseNode.CONFIG_AREA_IDS);
if(areaKeys == null) {
areaKeys = envMapper.toGroupKeyFromOriginalNames(areaNames);
areaKeys = envMapper.toAreaKeyFromOriginalNames(areaNames);
} else {
areaKeys = envMapper.toAreaKeyFromOriginalKeys(groupKeys);
}
......
......@@ -186,7 +186,7 @@ class ENEditGroupAreaFormController extends FormBasicController implements Gener
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// groups
List<Long> groupKeys = moduleConfig.getList(ENCourseNode.CONFIG_GROUP_IDS, Long.class);
if(groupKeys == null) {
if(groupKeys == null || groupKeys.isEmpty()) {
String groupNames = (String) moduleConfig.get(ENCourseNode.CONFIG_GROUPNAME);
if(StringHelper.containsNonWhitespace(groupNames)) {
groupKeys = businessGroupService.toGroupKeys(groupNames, cev.getCourseGroupManager().getCourseEntry());
......@@ -214,7 +214,7 @@ class ENEditGroupAreaFormController extends FormBasicController implements Gener
@SuppressWarnings("unchecked")
List<Long> areaKeys = (List<Long>)moduleConfig.get(ENCourseNode.CONFIG_AREA_IDS);
if(areaKeys == null) {
if(areaKeys == null || areaKeys.isEmpty()) {
String areaNames = (String) moduleConfig.get(ENCourseNode.CONFIG_AREANAME);
areaKeys = areaManager.toAreaKeys(areaNames, cev.getCourseGroupManager().getCourseResource());
}
......
......@@ -133,13 +133,13 @@ public class ENRunController extends BasicController implements GenericEventList
// Get groupnames from configuration
enrollableGroupKeys = moduleConfig.getList(ENCourseNode.CONFIG_GROUP_IDS, Long.class);
if(enrollableGroupKeys == null) {
if(enrollableGroupKeys == null || enrollableGroupKeys.isEmpty()) {
String groupNamesConfig = (String)moduleConfig.get(ENCourseNode.CONFIG_GROUPNAME);
enrollableGroupKeys = businessGroupService.toGroupKeys(groupNamesConfig, courseGroupManager.getCourseEntry());
}
enrollableAreaKeys = moduleConfig.getList(ENCourseNode.CONFIG_AREA_IDS, Long.class);
if(enrollableAreaKeys == null) {
if(enrollableAreaKeys == null || enrollableAreaKeys.isEmpty()) {
String areaInitVal = (String) moduleConfig.get(ENCourseNode.CONFIG_AREANAME);
enrollableAreaKeys = areaManager.toAreaKeys(areaInitVal, courseGroupManager.getCourseResource());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment