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.io.Serializable;
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.beans.factory.annotation.Qualifier;
28 import org.springframework.security.access.annotation.Secured;
29 import org.springframework.stereotype.Component;
30 import org.springframework.transaction.annotation.Propagation;
31 import org.springframework.transaction.annotation.Transactional;
32
33 import com.hack23.cia.service.api.DataContainer;
34 import com.hack23.cia.service.data.api.DataViewer;
35
36
37
38
39 @Component
40 @Transactional(propagation=Propagation.REQUIRED)
41 @Secured({"ROLE_ANONYMOUS","ROLE_USER", "ROLE_ADMIN" })
42 final class ViewDataDataContainerFactoryImpl implements DataViewer,ViewDataDataContainerFactory {
43
44
45 @Autowired
46 @Qualifier("DataViewer")
47 private DataViewer dataViewer;
48
49
50
51
52
53 public ViewDataDataContainerFactoryImpl() {
54 super();
55 }
56
57
58 @Override
59 public <T extends Serializable,I extends Serializable> DataContainer<T,I> createDataContainer(final Class<T> clazz) {
60 return new GenericDataContainer<>(clazz,this);
61 }
62
63
64 @Override
65 public <T, V> T findByQueryProperty(final Class<T> clazz,
66 final SingularAttribute<T, ? extends Object> property, final Class<V> clazz2,
67 final SingularAttribute<V, ? extends Object> property2, final Object value) {
68 return dataViewer.findByQueryProperty(clazz, property, clazz2, property2, value);
69 }
70
71
72 @Override
73 public <T> T findFirstByProperty(final Class<T> clazz,
74 final SingularAttribute<T, ? extends Object> property, final Object value) {
75 return dataViewer.findFirstByProperty(clazz, property, value);
76 }
77
78
79 @Override
80 public <T, V> List<T> findListByEmbeddedProperty(final Class<T> clazz,
81 final SingularAttribute<T, V> property, final Class<V> clazz2,
82 final SingularAttribute<V, ? extends Object> property2, final Object value) {
83 return dataViewer.findListByEmbeddedProperty(clazz, property, clazz2, property2, value);
84 }
85
86
87
88 @Override
89 public <T> List<T> findListByProperty(final Class<T> clazz, final Object[] values,
90 final SingularAttribute<T, ? extends Object>... properties) {
91 return dataViewer.findListByProperty(clazz, values, properties);
92 }
93
94
95
96 @Override
97 public <T> List<T> findListByProperty(final Class<T> clazz,
98 final SingularAttribute<T, ? extends Object> property, final Object value) {
99 return dataViewer.findListByProperty(clazz, property, value);
100 }
101
102
103
104 @Override
105 public <T, V> List<T> findOrderedByPropertyListByEmbeddedProperty(final Class<T> clazz, final SingularAttribute<T, V> property,
106 final Class<V> clazz2, final SingularAttribute<V, ? extends Object> property2, final Object value,
107 final SingularAttribute<T, ? extends Object> orderByProperty) {
108 return dataViewer.findOrderedByPropertyListByEmbeddedProperty(clazz,property,clazz2,property2,value,orderByProperty);
109 }
110
111
112
113 @Override
114 public <T, V> List<T> findOrderedListByEmbeddedProperty(final Class<T> clazz, final SingularAttribute<T, V> property,
115 final Class<V> clazz2, final SingularAttribute<V, ? extends Object> property2, final Object value,
116 final SingularAttribute<V, ? extends Object> orderByProperty) {
117 return dataViewer.findOrderedListByEmbeddedProperty(clazz,property,clazz2,property2,value,orderByProperty);
118 }
119
120
121
122 @Override
123 public <T> List<T> findOrderedListByProperty(final Class<T> clazz, final SingularAttribute<T, ? extends Object> property,
124 final Object value, final SingularAttribute<T, ? extends Object> orderByProperty) {
125 return dataViewer.findOrderedListByProperty(clazz,property,value,orderByProperty);
126 }
127
128
129
130 @Override
131 public <T> List<T> findOrderedListByProperty(final Class<T> clazz, final SingularAttribute<T, ? extends Object> orderByProperty,
132 final Object[] values, final SingularAttribute<T, ? extends Object>... properties) {
133 return dataViewer.findOrderedListByProperty(clazz,orderByProperty,values,properties);
134 }
135
136
137 @Override
138 public <T> List<T> getAll(final Class<T> clazz) {
139 return dataViewer.getAll(clazz);
140 }
141
142
143 @Override
144 public <T> List<T> getAllOrderBy(final Class<T> clazz, final SingularAttribute<T, ? extends Object> property) {
145 return dataViewer.getAllOrderBy(clazz, property);
146 }
147
148
149 @Override
150 public <T> T load(final Class<T> clazz, final Object id) {
151 return dataViewer.load(clazz, id);
152 }
153
154
155 @Override
156 public <T> List<T> getPage(final Class<T> clazz, final int pageNr, final int resultPerPage) {
157 return dataViewer.getPage(clazz, pageNr, resultPerPage);
158 }
159
160
161 @Override
162 public <T> List<T> getPageOrderBy(final Class<T> clazz, final int pageNr, final int resultPerPage,
163 final SingularAttribute<T, ? extends Object> property) {
164 return dataViewer.getPageOrderBy(clazz, pageNr, resultPerPage, property);
165 }
166
167
168 @Override
169 public <T> Long getSize(final Class<T> clazz) {
170 return dataViewer.getSize(clazz);
171 }
172
173 }