1 /*
2 * Copyright 2010 James Pether Sörling
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * $Id$
17 * $HeadURL$
18 */
19 package com.hack23.cia.service.data.api;
20
21 import java.util.List;
22
23 import javax.persistence.metamodel.SingularAttribute;
24
25 /**
26 * The Interface DataViewer.
27 */
28 public interface DataViewer {
29
30 /**
31 * Find by query property.
32 *
33 * @param <T>
34 * the generic type
35 * @param <V>
36 * the value type
37 * @param clazz
38 * the clazz
39 * @param property
40 * the property
41 * @param clazz2
42 * the clazz 2
43 * @param property2
44 * the property 2
45 * @param value
46 * the value
47 * @return the t
48 */
49 <T,V> T findByQueryProperty(Class<T> clazz,
50 SingularAttribute<T, ? extends Object> property,Class<V> clazz2,
51 SingularAttribute<V, ? extends Object> property2, Object value);
52
53
54 /**
55 * Find first by property.
56 *
57 * @param <T>
58 * the generic type
59 * @param clazz
60 * the clazz
61 * @param property
62 * the property
63 * @param value
64 * the value
65 * @return the t
66 */
67 <T> T findFirstByProperty(Class<T> clazz,
68 final SingularAttribute<T, ? extends Object> property, final Object value);
69
70 /**
71 * Find list by embedded property.
72 *
73 * @param <T>
74 * the generic type
75 * @param <V>
76 * the value type
77 * @param clazz
78 * the clazz
79 * @param property
80 * the property
81 * @param clazz2
82 * the clazz 2
83 * @param property2
84 * the property 2
85 * @param value
86 * the value
87 * @return the list
88 */
89 <T,V> List<T> findListByEmbeddedProperty(Class<T> clazz,
90 SingularAttribute<T, V> property,Class<V> clazz2,
91 SingularAttribute<V, ? extends Object> property2, Object value);
92
93 /**
94 * Find list by property.
95 *
96 * @param <T>
97 * the generic type
98 * @param clazz
99 * the clazz
100 * @param values
101 * the values
102 * @param properties
103 * the properties
104 * @return the list
105 */
106 <T> List<T> findListByProperty(Class<T> clazz, final Object[] values,final SingularAttribute<T, ? extends Object>... properties);
107
108
109 /**
110 * Find list by property.
111 *
112 * @param <T>
113 * the generic type
114 * @param clazz
115 * the clazz
116 * @param property
117 * the property
118 * @param value
119 * the value
120 * @return the list
121 */
122 <T> List<T> findListByProperty(Class<T> clazz,
123 final SingularAttribute<T, ? extends Object> property, final Object value);
124
125
126
127 /**
128 * Find ordered by property list by embedded property.
129 *
130 * @param <T>
131 * the generic type
132 * @param <V>
133 * the value type
134 * @param clazz
135 * the clazz
136 * @param property
137 * the property
138 * @param clazz2
139 * the clazz 2
140 * @param property2
141 * the property 2
142 * @param value
143 * the value
144 * @param orderByProperty
145 * the order by property
146 * @return the list
147 */
148 <T,V> List<T> findOrderedByPropertyListByEmbeddedProperty(Class<T> clazz,
149 SingularAttribute<T, V> property,Class<V> clazz2,
150 SingularAttribute<V, ? extends Object> property2, Object value,SingularAttribute<T, ? extends Object> orderByProperty);
151
152 /**
153 * Find ordered list by embedded property.
154 *
155 * @param <T>
156 * the generic type
157 * @param <V>
158 * the value type
159 * @param clazz
160 * the clazz
161 * @param property
162 * the property
163 * @param clazz2
164 * the clazz 2
165 * @param property2
166 * the property 2
167 * @param value
168 * the value
169 * @param orderByProperty
170 * the order by property
171 * @return the list
172 */
173 <T,V> List<T> findOrderedListByEmbeddedProperty(Class<T> clazz,
174 SingularAttribute<T, V> property,Class<V> clazz2,
175 SingularAttribute<V, ? extends Object> property2, Object value,SingularAttribute<V, ? extends Object> orderByProperty);
176
177
178
179 /**
180 * Find ordered list by property.
181 *
182 * @param <T>
183 * the generic type
184 * @param clazz
185 * the clazz
186 * @param property
187 * the property
188 * @param value
189 * the value
190 * @param orderByProperty
191 * the order by property
192 * @return the list
193 */
194 <T> List<T> findOrderedListByProperty(Class<T> clazz,
195 final SingularAttribute<T, ? extends Object> property, final Object value,SingularAttribute<T, ? extends Object> orderByProperty);
196
197
198 /**
199 * Find ordered list by property.
200 *
201 * @param <T>
202 * the generic type
203 * @param clazz
204 * the clazz
205 * @param orderByProperty
206 * the order by property
207 * @param values
208 * the values
209 * @param properties
210 * the properties
211 * @return the list
212 */
213 <T> List<T> findOrderedListByProperty(Class<T> clazz, SingularAttribute<T, ? extends Object> orderByProperty,final Object[] values,final SingularAttribute<T, ? extends Object>... properties);
214
215
216 /**
217 * Gets the all.
218 *
219 * @param <T>
220 * the generic type
221 * @param clazz
222 * the clazz
223 * @return the all
224 */
225 <T> List<T> getAll(Class<T> clazz);
226
227
228 /**
229 * Gets the all order by.
230 *
231 * @param <T>
232 * the generic type
233 * @param clazz
234 * the clazz
235 * @param property
236 * the property
237 * @return the all order by
238 */
239 <T> List<T> getAllOrderBy(Class<T> clazz, SingularAttribute<T, ? extends Object> property);
240
241
242 /**
243 * Gets the page.
244 *
245 * @param <T>
246 * the generic type
247 * @param clazz
248 * the clazz
249 * @param pageNr
250 * the page nr
251 * @param resultPerPage
252 * the result per page
253 * @return the page
254 */
255 <T> List<T> getPage(Class<T> clazz,int pageNr,int resultPerPage);
256
257 /**
258 * Gets the page order by.
259 *
260 * @param <T>
261 * the generic type
262 * @param clazz
263 * the clazz
264 * @param pageNr
265 * the page nr
266 * @param resultPerPage
267 * the result per page
268 * @param property
269 * the property
270 * @return the page order by
271 */
272 <T> List<T> getPageOrderBy(Class<T> clazz,int pageNr,int resultPerPage,SingularAttribute<T, ? extends Object> property);
273
274
275 /**
276 * Gets the size.
277 *
278 * @param <T>
279 * the generic type
280 * @param clazz
281 * the clazz
282 * @return the size
283 */
284 <T> Long getSize(final Class<T> clazz);
285
286 /**
287 * Load.
288 *
289 * @param <T>
290 * the generic type
291 * @param clazz
292 * the clazz
293 * @param id
294 * the id
295 * @return the t
296 */
297 <T> T load(Class<T> clazz,Object id);
298
299 }