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