1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.approval.summaryrow;
17
18 import java.io.Serializable;
19 import java.math.BigDecimal;
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Set;
25
26 import org.apache.commons.lang.StringUtils;
27 import org.kuali.kpme.core.util.HrConstants;
28 import org.kuali.kpme.core.util.HrContext;
29 import org.kuali.kpme.tklm.api.time.approval.summaryrow.ApprovalTimeSummaryRowContract;
30 import org.kuali.kpme.tklm.api.time.missedpunch.MissedPunch;
31 import org.kuali.kpme.tklm.api.time.timeblock.TimeBlock;
32 import org.kuali.kpme.tklm.api.time.timesummary.TimeSummaryContract;
33 import org.kuali.kpme.tklm.time.missedpunch.MissedPunchBo;
34 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
35 import org.kuali.kpme.tklm.time.timesheet.TimesheetDocument;
36 import org.kuali.rice.kew.api.KewApiConstants;
37 import org.kuali.rice.kew.api.KewApiServiceLocator;
38 import org.kuali.rice.kew.api.action.ActionRequest;
39 import org.kuali.rice.kew.api.document.DocumentStatus;
40 import org.kuali.rice.kew.api.note.Note;
41 import org.kuali.rice.kim.api.identity.principal.Principal;
42 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
43
44 public class ApprovalTimeSummaryRow implements Comparable<ApprovalTimeSummaryRow>, Serializable, ApprovalTimeSummaryRowContract {
45
46 private static final long serialVersionUID = -2005933528843934641L;
47 private String name;
48 private List<TimeBlock> lstTimeBlocks = new ArrayList<TimeBlock>();
49
50 private Map<String, Map<String, BigDecimal>> approverHoursByAssignment;
51
52 private Map<String, Map<String, BigDecimal>> otherHoursByAssignment;
53
54 private Map<String,String> assignmentDescriptions;
55
56 private String approvalStatus;
57 private String approvalStatusMessage;
58 private String documentId;
59 private Map<String, String> roleNames;
60 private Map<String,BigDecimal> hoursToPayLabelMap = new HashMap<String,BigDecimal>();
61 private Map<String,BigDecimal> hoursToFlsaPayLabelMap = new HashMap<String,BigDecimal>();
62 private String clockStatusMessage;
63 private String payCalendarGroup;
64 private List<Note> notes = new ArrayList<Note>();
65 private List<String> warnings = new ArrayList<String>();
66 private List<MissedPunch> missedPunchList = new ArrayList<MissedPunch>();
67 private Set<String> workAreas;
68 private String principalId;
69 private Boolean clockedInOverThreshold = Boolean.FALSE;
70 private String selected = "off";
71 private TimeSummaryContract timeSummary;
72 private BigDecimal periodTotal = BigDecimal.ZERO;
73 private String outputString;
74 private String color;
75
76 private Map<String, BigDecimal> weekTotalMap;
77
78 public List<MissedPunch> getMissedPunchList() {
79 return missedPunchList;
80 }
81
82 public void setMissedPunchList(List<MissedPunch> missedPunchList) {
83 this.missedPunchList = missedPunchList;
84 }
85
86 public String getApprovalStatusMessage() {
87 return approvalStatusMessage;
88 }
89
90 public void setApprovalStatusMessage(String approvalStatusMessage) {
91 this.approvalStatusMessage = approvalStatusMessage;
92 }
93
94 public Map<String, String> getAssignmentDescriptions() {
95 return assignmentDescriptions;
96 }
97
98 public void setAssignmentDescriptions(Map<String, String> assignmentDescriptions) {
99 this.assignmentDescriptions = assignmentDescriptions;
100 }
101
102 public Map<String, Map<String, BigDecimal>> getApproverHoursByAssignment() {
103 return approverHoursByAssignment;
104 }
105
106 public void setApproverHoursByAssignment(Map<String, Map<String, BigDecimal>> approverHoursByAssignment) {
107 this.approverHoursByAssignment = approverHoursByAssignment;
108 }
109
110 public Map<String, Map<String, BigDecimal>> getOtherHoursByAssignment() {
111 return otherHoursByAssignment;
112 }
113
114 public void setOtherHoursByAssignment(Map<String, Map<String, BigDecimal>> otherHoursByAssignment) {
115 this.otherHoursByAssignment = otherHoursByAssignment;
116 }
117
118 public String getName() {
119 return name;
120 }
121 public void setName(String name) {
122 this.name = name;
123 }
124 public List<TimeBlock> getLstTimeBlocks() {
125 return lstTimeBlocks;
126 }
127 public void setLstTimeBlocks(List<TimeBlock> lstTimeBlocks) {
128 this.lstTimeBlocks = lstTimeBlocks;
129 }
130 public String getApprovalStatus() {
131 return approvalStatus;
132 }
133 public void setApprovalStatus(String approvalStatus) {
134 this.approvalStatus = approvalStatus;
135 }
136 public void setDocumentId(String documentId) {
137 this.documentId = documentId;
138 }
139 public String getDocumentId() {
140 return documentId;
141 }
142 public void setHoursToPayLabelMap(Map<String,BigDecimal> hoursToPayLabelMap) {
143 this.hoursToPayLabelMap = hoursToPayLabelMap;
144 }
145 public Map<String,BigDecimal> getHoursToPayLabelMap() {
146 return hoursToPayLabelMap;
147 }
148 public void setHoursToFlsaPayLabelMap(Map<String,BigDecimal> hoursToFlsaPayLabelMap) {
149 this.hoursToFlsaPayLabelMap = hoursToFlsaPayLabelMap;
150 }
151 public Map<String,BigDecimal> getHoursToFlsaPayLabelMap() {
152 return hoursToFlsaPayLabelMap;
153 }
154 public void setClockStatusMessage(String clockStatusMessage) {
155 this.clockStatusMessage = clockStatusMessage;
156 }
157 public String getClockStatusMessage() {
158 return clockStatusMessage;
159 }
160
161 public String getPayCalendarGroup() {
162 return payCalendarGroup;
163 }
164
165 public void setPayCalendarGroup(String payCalendarGroup) {
166 this.payCalendarGroup = payCalendarGroup;
167 }
168
169
170
171
172
173 public boolean isRoutable() {
174 return StringUtils.equals(getApprovalStatus(), HrConstants.ROUTE_STATUS.INITIATED);
175 }
176
177
178
179
180
181 public boolean isApprovable() {
182 boolean isApprovable = false;
183
184 if (DocumentStatus.ENROUTE.getLabel().equals(getApprovalStatus())) {
185 TimesheetDocument timesheetDocument = TkServiceLocator.getTimesheetService().getTimesheetDocument(getDocumentId());
186 if (timesheetDocument != null) {
187 String timesheetPrincipalId = timesheetDocument.getPrincipalId();
188 String approverPrincipalId = HrContext.getPrincipalId();
189
190 if (!StringUtils.equals(timesheetPrincipalId, approverPrincipalId) && TkServiceLocator.getTimesheetService().isReadyToApprove(timesheetDocument) && TkServiceLocator.getTimesheetService().isTimesheetValid(timesheetDocument)) {
191 boolean authorized = KewApiServiceLocator.getWorkflowDocumentActionsService().isUserInRouteLog(getDocumentId(), approverPrincipalId, false);
192 if (authorized) {
193 List<String> approverPrincipalIds = KewApiServiceLocator.getWorkflowDocumentService().getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(KewApiConstants.ACTION_REQUEST_APPROVE_REQ, getDocumentId());
194 if (approverPrincipalIds.contains(approverPrincipalId)) {
195 isApprovable = true;
196 }
197 }
198 }
199 }
200 }
201
202 return isApprovable;
203 }
204
205
206
207
208
209
210
211 public String getTimesheetUserTargetURLParams() {
212 StringBuffer link = new StringBuffer();
213
214 link.append("methodToCall=changeTargetPerson");
215 link.append("&documentId=").append(this.getDocumentId());
216 Principal person = KimApiServiceLocator.getIdentityService().getPrincipal(this.getPrincipalId());
217 link.append("&principalName=").append(person.getPrincipalName());
218
219 return link.toString();
220 }
221
222 public List<Note> getNotes() {
223 return notes;
224 }
225
226 public void setNotes(List<Note> notes) {
227 this.notes = notes;
228 }
229
230 public List<String> getWarnings() {
231 return warnings;
232 }
233
234 public void setWarnings(List<String> warnings) {
235 this.warnings = warnings;
236 }
237
238 public Set<String> getWorkAreas() {
239 return workAreas;
240 }
241
242 public void setWorkAreas(Set<String> workAreas) {
243 this.workAreas = workAreas;
244 }
245
246 public String getPrincipalId() {
247 return principalId;
248 }
249
250 public void setPrincipalId(String principalId) {
251 this.principalId = principalId;
252 }
253 public Boolean getClockedInOverThreshold() {
254 return clockedInOverThreshold;
255 }
256 public void setClockedInOverThreshold(Boolean clockedInOverThreshold) {
257 this.clockedInOverThreshold = clockedInOverThreshold;
258 }
259 public String getSelected() {
260 return selected;
261 }
262
263 public void setSelected(String selected) {
264 this.selected = selected;
265 }
266
267 public TimeSummaryContract getTimeSummary() {
268 return timeSummary;
269 }
270
271 public void setTimeSummary(TimeSummaryContract timeSummary) {
272 this.timeSummary = timeSummary;
273 }
274
275 public BigDecimal getPeriodTotal() {
276 return periodTotal;
277 }
278
279 public void setPeriodTotal(BigDecimal periodTotal) {
280 this.periodTotal = periodTotal;
281 }
282
283 public int compareTo(ApprovalTimeSummaryRow row) {
284 return name.compareToIgnoreCase(row.getName());
285 }
286
287
288
289
290 public String getOutputString() {
291 return outputString;
292 }
293
294
295
296
297 public void setOutputString(String outputString) {
298 this.outputString = outputString;
299 }
300
301
302
303
304 public String getColor() {
305 return color;
306 }
307
308
309
310
311 public void setColor(String color) {
312 this.color = color;
313 }
314
315
316
317
318 public Map<String, BigDecimal> getWeekTotalMap() {
319 return weekTotalMap;
320 }
321
322
323
324
325 public void setWeekTotalMap(Map<String, BigDecimal> weekTotalMap) {
326 this.weekTotalMap = weekTotalMap;
327 }
328
329 public Map<String, String> getRoleNames() {
330
331 if (StringUtils.isNotBlank(documentId)) {
332 List<ActionRequest> actionRequests = KewApiServiceLocator.getWorkflowDocumentService().getPendingActionRequests(documentId);
333 Map<String, String> roleNames = new HashMap<String, String>();
334 for (ActionRequest ar : actionRequests) {
335 roleNames.put(ar.getPrincipalId(), ar.getQualifiedRoleNameLabel());
336 }
337 this.setRoleNames(roleNames);
338 }
339 return roleNames;
340 }
341
342 public void setRoleNames(Map<String, String> roleNames) {
343 this.roleNames = roleNames;
344 }
345
346 public String getRoleName() {
347 return getRoleNames().get(HrContext.getPrincipalId());
348 }
349
350 }