1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.calendar;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.hr.time.service.base.TkServiceLocator;
20 import org.kuali.hr.time.task.Task;
21 import org.kuali.hr.time.timeblock.TimeBlock;
22 import org.kuali.hr.time.timeblock.TimeHourDetail;
23 import org.kuali.hr.time.util.TKUtils;
24 import org.kuali.hr.time.util.TkConstants;
25 import org.kuali.hr.time.workarea.WorkArea;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33 public class TimeBlockRenderer {
34
35 private TimeBlock timeBlock;
36 private List<TimeHourDetailRenderer> detailRenderers = new ArrayList<TimeHourDetailRenderer>();
37 private String assignmentClass;
38 private String lunchLabel;
39 private String lunchLabelId;
40
41 public TimeBlockRenderer(TimeBlock b) {
42 this.timeBlock = b;
43 for (TimeHourDetail detail : timeBlock.getTimeHourDetails()) {
44 detailRenderers.add(new TimeHourDetailRenderer(detail));
45 }
46 }
47
48 public List<TimeHourDetailRenderer> getDetailRenderers() {
49 return detailRenderers;
50 }
51
52 public TimeBlock getTimeBlock() {
53 return timeBlock;
54 }
55
56 public String getTimeRange() {
57 StringBuilder b = new StringBuilder();
58 if(StringUtils.equals(timeBlock.getEarnCodeType(), TkConstants.EARN_CODE_TIME)) {
59 b.append(timeBlock.getBeginTimeDisplay().toString(TkConstants.DT_BASIC_TIME_FORMAT));
60 b.append(" - ");
61 b.append(timeBlock.getEndTimeDisplay().toString(TkConstants.DT_BASIC_TIME_FORMAT));
62 }
63
64 return b.toString();
65 }
66
67 public String getTitle() {
68 StringBuilder b = new StringBuilder();
69
70 WorkArea wa = TkServiceLocator.getWorkAreaService().getWorkArea(timeBlock.getWorkArea(), TKUtils.getCurrentDate());
71 b.append(wa.getDescription());
72 Task task = TkServiceLocator.getTaskService().getTask(timeBlock.getTask(), timeBlock.getBeginDate());
73 if(task != null) {
74
75
76 if(!task.getDescription().equals(TkConstants.TASK_DEFAULT_DESP)) {
77 b.append("-" + task.getDescription());
78 }
79 }
80 return b.toString();
81 }
82
83 public String getAmount() {
84 if(StringUtils.equals(timeBlock.getEarnCodeType(), TkConstants.EARN_CODE_AMOUNT)) {
85 if(timeBlock.getAmount() != null) {
86 return timeBlock.getEarnCode() + ": $" + timeBlock.getAmount().toString();
87 } else {
88 return timeBlock.getEarnCode() + ": $0.00";
89 }
90 }
91 return "";
92 }
93
94 public String getEarnCodeType() {
95 return timeBlock.getEarnCodeType();
96 }
97
98 public String getAssignmentClass() {
99 return assignmentClass;
100 }
101
102 public void setAssignmentClass(String assignmentClass) {
103 this.assignmentClass = assignmentClass;
104 }
105
106 public String getLunchLabel() {
107 return lunchLabel;
108 }
109
110 public void setLunchLabel(String lunchLabel) {
111 this.lunchLabel = lunchLabel;
112 }
113
114 public String getLunchLabelId() {
115 return lunchLabelId;
116 }
117
118 public void setLunchLabelId(String lunchLabelId) {
119 this.lunchLabelId = lunchLabelId;
120 }
121 }