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 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.hr.time.service.base.TkServiceLocator;
28 import org.kuali.hr.time.timeblock.TimeBlock;
29 import org.kuali.hr.time.timesheet.TimesheetDocument;
30 import org.kuali.hr.time.timesummary.TimeSummary;
31 import org.kuali.hr.time.util.TKContext;
32 import org.kuali.hr.time.util.TkConstants;
33 import org.kuali.rice.kew.api.KewApiConstants;
34 import org.kuali.rice.kew.api.document.DocumentStatus;
35 import org.kuali.rice.kew.api.note.Note;
36 import org.kuali.rice.kew.doctype.SecuritySession;
37 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
38 import org.kuali.rice.kew.service.KEWServiceLocator;
39 import org.kuali.rice.kim.api.identity.principal.Principal;
40 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
41
42 public class ApprovalTimeSummaryRow implements Comparable<ApprovalTimeSummaryRow>, Serializable {
43 private String name;
44 private List<TimeBlock> lstTimeBlocks = new ArrayList<TimeBlock>();
45
46 private Map<String, Map<String, BigDecimal>> approverHoursByAssignment;
47
48 private Map<String, Map<String, BigDecimal>> otherHoursByAssignment;
49
50 private Map<String,String> assignmentDescriptions;
51
52 private String approvalStatus;
53 private String approvalStatusMessage;
54 private String documentId;
55 private Map<String,BigDecimal> hoursToPayLabelMap = new HashMap<String,BigDecimal>();
56 private Map<String,BigDecimal> hoursToFlsaPayLabelMap = new HashMap<String,BigDecimal>();
57 private String clockStatusMessage;
58 private String payCalendarGroup;
59 private List<Note> notes = new ArrayList<Note>();
60 private List<String> warnings = new ArrayList<String>();
61 private Set<String> workAreas;
62 private String principalId;
63 private Boolean clockedInOverThreshold = Boolean.FALSE;
64 private String selected = "off";
65 private TimeSummary timeSummary;
66 private BigDecimal periodTotal = BigDecimal.ZERO;
67
68 public String getApprovalStatusMessage() {
69 return approvalStatusMessage;
70 }
71
72 public void setApprovalStatusMessage(String approvalStatusMessage) {
73 this.approvalStatusMessage = approvalStatusMessage;
74 }
75
76 public Map<String, String> getAssignmentDescriptions() {
77 return assignmentDescriptions;
78 }
79
80 public void setAssignmentDescriptions(Map<String, String> assignmentDescriptions) {
81 this.assignmentDescriptions = assignmentDescriptions;
82 }
83
84 public Map<String, Map<String, BigDecimal>> getApproverHoursByAssignment() {
85 return approverHoursByAssignment;
86 }
87
88 public void setApproverHoursByAssignment(Map<String, Map<String, BigDecimal>> approverHoursByAssignment) {
89 this.approverHoursByAssignment = approverHoursByAssignment;
90 }
91
92 public Map<String, Map<String, BigDecimal>> getOtherHoursByAssignment() {
93 return otherHoursByAssignment;
94 }
95
96 public void setOtherHoursByAssignment(Map<String, Map<String, BigDecimal>> otherHoursByAssignment) {
97 this.otherHoursByAssignment = otherHoursByAssignment;
98 }
99
100 public String getName() {
101 return name;
102 }
103 public void setName(String name) {
104 this.name = name;
105 }
106 public List<TimeBlock> getLstTimeBlocks() {
107 return lstTimeBlocks;
108 }
109 public void setLstTimeBlocks(List<TimeBlock> lstTimeBlocks) {
110 this.lstTimeBlocks = lstTimeBlocks;
111 }
112 public String getApprovalStatus() {
113 return approvalStatus;
114 }
115 public void setApprovalStatus(String approvalStatus) {
116 this.approvalStatus = approvalStatus;
117 }
118 public void setDocumentId(String documentId) {
119 this.documentId = documentId;
120 }
121 public String getDocumentId() {
122 return documentId;
123 }
124 public void setHoursToPayLabelMap(Map<String,BigDecimal> hoursToPayLabelMap) {
125 this.hoursToPayLabelMap = hoursToPayLabelMap;
126 }
127 public Map<String,BigDecimal> getHoursToPayLabelMap() {
128 return hoursToPayLabelMap;
129 }
130 public void setHoursToFlsaPayLabelMap(Map<String,BigDecimal> hoursToFlsaPayLabelMap) {
131 this.hoursToFlsaPayLabelMap = hoursToFlsaPayLabelMap;
132 }
133 public Map<String,BigDecimal> getHoursToFlsaPayLabelMap() {
134 return hoursToFlsaPayLabelMap;
135 }
136 public void setClockStatusMessage(String clockStatusMessage) {
137 this.clockStatusMessage = clockStatusMessage;
138 }
139 public String getClockStatusMessage() {
140 return clockStatusMessage;
141 }
142
143 public String getPayCalendarGroup() {
144 return payCalendarGroup;
145 }
146
147 public void setPayCalendarGroup(String payCalendarGroup) {
148 this.payCalendarGroup = payCalendarGroup;
149 }
150
151
152
153
154
155 public boolean isRoutable() {
156 return StringUtils.equals(getApprovalStatus(), TkConstants.ROUTE_STATUS.INITIATED);
157 }
158
159 public boolean isApprovable() {
160 boolean isApprovable = false;
161
162 if (DocumentStatus.ENROUTE.getLabel().equals(getApprovalStatus())) {
163 TimesheetDocument timesheetDocument = TkServiceLocator.getTimesheetService().getTimesheetDocument(getDocumentId());
164 if (timesheetDocument != null) {
165 String timesheetPrincipalId = timesheetDocument.getPrincipalId();
166 String approverPrincipalId = TKContext.getPrincipalId();
167
168 if (!StringUtils.equals(timesheetPrincipalId, approverPrincipalId) && TkServiceLocator.getTimesheetService().isReadyToApprove(timesheetDocument)) {
169 DocumentRouteHeaderValue routeHeader = TkServiceLocator.getTimeApproveService().getRouteHeader(getDocumentId());
170 boolean authorized = KEWServiceLocator.getDocumentSecurityService().routeLogAuthorized(approverPrincipalId, routeHeader, new SecuritySession(approverPrincipalId));
171 if (authorized) {
172 List<String> approverPrincipalIds = KEWServiceLocator.getActionRequestService().getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(KewApiConstants.ACTION_REQUEST_APPROVE_REQ, getDocumentId());
173 if (approverPrincipalIds.contains(approverPrincipalId)) {
174 isApprovable = true;
175 }
176 }
177 }
178 }
179 }
180
181 return isApprovable;
182 }
183
184
185
186
187
188
189
190 public String getTimesheetUserTargetURLParams() {
191 StringBuffer link = new StringBuffer();
192
193 link.append("methodToCall=changeTargetPerson");
194 link.append("&documentId=").append(this.getDocumentId());
195 Principal person = KimApiServiceLocator.getIdentityService().getPrincipal(this.getPrincipalId());
196 link.append("&principalName=").append(person.getPrincipalName());
197
198 return link.toString();
199 }
200
201 public List<Note> getNotes() {
202 return notes;
203 }
204
205 public void setNotes(List<Note> notes) {
206 this.notes = notes;
207 }
208
209 public List<String> getWarnings() {
210 return warnings;
211 }
212
213 public void setWarnings(List<String> warnings) {
214 this.warnings = warnings;
215 }
216
217 public Set<String> getWorkAreas() {
218 return workAreas;
219 }
220
221 public void setWorkAreas(Set<String> workAreas) {
222 this.workAreas = workAreas;
223 }
224
225 public String getPrincipalId() {
226 return principalId;
227 }
228
229 public void setPrincipalId(String principalId) {
230 this.principalId = principalId;
231 }
232 public Boolean getClockedInOverThreshold() {
233 return clockedInOverThreshold;
234 }
235 public void setClockedInOverThreshold(Boolean clockedInOverThreshold) {
236 this.clockedInOverThreshold = clockedInOverThreshold;
237 }
238 public String getSelected() {
239 return selected;
240 }
241
242 public void setSelected(String selected) {
243 this.selected = selected;
244 }
245
246 public TimeSummary getTimeSummary() {
247 return timeSummary;
248 }
249
250 public void setTimeSummary(TimeSummary timeSummary) {
251 this.timeSummary = timeSummary;
252 }
253
254 public BigDecimal getPeriodTotal() {
255 return periodTotal;
256 }
257
258 public void setPeriodTotal(BigDecimal periodTotal) {
259 this.periodTotal = periodTotal;
260 }
261
262 public int compareTo(ApprovalTimeSummaryRow row) {
263 return name.compareToIgnoreCase(row.getName());
264 }
265 }