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.leaveadjustment; 017 018 import java.math.BigDecimal; 019 import java.util.LinkedHashMap; 020 021 import org.apache.commons.lang.StringUtils; 022 import org.kuali.hr.lm.accrual.AccrualCategory; 023 import org.kuali.hr.time.HrBusinessObject; 024 import org.kuali.hr.time.earncode.EarnCode; 025 import org.kuali.hr.time.principal.PrincipalHRAttributes; 026 import org.kuali.hr.time.service.base.TkServiceLocator; 027 import org.kuali.rice.kim.api.identity.Person; 028 import org.kuali.rice.kim.api.services.KimApiServiceLocator; 029 030 public class LeaveAdjustment extends HrBusinessObject { 031 private static final long serialVersionUID = 1L; 032 private String lmLeaveAdjustmentId; 033 private String principalId; 034 private String leavePlan; 035 private String accrualCategory; 036 private String earnCode; 037 private String description; 038 private BigDecimal adjustmentAmount = new BigDecimal("0.0"); 039 private transient Person principal; 040 private transient AccrualCategory accrualCategoryObj; 041 private transient EarnCode earnCodeObj; 042 private transient PrincipalHRAttributes principalHRAttrObj; 043 044 public String getEarnCode() { 045 return earnCode; 046 } 047 public void setEarnCode(String earnCode) { 048 this.earnCode = earnCode; 049 } 050 public EarnCode getEarnCodeObj() { 051 return earnCodeObj; 052 } 053 public void setEarnCodeObj(EarnCode earnCodeObj) { 054 this.earnCodeObj = earnCodeObj; 055 } 056 public String getPrincipalId() { 057 return principalId; 058 } 059 public void setPrincipalId(String principalId) { 060 this.principalId = principalId; 061 } 062 public Person getPrincipal() { 063 return principal; 064 } 065 public void setPrincipal(Person principal) { 066 this.principal = principal; 067 } 068 public String getName() { 069 if (principal == null) { 070 principal = KimApiServiceLocator.getPersonService().getPerson(this.principalId); 071 } 072 return (principal != null) ? principal.getName() : ""; 073 } 074 075 public String getLeavePlan() { 076 if (!StringUtils.isEmpty(this.principalId)) { 077 principalHRAttrObj = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalCalendar(principalId, this.getEffectiveDate()); 078 } 079 return (principalHRAttrObj != null) ? principalHRAttrObj.getLeavePlan() : ""; 080 } 081 082 public void setLeavePlan(String leavePlan) { 083 this.leavePlan = leavePlan; 084 } 085 public String getAccrualCategory() { 086 return accrualCategory; 087 } 088 public void setAccrualCategory(String accrualCategory) { 089 this.accrualCategory = accrualCategory; 090 } 091 092 public String getDescription() { 093 return description; 094 } 095 public void setDescription(String description) { 096 this.description = description; 097 } 098 public BigDecimal getAdjustmentAmount() { 099 return adjustmentAmount; 100 } 101 public void setAdjustmentAmount(BigDecimal adjustmentAmount) { 102 this.adjustmentAmount = adjustmentAmount; 103 } 104 public AccrualCategory getAccrualCategoryObj() { 105 return accrualCategoryObj; 106 } 107 public void setAccrualCategoryObj(AccrualCategory accrualCategoryObj) { 108 this.accrualCategoryObj = accrualCategoryObj; 109 } 110 public static long getSerialversionuid() { 111 return serialVersionUID; 112 } 113 public String getLmLeaveAdjustmentId() { 114 return lmLeaveAdjustmentId; 115 } 116 public void setLmLeaveAdjustmentId(String lmLeaveAdjustmentId) { 117 this.lmLeaveAdjustmentId = lmLeaveAdjustmentId; 118 } 119 120 @Override 121 protected String getUniqueKey() { 122 return getLmLeaveAdjustmentId(); 123 } 124 125 @Override 126 public String getId() { 127 return getLmLeaveAdjustmentId(); 128 } 129 130 @Override 131 public void setId(String id) { 132 setLmLeaveAdjustmentId(id); 133 } 134 135 public PrincipalHRAttributes getPrincipalHRAttrObj() { 136 return principalHRAttrObj; 137 } 138 public void setPrincipalHRAttrObj(PrincipalHRAttributes principalHRAttrObj) { 139 this.principalHRAttrObj = principalHRAttrObj; 140 } 141 }