Search in sources :

Example 6 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project OpenOLAT by OpenOLAT.

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 7 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project OpenOLAT by OpenOLAT.

the class PersistingCourseGroupManager method getBusinessGroupEnvironment.

/**
 * This operation load all business groups and areas. Use with caution, costly!
 * @param resource
 * @param fGroupExportXML
 * @return
 */
public CourseEnvironmentMapper getBusinessGroupEnvironment() {
    CourseEnvironmentMapper env = new CourseEnvironmentMapper();
    List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, getCourseEntry(), 0, -1);
    for (BusinessGroup group : groups) {
        env.getGroups().add(new BusinessGroupReference(group));
    }
    List<BGArea> areas = areaManager.findBGAreasInContext(getCourseResource());
    for (BGArea area : areas) {
        env.getAreas().add(new BGAreaReference(area));
    }
    return env;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGArea(org.olat.group.area.BGArea) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper)

Example 8 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project OpenOLAT by OpenOLAT.

the class BusinessGroupRoleRuleSPI method clone.

@Override
public ReminderRule clone(ReminderRule rule, CourseEnvironmentMapper envMapper) {
    ReminderRuleImpl clone = (ReminderRuleImpl) rule.clone();
    String groupKey = clone.getRightOperand();
    boolean found = false;
    if (StringHelper.isLong(groupKey)) {
        Long key = Long.parseLong(groupKey);
        for (BusinessGroupReference ref : envMapper.getGroups()) {
            if (key.equals(ref.getOriginalKey()) && ref.getKey() != null) {
                clone.setRightOperand(ref.getKey().toString());
                found = true;
            }
        }
    }
    return found ? clone : null;
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) BusinessGroupReference(org.olat.group.model.BusinessGroupReference)

Example 9 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project OpenOLAT by OpenOLAT.

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;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGArea(org.olat.group.area.BGArea) BGAreaReference(org.olat.group.model.BGAreaReference) CourseEnvironmentMapper(org.olat.course.export.CourseEnvironmentMapper)

Example 10 with BusinessGroupReference

use of org.olat.group.model.BusinessGroupReference in project OpenOLAT by OpenOLAT.

the class KeyAndNameConverter method convertExpressionKeyToName.

/**
 * isLearningGroupFull, inLearningGroup, inRightGroup, inLearningArea, isLearningGroupFull
 */
public static String convertExpressionKeyToName(String expression, CourseEnvironmentMapper envMapper) {
    for (String groupMethod : groupMethods) {
        for (BusinessGroupReference group : envMapper.getGroups()) {
            String strToMatch = groupMethod + "(\"" + group.getKey() + "\")";
            String replacement = groupMethod + "(\"" + group.getName() + "\")";
            expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
        }
    }
    for (BGAreaReference area : envMapper.getAreas()) {
        String strToMatch = areaMethod + "(\"" + area.getKey() + "\")";
        String replacement = areaMethod + "(\"" + area.getName() + "\")";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    for (BusinessGroupReference group : envMapper.getGroups()) {
        String strToMatch = "\"" + group.getKey() + "\"";
        String replacement = "\"" + group.getName() + "\"";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    for (BGAreaReference area : envMapper.getAreas()) {
        String strToMatch = "\"" + area.getKey() + "\"";
        String replacement = "\"" + area.getName() + "\"";
        expression = StringHelper.replaceAllCaseInsensitive(expression, strToMatch, replacement);
    }
    return expression;
}
Also used : BusinessGroupReference(org.olat.group.model.BusinessGroupReference) BGAreaReference(org.olat.group.model.BGAreaReference)

Aggregations

BusinessGroupReference (org.olat.group.model.BusinessGroupReference)32 BGAreaReference (org.olat.group.model.BGAreaReference)20 CourseEnvironmentMapper (org.olat.course.export.CourseEnvironmentMapper)16 Test (org.junit.Test)12 BGArea (org.olat.group.area.BGArea)12 BusinessGroup (org.olat.group.BusinessGroup)8 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 AssertException (org.olat.core.logging.AssertException)4 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)4 XStream (com.thoughtworks.xstream.XStream)2 File (java.io.File)2 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CollaborationTools (org.olat.collaboration.CollaborationTools)2 Identity (org.olat.core.id.Identity)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 Project (org.olat.course.nodes.projectbroker.datamodel.Project)2