1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.earncode.group;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.joda.time.LocalDate;
20 import org.kuali.kpme.core.api.earncode.EarnCodeContract;
21 import org.kuali.kpme.core.api.earncode.group.EarnCodeGroupDefinition;
22 import org.kuali.kpme.core.api.earncode.group.EarnCodeGroupDefinitionContract;
23 import org.kuali.kpme.core.api.earncode.service.EarnCodeService;
24 import org.kuali.kpme.core.earncode.EarnCodeBo;
25 import org.kuali.kpme.core.service.HrServiceLocator;
26 import org.kuali.rice.core.api.mo.ModelObjectUtils;
27 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
28
29 public class EarnCodeGroupDefinitionBo extends PersistableBusinessObjectBase implements EarnCodeGroupDefinitionContract {
30
31
32
33
34 private static final long serialVersionUID = -8463674251885306591L;
35
36 public static final ModelObjectUtils.Transformer<EarnCodeGroupDefinition, EarnCodeGroupDefinitionBo> toEarnCodeGroupDefinitionBo =
37 new ModelObjectUtils.Transformer<EarnCodeGroupDefinition, EarnCodeGroupDefinitionBo>() {
38 public EarnCodeGroupDefinitionBo transform(EarnCodeGroupDefinition input) {
39 return EarnCodeGroupDefinitionBo.from(input);
40 };
41 };
42
43 private String hrEarnCodeGroupDefId;
44
45 private String earnCode;
46
47 private String hrEarnCodeGroupId;
48
49 private String userPrincipalId;
50
51 private boolean active=true;
52
53 private EarnCodeBo earnCodeObj;
54 private transient EarnCodeService earnCodeService;
55
56 public String getEarnCode() {
57 return earnCode;
58 }
59
60 public void setEarnCode(String earnCode) {
61 this.earnCode = earnCode;
62 }
63
64 public String getHrEarnCodeGroupDefId() {
65 return hrEarnCodeGroupDefId;
66 }
67
68 public void setHrEarnCodeGroupDefId(String hrEarnCodeGroupDefId) {
69 this.hrEarnCodeGroupDefId = hrEarnCodeGroupDefId;
70 }
71
72 public String getHrEarnCodeGroupId() {
73 return hrEarnCodeGroupId;
74 }
75
76 public void setHrEarnCodeGroupId(String hrEarnCodeGroupId) {
77 this.hrEarnCodeGroupId = hrEarnCodeGroupId;
78 }
79
80 public EarnCodeBo getEarnCodeObj() {
81 return earnCodeObj;
82 }
83
84 public void setEarnCodeObj(EarnCodeBo earnCodeObj) {
85 this.earnCodeObj = earnCodeObj;
86 }
87
88
89 public String getEarnCodeDesc() {
90 EarnCodeContract earnCode =getEarnCodeService().getEarnCode(this.earnCode, LocalDate.now());
91
92 if(earnCode != null && StringUtils.isNotBlank(earnCode.getDescription())) {
93 return earnCode.getDescription();
94 }
95 return "";
96 }
97
98 public String getUserPrincipalId() {
99 return userPrincipalId;
100 }
101
102 public void setUserPrincipalId(String userPrincipalId) {
103 this.userPrincipalId = userPrincipalId;
104 }
105
106 public boolean isActive() {
107 return active;
108 }
109
110 public void setActive(boolean active) {
111 this.active = active;
112 }
113
114 @Override
115 public String getId() {
116 return hrEarnCodeGroupDefId;
117 }
118
119 public void setId(String id) {
120 setHrEarnCodeGroupDefId(id);
121 }
122
123 public static EarnCodeGroupDefinitionBo from(EarnCodeGroupDefinition im) {
124 if (im == null) {
125 return null;
126 }
127 EarnCodeGroupDefinitionBo ecgd = new EarnCodeGroupDefinitionBo();
128
129 ecgd.setHrEarnCodeGroupDefId(im.getHrEarnCodeGroupDefId());
130 ecgd.setEarnCode(im.getEarnCode());
131 ecgd.setHrEarnCodeGroupId(im.getHrEarnCodeGroupId());
132 ecgd.setActive(im.isActive());
133 ecgd.setUserPrincipalId(im.getUserPrincipalId());
134 ecgd.setVersionNumber(im.getVersionNumber());
135 ecgd.setObjectId(im.getObjectId());
136 return ecgd;
137 }
138
139 public static EarnCodeGroupDefinition to(EarnCodeGroupDefinitionBo bo) {
140 if (bo == null) {
141 return null;
142 }
143 return EarnCodeGroupDefinition.Builder.create(bo).build();
144 }
145
146 public EarnCodeService getEarnCodeService() {
147 if(earnCodeService == null) {
148 earnCodeService = HrServiceLocator.getEarnCodeService();
149 }
150 return earnCodeService;
151 }
152
153 public void setEarnCodeService(EarnCodeService earnCodeService) {
154 this.earnCodeService = earnCodeService;
155 }
156
157 }