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.HashMap;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.kuali.rice.krad.bo.DataObjectRelationship;
23 import org.kuali.rice.krad.bo.PersistableBusinessObject;
24 import org.kuali.rice.krad.service.PersistenceStructureService;
25 import org.kuali.rice.krad.util.ForeignKeyFieldsPopulationState;
26
27
28
29
30
31
32
33 public class PersistenceStructureServiceImpl extends PersistenceServiceImplBase implements PersistenceStructureService {
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 public static Map<Class, Class> referenceConversionMap = new HashMap<Class, Class>();
51
52 private PersistenceStructureService persistenceStructureServiceJpa;
53 private PersistenceStructureService persistenceStructureServiceOjb;
54
55 public void setPersistenceStructureServiceJpa(PersistenceStructureService persistenceStructureServiceJpa) {
56 this.persistenceStructureServiceJpa = persistenceStructureServiceJpa;
57 }
58
59 public void setPersistenceStructureServiceOjb(PersistenceStructureService persistenceStructureServiceOjb) {
60 this.persistenceStructureServiceOjb = persistenceStructureServiceOjb;
61 }
62
63 private PersistenceStructureService getService(Class clazz) {
64 return (isJpaEnabledForKradClass(clazz)) ?
65 persistenceStructureServiceJpa : persistenceStructureServiceOjb;
66 }
67
68
69
70
71
72 public boolean isPersistable(Class clazz) {
73 return getService(clazz).isPersistable(clazz);
74 }
75
76
77
78
79
80 public List getPrimaryKeys(Class clazz) {
81 return getService(clazz).getPrimaryKeys(clazz);
82 }
83
84
85
86
87
88 public List listFieldNames(Class clazz) {
89 return getService(clazz).listFieldNames(clazz);
90 }
91
92
93
94
95
96 public Object clearPrimaryKeyFields(Object persistableObject) {
97 return getService(persistableObject.getClass()).clearPrimaryKeyFields(persistableObject);
98 }
99
100
101
102
103
104
105 public List listPersistableSubclasses(Class superclazz) {
106 return getService(superclazz).listPersistableSubclasses(superclazz);
107 }
108
109
110
111
112
113
114 public Map<String, DataObjectRelationship> getRelationshipMetadata(Class persistableClass, String attributeName, String attributePrefix) {
115 return getService(persistableClass).getRelationshipMetadata(persistableClass, attributeName, attributePrefix);
116 }
117
118
119
120 public Map<String, DataObjectRelationship> getRelationshipMetadata(Class persistableClass, String attributeName) {
121 return getService(persistableClass).getRelationshipMetadata(persistableClass, attributeName);
122 }
123
124
125
126
127
128
129 public String getForeignKeyFieldName(Class persistableObjectClass, String attributeName, String pkName) {
130 return getService(persistableObjectClass).getForeignKeyFieldName(persistableObjectClass, attributeName, pkName);
131 }
132
133
134
135
136
137
138 public Map getReferencesForForeignKey(Class persistableObjectClass, String attributeName) {
139 return getService(persistableObjectClass).getReferencesForForeignKey(persistableObjectClass, attributeName);
140 }
141
142
143
144
145
146 public Map getForeignKeysForReference(Class clazz, String attributeName) {
147 return getService(clazz).getForeignKeysForReference(clazz, attributeName);
148 }
149
150
151 public Map<String, String> getInverseForeignKeysForCollection(Class boClass, String collectionName) {
152 return getService(boClass).getInverseForeignKeysForCollection(boClass, collectionName);
153 }
154
155
156
157
158
159 public Map getNestedForeignKeyMap(Class persistableObjectClass) {
160 return getService(persistableObjectClass).getNestedForeignKeyMap(persistableObjectClass);
161 }
162
163
164
165
166 public boolean hasPrimaryKeyFieldValues(Object persistableObject) {
167 return getService(persistableObject.getClass()).hasPrimaryKeyFieldValues(persistableObject);
168 }
169
170
171
172
173
174 public ForeignKeyFieldsPopulationState getForeignKeyFieldsPopulationState(PersistableBusinessObject bo, String referenceName) {
175 return getService(bo.getClass()).getForeignKeyFieldsPopulationState(bo, referenceName);
176 }
177
178
179
180
181
182 public Map<String, Class> listReferenceObjectFields(Class boClass) {
183 return getService(boClass).listReferenceObjectFields(boClass);
184 }
185
186
187 public Map<String, Class> listCollectionObjectTypes(Class boClass) {
188 return getService(boClass).listCollectionObjectTypes(boClass);
189 }
190
191 public Map<String, Class> listCollectionObjectTypes(PersistableBusinessObject bo) {
192 return getService(bo.getClass()).listCollectionObjectTypes(bo);
193 }
194
195
196
197
198 public Map<String, Class> listReferenceObjectFields(PersistableBusinessObject bo) {
199 return getService(bo.getClass()).listReferenceObjectFields(bo);
200 }
201
202
203 public boolean isReferenceUpdatable(Class boClass, String referenceName) {
204 return getService(boClass).isReferenceUpdatable(boClass, referenceName);
205 }
206
207
208 public boolean isCollectionUpdatable(Class boClass, String collectionName) {
209 return getService(boClass).isCollectionUpdatable(boClass, collectionName);
210 }
211
212
213 public boolean hasCollection(Class boClass, String collectionName) {
214 return getService(boClass).hasCollection(boClass, collectionName);
215 }
216
217
218 public boolean hasReference(Class boClass, String referenceName) {
219 return getService(boClass).hasReference(boClass, referenceName);
220 }
221
222
223
224
225
226
227 public String getTableName(
228 Class<? extends PersistableBusinessObject> boClass) {
229 return getService(boClass).getTableName(boClass);
230 }
231
232
233 }