1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.task;
17
18 import org.kuali.kpme.core.api.paygrade.PayGrade;
19 import org.kuali.kpme.core.api.task.Task;
20 import org.kuali.kpme.core.api.task.TaskContract;
21 import org.kuali.kpme.core.bo.HrBusinessObject;
22 import org.kuali.kpme.core.util.HrConstants;
23 import org.kuali.kpme.core.workarea.WorkAreaBo;
24
25 import com.google.common.collect.ImmutableList;
26 import com.google.common.collect.ImmutableMap;
27 import org.kuali.rice.core.api.mo.ModelObjectUtils;
28
29 import java.sql.Timestamp;
30
31 public class TaskBo extends HrBusinessObject implements TaskContract {
32
33 private static final String TASK = "task";
34
35 private static final long serialVersionUID = -7536342291963303862L;
36
37 public static final String CACHE_NAME = HrConstants.CacheNamespace.NAMESPACE_PREFIX + "Task";
38
39 public static final ImmutableList<String> BUSINESS_KEYS = new ImmutableList.Builder<String>()
40 .add(TASK)
41 .build();
42
43 public static final ModelObjectUtils.Transformer<TaskBo, Task> toTask =
44 new ModelObjectUtils.Transformer<TaskBo, Task>() {
45 public Task transform(TaskBo input) {
46 return TaskBo.to(input);
47 };
48 };
49 public static final ModelObjectUtils.Transformer<Task, TaskBo> toTaskBo =
50 new ModelObjectUtils.Transformer<Task, TaskBo>() {
51 public TaskBo transform(Task input) {
52 return TaskBo.from(input);
53 };
54 };
55
56 private String tkTaskId;
57 private Long task;
58 private Long workArea;
59 private String description;
60 private String administrativeDescription;
61
62 private WorkAreaBo workAreaObj;
63
64 @Override
65 public ImmutableMap<String, Object> getBusinessKeyValuesMap() {
66 return new ImmutableMap.Builder<String, Object>()
67 .put(TASK, this.getTask())
68 .build();
69 }
70
71 public String getTkTaskId() {
72 return tkTaskId;
73 }
74
75 public void setTkTaskId(String tkTaskId) {
76 this.tkTaskId = tkTaskId;
77 }
78
79 public Long getTask() {
80 return task;
81 }
82
83 public void setTask(Long task) {
84 this.task = task;
85 }
86
87 public Long getWorkArea() {
88 return workArea;
89 }
90
91 public void setWorkArea(Long workArea) {
92 this.workArea = workArea;
93 }
94
95 public String getDescription() {
96 return description;
97 }
98
99 public void setDescription(String description) {
100 this.description = description;
101 }
102
103 public String getAdministrativeDescription() {
104 return administrativeDescription;
105 }
106
107 public void setAdministrativeDescription(String administrativeDescription) {
108 this.administrativeDescription = administrativeDescription;
109 }
110
111 public WorkAreaBo getWorkAreaObj() {
112 return workAreaObj;
113 }
114
115 public void setWorkAreaObj(WorkAreaBo workAreaObj) {
116 this.workAreaObj = workAreaObj;
117 }
118
119 @Override
120 public String getUniqueKey() {
121 return workArea + "_" + task;
122 }
123
124 @Override
125 public String getId() {
126 return getTkTaskId();
127 }
128
129 @Override
130 public void setId(String id) {
131 setTkTaskId(id);
132 }
133
134 public static TaskBo from(Task im) {
135 if (im == null) {
136 return null;
137 }
138 TaskBo task = new TaskBo();
139
140 task.setTkTaskId(im.getTkTaskId());
141 task.setTask(im.getTask());
142 task.setDescription(im.getDescription());
143 task.setWorkArea(im.getWorkArea());
144 task.setDescription(im.getDescription());
145 task.setAdministrativeDescription(im.getAdministrativeDescription());
146
147 task.setEffectiveDate(im.getEffectiveLocalDate() == null ? null : im.getEffectiveLocalDate().toDate());
148 task.setActive(im.isActive());
149 if (im.getCreateTime() != null) {
150 task.setTimestamp(new Timestamp(im.getCreateTime().getMillis()));
151 }
152 task.setUserPrincipalId(im.getUserPrincipalId());
153 task.setVersionNumber(im.getVersionNumber());
154 task.setObjectId(im.getObjectId());
155
156 return task;
157 }
158
159 public static Task to(TaskBo bo) {
160 if (bo == null) {
161 return null;
162 }
163
164 return Task.Builder.create(bo).build();
165 }
166
167 }