View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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.dao.proxy;
17  
18  import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
19  import org.kuali.rice.krad.bo.DocumentHeader;
20  import org.kuali.rice.krad.dao.DocumentHeaderDao;
21  
22  public class DocumentHeaderDaoProxy implements DocumentHeaderDao {
23      private DocumentHeaderDao documentHeaderDaoJpa;
24      private DocumentHeaderDao documentHeaderDaoOjb;
25  	
26      private DocumentHeaderDao getDao(Class clazz) {
27      	final String TMP_NM = clazz.getName();
28  		final int START_INDEX = TMP_NM.indexOf('.', TMP_NM.indexOf('.') + 1) + 1;
29      	return (OrmUtils.isJpaAnnotated(clazz) && (OrmUtils.isJpaEnabled() || OrmUtils.isJpaEnabled("rice.krad"))) ?
30  						documentHeaderDaoJpa : documentHeaderDaoOjb; 
31      }
32      
33      public DocumentHeader getByDocumentHeaderId(String id) {    	
34      	return getDao(DocumentHeader.class).getByDocumentHeaderId(id);
35      }
36  
37  	public Class getDocumentHeaderBaseClass() {
38  		return getDao(DocumentHeader.class).getDocumentHeaderBaseClass();
39  	}
40  
41  	public void setDocumentHeaderDaoJpa(DocumentHeaderDao documentHeaderDaoJpa) {
42  		this.documentHeaderDaoJpa = documentHeaderDaoJpa;
43  	}
44  
45  	public void setDocumentHeaderDaoOjb(DocumentHeaderDao documentHeaderDaoOjb) {
46  		this.documentHeaderDaoOjb = documentHeaderDaoOjb;
47  	}
48  
49  }