Search in sources :

Example 1 with Group

use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.

the class BinderDAO method deleteBinder.

public int deleteBinder(BinderRef binderRef) {
    int rows = userInformationsDAO.deleteBinderUserInfos(binderRef);
    BinderImpl binder = (BinderImpl) loadByKey(binderRef.getKey());
    List<Section> sections = new ArrayList<>(binder.getSections());
    for (Section section : sections) {
        List<Page> pages = new ArrayList<>(section.getPages());
        section.getPages().clear();
        section = dbInstance.getCurrentEntityManager().merge(section);
        for (Page page : pages) {
            if (page != null) {
                rows += pageDao.deletePage(page);
                rows += pageUserInfosDao.delete(page);
            }
        }
        rows += assessmentSectionDao.deleteAssessmentSections(section);
        Group baseGroup = section.getBaseGroup();
        rows += groupDao.removeMemberships(baseGroup);
        dbInstance.getCurrentEntityManager().remove(section);
        dbInstance.getCurrentEntityManager().remove(baseGroup);
        rows += 2;
    }
    binder.getSections().clear();
    Group baseGroup = binder.getBaseGroup();
    rows += groupDao.removeMemberships(baseGroup);
    dbInstance.getCurrentEntityManager().remove(binder);
    dbInstance.getCurrentEntityManager().remove(baseGroup);
    return rows + 2;
}
Also used : Group(org.olat.basesecurity.Group) ArrayList(java.util.ArrayList) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) Section(org.olat.modules.portfolio.Section)

Example 2 with Group

use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.

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)

Example 3 with Group

use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.

the class LectureBlockWebService method addRepositoryEntryParticipantGroup.

/**
 * Add the group of the course to the lecture block participants list.
 * @response.representation.200.doc Successfully added
 * @return 200 if all ok
 */
@PUT
@Path("participants/repositoryentry")
public Response addRepositoryEntryParticipantGroup() {
    LectureBlock reloadedBlock = lectureService.getLectureBlock(lectureBlock);
    Group defGroup = CoreSpringFactory.getImpl(RepositoryService.class).getDefaultGroup(entry);
    List<Group> currentGroups = lectureService.getLectureBlockToGroups(reloadedBlock);
    if (!currentGroups.contains(defGroup)) {
        currentGroups.add(defGroup);
        reloadedBlock = lectureService.save(reloadedBlock, currentGroups);
    }
    lectureService.syncParticipantSummaries(reloadedBlock);
    return Response.ok().build();
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) RepositoryService(org.olat.repository.RepositoryService) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 4 with Group

use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.

the class TaxonomyDAO method createTaxonomy.

public Taxonomy createTaxonomy(String identifier, String displayName, String description, String externalId) {
    TaxonomyImpl taxonomy = new TaxonomyImpl();
    taxonomy.setCreationDate(new Date());
    taxonomy.setLastModified(taxonomy.getCreationDate());
    if (StringHelper.containsNonWhitespace(identifier)) {
        taxonomy.setIdentifier(identifier);
    } else {
        taxonomy.setIdentifier(UUID.randomUUID().toString());
    }
    taxonomy.setDisplayName(displayName);
    taxonomy.setDescription(description);
    taxonomy.setExternalId(externalId);
    Group group = groupDao.createGroup();
    taxonomy.setGroup(group);
    dbInstance.getCurrentEntityManager().persist(taxonomy);
    String storage = createStorage(taxonomy, "directory");
    taxonomy.setDirectoryPath(storage);
    String lostFoundStorage = createStorage(taxonomy, "lostfound");
    taxonomy.setDirectoryLostFoundPath(lostFoundStorage);
    taxonomy = dbInstance.getCurrentEntityManager().merge(taxonomy);
    taxonomy.getGroup();
    return taxonomy;
}
Also used : Group(org.olat.basesecurity.Group) TaxonomyImpl(org.olat.modules.taxonomy.model.TaxonomyImpl) Date(java.util.Date)

Example 5 with Group

use of org.olat.basesecurity.Group in project OpenOLAT by OpenOLAT.

the class InvitationDAOTest method loadOrCreateIdentityAndPersistInvitation.

@Test
public void loadOrCreateIdentityAndPersistInvitation() {
    Invitation invitation = invitationDao.createAndPersistInvitation();
    String uuid = UUID.randomUUID().toString().replace("-", "");
    invitation = invitationDao.update(invitation, "Flora", uuid, uuid + "@frentix.com");
    Group group = groupDao.createGroup();
    dbInstance.commit();
    // use the create part of the method
    Identity identity = invitationDao.loadOrCreateIdentityAndPersistInvitation(invitation, group, Locale.ENGLISH);
    Assert.assertNotNull(identity);
    Assert.assertNotNull(identity.getKey());
    dbInstance.commitAndCloseSession();
    // reload and check
    Identity reloadIdentity = securityManager.loadIdentityByKey(identity.getKey());
    Assert.assertNotNull(reloadIdentity);
    Assert.assertNotNull(reloadIdentity.getUser());
    Assert.assertEquals(identity.getKey(), reloadIdentity.getKey());
    Assert.assertEquals("Flora", reloadIdentity.getUser().getFirstName());
    Assert.assertEquals(uuid, reloadIdentity.getUser().getLastName());
    Assert.assertEquals(uuid + "@frentix.com", reloadIdentity.getUser().getEmail());
}
Also used : Group(org.olat.basesecurity.Group) Invitation(org.olat.basesecurity.Invitation) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

Group (org.olat.basesecurity.Group)170 Test (org.junit.Test)92 Identity (org.olat.core.id.Identity)80 BusinessGroup (org.olat.group.BusinessGroup)72 RepositoryEntry (org.olat.repository.RepositoryEntry)46 ArrayList (java.util.ArrayList)28 GroupMembership (org.olat.basesecurity.GroupMembership)26 LectureBlock (org.olat.modules.lecture.LectureBlock)26 OLATResource (org.olat.resource.OLATResource)26 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)20 Date (java.util.Date)16 SecurityGroup (org.olat.basesecurity.SecurityGroup)16 EPStructureElementToGroupRelation (org.olat.portfolio.model.structel.EPStructureElementToGroupRelation)14 HashSet (java.util.HashSet)12 RepositoryEntryToGroupRelation (org.olat.repository.model.RepositoryEntryToGroupRelation)11 HashMap (java.util.HashMap)8 Grant (org.olat.basesecurity.Grant)8 Calendar (java.util.Calendar)6 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)6 BGRights (org.olat.group.right.BGRights)5