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