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