Search in sources :

Example 6 with LectureBlockToGroupImpl

use of org.olat.modules.lecture.model.LectureBlockToGroupImpl in project OpenOLAT by OpenOLAT.

the class LectureBlockDAO method addGroupToLectureBlock.

public LectureBlock addGroupToLectureBlock(LectureBlock block, Group group) {
    LectureBlockImpl reloadedBlock = (LectureBlockImpl) loadByKey(block.getKey());
    LectureBlockToGroupImpl blockToGroup = new LectureBlockToGroupImpl();
    blockToGroup.setGroup(group);
    blockToGroup.setLectureBlock(block);
    dbInstance.getCurrentEntityManager().persist(blockToGroup);
    return reloadedBlock;
}
Also used : LectureBlockToGroupImpl(org.olat.modules.lecture.model.LectureBlockToGroupImpl) LectureBlockImpl(org.olat.modules.lecture.model.LectureBlockImpl)

Example 7 with LectureBlockToGroupImpl

use of org.olat.modules.lecture.model.LectureBlockToGroupImpl in project openolat by klemens.

the class LectureBlockDAOTest method addGroup.

@Test
public void addGroup() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    LectureBlock lectureBlock = lectureBlockDao.createLectureBlock(entry);
    lectureBlock.setStartDate(new Date());
    lectureBlock.setEndDate(new Date());
    lectureBlock.setTitle("Hello lecturers");
    lectureBlock = lectureBlockDao.update(lectureBlock);
    dbInstance.commitAndCloseSession();
    Group defGroup = repositoryEntryRelationDao.getDefaultGroup(entry);
    lectureBlockDao.addGroupToLectureBlock(lectureBlock, defGroup);
    dbInstance.commitAndCloseSession();
    LectureBlockImpl reloadedLectureBlock = (LectureBlockImpl) lectureBlockDao.loadByKey(lectureBlock.getKey());
    Set<LectureBlockToGroup> blockToGroupSet = reloadedLectureBlock.getGroups();
    Assert.assertNotNull(blockToGroupSet);
    Assert.assertEquals(1, blockToGroupSet.size());
    LectureBlockToGroupImpl defBlockToGroup = (LectureBlockToGroupImpl) blockToGroupSet.iterator().next();
    Assert.assertEquals(defGroup, defBlockToGroup.getGroup());
    Assert.assertEquals(lectureBlock, defBlockToGroup.getLectureBlock());
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) BusinessGroup(org.olat.group.BusinessGroup) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) LectureBlockToGroupImpl(org.olat.modules.lecture.model.LectureBlockToGroupImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) LectureBlockImpl(org.olat.modules.lecture.model.LectureBlockImpl) Date(java.util.Date) Test(org.junit.Test)

Example 8 with LectureBlockToGroupImpl

use of org.olat.modules.lecture.model.LectureBlockToGroupImpl in project openolat by klemens.

the class LectureBlockDAO method addGroupToLectureBlock.

public LectureBlock addGroupToLectureBlock(LectureBlock block, Group group) {
    LectureBlockImpl reloadedBlock = (LectureBlockImpl) loadByKey(block.getKey());
    LectureBlockToGroupImpl blockToGroup = new LectureBlockToGroupImpl();
    blockToGroup.setGroup(group);
    blockToGroup.setLectureBlock(block);
    dbInstance.getCurrentEntityManager().persist(blockToGroup);
    return reloadedBlock;
}
Also used : LectureBlockToGroupImpl(org.olat.modules.lecture.model.LectureBlockToGroupImpl) LectureBlockImpl(org.olat.modules.lecture.model.LectureBlockImpl)

Aggregations

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