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