Search in sources :

Example 26 with CommunicatorMessageRecipient

use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient 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)

Aggregations

CommunicatorMessageRecipient (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient)26 CommunicatorMessage (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessage)13 EntityManager (javax.persistence.EntityManager)12 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)12 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)9 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)9 Path (javax.ws.rs.Path)9 CommunicatorMessageId (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageId)6 CommunicatorMessageIdLabel (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageIdLabel)5 UserBasicInfo (fi.otavanopisto.muikku.rest.model.UserBasicInfo)5 Date (java.util.Date)5 GET (javax.ws.rs.GET)5 CommunicatorMessageRecipientUserGroup (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientUserGroup)4 CommunicatorMessageRecipientWorkspaceGroup (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipientWorkspaceGroup)4 ArrayList (java.util.ArrayList)4 POST (javax.ws.rs.POST)4 CommunicatorLabel (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorLabel)1 UserGroup (fi.otavanopisto.muikku.schooldata.entity.UserGroup)1 HashSet (java.util.HashSet)1 Join (javax.persistence.criteria.Join)1