Search in sources :

Example 6 with FlagShare

use of fi.otavanopisto.muikku.model.users.FlagShare in project muikku by otavanopisto.

the class FlagShareDAO method listByFlag.

public List<FlagShare> listByFlag(Flag flag) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<FlagShare> criteria = criteriaBuilder.createQuery(FlagShare.class);
    Root<FlagShare> root = criteria.from(FlagShare.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(FlagShare_.flag), flag));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) FlagShare(fi.otavanopisto.muikku.model.users.FlagShare)

Example 7 with FlagShare

use of fi.otavanopisto.muikku.model.users.FlagShare in project muikku by otavanopisto.

the class FlagShareDAO method findByFlagAndUserIdentifier.

public FlagShare findByFlagAndUserIdentifier(Flag flag, UserSchoolDataIdentifier userIdentifier) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<FlagShare> criteria = criteriaBuilder.createQuery(FlagShare.class);
    Root<FlagShare> root = criteria.from(FlagShare.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(FlagShare_.flag), flag), criteriaBuilder.equal(root.get(FlagShare_.userIdentifier), userIdentifier));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) FlagShare(fi.otavanopisto.muikku.model.users.FlagShare)

Example 8 with FlagShare

use of fi.otavanopisto.muikku.model.users.FlagShare in project muikku by otavanopisto.

the class FlagShareDAO method listByUserIdentifier.

public List<FlagShare> listByUserIdentifier(UserSchoolDataIdentifier userIdentifier) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<FlagShare> criteria = criteriaBuilder.createQuery(FlagShare.class);
    Root<FlagShare> root = criteria.from(FlagShare.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.equal(root.get(FlagShare_.userIdentifier), userIdentifier));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) FlagShare(fi.otavanopisto.muikku.model.users.FlagShare)

Example 9 with FlagShare

use of fi.otavanopisto.muikku.model.users.FlagShare in project muikku by otavanopisto.

the class FlagShareDAO method create.

public FlagShare create(Flag flag, UserSchoolDataIdentifier userIdentifier) {
    FlagShare flagShare = new FlagShare();
    flagShare.setFlag(flag);
    flagShare.setUserIdentifier(userIdentifier);
    return persist(flagShare);
}
Also used : FlagShare(fi.otavanopisto.muikku.model.users.FlagShare)

Aggregations

FlagShare (fi.otavanopisto.muikku.model.users.FlagShare)9 EntityManager (javax.persistence.EntityManager)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 Flag (fi.otavanopisto.muikku.model.users.Flag)3 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)2 DELETE (javax.ws.rs.DELETE)2 Path (javax.ws.rs.Path)2 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)1 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)1