/
PersistenceEntryManager.java
347 lines (263 loc) · 13.1 KB
/
PersistenceEntryManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/*
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text.
*
* Copyright (c) 2020, Janssen Project
*/
package io.jans.orm;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import jakarta.persistence.EntityGraph;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.EntityTransaction;
import jakarta.persistence.FlushModeType;
import jakarta.persistence.LockModeType;
import jakarta.persistence.Query;
import jakarta.persistence.StoredProcedureQuery;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaDelete;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.CriteriaUpdate;
import jakarta.persistence.metamodel.Metamodel;
import io.jans.orm.annotation.AttributesList;
import io.jans.orm.event.DeleteNotifier;
import io.jans.orm.extension.PersistenceExtension;
import io.jans.orm.model.AttributeData;
import io.jans.orm.model.AttributeType;
import io.jans.orm.model.BatchOperation;
import io.jans.orm.model.PagedResult;
import io.jans.orm.model.SearchScope;
import io.jans.orm.model.SortOrder;
import io.jans.orm.operation.PersistenceOperationService;
import io.jans.orm.reflect.property.PropertyAnnotation;
import io.jans.orm.search.filter.Filter;
/**
* Methods which Entry Manager must provide
*
* @author Yuriy Movchan Date: 01/29/2018
*/
public interface PersistenceEntryManager extends EntityManager {
enum PERSITENCE_TYPES {ldap, couchbase, sql, spanner, hybrid};
@Deprecated
boolean authenticate(String primaryKey, String password);
<T> boolean authenticate(String primaryKey, Class<T> entryClass, String password);
<T> boolean authenticate(String baseDN, Class<T> entryClass, String userName, String password);
void persist(Object entry);
Void merge(Object entry);
@Deprecated
boolean contains(Object entity);
<T> boolean contains(String primaryKey, Class<T> entryClass);
<T> boolean contains(String primaryKey, Class<T> entryClass, Filter filter);
<T> int countEntries(Object entry);
<T> int countEntries(String primaryKey, Class<T> entryClass, Filter filter);
<T> int countEntries(String primaryKey, Class<T> entryClass, Filter filter, SearchScope scope);
<T> List<T> createEntities(Class<T> entryClass, Map<String, List<AttributeData>> entriesAttributes);
<T> T find(Object primaryKey, Class<T> entryClass, String[] ldapReturnAttributes);
/**
* Search by sample
*
* @param entry Sample
* @return Result entries
*/
<T> List<T> findEntries(Object entry);
<T> List<T> findEntries(Object entry, int count);
<T> List<T> findEntries(String primaryKey, Class<T> entryClass, Filter filter);
<T> List<T> findEntries(String primaryKey, Class<T> entryClass, Filter filter, int count);
<T> List<T> findEntries(String primaryKey, Class<T> entryClass, Filter filter, String[] ldapReturnAttributes);
<T> List<T> findEntries(String primaryKey, Class<T> entryClass, Filter filter, String[] ldapReturnAttributes, int count);
<T> List<T> findEntries(String primaryKey, Class<T> entryClass, Filter filter, SearchScope scope, String[] ldapReturnAttributes,
int start, int count, int chunkSize);
<T> List<T> findEntries(String primaryKey, Class<T> entryClass, Filter filter, SearchScope scope, String[] ldapReturnAttributes,
BatchOperation<T> batchOperation, int start, int count, int chunkSize);
// TODO: Combine sortBy and SortOrder into Sort
<T> PagedResult<T> findPagedEntries(String primaryKey, Class<T> entryClass, Filter filter, String[] ldapReturnAttributes, String sortBy,
SortOrder sortOrder, int start, int count, int chunkSize);
void remove(Object entry);
@Deprecated
void remove(String dn);
<T> void removeByDn(String dn, String[] objectClasses);
<T> void remove(String primaryKey, Class<T> entryClass);
<T> int remove(String primaryKey, Class<T> entryClass, Filter filter, int count);
@Deprecated
void removeRecursively(String primaryKey);
<T> void removeRecursively(String primaryKey, Class<T> entryClass);
<T> void removeRecursivelyFromDn(String primaryKey, String[] objectClasses);
boolean hasBranchesSupport(String primaryKey);
boolean hasExpirationSupport(String primaryKey);
String getPersistenceType();
String getPersistenceType(String primaryKey);
Date decodeTime(String primaryKey, String date);
String encodeTime(String primaryKey, Date date);
int getHashCode(Object entry);
String[] getObjectClasses(Object entry, Class<?> entryClass);
<T> Map<T, List<T>> groupListByProperties(Class<T> entryClass, List<T> entries, boolean caseSensetive, String groupByProperties,
String sumByProperties);
void addDeleteSubscriber(DeleteNotifier subscriber);
void removeDeleteSubscriber(DeleteNotifier subscriber);
<T> void sortListByProperties(Class<T> entryClass, List<T> entries, boolean caseSensetive, String... sortByProperties);
@Deprecated
List<AttributeData> exportEntry(String dn);
<T> List<AttributeData> exportEntry(String dn, String objectClass);
<T> void importEntry(String dn, Class<T> entryClass, List<AttributeData> data);
PersistenceOperationService getOperationService();
PersistenceEntryManager getPersistenceEntryManager(String persistenceType);
void setPersistenceExtension(PersistenceExtension persistenceExtension);
<T> AttributeType getAttributeType(String primaryKey, Class<T> entryClass, String propertyName);
Class<?> getCustomAttributesListItemType(Object entry, AttributesList attributesList,
String propertyName);
List<AttributeData> getAttributeDataListFromCustomAttributesList(Object entry, AttributesList attributesList,
String propertyName);
List<Object> getCustomAttributesListFromAttributeDataList(Object entry, AttributesList attributesList,
String propertyName, Collection<AttributeData> attributes);
<T> List<PropertyAnnotation> getEntryPropertyAnnotations(Class<T> entryClass);
boolean destroy();
default void clear() {
throw new UnsupportedOperationException("Method not implemented.");
}
default void close() {
throw new UnsupportedOperationException("Method not implemented.");
}
default Query createNamedQuery(String name) {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> TypedQuery<T> createNamedQuery(String name, Class<T> resultClass) {
throw new UnsupportedOperationException("Method not implemented.");
}
default Query createNativeQuery(String sqlString) {
throw new UnsupportedOperationException("Method not implemented.");
}
default Query createNativeQuery(String sqlString, @SuppressWarnings("rawtypes") Class resultClass) {
throw new UnsupportedOperationException("Method not implemented.");
}
default Query createNativeQuery(String sqlString, String resultSetMapping) {
throw new UnsupportedOperationException("Method not implemented.");
}
default Query createQuery(String qlString) {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery) {
throw new UnsupportedOperationException("Method not implemented.");
}
default Query createQuery(CriteriaUpdate updateQuery) {
throw new UnsupportedOperationException("Method not implemented.");
}
default Query createQuery(CriteriaDelete deleteQuery) {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> TypedQuery<T> createQuery(String qlString, Class<T> resultClass) {
throw new UnsupportedOperationException("Method not implemented.");
}
default void flush() {
throw new UnsupportedOperationException("Method not implemented.");
}
default Object getDelegate() {
throw new UnsupportedOperationException("Method not implemented.");
}
default FlushModeType getFlushMode() {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> T getReference(Class<T> entryClass, Object primaryKey) {
throw new UnsupportedOperationException("Method not implemented.");
}
default EntityTransaction getTransaction() {
throw new UnsupportedOperationException("Method not implemented.");
}
default boolean isOpen() {
throw new UnsupportedOperationException("Method not implemented.");
}
default void joinTransaction() {
throw new UnsupportedOperationException("Method not implemented.");
}
default void lock(Object entry, LockModeType lockMode) {
throw new UnsupportedOperationException("Method not implemented.");
}
default void lock(Object entity, LockModeType lockMode,
Map<String, Object> properties) {
throw new UnsupportedOperationException("Method not implemented.");
}
default void refresh(Object entry) {
throw new UnsupportedOperationException("Method not implemented.");
}
default void refresh(Object entity, Map<String, Object> properties) {
throw new UnsupportedOperationException("Method not implemented.");
}
default void refresh(Object entity, LockModeType lockMode) {
throw new UnsupportedOperationException("Method not implemented.");
}
default void refresh(Object entity, LockModeType lockMode,
Map<String, Object> properties) {
throw new UnsupportedOperationException("Method not implemented.");
}
default void setFlushMode(FlushModeType flushMode) {
throw new UnsupportedOperationException("Method not implemented.");
}
default StoredProcedureQuery createNamedStoredProcedureQuery(String name) {
throw new UnsupportedOperationException("Method not implemented.");
}
default StoredProcedureQuery createStoredProcedureQuery(String procedureName) {
throw new UnsupportedOperationException("Method not implemented.");
}
default StoredProcedureQuery createStoredProcedureQuery(
String procedureName, Class... resultClasses) {
throw new UnsupportedOperationException("Method not implemented.");
}
default StoredProcedureQuery createStoredProcedureQuery(
String procedureName, String... resultSetMappings) {
throw new UnsupportedOperationException("Method not implemented.");
}
default boolean isJoinedToTransaction() {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> T unwrap(Class<T> cls) {
throw new UnsupportedOperationException("Method not implemented.");
}
default EntityManagerFactory getEntityManagerFactory() {
throw new UnsupportedOperationException("Method not implemented.");
}
default CriteriaBuilder getCriteriaBuilder() {
throw new UnsupportedOperationException("Method not implemented.");
}
default Metamodel getMetamodel() {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> EntityGraph<T> createEntityGraph(Class<T> rootType) {
throw new UnsupportedOperationException("Method not implemented.");
}
default EntityGraph<?> createEntityGraph(String graphName) {
throw new UnsupportedOperationException("Method not implemented.");
}
default EntityGraph<?> getEntityGraph(String graphName) {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {
throw new UnsupportedOperationException("Method not implemented.");
}
default Map<String, Object> getProperties() {
throw new UnsupportedOperationException("Method not implemented.");
}
default void setProperty(String propertyName, Object value) {
throw new UnsupportedOperationException("Method not implemented.");
}
default LockModeType getLockMode(Object entity) {
throw new UnsupportedOperationException("Method not implemented.");
}
default void detach(Object entity) {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> T find(Class<T> entityClass, Object primaryKey,
LockModeType lockMode) {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> T find(Class<T> entityClass, Object primaryKey,
Map<String, Object> properties) {
throw new UnsupportedOperationException("Method not implemented.");
}
default <T> T find(Class<T> entityClass, Object primaryKey,
LockModeType lockMode,
Map<String, Object> properties) {
throw new UnsupportedOperationException("Method not implemented.");
}
}