1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.service.impl;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import javax.persistence.metamodel.SingularAttribute;
25
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.security.access.annotation.Secured;
28 import org.springframework.stereotype.Component;
29 import org.springframework.transaction.annotation.Propagation;
30 import org.springframework.transaction.annotation.Transactional;
31
32 import com.hack23.cia.model.external.riksdagen.person.impl.PersonData;
33 import com.hack23.cia.service.api.DataContainer;
34 import com.hack23.cia.service.api.DataSummary;
35 import com.hack23.cia.service.data.api.CommitteeProposalComponentDataDAO;
36 import com.hack23.cia.service.data.api.DocumentContentDataDAO;
37 import com.hack23.cia.service.data.api.DocumentElementDAO;
38 import com.hack23.cia.service.data.api.DocumentStatusContainerDAO;
39 import com.hack23.cia.service.data.api.PersonDataDAO;
40 import com.hack23.cia.service.data.api.VoteDataDAO;
41
42
43
44
45 @Component("DataSummaryDataContainer")
46 @Transactional(propagation=Propagation.REQUIRED)
47 @Secured({"ROLE_ANONYMOUS","ROLE_USER", "ROLE_ADMIN" })
48 public final class DataSummaryDataContainer implements DataContainer<DataSummary,String>{
49
50
51 @Autowired
52 private CommitteeProposalComponentDataDAO committeeProposalComponentDataDAO;
53
54
55 @Autowired
56 private DocumentContentDataDAO documentContentDataDAO;
57
58
59 @Autowired
60 private DocumentElementDAO documentElementDAO;
61
62
63 @Autowired
64 private DocumentStatusContainerDAO documentStatusContainerDAO;
65
66
67 @Autowired
68 private PersonDataDAO personDataDAO;
69
70
71 @Autowired
72 private VoteDataDAO voteDataDAO;
73
74
75
76
77 public DataSummaryDataContainer() {
78 super();
79 }
80
81 @Override
82 public <T, V> T findByQueryProperty(final Class<T> clazz,
83 final SingularAttribute<T, ? extends Object> property, final Class<V> clazz2,
84 final SingularAttribute<V, ? extends Object> property2, final Object value) {
85 return null;
86 }
87
88 @Override
89 public <T, V> List<T> findListByEmbeddedProperty(final Class<T> clazz,
90 final SingularAttribute<T, V> property, final Class<V> clazz2,
91 final SingularAttribute<V, ? extends Object> property2, final Object value) {
92 return new ArrayList<>();
93 }
94
95 @Override
96 public List<DataSummary> findListByProperty(final Object[] values,
97 final SingularAttribute<DataSummary, ? extends Object>... properties) {
98 return new ArrayList<>();
99 }
100
101 @Override
102 public <T, V> List<T> findOrderedByPropertyListByEmbeddedProperty(final Class<T> clazz, final SingularAttribute<T, V> property,
103 final Class<V> clazz2, final SingularAttribute<V, ? extends Object> property2, final Object value,
104 final SingularAttribute<T, ? extends Object> orderByProperty) {
105 return new ArrayList<>();
106 }
107
108 @Override
109 public <T, V> List<T> findOrderedListByEmbeddedProperty(final Class<T> clazz, final SingularAttribute<T, V> property,
110 final Class<V> clazz2, final SingularAttribute<V, ? extends Object> property2, final Object value,
111 final SingularAttribute<V, ? extends Object> orderByProperty) {
112 return new ArrayList<>();
113 }
114
115 @Override
116 public List<DataSummary> findOrderedListByProperty(final SingularAttribute<DataSummary, ? extends Object> property,
117 final Object value, final SingularAttribute<DataSummary, ? extends Object> orderByProperty) {
118 return new ArrayList<>();
119 }
120
121 @Override
122 public List<DataSummary> findOrderedListByProperty(final SingularAttribute<DataSummary, ? extends Object> orderByProperty,
123 final Object[] values, final SingularAttribute<DataSummary, ? extends Object>... properties) {
124 return new ArrayList<>();
125 }
126
127 @Override
128 public List<DataSummary> getAll() {
129 final List<DataSummary> list = new ArrayList<>();
130 list.add(load(null));
131 return list;
132 }
133
134 @Override
135 public List<DataSummary> getAllBy(
136 final SingularAttribute<DataSummary, ? extends Object> property,
137 final Object value) {
138 return new ArrayList<>();
139 }
140
141 @Override
142 public List<DataSummary> getAllOrderBy(final SingularAttribute<DataSummary, ? extends Object> property) {
143 return new ArrayList<>();
144 }
145
146 @Override
147 public DataSummary load(final String id) {
148 final List<PersonData> all = personDataDAO.getAll();
149 final long personSize=all.size();
150
151 return new DataSummary(personSize,voteDataDAO.getSize(),voteDataDAO.getSize(),documentElementDAO.getSize(),documentContentDataDAO.getSize(),documentStatusContainerDAO.getSize(),committeeProposalComponentDataDAO.getSize());
152 }
153
154 @Override
155 public List<DataSummary> getPage(final int pageNr, final int resultPerPage) {
156 return new ArrayList<>();
157 }
158
159 @Override
160 public List<DataSummary> getPageOrderBy(final int pageNr, final int resultPerPage,
161 final SingularAttribute<DataSummary, ? extends Object> orderBy) {
162 return new ArrayList<>();
163 }
164
165 @Override
166 public Long getSize() {
167 return Long.valueOf(getAll().size());
168 }
169 }