View Javadoc
1   /**
2    * Copyright 2004-2014 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.kpme.core.bo;
17  
18  import org.kuali.kpme.core.api.bo.HrKeyedBusinessObjectContract;
19  import org.kuali.kpme.core.groupkey.HrGroupKeyBo;
20  import org.kuali.kpme.core.institution.InstitutionBo;
21  import org.kuali.kpme.core.location.LocationBo;
22  import org.kuali.kpme.core.service.HrServiceLocator;
23  
24  public abstract class HrKeyedBusinessObject extends HrBusinessObject implements HrKeyedBusinessObjectContract {
25  
26  	private static final long serialVersionUID = -4676316817255855400L;
27  	
28  	protected String groupKeyCode;
29  	protected transient HrGroupKeyBo groupKey;
30  	
31  	//purely for lookup criteria
32      protected transient String locationId;
33  	protected transient String institutionCode;
34  	
35  	// purely for KNS lookup criteria
36  	protected transient InstitutionBo institutionObj;
37  	protected transient LocationBo locationObj;
38  	
39  	@Override
40  	public String getGroupKeyCode() {
41  		return groupKeyCode;
42  	}
43  
44  	public void setGroupKeyCode(String groupKeyCode) {
45  		this.groupKeyCode = groupKeyCode;
46  	}
47  	
48  	public String getLocationId() {
49  		return locationId;
50  	}
51  
52  	public void setLocationId(String locationId) {
53  		this.locationId = locationId;
54  	}
55  
56  	public String getInstitutionCode() {
57  		return institutionCode;
58  	}
59  
60  	public void setInstitutionCode(String institutionCode) {
61  		this.institutionCode = institutionCode;
62  	}
63  
64  	@Override
65  	public HrGroupKeyBo getGroupKey() {
66  		if (groupKey == null) {
67  			groupKey = HrGroupKeyBo.from(HrServiceLocator.getHrGroupKeyService().getHrGroupKey(getGroupKeyCode(), this.getEffectiveLocalDate()));
68  		}
69  		return groupKey;
70  	}
71  
72  	public void setGroupKey(HrGroupKeyBo groupKey) {
73  		this.groupKey = groupKey;
74  	}
75  	
76  	
77  	/**
78  	 * @return the locationObj
79  	 */
80  	public LocationBo getLocationObj() {
81  		HrGroupKeyBo grpKey = getGroupKey(); 
82  		if(grpKey != null) {
83  			return grpKey.getLocation();
84  		}
85  		return null;		
86  	}
87  
88  	
89  	/**
90  	 * @return the institutionObj
91  	 */
92  	public InstitutionBo getInstitutionObj() {
93  		HrGroupKeyBo grpKey = getGroupKey(); 
94  		if(grpKey != null) {
95  			return grpKey.getInstitution();
96  		}
97  		return null;
98  	}
99  	
100 	/**
101 	 * @return the institutionCode
102 	 */
103 	public String getInstitution() {
104 		HrGroupKeyBo grpKey = getGroupKey(); 
105 		if(grpKey != null) {
106 			return grpKey.getInstitutionCode();
107 		}
108 		return null;
109 	}
110 
111 
112 	/**
113 	 * @return the locationId
114 	 */
115 	public String getLocation() {
116 		HrGroupKeyBo grpKey = getGroupKey(); 
117 		if(grpKey != null) {
118 			return grpKey.getLocationId();
119 		}
120 		return null;
121 	}
122 
123 }