Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.krad.dao.proxy;
 
 
 
 
 public class PersistenceDaoProxy implements PersistenceDao {
 
 	
     public void setPersistenceDaoJpa(PersistenceDao persistenceDaoJpa) {
 		this. = persistenceDaoJpa;
 	}
 
 	public void setPersistenceDaoOjb(PersistenceDao persistenceDaoOjb) {
 		this. = persistenceDaoOjb;
 	}
 	
     private PersistenceDao getDao(Class clazz) {
         ModuleService moduleService = getKualiModuleService().getResponsibleModuleService(clazz);
         if (moduleService != null) {
             ModuleConfiguration moduleConfig = moduleService.getModuleConfiguration();
             String dataSourceName = "";
             EntityManager entityManager = null;
             if (moduleConfig != null) {
                 dataSourceName = moduleConfig.getDataSourceName();
                 entityManager = moduleConfig.getEntityManager();
             }
 
             if (StringUtils.isNotEmpty(dataSourceName)) {
                 if (.get(dataSourceName) != null) {
                     return .get(dataSourceName);
                 } else {
                 	if (OrmUtils.isJpaAnnotated(clazz) && (OrmUtils.isJpaEnabled() || OrmUtils.isJpaEnabled("rice.krad"))) {
                         //return the default JPA values since PersistenceDaoJPA delegates to the BusinessObjectService which should grab the correct datasource
                         .put(dataSourceName);
                         return ;
 
                     } else {
                         //using OJB
                         PersistenceDaoOjb persistDaoOjb = new PersistenceDaoOjb();
                         persistDaoOjb.setJcdAlias(dataSourceName);
                 
                         .put(dataSourceNamepersistDaoOjb);
                         return persistDaoOjb;
                     }
 
                 }
 
             }
         }
     	return (OrmUtils.isJpaAnnotated(clazz) && (OrmUtils.isJpaEnabled() || OrmUtils.isJpaEnabled("rice.krad"))) ?
     }

 
     public void clearCache() {
     	//if (OrmUtils.isJpaEnabled()) {
     	//} else {
     	//}
     }

    
    public Object resolveProxy(Object o) {
    	return getDao(ObjectUtils.materializeClassForProxiedObject(o)).resolveProxy(o);
    }

    
    public void retrieveAllReferences(Object o) {
    }

    
    public void retrieveReference(Object oString referenceName) {
    	getDao(ObjectUtils.materializeClassForProxiedObject(o)).retrieveReference(oreferenceName);
    }
 
    
Asks proper DAO implementation if the object is proxied

	public boolean isProxied(Object object) {
		if (object instanceof HibernateProxyreturn true;
		if (ProxyHelper.isProxy(object)) return true;
		return false;
	}
        if ( == null) {
             = KRADServiceLocatorWeb.getKualiModuleService();
        }
        return ;
    }
New to GrepCode? Check out our FAQ X