1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service.impl;
17
18 import java.lang.reflect.InvocationTargetException;
19 import java.util.Collection;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.kuali.rice.core.api.uif.RemotableQuickFinder;
24 import org.kuali.rice.krad.datadictionary.RelationshipDefinition;
25 import org.kuali.rice.krad.document.Document;
26 import org.kuali.rice.krad.service.LegacyDataAdapter;
27 import org.kuali.rice.krad.service.LegacyDataAdapter;
28 import org.kuali.rice.krad.util.ForeignKeyFieldsPopulationState;
29 import org.kuali.rice.krad.util.LegacyUtils;
30
31
32
33
34
35
36 @Deprecated
37 public class LegacyDataAdapterImpl implements LegacyDataAdapter {
38
39 private LegacyDataAdapter kradLegacyDataAdapter;
40 private LegacyDataAdapter knsLegacyDataAdapter;
41
42 @Override
43 public <T> T save(T dataObject) {
44 return selectAdapter(dataObject).save(dataObject);
45 }
46
47 @Override
48 public <T> T linkAndSave(T dataObject) {
49 return selectAdapter(dataObject).linkAndSave(dataObject);
50 }
51
52 @Override
53 public <T> T saveDocument(T document) {
54 return selectAdapter(document).saveDocument(document);
55 }
56
57 @Override
58 public <T> T findByPrimaryKey(Class<T> clazz, Map<String, ?> primaryKeys) {
59 return selectAdapter(clazz).findByPrimaryKey(clazz, primaryKeys);
60 }
61
62 @Override
63 public <T> T findBySinglePrimaryKey(Class<T> clazz, Object primaryKey) {
64 return selectAdapter(clazz).findBySinglePrimaryKey(clazz, primaryKey);
65 }
66
67 @Override
68 public void delete(Object dataObject) {
69 selectAdapter(dataObject).delete(dataObject);
70 }
71
72 @Override
73 public void deleteMatching(Class<?> type, Map<String, ?> fieldValues) {
74 selectAdapter(type).deleteMatching(type, fieldValues);
75 }
76
77 @Override
78 public <T> T retrieve(T dataObject) {
79 return selectAdapter(dataObject).retrieve(dataObject);
80 }
81
82 @Override
83 public <T> Collection<T> findAll(Class<T> clazz) {
84 return selectAdapter(clazz).findAll(clazz);
85 }
86
87 @Override
88 public <T> Collection<T> findMatching(Class<T> clazz, Map<String, ?> fieldValues) {
89 return selectAdapter(clazz).findMatching(clazz, fieldValues);
90 }
91
92 @Override
93 public <T> Collection<T> findMatchingOrderBy(Class<T> clazz, Map<String, ?> fieldValues, String sortField,
94 boolean sortAscending) {
95 return selectAdapter(clazz).findMatchingOrderBy(clazz, fieldValues, sortField, sortAscending);
96 }
97
98 @Override
99 public Map<String, ?> getPrimaryKeyFieldValues(Object dataObject) {
100 return selectAdapter(dataObject).getPrimaryKeyFieldValues(dataObject);
101 }
102
103 @Override
104 public void retrieveNonKeyFields(Object persistableObject) {
105 selectAdapter(persistableObject).retrieveNonKeyFields(persistableObject);
106 }
107
108 @Override
109 public void retrieveReferenceObject(Object persistableObject, String referenceObjectName) {
110 selectAdapter(persistableObject).retrieveReferenceObject(persistableObject, referenceObjectName);
111 }
112
113 @Override
114 public void refreshAllNonUpdatingReferences(Object persistableObject) {
115 selectAdapter(persistableObject).refreshAllNonUpdatingReferences(persistableObject);
116 }
117
118 @Override
119 public boolean isProxied(Object object) {
120 return selectAdapter(object).isProxied(object);
121 }
122
123 @Override
124 public Object resolveProxy(Object object) {
125 return selectAdapter(object).resolveProxy(object);
126 }
127
128
129
130 @Override
131 public <T> Collection<T> findCollectionBySearchHelper(Class<T> dataObjectClass, Map<String, String> formProperties,
132 boolean unbounded, boolean allPrimaryKeyValuesPresentAndNotWildcard, Integer searchResultsLimit) {
133 return selectAdapter(dataObjectClass).findCollectionBySearchHelper(dataObjectClass, formProperties, unbounded,
134 allPrimaryKeyValuesPresentAndNotWildcard, searchResultsLimit);
135 }
136
137 @Override
138 public <T> Collection<T> findCollectionBySearchHelper(Class<T> dataObjectClass, Map<String, String> formProperties,
139 List<String> wildcardAsLiteralPropertyNames, boolean unbounded,
140 boolean allPrimaryKeyValuesPresentAndNotWildcard, Integer searchResultsLimit) {
141 return selectAdapter(dataObjectClass).findCollectionBySearchHelper(dataObjectClass, formProperties,
142 wildcardAsLiteralPropertyNames, unbounded, allPrimaryKeyValuesPresentAndNotWildcard,
143 searchResultsLimit);
144 }
145
146 @Override
147 public <T> T findObjectBySearch(Class<T> type, Map<String, String> formProps) {
148 return selectAdapter(type).findObjectBySearch(type, formProps);
149 }
150
151 @Override
152 public boolean allPrimaryKeyValuesPresentAndNotWildcard(Class<?> boClass, Map<String, String> formProps) {
153 return selectAdapter(boClass).allPrimaryKeyValuesPresentAndNotWildcard(boClass, formProps);
154 }
155
156 @Override
157 public List<String> listPrimaryKeyFieldNames(Class<?> type) {
158 return selectAdapter(type).listPrimaryKeyFieldNames(type);
159 }
160
161 @Override
162 public Class<?> determineCollectionObjectType(Class<?> containingType, String collectionPropertyName) {
163 return selectAdapter(containingType).determineCollectionObjectType(containingType, collectionPropertyName);
164 }
165
166 @Override
167 public boolean hasReference(Class<?> boClass, String referenceName) {
168 return selectAdapter(boClass).hasReference(boClass, referenceName);
169 }
170
171 @Override
172 public boolean hasCollection(Class<?> boClass, String collectionName) {
173 return selectAdapter(boClass).hasCollection(boClass, collectionName);
174 }
175
176 @Override
177 public boolean isExtensionAttribute(Class<?> boClass, String attributePropertyName, Class<?> propertyType) {
178 return selectAdapter(boClass).isExtensionAttribute(boClass, attributePropertyName, propertyType);
179 }
180
181 @Override
182 public Class<?> getExtensionAttributeClass(Class<?> boClass, String attributePropertyName) {
183 return selectAdapter(boClass).getExtensionAttributeClass(boClass, attributePropertyName);
184 }
185
186 @Override
187 public Map<String, ?> getPrimaryKeyFieldValuesDOMDS(Object dataObject) {
188 return selectAdapter(dataObject).getPrimaryKeyFieldValuesDOMDS(dataObject);
189 }
190
191 @Override
192 public boolean equalsByPrimaryKeys(Object do1, Object do2) {
193 return selectAdapter(do1).equalsByPrimaryKeys(do1, do2);
194 }
195
196 @Override
197 public void materializeAllSubObjects(Object object) {
198 selectAdapter(object).materializeAllSubObjects(object);
199 }
200
201 @Override
202 public Class<?> getPropertyType(Object object, String propertyName) {
203 return selectAdapter(object).getPropertyType(object, propertyName);
204 }
205
206 @Override
207 public Object getExtension(
208 Class<?> businessObjectClass) throws InstantiationException, IllegalAccessException {
209 return selectAdapter(businessObjectClass).getExtension(businessObjectClass);
210 }
211
212 @Override
213 public void refreshReferenceObject(Object businessObject, String referenceObjectName) {
214 selectAdapter(businessObject).refreshReferenceObject(businessObject, referenceObjectName);
215 }
216
217 @Override
218 public boolean isLockable(Object object) {
219 return selectAdapter(object).isLockable(object);
220 }
221
222 @Override
223 public void verifyVersionNumber(Object dataObject) {
224 selectAdapter(dataObject).verifyVersionNumber(dataObject);
225 }
226
227 @Override
228 public RemotableQuickFinder.Builder createQuickFinder(Class<?> containingClass, String attributeName) {
229 return selectAdapter(containingClass).createQuickFinder(containingClass, attributeName);
230 }
231
232 @Override
233 public boolean isReferenceUpdatable(Class<?> type, String referenceName) {
234 return selectAdapter(type).isReferenceUpdatable(type, referenceName);
235 }
236
237 @Override
238 @SuppressWarnings("rawtypes")
239 public Map<String, Class> listReferenceObjectFields(Class<?> type) {
240 return selectAdapter(type).listReferenceObjectFields(type);
241 }
242
243 @Override
244 public boolean isCollectionUpdatable(Class<?> type, String collectionName) {
245 return selectAdapter(type).isCollectionUpdatable(type, collectionName);
246 }
247
248 @Override
249 @SuppressWarnings("rawtypes")
250 public Map<String, Class> listCollectionObjectTypes(Class<?> type) {
251 return selectAdapter(type).listCollectionObjectTypes(type);
252 }
253
254 @Override
255 public Object getReferenceIfExists(Object bo, String referenceName) {
256 return selectAdapter(bo).getReferenceIfExists(bo, referenceName);
257 }
258
259 @Override
260 public boolean allForeignKeyValuesPopulatedForReference(Object bo, String referenceName) {
261 return selectAdapter(bo).allForeignKeyValuesPopulatedForReference(bo, referenceName);
262 }
263
264 @Override
265 public RelationshipDefinition getDictionaryRelationship(Class<?> c, String attributeName) {
266 return selectAdapter(c).getDictionaryRelationship(c, attributeName);
267 }
268
269 @Override
270 public String getTitleAttribute(Class<?> dataObjectClass) {
271 return selectAdapter(dataObjectClass).getTitleAttribute(dataObjectClass);
272 }
273
274 @Override
275 public boolean areNotesSupported(Class<?> dataObjectClass) {
276 return selectAdapter(dataObjectClass).areNotesSupported(dataObjectClass);
277 }
278
279 @Override
280 public String getDataObjectIdentifierString(Object dataObject) {
281 return selectAdapter(dataObject).getDataObjectIdentifierString(dataObject);
282 }
283
284 @Override
285 public Class<?> getInquiryObjectClassIfNotTitle(Object dataObject, String propertyName) {
286 return selectAdapter(dataObject).getInquiryObjectClassIfNotTitle(dataObject, propertyName);
287 }
288
289 @Override
290 public Map<String, String> getInquiryParameters(Object dataObject, List<String> keys, String propertyName) {
291 return selectAdapter(dataObject).getInquiryParameters(dataObject, keys, propertyName);
292 }
293
294 @Override
295 public boolean hasLocalLookup(Class<?> dataObjectClass) {
296 return selectAdapter(dataObjectClass).hasLocalLookup(dataObjectClass);
297 }
298
299 @Override
300 public boolean hasLocalInquiry(Class<?> dataObjectClass) {
301 return selectAdapter(dataObjectClass).hasLocalInquiry(dataObjectClass);
302 }
303
304 @Override
305 public org.kuali.rice.krad.bo.DataObjectRelationship getDataObjectRelationship(Object dataObject,
306 Class<?> dataObjectClass, String attributeName, String attributePrefix, boolean keysOnly,
307 boolean supportsLookup, boolean supportsInquiry) {
308 return selectAdapter(dataObjectClass).getDataObjectRelationship(dataObject, dataObjectClass, attributeName,
309 attributePrefix, keysOnly, supportsLookup, supportsInquiry);
310 }
311
312 @Override
313 public boolean isPersistable(Class<?> dataObjectClass) {
314 return selectAdapter(dataObjectClass).isPersistable(dataObjectClass);
315 }
316
317 @Override
318 public ForeignKeyFieldsPopulationState getForeignKeyFieldsPopulationState(Object dataObject, String referenceName) {
319 return selectAdapter(dataObject).getForeignKeyFieldsPopulationState(dataObject, referenceName);
320 }
321
322 @Override
323 public Map<String, String> getForeignKeysForReference(Class<?> clazz, String attributeName) {
324 return selectAdapter(clazz).getForeignKeysForReference(clazz, attributeName);
325 }
326
327 @Override
328 public boolean hasPrimaryKeyFieldValues(Object dataObject) {
329 return selectAdapter(dataObject).hasPrimaryKeyFieldValues(dataObject);
330 }
331
332 @Override
333 public void setObjectPropertyDeep(Object bo, String propertyName, Class type,
334 Object propertyValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
335 selectAdapter(bo).setObjectPropertyDeep(bo, propertyName, type, propertyValue);
336 }
337
338 @Override
339 @SuppressWarnings("rawtypes")
340 public Class materializeClassForProxiedObject(Object object) {
341 return selectAdapter(object).materializeClassForProxiedObject(object);
342 }
343
344 @Override
345 public Object getNestedValue(Object bo, String fieldName) {
346 return selectAdapter(bo).getNestedValue(bo, fieldName);
347 }
348
349 @Override
350 @SuppressWarnings("rawtypes")
351 public Object createNewObjectFromClass(Class clazz) {
352 return selectAdapter(clazz).createNewObjectFromClass(clazz);
353 }
354
355 @Override
356 public boolean isNull(Object object) {
357 return selectAdapter(object).isNull(object);
358 }
359
360 @Override
361 public void setObjectProperty(Object bo, String propertyName, Class propertyType,
362 Object propertyValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
363 selectAdapter(bo).setObjectProperty(bo, propertyName, propertyType, propertyValue);
364 }
365
366 @Override
367 public <T extends Document> T findByDocumentHeaderId(Class<T> documentClass, String id) {
368 return selectAdapter(documentClass).findByDocumentHeaderId(documentClass, id);
369 }
370
371 @Override
372 public <T extends Document> List<T> findByDocumentHeaderIds(Class<T> documentClass, List<String> ids) {
373 return selectAdapter(documentClass).findByDocumentHeaderIds(documentClass, ids);
374 }
375
376 protected LegacyDataAdapter selectAdapter(Object dataObject) {
377 if (LegacyUtils.isKnsEnabled() && (dataObject instanceof Class) && LegacyUtils.useLegacy(
378 (Class<?>) dataObject)) {
379 return getKnsLegacyDataAdapter();
380 } else if (LegacyUtils.isKnsEnabled() && !(dataObject instanceof Class) && LegacyUtils.useLegacyForObject(
381 dataObject)) {
382 return getKnsLegacyDataAdapter();
383 } else {
384 return getKradLegacyDataAdapter();
385 }
386
387 }
388
389 public LegacyDataAdapter getKradLegacyDataAdapter() {
390 return kradLegacyDataAdapter;
391 }
392
393 public void setKradLegacyDataAdapter(LegacyDataAdapter kradLegacyDataAdapter) {
394 this.kradLegacyDataAdapter = kradLegacyDataAdapter;
395 }
396
397 public LegacyDataAdapter getKnsLegacyDataAdapter() {
398 return knsLegacyDataAdapter;
399 }
400
401 public void setKnsLegacyDataAdapter(LegacyDataAdapter knsLegacyDataAdapter) {
402 this.knsLegacyDataAdapter = knsLegacyDataAdapter;
403 }
404
405 }
406