| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| PackagePersistableBusinessObjectClassExposer |
|
| 1.5;1.5 |
| 1 | /* | |
| 2 | * Copyright 2007 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 1.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.opensource.org/licenses/ecl1.php | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package org.kuali.rice.krad.app.persistence.jpa; | |
| 17 | ||
| 18 | //import org.reflections.Reflections; | |
| 19 | ||
| 20 | import java.util.HashSet; | |
| 21 | import java.util.List; | |
| 22 | import java.util.Set; | |
| 23 | ||
| 24 | /** | |
| 25 | * Abstract class which exposes as JPA managed classes all of the business objects in a given package | |
| 26 | * | |
| 27 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 28 | * | |
| 29 | */ | |
| 30 | 0 | public abstract class PackagePersistableBusinessObjectClassExposer implements |
| 31 | PersistableBusinessObjectClassExposer { | |
| 32 | ||
| 33 | /** | |
| 34 | * Exposes all of the JPA annotated entities in the package given by the getPackageNameToExpose method | |
| 35 | * to be managed by the PersistenceUnit calling this | |
| 36 | * | |
| 37 | * @see PersistableBusinessObjectClassExposer#exposePersistableBusinessObjectClassNames() | |
| 38 | */ | |
| 39 | @Override | |
| 40 | public Set<String> exposePersistableBusinessObjectClassNames() { | |
| 41 | 0 | Set<String> exposedClassNames = new HashSet<String>(); |
| 42 | ||
| 43 | 0 | for (String packageNameToExpose: getPackageNamesToExpose()) { |
| 44 | /*Reflections reflections = new Reflections(packageNameToExpose); | |
| 45 | final Set<Class<?>> entities = reflections.getTypesAnnotatedWith(Entity.class); | |
| 46 | for (Class<?> entityClass : entities) { | |
| 47 | exposedClassNames.add(entityClass.getName()); | |
| 48 | } | |
| 49 | | |
| 50 | final Set<Class<?>> mappedSuperclasses = reflections.getTypesAnnotatedWith(MappedSuperclass.class); | |
| 51 | for (Class<?> mappedSuperclassClass : mappedSuperclasses) { | |
| 52 | exposedClassNames.add(mappedSuperclassClass.getName()); | |
| 53 | } | |
| 54 | | |
| 55 | final Set<Class<?>> embeddables = reflections.getTypesAnnotatedWith(Embeddable.class); | |
| 56 | for (Class<?> embeddableClass : embeddables) { | |
| 57 | // may this loop never be entered | |
| 58 | exposedClassNames.add(embeddableClass.getName()); | |
| 59 | }*/ | |
| 60 | } | |
| 61 | 0 | return exposedClassNames; |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * @return the name of the package to expose all JPA annotated entities in | |
| 66 | */ | |
| 67 | public abstract List<String> getPackageNamesToExpose(); | |
| 68 | ||
| 69 | } |