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;
 
 
 import java.util.List;
 import java.util.Map;
 
 public class DocumentDaoProxy implements DocumentDao {
 
     private DocumentDao documentDaoJpa;
     private DocumentDao documentDaoOjb;
 
     private static KualiModuleService kualiModuleService;
     private static Map<StringDocumentDaodocumentDaoValues = new ConcurrentHashMap<StringDocumentDao>();
 
     private DocumentDao getDao(Class<? extends Documentclazz) {
     	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);
                 }
                 if (OrmUtils.isJpaAnnotated(clazz) && (OrmUtils.isJpaEnabled() || OrmUtils.isJpaEnabled("rice.krad"))) {
                 	//using JPA
                 	if (entityManager != null) {
                 		// we set the entity manager directly in the constructor
                 		DocumentDaoJpa documentDaoJpaInstance =
                 			new DocumentDaoJpa(entityManagerthis..getBusinessObjectDao(),
                 					this..getDocumentAdHocService());
 
                 		.put(dataSourceNamedocumentDaoJpaInstance);
                 		return documentDaoJpaInstance;
                 	}
                 	throw new ConfigurationException("EntityManager is null. EntityManager must be set in the Module Configuration bean in the appropriate spring beans xml. (see nested exception for details).");
                 }
                 //using OJB
                 DocumentDaoOjb documentDaoOjbInstance =
                 	new DocumentDaoOjb(
                 			this..getBusinessObjectDao(),
                 			this..getDocumentAdHocService());
 
                 // set the data source alias
                 documentDaoOjbInstance.setJcdAlias(dataSourceName);
 
                 .put(dataSourceNamedocumentDaoOjbInstance);
                 return documentDaoOjbInstance;
 
                 }
 
         }
         return (OrmUtils.isJpaAnnotated(clazz) && OrmUtils.isJpaEnabled()) ?  : ;
     }
    
    
 
     @Override
 	public <T extends Document> T save(T document) {
 		return getDao(document.getClass()).save(document);
 	}
    
    @Override
	public <T extends Document> T findByDocumentHeaderId(Class<T> clazzString id) {
		return getDao(clazz).findByDocumentHeaderId(clazzid);
	}

    @Override
	public <T extends DocumentList<T> findByDocumentHeaderIds(Class<T> clazzList<StringidList) {
		return getDao(clazz).findByDocumentHeaderIds(clazzidList);
	}

    @Override
		if (OrmUtils.isJpaEnabled()) {
		}
	}

    @Override
		if (OrmUtils.isJpaEnabled()) {
		}
    }
	public void setDocumentDaoJpa(DocumentDao documentDaoJpa) {
		this. = documentDaoJpa;
	}
	public void setDocumentDaoOjb(DocumentDao documentDaoOjb) {
		this. = documentDaoOjb;
	}
    private synchronized static KualiModuleService getKualiModuleService() {
        if ( == null) {
             = KRADServiceLocatorWeb.getKualiModuleService();
        }
        return ;
    }
New to GrepCode? Check out our FAQ X