Search in sources :

Example 6 with CommunicatorMessageRecipientUserGroup

use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientUserGroup in project muikku by otavanopisto.

the class CommunicatorMessageRecipientUserGroupDAO method listByMessage.

public List<CommunicatorMessageRecipientUserGroup> listByMessage(CommunicatorMessage communicatorMessage) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CommunicatorMessageRecipientUserGroup> criteria = criteriaBuilder.createQuery(CommunicatorMessageRecipientUserGroup.class);
    Root<CommunicatorMessageRecipientUserGroup> root = criteria.from(CommunicatorMessageRecipientUserGroup.class);
    Root<CommunicatorMessageRecipient> root2 = criteria.from(CommunicatorMessageRecipient.class);
    criteria.select(root).distinct(true);
    criteria.where(criteriaBuilder.and(root2.get(CommunicatorMessageRecipient_.recipientGroup).in(root), criteriaBuilder.equal(root2.get(CommunicatorMessageRecipient_.communicatorMessage), communicatorMessage)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) CommunicatorMessageRecipient(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient) EntityManager(javax.persistence.EntityManager) CommunicatorMessageRecipientUserGroup(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientUserGroup)

Example 7 with CommunicatorMessageRecipientUserGroup

use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientUserGroup in project muikku by otavanopisto.

the class CommunicatorMessageRecipientUserGroupDAO method create.

public CommunicatorMessageRecipientUserGroup create(UserGroupEntity userGroupEntity) {
    CommunicatorMessageRecipientUserGroup workspaceGroup = new CommunicatorMessageRecipientUserGroup();
    workspaceGroup.setUserGroupEntityId(userGroupEntity.getId());
    getEntityManager().persist(workspaceGroup);
    return workspaceGroup;
}
Also used : CommunicatorMessageRecipientUserGroup(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientUserGroup)

Aggregations

CommunicatorMessageRecipientUserGroup (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientUserGroup)7 CommunicatorMessageRecipient (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient)4 CommunicatorMessageRecipientWorkspaceGroup (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientWorkspaceGroup)4 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)3 CommunicatorMessage (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage)3 UserBasicInfo (fi.otavanopisto.muikku.rest.model.UserBasicInfo)3 Date (java.util.Date)3 UserGroupEntity (fi.otavanopisto.muikku.model.users.UserGroupEntity)2 CommunicatorMessageIdLabel (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageIdLabel)2 UserGroup (fi.otavanopisto.muikku.schooldata.entity.UserGroup)2 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 UserGroupUserEntity (fi.otavanopisto.muikku.model.users.UserGroupUserEntity)1 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)1 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)1 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)1 HashSet (java.util.HashSet)1 EntityManager (javax.persistence.EntityManager)1