use of org.olat.course.export.CourseEnvironmentMapper in project OpenOLAT by OpenOLAT.
the class KeyAndNameConverterTest method convertGroupAndAreaKeyToName_sameKey.
@Test
public void convertGroupAndAreaKeyToName_sameKey() {
CourseEnvironmentMapper envMapper = new CourseEnvironmentMapper();
BGArea newArea = new MockArea(567l, "Area 1");
BGAreaReference areaRef = new BGAreaReference(newArea, null, null);
envMapper.getAreas().add(areaRef);
MockBusinessGroup newGroup = new MockBusinessGroup(567l, "Group 1");
BusinessGroupReference bgRef = new BusinessGroupReference(newGroup, null, null);
envMapper.getGroups().add(bgRef);
String convertedExp = convertExpressionKeyToName("inLearningArea(\"567\") & isLearningGroupFull(\"567\")", envMapper);
Assert.assertEquals("inLearningArea(\"Area 1\") & isLearningGroupFull(\"Group 1\")", convertedExp);
}
use of org.olat.course.export.CourseEnvironmentMapper 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;
}
use of org.olat.course.export.CourseEnvironmentMapper in project OpenOLAT by OpenOLAT.
the class CourseHandler method copy.
@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
final OLATResource sourceResource = source.getOlatResource();
final OLATResource targetResource = target.getOlatResource();
CourseFactory.copyCourse(sourceResource, targetResource);
// transaction copied
ICourse sourceCourse = CourseFactory.loadCourse(source);
CourseGroupManager sourceCgm = sourceCourse.getCourseEnvironment().getCourseGroupManager();
CourseEnvironmentMapper env = PersistingCourseGroupManager.getInstance(sourceResource).getBusinessGroupEnvironment();
File fExportDir = new File(WebappHelper.getTmpDir(), UUID.randomUUID().toString());
fExportDir.mkdirs();
sourceCgm.exportCourseBusinessGroups(fExportDir, env, false, false);
ICourse course = CourseFactory.loadCourse(target);
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
// import groups
CourseEnvironmentMapper envMapper = cgm.importCourseBusinessGroups(fExportDir);
envMapper.setAuthor(author);
// upgrade to the current version of the course
course = CourseFactory.loadCourse(cgm.getCourseResource());
course.postCopy(envMapper, sourceCourse);
cloneReminders(author, envMapper, source, target);
cloneLectureConfig(source, target);
return target;
}
use of org.olat.course.export.CourseEnvironmentMapper 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;
}
use of org.olat.course.export.CourseEnvironmentMapper in project openolat by klemens.
the class OLATUpgrade_8_2_0 method upgradeCourseConditions.
private boolean upgradeCourseConditions(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_CONDITIONS)) {
int counter = 0;
List<RepositoryEntry> entries;
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(new Roles(true, false, false, false, false, false, false));
params.addResourceTypes("CourseModule");
do {
entries = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, REPO_ENTRIES_BATCH_SIZE, true);
for (RepositoryEntry entry : entries) {
try {
ICourse course = CourseFactory.loadCourse(entry.getOlatResource());
CourseEnvironmentMapper envMapper = getCourseEnvironmentMapper(entry);
course.postImport(null, envMapper);
} catch (CorruptedCourseException e) {
log.error("Course seems corrupt: " + entry.getOlatResource().getResourceableId());
} catch (Exception e) {
log.error("Course seems highly corrupt: " + entry.getOlatResource().getResourceableId());
}
}
dbInstance.intermediateCommit();
counter += entries.size();
log.audit("Processed repository entries: " + entries.size());
} while (entries.size() == REPO_ENTRIES_BATCH_SIZE);
uhd.setBooleanDataValue(TASK_CONDITIONS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return true;
}
Aggregations