use of org.olat.modules.lecture.LectureBlockToGroup in project openolat by klemens.
the class LectureServiceImpl method save.
@Override
public LectureBlock save(LectureBlock lectureBlock, List<Group> groups) {
LectureBlockImpl block = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
if (groups != null) {
List<LectureBlockToGroup> lectureToGroups = lectureBlockToGroupDao.getLectureBlockToGroups(block);
for (Group group : groups) {
boolean found = false;
for (LectureBlockToGroup lectureToGroup : lectureToGroups) {
if (lectureToGroup.getGroup().equals(group)) {
found = true;
break;
}
}
if (!found) {
LectureBlockToGroup blockToGroup = lectureBlockToGroupDao.createAndPersist(block, group);
lectureToGroups.add(blockToGroup);
}
}
for (Iterator<LectureBlockToGroup> lectureToGroupIt = lectureToGroups.iterator(); lectureToGroupIt.hasNext(); ) {
LectureBlockToGroup lectureBlockToGroup = lectureToGroupIt.next();
if (!groups.contains(lectureBlockToGroup.getGroup())) {
lectureBlockToGroupDao.remove(lectureBlockToGroup);
}
}
}
block.getTeacherGroup().getKey();
return block;
}
Aggregations