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