1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.service.data.impl;
20
21 import java.util.List;
22
23 import javax.persistence.TypedQuery;
24 import javax.persistence.criteria.CriteriaQuery;
25 import javax.persistence.criteria.Predicate;
26 import javax.persistence.criteria.Root;
27
28 import org.springframework.stereotype.Repository;
29
30 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentData;
31 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentData_;
32 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer;
33 import com.hack23.cia.service.data.api.DocumentStatusContainerDAO;
34
35
36
37
38 @Repository("DocumentStatusContainerDAO")
39 final class DocumentStatusContainerDAOImpl extends
40 AbstractGenericDAOImpl<DocumentStatusContainer, Long> implements
41 DocumentStatusContainerDAO {
42
43
44
45
46 public DocumentStatusContainerDAOImpl() {
47 super(DocumentStatusContainer.class);
48 }
49
50 @Override
51 public int checkExistByDocumentId(final String id) {
52 final CriteriaQuery<DocumentData> criteriaQuery = getCriteriaBuilder()
53 .createQuery(DocumentData.class);
54 final Root<DocumentData> root = criteriaQuery.from(DocumentData.class);
55 criteriaQuery.select(root);
56 final Predicate condition = getCriteriaBuilder().equal(root.get(DocumentData_.id), id);
57 criteriaQuery.where(condition);
58 final TypedQuery<DocumentData> typedQuery = getEntityManager()
59 .createQuery(criteriaQuery);
60 addCacheHints(typedQuery, "findFirstByProperty");
61
62 return typedQuery.getResultList().size();
63 }
64
65 @Override
66 public List<String> getAvaibleCommitteeProposal() {
67 final CriteriaQuery<String> criteria = getCriteriaBuilder().createQuery(String.class);
68 final Root<DocumentData> root = criteria.from(DocumentData.class);
69 criteria.select(root.get(DocumentData_.id));
70 criteria.where(getCriteriaBuilder().isNotNull(root.get(DocumentData_.committeeReportUrlXml)));
71 return getEntityManager().createQuery(criteria).getResultList();
72
73 }
74
75 @Override
76 public List<String> getIdList() {
77 final CriteriaQuery<String> criteria = getCriteriaBuilder().createQuery(String.class);
78 final Root<DocumentData> root = criteria.from(DocumentData.class);
79 criteria.select(root.get(DocumentData_.id));
80 return getEntityManager().createQuery(criteria).getResultList();
81 }
82
83 }