use of org.olat.group.area.BGAreaManager in project openolat by klemens.
the class COCourseNode method isConfigValid.
/**
* @see org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment)
*/
public StatusDescription[] isConfigValid(CourseEditorEnv cev) {
oneClickStatusCache = null;
// only here we know which translator to take for translating condition
// error messages
String translatorStr = Util.getPackageName(ConditionEditController.class);
List<StatusDescription> condErrs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions());
List<StatusDescription> missingNames = new ArrayList<StatusDescription>();
/*
* check group and area names for existence
*/
String nodeId = getIdent();
ModuleConfiguration mc = getModuleConfiguration();
@SuppressWarnings("unchecked") List<Long> areaKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA_IDS);
if (areaKeys != null) {
BGAreaManager areaManager = CoreSpringFactory.getImpl(BGAreaManager.class);
List<BGArea> areas = areaManager.loadAreas(areaKeys);
a_a: for (Long areaKey : areaKeys) {
for (BGArea area : areas) {
if (area.getKey().equals(areaKey)) {
continue a_a;
}
}
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", areaKey.toString() }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
} else {
String areaStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA);
if (areaStr != null) {
String[] areas = areaStr.split(",");
for (int i = 0; i < areas.length; i++) {
String trimmed = areas[i] != null ? areas[i].trim() : areas[i];
if (!trimmed.equals("") && !cev.existsArea(trimmed)) {
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
}
}
}
@SuppressWarnings("unchecked") List<Long> groupKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP_ID);
if (groupKeys != null) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
List<BusinessGroupShort> groups = bgs.loadShortBusinessGroups(groupKeys);
a_a: for (Long activeGroupKey : groupKeys) {
for (BusinessGroupShort group : groups) {
if (group.getKey().equals(activeGroupKey)) {
continue a_a;
}
}
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", activeGroupKey.toString() }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
} else {
String groupStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP);
if (groupStr != null) {
String[] groups = groupStr.split(",");
for (int i = 0; i < groups.length; i++) {
String trimmed = groups[i] != null ? groups[i].trim() : groups[i];
if (!trimmed.equals("") && !cev.existsGroup(trimmed)) {
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
}
}
}
missingNames.addAll(condErrs);
oneClickStatusCache = StatusDescriptionHelper.sort(missingNames);
return oneClickStatusCache;
}
use of org.olat.group.area.BGAreaManager in project OpenOLAT by OpenOLAT.
the class COCourseNode method isConfigValid.
/**
* @see org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment)
*/
public StatusDescription[] isConfigValid(CourseEditorEnv cev) {
oneClickStatusCache = null;
// only here we know which translator to take for translating condition
// error messages
String translatorStr = Util.getPackageName(ConditionEditController.class);
List<StatusDescription> condErrs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions());
List<StatusDescription> missingNames = new ArrayList<StatusDescription>();
/*
* check group and area names for existence
*/
String nodeId = getIdent();
ModuleConfiguration mc = getModuleConfiguration();
@SuppressWarnings("unchecked") List<Long> areaKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA_IDS);
if (areaKeys != null) {
BGAreaManager areaManager = CoreSpringFactory.getImpl(BGAreaManager.class);
List<BGArea> areas = areaManager.loadAreas(areaKeys);
a_a: for (Long areaKey : areaKeys) {
for (BGArea area : areas) {
if (area.getKey().equals(areaKey)) {
continue a_a;
}
}
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", areaKey.toString() }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
} else {
String areaStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA);
if (areaStr != null) {
String[] areas = areaStr.split(",");
for (int i = 0; i < areas.length; i++) {
String trimmed = areas[i] != null ? areas[i].trim() : areas[i];
if (!trimmed.equals("") && !cev.existsArea(trimmed)) {
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
}
}
}
@SuppressWarnings("unchecked") List<Long> groupKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP_ID);
if (groupKeys != null) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
List<BusinessGroupShort> groups = bgs.loadShortBusinessGroups(groupKeys);
a_a: for (Long activeGroupKey : groupKeys) {
for (BusinessGroupShort group : groups) {
if (group.getKey().equals(activeGroupKey)) {
continue a_a;
}
}
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", activeGroupKey.toString() }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
} else {
String groupStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP);
if (groupStr != null) {
String[] groups = groupStr.split(",");
for (int i = 0; i < groups.length; i++) {
String trimmed = groups[i] != null ? groups[i].trim() : groups[i];
if (!trimmed.equals("") && !cev.existsGroup(trimmed)) {
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
sd.setDescriptionForUnit(nodeId);
missingNames.add(sd);
}
}
}
}
missingNames.addAll(condErrs);
oneClickStatusCache = StatusDescriptionHelper.sort(missingNames);
return oneClickStatusCache;
}
Aggregations