001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.app.persistence.jpa;
017
018//import org.reflections.Reflections;
019
020import java.util.HashSet;
021import java.util.List;
022import java.util.Set;
023
024/**
025 * Abstract class which exposes as JPA managed classes all of the business objects in a given package 
026 * 
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 *
029 */
030public abstract class PackagePersistableBusinessObjectClassExposer implements
031                PersistableBusinessObjectClassExposer {
032
033        /**
034         * Exposes all of the JPA annotated entities in the package given by the getPackageNameToExpose method
035         * to be managed by the PersistenceUnit calling this
036         * 
037         * @see PersistableBusinessObjectClassExposer#exposePersistableBusinessObjectClassNames()
038         */
039        @Override
040        public Set<String> exposePersistableBusinessObjectClassNames() {
041                Set<String> exposedClassNames = new HashSet<String>();
042                
043                for (String packageNameToExpose: getPackageNamesToExpose()) {
044                        /*Reflections reflections = new Reflections(packageNameToExpose);
045                        final Set<Class<?>> entities = reflections.getTypesAnnotatedWith(Entity.class);
046                        for (Class<?> entityClass : entities) {
047                                exposedClassNames.add(entityClass.getName());
048                        }
049                        
050                        final Set<Class<?>> mappedSuperclasses = reflections.getTypesAnnotatedWith(MappedSuperclass.class);
051                        for (Class<?> mappedSuperclassClass : mappedSuperclasses) {
052                                exposedClassNames.add(mappedSuperclassClass.getName());
053                        }
054                        
055                        final Set<Class<?>> embeddables = reflections.getTypesAnnotatedWith(Embeddable.class);
056                        for (Class<?> embeddableClass : embeddables) {
057                                // may this loop never be entered
058                                exposedClassNames.add(embeddableClass.getName());
059                        }*/
060                }
061                return exposedClassNames;
062        }
063        
064        /**
065         * @return the name of the package to expose all JPA annotated entities in
066         */
067        public abstract List<String> getPackageNamesToExpose();
068
069}