Search in sources :

Example 6 with RepositoryEntryToGroupRelation

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;
}
Also used : Date(java.util.Date) RepositoryEntryToGroupRelation(org.olat.repository.model.RepositoryEntryToGroupRelation)

Example 7 with RepositoryEntryToGroupRelation

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();
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) GroupMembershipImpl(org.olat.basesecurity.model.GroupMembershipImpl) RepositoryEntryToGroupRelation(org.olat.repository.model.RepositoryEntryToGroupRelation)

Example 8 with RepositoryEntryToGroupRelation

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;
}
Also used : Date(java.util.Date) RepositoryEntryToGroupRelation(org.olat.repository.model.RepositoryEntryToGroupRelation)

Example 9 with RepositoryEntryToGroupRelation

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();
}
Also used : EntityManager(javax.persistence.EntityManager) RepositoryEntryToGroupRelation(org.olat.repository.model.RepositoryEntryToGroupRelation)

Example 10 with RepositoryEntryToGroupRelation

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;
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryEntryToGroupRelation(org.olat.repository.model.RepositoryEntryToGroupRelation)

Aggregations

RepositoryEntryToGroupRelation (org.olat.repository.model.RepositoryEntryToGroupRelation)28 RepositoryEntry (org.olat.repository.RepositoryEntry)16 Group (org.olat.basesecurity.Group)12 Date (java.util.Date)10 BusinessGroup (org.olat.group.BusinessGroup)10 Test (org.junit.Test)8 Identity (org.olat.core.id.Identity)8 EntityManager (javax.persistence.EntityManager)6 Calendar (java.util.Calendar)4 GroupMembershipImpl (org.olat.basesecurity.model.GroupMembershipImpl)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 RepositoryEntryStatistics (org.olat.repository.model.RepositoryEntryStatistics)2