1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.approval.web;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.hr.lm.leaveblock.LeaveBlock;
20 import org.kuali.hr.lm.leavecalendar.LeaveCalendarDocument;
21 import org.kuali.hr.time.service.base.TkServiceLocator;
22 import org.kuali.hr.time.util.TKContext;
23 import org.kuali.hr.time.util.TkConstants;
24 import org.kuali.rice.kew.api.KewApiConstants;
25 import org.kuali.rice.kew.api.document.DocumentStatus;
26 import org.kuali.rice.kew.api.note.Note;
27 import org.kuali.rice.kew.doctype.SecuritySession;
28 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
29 import org.kuali.rice.kew.service.KEWServiceLocator;
30 import org.kuali.rice.kim.api.identity.principal.Principal;
31 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
32
33 import java.io.Serializable;
34 import java.math.BigDecimal;
35 import java.util.*;
36
37 public class ApprovalLeaveSummaryRow implements Comparable<ApprovalLeaveSummaryRow>, Serializable {
38 private String name;
39 private String principalId;
40 private String documentId;
41 private List<String> warnings = new ArrayList<String>();
42 private String selected = "off";
43 private String approvalStatus;
44
45 private List<Note> notes = new ArrayList<Note>();
46 private Boolean moreThanOneCalendar = Boolean.FALSE;
47 private String lastApproveMessage;
48 private List<LeaveBlock> leaveBlockList = new ArrayList<LeaveBlock>();
49 private Map<Date, Map<String, BigDecimal>> earnCodeLeaveHours = new LinkedHashMap<Date, Map<String, BigDecimal>>();
50 private Boolean exemptEmployee;
51
52 public boolean isApprovable() {
53 boolean isApprovable = false;
54
55 if (DocumentStatus.ENROUTE.getLabel().equals(getApprovalStatus())) {
56 LeaveCalendarDocument leaveCalendarDocument = TkServiceLocator.getLeaveCalendarService().getLeaveCalendarDocument(getDocumentId());
57 if (leaveCalendarDocument != null) {
58 String leaveCalendarPrincipalId = leaveCalendarDocument.getPrincipalId();
59 String approverPrincipalId = TKContext.getPrincipalId();
60
61 if (!StringUtils.equals(leaveCalendarPrincipalId, approverPrincipalId) && TkServiceLocator.getLeaveCalendarService().isReadyToApprove(leaveCalendarDocument)) {
62 DocumentRouteHeaderValue routeHeader = TkServiceLocator.getTimeApproveService().getRouteHeader(getDocumentId());
63 boolean authorized = KEWServiceLocator.getDocumentSecurityService().routeLogAuthorized(approverPrincipalId, routeHeader, new SecuritySession(approverPrincipalId));
64 if (authorized) {
65 List<String> approverPrincipalIds = KEWServiceLocator.getActionRequestService().getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(KewApiConstants.ACTION_REQUEST_APPROVE_REQ, getDocumentId());
66 if (approverPrincipalIds.contains(approverPrincipalId)) {
67 isApprovable = true;
68 }
69 }
70 }
71 }
72 }
73
74 return isApprovable;
75 }
76
77
78 public int compareTo(ApprovalLeaveSummaryRow row) {
79 return name.compareToIgnoreCase(row.getName());
80 }
81
82 public String getName() {
83 return name;
84 }
85
86 public void setName(String name) {
87 this.name = name;
88 }
89
90 public String getPrincipalId() {
91 return principalId;
92 }
93
94 public void setPrincipalId(String principalId) {
95 this.principalId = principalId;
96 }
97
98 public String getUserTargetURLParams() {
99 StringBuffer link = new StringBuffer();
100
101 link.append("methodToCall=changeTargetPerson");
102 link.append("&documentId=").append(this.getDocumentId());
103 Principal person = KimApiServiceLocator.getIdentityService().getPrincipal(this.getPrincipalId());
104 link.append("&principalName=").append(person.getPrincipalName());
105
106 return link.toString();
107 }
108
109 public List<LeaveBlock> getLeaveBlockList() {
110 return leaveBlockList;
111 }
112
113 public void setLeaveBlockList(List<LeaveBlock> leaveBlockList) {
114 this.leaveBlockList = leaveBlockList;
115 }
116
117 public String getDocumentId() {
118 return documentId;
119 }
120
121 public void setDocumentId(String documentId) {
122 this.documentId = documentId;
123 }
124
125 public List<String> getWarnings() {
126 return warnings;
127 }
128
129 public void setWarnings(List<String> warnings) {
130 this.warnings = warnings;
131 }
132
133 public String getSelected() {
134 return selected;
135 }
136
137 public void setSelected(String selected) {
138 this.selected = selected;
139 }
140
141 public List<Note> getNotes() {
142 return notes;
143 }
144
145 public void setNotes(List<Note> notes) {
146 this.notes = notes;
147 }
148
149 public String getLastApproveMessage() {
150 return lastApproveMessage;
151 }
152
153 public void setLastApproveMessage(String lastApproveMessage) {
154 this.lastApproveMessage = lastApproveMessage;
155 }
156
157 public String getApprovalStatus() {
158 return approvalStatus;
159 }
160
161 public void setApprovalStatus(String approvalStatus) {
162 this.approvalStatus = approvalStatus;
163 }
164
165 public Map<Date, Map<String, BigDecimal>> getEarnCodeLeaveHours() {
166 return earnCodeLeaveHours;
167 }
168
169 public void setEarnCodeLeaveHours(Map<Date, Map<String, BigDecimal>> earnCodeLeaveHours) {
170 this.earnCodeLeaveHours = earnCodeLeaveHours;
171 }
172
173 public Boolean getMoreThanOneCalendar() {
174 return moreThanOneCalendar;
175 }
176
177
178 public void setMoreThanOneCalendar(Boolean moreThanOneCalendar) {
179 this.moreThanOneCalendar = moreThanOneCalendar;
180 }
181
182
183 public Boolean getExemptEmployee() {
184 if(this.exemptEmployee == null) {
185 this.exemptEmployee = TkServiceLocator.getLeaveApprovalService().isActiveAssignmentFoundOnJobFlsaStatus(this.principalId,TkConstants.FLSA_STATUS_EXEMPT, true);
186 }
187 return exemptEmployee;
188 }
189
190
191 public void setExemptEmployee(Boolean exemptEmployee) {
192 this.exemptEmployee = exemptEmployee;
193 }
194
195
196 }