Search in sources :

Example 6 with LectureBlockToGroup

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;
}
Also used : Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) LectureBlockImpl(org.olat.modules.lecture.model.LectureBlockImpl)

Aggregations

Group (org.olat.basesecurity.Group)6 BusinessGroup (org.olat.group.BusinessGroup)6 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)6 LectureBlockImpl (org.olat.modules.lecture.model.LectureBlockImpl)6 Date (java.util.Date)4 Test (org.junit.Test)4 LectureBlock (org.olat.modules.lecture.LectureBlock)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 ArrayList (java.util.ArrayList)2 Identity (org.olat.core.id.Identity)2 LectureBlockToGroupImpl (org.olat.modules.lecture.model.LectureBlockToGroupImpl)2