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.util.Iterator;
19 import java.util.List;
20
21 import org.apache.log4j.Logger;
22 import org.kuali.rice.krad.bo.PersistableBusinessObject;
23 import org.kuali.rice.krad.service.PersistenceService;
24 import org.springframework.transaction.annotation.Transactional;
25
26
27
28
29
30
31
32 @Transactional
33 public class PersistenceServiceImpl extends PersistenceServiceImplBase implements PersistenceService {
34
35 private static Logger LOG = Logger.getLogger(PersistenceServiceImpl.class);
36
37 private PersistenceService persistenceServiceJpa;
38
39 private PersistenceService persistenceServiceOjb;
40
41 public void setPersistenceServiceJpa(PersistenceService persistenceServiceJpa) {
42 this.persistenceServiceJpa = persistenceServiceJpa;
43 }
44
45 public void setPersistenceServiceOjb(PersistenceService persistenceServiceOjb) {
46 this.persistenceServiceOjb = persistenceServiceOjb;
47 }
48
49 private PersistenceService getService(Class clazz) {
50 return (isJpaEnabledForKradClass(clazz)) ?
51 persistenceServiceJpa : persistenceServiceOjb;
52 }
53
54
55 public void clearCache() {
56 throw new UnsupportedOperationException("This should be called directly from the OJB Impl if needed.");
57 }
58
59
60 public void loadRepositoryDescriptor(String ojbRepositoryFilePath) {
61 throw new UnsupportedOperationException("This should be called directly from the OJB Impl if needed.");
62 }
63
64 public Object resolveProxy(Object o) {
65 return getService(o.getClass()).resolveProxy(o);
66 }
67
68
69
70
71 public void retrieveNonKeyFields(Object persistableObject) {
72 getService(persistableObject.getClass()).retrieveNonKeyFields(persistableObject);
73 }
74
75
76
77
78
79 public void retrieveReferenceObject(Object persistableObject, String referenceObjectName) {
80 getService(persistableObject.getClass()).retrieveReferenceObject(persistableObject, referenceObjectName);
81 }
82
83
84
85
86
87 public void retrieveReferenceObjects(Object persistableObject, List referenceObjectNames) {
88 getService(persistableObject.getClass()).retrieveReferenceObjects(persistableObject, referenceObjectNames);
89 }
90
91
92
93
94
95 public void retrieveReferenceObjects(List persistableObjects, List referenceObjectNames) {
96 if (persistableObjects == null) {
97 throw new IllegalArgumentException("invalid (null) persistableObjects");
98 }
99 if (persistableObjects.isEmpty()) {
100 throw new IllegalArgumentException("invalid (empty) persistableObjects");
101 }
102 if (referenceObjectNames == null) {
103 throw new IllegalArgumentException("invalid (null) referenceObjectNames");
104 }
105 if (referenceObjectNames.isEmpty()) {
106 throw new IllegalArgumentException("invalid (empty) referenceObjectNames");
107 }
108
109 for (Iterator i = persistableObjects.iterator(); i.hasNext();) {
110 Object persistableObject = i.next();
111 retrieveReferenceObjects(persistableObject, referenceObjectNames);
112 }
113 }
114
115
116
117
118 public String getFlattenedPrimaryKeyFieldValues(Object persistableObject) {
119 return getService(persistableObject.getClass()).getFlattenedPrimaryKeyFieldValues(persistableObject);
120 }
121
122
123
124
125
126
127
128
129
130
131
132
133 public void linkObjects(Object persistableObject) {
134 getService(persistableObject.getClass()).linkObjects(persistableObject);
135 }
136
137
138
139
140
141
142 public boolean allForeignKeyValuesPopulatedForReference(PersistableBusinessObject bo, String referenceName) {
143 return getService(bo.getClass()).allForeignKeyValuesPopulatedForReference(bo, referenceName);
144 }
145
146
147
148
149
150 public void refreshAllNonUpdatingReferences(PersistableBusinessObject bo) {
151 getService(bo.getClass()).refreshAllNonUpdatingReferences(bo);
152 }
153
154
155
156
157
158
159 public boolean isProxied(Object bo) {
160 return getService(bo.getClass()).isProxied(bo);
161 }
162
163 }