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.api;
20
21 import java.io.Serializable;
22 import java.util.List;
23
24 import javax.persistence.metamodel.SingularAttribute;
25
26 /**
27 * The Interface DataContainer.
28 *
29 * @param <T>
30 * the generic type
31 * @param <I>
32 * the generic type
33 */
34 public interface DataContainer<T extends Serializable,I extends Serializable> {
35
36 /**
37 * Gets the all.
38 *
39 * @return the all
40 */
41 List<T> getAll();
42
43 /**
44 * Gets the all order by.
45 *
46 * @param property
47 * the property
48 * @return the all order by
49 */
50 List<T> getAllOrderBy(final SingularAttribute<T, ? extends Object> property);
51
52
53 /**
54 * Gets the page.
55 *
56 * @param pageNr
57 * the page nr
58 * @param resultPerPage
59 * the result per page
60 * @return the page
61 */
62 List<T> getPage(int pageNr,int resultPerPage);
63
64 /**
65 * Gets the page order by.
66 *
67 * @param pageNr
68 * the page nr
69 * @param resultPerPage
70 * the result per page
71 * @param orderBy
72 * the order by
73 * @return the page order by
74 */
75 List<T> getPageOrderBy(int pageNr,int resultPerPage,final SingularAttribute<T, ? extends Object> orderBy);
76
77
78 /**
79 * Gets the all by.
80 *
81 * @param property
82 * the property
83 * @param value
84 * the value
85 * @return the all by
86 */
87 List<T> getAllBy(final SingularAttribute<T, ? extends Object> property, final Object value);
88
89 /**
90 * Find list by property.
91 *
92 * @param values
93 * the values
94 * @param properties
95 * the properties
96 * @return the list
97 */
98 List<T> findListByProperty(final Object[] values,final SingularAttribute<T, ? extends Object>... properties);
99
100 /**
101 * Find ordered list by property.
102 *
103 * @param property
104 * the property
105 * @param value
106 * the value
107 * @param orderByProperty
108 * the order by property
109 * @return the list
110 */
111 List<T> findOrderedListByProperty(final SingularAttribute<T, ? extends Object> property, final Object value,SingularAttribute<T, ? extends Object> orderByProperty);
112
113 /**
114 * Find ordered list by property.
115 *
116 * @param orderByProperty
117 * the order by property
118 * @param values
119 * the values
120 * @param properties
121 * the properties
122 * @return the list
123 */
124 List<T> findOrderedListByProperty(SingularAttribute<T, ? extends Object> orderByProperty,final Object[] values,final SingularAttribute<T, ? extends Object>... properties);
125
126
127 /**
128 * Find by query 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 clazz2
140 * @param property2
141 * the property2
142 * @param value
143 * the value
144 * @return the t
145 */
146 <T,V> T findByQueryProperty(Class<T> clazz,
147 SingularAttribute<T, ? extends Object> property,Class<V> clazz2,
148 SingularAttribute<V, ? extends Object> property2, Object value);
149
150 /**
151 * Find list by embedded property.
152 *
153 * @param <T>
154 * the generic type
155 * @param <V>
156 * the value type
157 * @param clazz
158 * the clazz
159 * @param property
160 * the property
161 * @param clazz2
162 * the clazz2
163 * @param property2
164 * the property2
165 * @param value
166 * the value
167 * @return the list
168 */
169 <T,V> List<T> findListByEmbeddedProperty(Class<T> clazz,
170 SingularAttribute<T, V> property,Class<V> clazz2,
171 SingularAttribute<V, ? extends Object> property2, Object value);
172
173 /**
174 * Find ordered list by embedded property.
175 *
176 * @param <T>
177 * the generic type
178 * @param <V>
179 * the value type
180 * @param clazz
181 * the clazz
182 * @param property
183 * the property
184 * @param clazz2
185 * the clazz2
186 * @param property2
187 * the property2
188 * @param value
189 * the value
190 * @param orderByProperty
191 * the order by property
192 * @return the list
193 */
194 <T,V> List<T> findOrderedListByEmbeddedProperty(Class<T> clazz,
195 SingularAttribute<T, V> property,Class<V> clazz2,
196 SingularAttribute<V, ? extends Object> property2, Object value,SingularAttribute<V, ? extends Object> orderByProperty);
197
198 /**
199 * Find ordered by property list by embedded property.
200 *
201 * @param <T>
202 * the generic type
203 * @param <V>
204 * the value type
205 * @param clazz
206 * the clazz
207 * @param property
208 * the property
209 * @param clazz2
210 * the clazz2
211 * @param property2
212 * the property2
213 * @param value
214 * the value
215 * @param orderByProperty
216 * the order by property
217 * @return the list
218 */
219 <T,V> List<T> findOrderedByPropertyListByEmbeddedProperty(Class<T> clazz,
220 SingularAttribute<T, V> property,Class<V> clazz2,
221 SingularAttribute<V, ? extends Object> property2, Object value,SingularAttribute<T, ? extends Object> orderByProperty);
222
223
224 /**
225 * Load.
226 *
227 * @param id
228 * the id
229 * @return the t
230 */
231 T load(I id);
232
233 /**
234 * Gets the size.
235 *
236 * @return the size
237 */
238 Long getSize();
239
240 }