001 /** 002 * Copyright 2004-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.lm.employeeoverride; 017 018 import java.util.LinkedHashMap; 019 020 import org.apache.commons.lang.StringUtils; 021 import org.kuali.hr.lm.accrual.AccrualCategory; 022 import org.kuali.hr.time.HrBusinessObject; 023 import org.kuali.hr.time.principal.PrincipalHRAttributes; 024 import org.kuali.hr.time.service.base.TkServiceLocator; 025 import org.kuali.rice.kim.api.identity.Person; 026 import org.kuali.rice.kim.api.services.KimApiServiceLocator; 027 028 public class EmployeeOverride extends HrBusinessObject { 029 030 private static final long serialVersionUID = 1L; 031 032 private String lmEmployeeOverrideId; 033 private String principalId; 034 private String accrualCategory; 035 private String leavePlan; 036 private transient Person principal; 037 private transient PrincipalHRAttributes principalHRAttrObj; 038 private transient AccrualCategory accrualCategoryObj; 039 private String overrideType; 040 private Long overrideValue; 041 private String description; 042 043 @Override 044 public String getId() { 045 return getLmEmployeeOverrideId(); 046 } 047 048 @Override 049 protected String getUniqueKey() { 050 return getLmEmployeeOverrideId(); 051 } 052 053 @Override 054 public void setId(String id) { 055 setLmEmployeeOverrideId(id); 056 } 057 058 // @SuppressWarnings("unchecked") 059 // @Override 060 // protected LinkedHashMap toStringMapper() { 061 // LinkedHashMap<String, Object> toStringMap = new LinkedHashMap<String, Object>(); 062 // toStringMap.put("lmEmployeeOverrideId", lmEmployeeOverrideId); 063 // toStringMap.put("principalId", principalId); 064 // toStringMap.put("overrideType", overrideType); 065 // toStringMap.put("accrualCategory", accrualCategory); 066 // 067 // return toStringMap; 068 // } 069 070 public String getLmEmployeeOverrideId() { 071 return lmEmployeeOverrideId; 072 } 073 074 public void setLmEmployeeOverrideId(String lmEmployeeOverrideId) { 075 this.lmEmployeeOverrideId = lmEmployeeOverrideId; 076 } 077 078 public String getPrincipalId() { 079 return principalId; 080 } 081 082 public void setPrincipalId(String principalId) { 083 this.principalId = principalId; 084 this.setPrincipal(KimApiServiceLocator.getPersonService().getPerson(this.principalId)); 085 } 086 087 public String getName() { 088 if (principal == null) { 089 principal = KimApiServiceLocator.getPersonService().getPerson(this.principalId); 090 } 091 return (principal != null) ? principal.getName() : ""; 092 } 093 094 public AccrualCategory getAccrualCategoryObj() { 095 return accrualCategoryObj; 096 } 097 098 public void setAccrualCategoryObj(AccrualCategory accrualCategoryObj) { 099 this.accrualCategoryObj = accrualCategoryObj; 100 } 101 102 public String getOverrideType() { 103 return overrideType; 104 } 105 106 public void setOverrideType(String overrideType) { 107 this.overrideType = overrideType; 108 } 109 110 public String getDescription() { 111 return description; 112 } 113 114 public void setDescription(String description) { 115 this.description = description; 116 } 117 118 public String getAccrualCategory() { 119 return accrualCategory; 120 } 121 122 public void setAccrualCategory(String accrualCategory) { 123 this.accrualCategory = accrualCategory; 124 } 125 126 public String getLeavePlan() { 127 if (leavePlan != null) { 128 return leavePlan; 129 } 130 if (this.principalHRAttrObj == null && !StringUtils.isEmpty(this.principalId)) { 131 principalHRAttrObj = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalCalendar(principalId, this.getEffectiveDate()); 132 } 133 leavePlan = principalHRAttrObj == null ? null : principalHRAttrObj.getLeavePlan(); 134 return leavePlan; 135 } 136 137 public void setLeavePlan(String leavePlan) { 138 this.leavePlan = leavePlan; 139 } 140 141 public Long getOverrideValue() { 142 return overrideValue; 143 } 144 145 public void setOverrideValue(Long overrideValue) { 146 this.overrideValue = overrideValue; 147 } 148 149 public Person getPrincipal() { 150 return principal; 151 } 152 153 public void setPrincipal(Person principal) { 154 this.principal = principal; 155 } 156 157 public PrincipalHRAttributes getPrincipalHRAttrObj() { 158 return principalHRAttrObj; 159 } 160 161 public void setPrincipalHRAttrObj(PrincipalHRAttributes principalHRAttrObj) { 162 this.principalHRAttrObj = principalHRAttrObj; 163 } 164 165 }