1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.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.core.util.OrmUtils; |
23 | |
import org.kuali.rice.kns.bo.PersistableBusinessObject; |
24 | |
import org.kuali.rice.kns.service.PersistenceService; |
25 | |
import org.springframework.transaction.annotation.Transactional; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
@Transactional |
34 | 0 | public class PersistenceServiceImpl extends PersistenceServiceImplBase implements PersistenceService { |
35 | |
|
36 | 0 | private static Logger LOG = Logger.getLogger(PersistenceServiceImpl.class); |
37 | |
|
38 | |
private PersistenceService persistenceServiceJpa; |
39 | |
|
40 | |
private PersistenceService persistenceServiceOjb; |
41 | |
|
42 | |
public void setPersistenceServiceJpa(PersistenceService persistenceServiceJpa) { |
43 | 0 | this.persistenceServiceJpa = persistenceServiceJpa; |
44 | 0 | } |
45 | |
|
46 | |
public void setPersistenceServiceOjb(PersistenceService persistenceServiceOjb) { |
47 | 0 | this.persistenceServiceOjb = persistenceServiceOjb; |
48 | 0 | } |
49 | |
|
50 | |
private PersistenceService getService(Class clazz) { |
51 | 0 | return (OrmUtils.isJpaAnnotated(clazz) && OrmUtils.isJpaEnabled()) ? persistenceServiceJpa : persistenceServiceOjb; |
52 | |
} |
53 | |
|
54 | |
|
55 | |
public void clearCache() { |
56 | 0 | throw new UnsupportedOperationException("This should be called directly from the OJB Impl if needed."); |
57 | |
} |
58 | |
|
59 | |
|
60 | |
public void loadRepositoryDescriptor(String ojbRepositoryFilePath) { |
61 | 0 | throw new UnsupportedOperationException("This should be called directly from the OJB Impl if needed."); |
62 | |
} |
63 | |
|
64 | |
public Object resolveProxy(Object o) { |
65 | 0 | return getService(o.getClass()).resolveProxy(o); |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
public void retrieveNonKeyFields(Object persistableObject) { |
72 | 0 | getService(persistableObject.getClass()).retrieveNonKeyFields(persistableObject); |
73 | 0 | } |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
public void retrieveReferenceObject(Object persistableObject, String referenceObjectName) { |
80 | 0 | getService(persistableObject.getClass()).retrieveReferenceObject(persistableObject, referenceObjectName); |
81 | 0 | } |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
public void retrieveReferenceObjects(Object persistableObject, List referenceObjectNames) { |
88 | 0 | getService(persistableObject.getClass()).retrieveReferenceObjects(persistableObject, referenceObjectNames); |
89 | 0 | } |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
public void retrieveReferenceObjects(List persistableObjects, List referenceObjectNames) { |
96 | 0 | if (persistableObjects == null) { |
97 | 0 | throw new IllegalArgumentException("invalid (null) persistableObjects"); |
98 | |
} |
99 | 0 | if (persistableObjects.isEmpty()) { |
100 | 0 | throw new IllegalArgumentException("invalid (empty) persistableObjects"); |
101 | |
} |
102 | 0 | if (referenceObjectNames == null) { |
103 | 0 | throw new IllegalArgumentException("invalid (null) referenceObjectNames"); |
104 | |
} |
105 | 0 | if (referenceObjectNames.isEmpty()) { |
106 | 0 | throw new IllegalArgumentException("invalid (empty) referenceObjectNames"); |
107 | |
} |
108 | |
|
109 | 0 | for (Iterator i = persistableObjects.iterator(); i.hasNext();) { |
110 | 0 | Object persistableObject = i.next(); |
111 | 0 | retrieveReferenceObjects(persistableObject, referenceObjectNames); |
112 | 0 | } |
113 | 0 | } |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
public String getFlattenedPrimaryKeyFieldValues(Object persistableObject) { |
119 | 0 | 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 | 0 | getService(persistableObject.getClass()).linkObjects(persistableObject); |
135 | 0 | } |
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
public boolean allForeignKeyValuesPopulatedForReference(PersistableBusinessObject bo, String referenceName) { |
143 | 0 | return getService(bo.getClass()).allForeignKeyValuesPopulatedForReference(bo, referenceName); |
144 | |
} |
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
public void refreshAllNonUpdatingReferences(PersistableBusinessObject bo) { |
151 | 0 | getService(bo.getClass()).refreshAllNonUpdatingReferences(bo); |
152 | 0 | } |
153 | |
|
154 | |
} |