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;
}
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;
}
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();
}
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;
}
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());
}
Aggregations