1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.role;
17
18 import java.sql.Timestamp;
19 import java.util.Date;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.kpme.core.api.namespace.KPMENamespace;
23 import org.kuali.kpme.core.api.role.KPMERoleMemberBoContract;
24 import org.kuali.kpme.core.util.HrConstants;
25 import org.kuali.rice.kim.api.role.Role;
26 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
27 import org.kuali.rice.kim.impl.role.RoleMemberBo;
28
29 @SuppressWarnings("unchecked")
30 public abstract class KPMERoleMemberBo extends RoleMemberBo implements KPMERoleMemberBoContract {
31 public static final String CACHE_NAME = HrConstants.CacheNamespace.NAMESPACE_PREFIX + "KPMERoleMember";
32 private static final long serialVersionUID = 3137509859347223332L;
33
34 public Date getEffectiveDate() {
35 Date effectiveDate = null;
36
37 if (getActiveFromDate() != null) {
38 effectiveDate = getActiveFromDate().toDate();
39 }
40
41 return effectiveDate;
42 }
43
44 public void setEffectiveDate(Date effectiveDate) {
45 if (effectiveDate != null) {
46 setActiveFromDateValue(new Timestamp(effectiveDate.getTime()));
47 }
48 }
49
50 public Date getExpirationDate() {
51 Date expirationDate = null;
52
53 if (getActiveToDate() != null) {
54 expirationDate = getActiveToDate().toDate();
55 }
56
57 return expirationDate;
58 }
59
60 public void setExpirationDate(Date expirationDate) {
61 if (expirationDate != null) {
62 setActiveToDateValue(new Timestamp(expirationDate.getTime()));
63 }
64 }
65
66 public String getRoleName() {
67 String roleName = StringUtils.EMPTY;
68
69 if (getRoleId() != null) {
70 Role role = KimApiServiceLocator.getRoleService().getRole(getRoleId());
71
72 if (role != null) {
73 roleName = role.getName();
74 }
75 }
76
77 return roleName;
78 }
79
80 public void setRoleName(String roleName) {
81 if (StringUtils.isNotBlank(roleName)) {
82 setRoleId(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KPMENamespace.KPME_HR.getNamespaceCode(), roleName));
83 if (StringUtils.isBlank(getRoleId())) {
84 setRoleId(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KPMENamespace.KPME_TK.getNamespaceCode(), roleName));
85 if (StringUtils.isBlank(getRoleId())) {
86 setRoleId(KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(KPMENamespace.KPME_LM.getNamespaceCode(), roleName));
87 }
88 }
89 }
90 }
91
92 }