use of org.olat.repository.model.RepositoryEntryToGroupRelation in project OpenOLAT by OpenOLAT.
the class GTAReminderRuleTest method addEnrollmentDate.
private void addEnrollmentDate(RepositoryEntry entry, Identity id, GroupRoles role, int amount, int field) {
RepositoryEntryToGroupRelation rel = entry.getGroups().iterator().next();
rel.getGroup();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(field, amount);
GroupMembershipImpl membership = new GroupMembershipImpl();
membership.setCreationDate(cal.getTime());
membership.setLastModified(cal.getTime());
membership.setGroup(rel.getGroup());
membership.setIdentity(id);
membership.setRole(role.name());
dbInstance.getCurrentEntityManager().persist(membership);
dbInstance.commit();
}
use of org.olat.repository.model.RepositoryEntryToGroupRelation in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngineTest method addEnrollmentDate.
private void addEnrollmentDate(RepositoryEntry entry, Identity id, GroupRoles role, int amount, int field) {
RepositoryEntryToGroupRelation rel = entry.getGroups().iterator().next();
rel.getGroup();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(field, amount);
GroupMembershipImpl membership = new GroupMembershipImpl();
membership.setCreationDate(cal.getTime());
membership.setLastModified(cal.getTime());
membership.setGroup(rel.getGroup());
membership.setIdentity(id);
membership.setRole(role.name());
dbInstance.getCurrentEntityManager().persist(membership);
dbInstance.commit();
}
use of org.olat.repository.model.RepositoryEntryToGroupRelation in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRelationDAOTest method removeRelation_byGroup.
@Test
public void removeRelation_byGroup() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("re-member-lc-" + UUID.randomUUID().toString());
RepositoryEntry re1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re2 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupService.createBusinessGroup(null, "remove relation by group", "tg", null, null, false, false, re1);
businessGroupRelationDao.addRole(id, group, GroupRoles.coach.name());
businessGroupService.addResourceTo(group, re2);
dbInstance.commitAndCloseSession();
int numOfRelations = repositoryEntryRelationDao.removeRelation(group.getBaseGroup());
Assert.assertEquals(2, numOfRelations);
dbInstance.commitAndCloseSession();
List<Group> groups = Collections.singletonList(group.getBaseGroup());
List<RepositoryEntryToGroupRelation> relations = repositoryEntryRelationDao.getRelations(groups);
Assert.assertEquals(0, relations.size());
}
use of org.olat.repository.model.RepositoryEntryToGroupRelation in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRelationDAO method removeRelation.
public int removeRelation(Group group, RepositoryEntryRef re) {
EntityManager em = dbInstance.getCurrentEntityManager();
List<RepositoryEntryToGroupRelation> rels = em.createNamedQuery("relationByRepositoryEntryAndGroup", RepositoryEntryToGroupRelation.class).setParameter("repoKey", re.getKey()).setParameter("groupKey", group.getKey()).getResultList();
for (RepositoryEntryToGroupRelation rel : rels) {
em.remove(rel);
}
return rels.size();
}
use of org.olat.repository.model.RepositoryEntryToGroupRelation in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRelationDAO method removeRelations.
/**
* This will remove all relations from the repository entry,
* the default one too.
*
* @param re
* @return
*/
public int removeRelations(RepositoryEntryRef re) {
EntityManager em = dbInstance.getCurrentEntityManager();
List<RepositoryEntryToGroupRelation> rels = em.createNamedQuery("relationByRepositoryEntry", RepositoryEntryToGroupRelation.class).setParameter("repoKey", re.getKey()).getResultList();
for (RepositoryEntryToGroupRelation rel : rels) {
em.remove(rel);
}
return rels.size();
}
Aggregations