use of fi.otavanopisto.muikku.plugins.material.coops.model.HtmlMaterialRevision in project muikku by otavanopisto.
the class HtmlMaterialRevisionDAO method listByFileAndRevisionGtAndRevisonLeOrderedByRevision.
public List<HtmlMaterialRevision> listByFileAndRevisionGtAndRevisonLeOrderedByRevision(HtmlMaterial htmlMaterial, Long revisionGe, Long revisionLt) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<HtmlMaterialRevision> criteria = criteriaBuilder.createQuery(HtmlMaterialRevision.class);
Root<HtmlMaterialRevision> root = criteria.from(HtmlMaterialRevision.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(HtmlMaterialRevision_.htmlMaterial), htmlMaterial), criteriaBuilder.greaterThan(root.get(HtmlMaterialRevision_.revision), revisionGe), criteriaBuilder.lessThanOrEqualTo(root.get(HtmlMaterialRevision_.revision), revisionLt)));
criteria.orderBy(criteriaBuilder.asc(root.get(HtmlMaterialRevision_.revision)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.plugins.material.coops.model.HtmlMaterialRevision in project muikku by otavanopisto.
the class HtmlMaterialRevisionDAO method listByFileAndRevisionGeAndRevisonLtOrderedByRevision.
public List<HtmlMaterialRevision> listByFileAndRevisionGeAndRevisonLtOrderedByRevision(HtmlMaterial htmlMaterial, Long revisionGe, Long revisionLt) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<HtmlMaterialRevision> criteria = criteriaBuilder.createQuery(HtmlMaterialRevision.class);
Root<HtmlMaterialRevision> root = criteria.from(HtmlMaterialRevision.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(HtmlMaterialRevision_.htmlMaterial), htmlMaterial), criteriaBuilder.greaterThanOrEqualTo(root.get(HtmlMaterialRevision_.revision), revisionGe), criteriaBuilder.lessThan(root.get(HtmlMaterialRevision_.revision), revisionLt)));
criteria.orderBy(criteriaBuilder.asc(root.get(HtmlMaterialRevision_.revision)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.plugins.material.coops.model.HtmlMaterialRevision in project muikku by otavanopisto.
the class HtmlMaterialRevisionDAO method create.
public HtmlMaterialRevision create(HtmlMaterial htmlMaterial, String sessionId, Long revision, Date created, String data, String checksum) {
HtmlMaterialRevision htmlMaterialRevision = new HtmlMaterialRevision();
htmlMaterialRevision.setChecksum(checksum);
htmlMaterialRevision.setCreated(created);
htmlMaterialRevision.setData(data);
htmlMaterialRevision.setFile(htmlMaterial);
htmlMaterialRevision.setRevision(revision);
htmlMaterialRevision.setSessionId(sessionId);
return persist(htmlMaterialRevision);
}
use of fi.otavanopisto.muikku.plugins.material.coops.model.HtmlMaterialRevision in project muikku by otavanopisto.
the class HtmlMaterialRevisionDAO method maxRevisionByHtmlMaterial.
public Long maxRevisionByHtmlMaterial(HtmlMaterial htmlMaterial) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class);
Root<HtmlMaterialRevision> root = criteria.from(HtmlMaterialRevision.class);
criteria.select(criteriaBuilder.max(root.get(HtmlMaterialRevision_.revision)));
criteria.where(criteriaBuilder.equal(root.get(HtmlMaterialRevision_.htmlMaterial), htmlMaterial));
return entityManager.createQuery(criteria).getSingleResult();
}
use of fi.otavanopisto.muikku.plugins.material.coops.model.HtmlMaterialRevision in project muikku by otavanopisto.
the class HtmlMaterialRevisionPropertyDAO method listKeysByHtmlMaterial.
public List<String> listKeysByHtmlMaterial(HtmlMaterial htmlMaterial) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<String> criteria = criteriaBuilder.createQuery(String.class);
Root<HtmlMaterialRevisionProperty> root = criteria.from(HtmlMaterialRevisionProperty.class);
Join<HtmlMaterialRevisionProperty, HtmlMaterialRevision> revisionJoin = root.join(HtmlMaterialRevisionProperty_.htmlMaterialRevision);
criteria.select(root.get(HtmlMaterialRevisionProperty_.key)).distinct(true);
criteria.where(criteriaBuilder.equal(revisionJoin.get(HtmlMaterialRevision_.htmlMaterial), htmlMaterial));
return entityManager.createQuery(criteria).getResultList();
}
Aggregations