View Javadoc

1   /**
2    * Copyright 2004-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.hr.time.calendar;
17  
18  import java.math.BigDecimal;
19  
20  import org.kuali.hr.lm.LMConstants;
21  import org.kuali.hr.lm.leaveblock.LeaveBlock;
22  import org.kuali.hr.time.service.base.TkServiceLocator;
23  import org.kuali.rice.krad.util.ObjectUtils;
24  
25  import static org.kuali.hr.time.service.base.TkServiceLocator.*;
26  
27  public class LeaveBlockRenderer {
28      private LeaveBlock leaveBlock;
29      private String assignmentClass;
30      //private boolean readOnly;
31  
32      public  LeaveBlockRenderer(LeaveBlock leaveBlock) {
33          this.leaveBlock = leaveBlock;
34      }
35   
36      public LeaveBlock getLeaveBlock() {
37          return leaveBlock;
38      }
39  
40      public BigDecimal getHours() {
41          return leaveBlock.getLeaveAmount();
42      }
43  
44      public String getEarnCode() {
45          return leaveBlock.getEarnCode();
46      }
47  
48      public String getLeaveBlockId() {
49          return leaveBlock.getLmLeaveBlockId();
50      }
51  
52      public String getDocumentId() {
53          return leaveBlock.getDocumentId();
54      }
55  
56  	public String getAssignmentTitle() {
57  		return leaveBlock.getAssignmentTitle();
58  	}
59  
60      public boolean getEditable() {
61          return leaveBlock.isEditable();
62      }
63  
64      public boolean getDeletable() {
65          return leaveBlock.isDeletable();
66      }
67  
68  	public String getAssignmentClass() {
69  		return assignmentClass;
70  	}
71  
72  	public void setAssignmentClass(String assignmentClass) {
73  		this.assignmentClass = assignmentClass;
74  	}
75  
76      public String getRequestStatusClass() {
77          return this.leaveBlock.getRequestStatusString().toLowerCase();
78      }
79  
80      public String getLeaveBlockDetails() {
81          if (this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE)) {
82  //            return "accrual";
83          	if(ObjectUtils.isNotNull(leaveBlock.getScheduleTimeOffId()))
84          		return TkServiceLocator.getSysSchTimeOffService().getSystemScheduledTimeOff(this.leaveBlock.getScheduleTimeOffId()).getDescr();
85          	else
86          		return "accrual";
87          }
88          else if(this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.BALANCE_TRANSFER)) {
89          	if(this.leaveBlock.getDescription().contains("Forfeited"))
90          		return "transfer forfeiture";
91          	else if(this.leaveBlock.getDescription().contains("Amount transferred"))
92          		return "amount transferred";
93          	else if(this.leaveBlock.getDescription().contains("Transferred amount"))
94          		return "transferred amount";
95          	else
96          		return "balance transfer";
97          }
98          else if(this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.LEAVE_PAYOUT)) {
99          	if(this.leaveBlock.getDescription().contains("Forfeited"))
100         		return "payout forfeiture";
101         	else if(this.leaveBlock.getDescription().contains("Amount paid out"))
102         		return "amount paid out";
103         	else if(this.leaveBlock.getDescription().contains("Payout amount"))
104         		return "payout amount";
105         	else
106         		return "leave payout";
107         }
108         else
109         	if(!this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.LEAVE_CALENDAR) &&
110         			!this.leaveBlock.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.TIME_CALENDAR))
111         		return LMConstants.LEAVE_BLOCK_TYPE_MAP.get(this.leaveBlock.getLeaveBlockType()).toLowerCase();
112         	else
113         		return getRequestStatusClass();
114         
115     }
116     
117     public String getDescription() {
118     	return leaveBlock.getDescription();
119     }
120 
121 }