use of org.olat.repository.model.RepositoryEntryToGroupRelation in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRelationDAO method createRelation.
public RepositoryEntryToGroupRelation createRelation(Group group, RepositoryEntry re) {
RepositoryEntryToGroupRelation rel = new RepositoryEntryToGroupRelation();
rel.setCreationDate(new Date());
rel.setDefaultGroup(false);
rel.setGroup(group);
rel.setEntry(re);
dbInstance.getCurrentEntityManager().persist(rel);
return rel;
}
use of org.olat.repository.model.RepositoryEntryToGroupRelation in project openolat by klemens.
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 klemens.
the class RepositoryEntryRelationDAO method createRelation.
public RepositoryEntryToGroupRelation createRelation(Group group, RepositoryEntry re) {
RepositoryEntryToGroupRelation rel = new RepositoryEntryToGroupRelation();
rel.setCreationDate(new Date());
rel.setDefaultGroup(false);
rel.setGroup(group);
rel.setEntry(re);
dbInstance.getCurrentEntityManager().persist(rel);
return rel;
}
use of org.olat.repository.model.RepositoryEntryToGroupRelation in project openolat by klemens.
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 klemens.
the class RepositoryServiceImpl method unpublishRepositoryEntry.
@Override
public RepositoryEntry unpublishRepositoryEntry(RepositoryEntry entry) {
RepositoryEntry reloadedEntry = repositoryEntryDAO.loadForUpdate(entry);
reloadedEntry.setStatusCode(RepositoryEntryStatus.REPOSITORY_STATUS_UNPUBLISHED);
reloadedEntry = dbInstance.getCurrentEntityManager().merge(reloadedEntry);
dbInstance.commit();
// remove catalog entries
catalogManager.resourceableDeleted(reloadedEntry);
// remove users and participants
// remove participant and coach
removeMembers(reloadedEntry, GroupRoles.coach.name(), GroupRoles.participant.name(), GroupRoles.waiting.name());
// remove relation to business groups
List<RepositoryEntryToGroupRelation> relations = reToGroupDao.getRelations(reloadedEntry);
for (RepositoryEntryToGroupRelation relation : relations) {
if (!relation.isDefaultGroup()) {
reToGroupDao.removeRelation(relation);
}
}
return reloadedEntry;
}
Aggregations