Search in sources :

Example 6 with CommunicatorMessageSignature

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

the class CommunicatorMessageSignatureDAO method create.

public CommunicatorMessageSignature create(String name, String content, UserEntity user) {
    CommunicatorMessageSignature sig = new CommunicatorMessageSignature();
    sig.setName(name);
    sig.setSignature(content);
    sig.setUser(user.getId());
    getEntityManager().persist(sig);
    return sig;
}
Also used : CommunicatorMessageSignature(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature)

Example 7 with CommunicatorMessageSignature

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

the class CommunicatorMessageSignatureDAO method listByUser.

public List<CommunicatorMessageSignature> listByUser(UserEntity user) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CommunicatorMessageSignature> criteria = criteriaBuilder.createQuery(CommunicatorMessageSignature.class);
    Root<CommunicatorMessageSignature> root = criteria.from(CommunicatorMessageSignature.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(CommunicatorMessageSignature_.user), user.getId()));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CommunicatorMessageSignature(fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature)

Aggregations

CommunicatorMessageSignature (fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageSignature)7 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)5 Path (javax.ws.rs.Path)5 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 GET (javax.ws.rs.GET)2 ArrayList (java.util.ArrayList)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 DELETE (javax.ws.rs.DELETE)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1