1 package org.kuali.kpme.edo.committeesready;
2
3 import java.sql.Timestamp;
4
5 import org.joda.time.DateTime;
6 import org.kuali.kpme.core.groupkey.HrGroupKeyBo;
7 import org.kuali.kpme.core.service.HrServiceLocator;
8 import org.kuali.kpme.edo.api.committeesready.EdoCommitteesReady;
9 import org.kuali.kpme.edo.api.committeesready.EdoCommitteesReadyContract;
10 import org.kuali.rice.core.api.mo.ModelObjectUtils;
11 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
12
13 import com.google.common.collect.ImmutableList;
14
15 public class EdoCommitteesReadyBo extends PersistableBusinessObjectBase implements EdoCommitteesReadyContract {
16
17 private static final long serialVersionUID = -1822153069956148475L;
18
19 static class KeyFields {
20 private static final String GROUP_KEY_CODE = "groupKeyCode";
21 }
22
23 private String edoCommitteesReadyId;
24 private boolean ready;
25 private String userPrincipalId;
26 private String groupKeyCode;
27 private transient HrGroupKeyBo groupKey;
28 private Timestamp timestamp;
29
30 public static final ImmutableList<String> BUSINESS_KEYS = new ImmutableList.Builder<String>()
31 .add(KeyFields.GROUP_KEY_CODE)
32 .build();
33
34 public String getEdoCommitteesReadyId() {
35 return edoCommitteesReadyId;
36 }
37
38 public void setEdoCommitteesReadyId(String edoCommitteesReadyId) {
39 this.edoCommitteesReadyId = edoCommitteesReadyId;
40 }
41
42 public boolean isReady() {
43 return ready;
44 }
45
46 public void setReady(boolean ready) {
47 this.ready = ready;
48 }
49
50 @Override
51 public String getUserPrincipalId() {
52 return userPrincipalId;
53 }
54
55 public void setUserPrincipalId(String userPrincipalId) {
56 this.userPrincipalId = userPrincipalId;
57 }
58
59 @Override
60 public String getGroupKeyCode() {
61 return groupKeyCode;
62 }
63
64 public void setGroupKeyCode(String groupKeyCode) {
65 this.groupKeyCode = groupKeyCode;
66 }
67
68 @Override
69 public HrGroupKeyBo getGroupKey() {
70 if (groupKey == null) {
71 groupKey = HrGroupKeyBo.from(HrServiceLocator.getHrGroupKeyService().getHrGroupKey(getGroupKeyCode(), getCreateTime().toLocalDate()));
72 }
73 return groupKey;
74 }
75
76 public void setGroupKey(HrGroupKeyBo groupKey) {
77 this.groupKey = groupKey;
78 }
79
80 public Timestamp getTimestamp() {
81 return timestamp == null ? null : new Timestamp(timestamp.getTime());
82 }
83
84 public DateTime getCreateTime() {
85 return timestamp == null ? null : new DateTime(timestamp.getTime());
86 }
87
88 public void setTimestamp(Timestamp timestamp) {
89 this.timestamp = timestamp;
90 }
91
92 public static EdoCommitteesReadyBo from(EdoCommitteesReady im) {
93 if (im == null) {
94 return null;
95 }
96
97 EdoCommitteesReadyBo ecd = new EdoCommitteesReadyBo();
98
99 ecd.setEdoCommitteesReadyId(im.getEdoCommitteesReadyId());
100 ecd.setReady(im.isReady());
101 ecd.setUserPrincipalId(im.getUserPrincipalId());
102 ecd.setGroupKeyCode(im.getGroupKeyCode());
103 ecd.setGroupKey(HrGroupKeyBo.from(im.getGroupKey()));
104 ecd.setTimestamp(im.getCreateTime() == null ? null : new Timestamp(im.getCreateTime().getMillis()));
105 ecd.setVersionNumber(im.getVersionNumber());
106 ecd.setObjectId(im.getObjectId());
107
108 return ecd;
109 }
110
111 public static EdoCommitteesReady to(EdoCommitteesReadyBo bo) {
112 if (bo == null) {
113 return null;
114 }
115
116 return EdoCommitteesReady.Builder.create(bo).build();
117 }
118
119 public static final ModelObjectUtils.Transformer<EdoCommitteesReadyBo, EdoCommitteesReady> toImmutable = new ModelObjectUtils.Transformer<EdoCommitteesReadyBo, EdoCommitteesReady>() {
120 public EdoCommitteesReady transform(EdoCommitteesReadyBo input) {
121 return EdoCommitteesReadyBo.to(input);
122 };
123 };
124
125 public static final ModelObjectUtils.Transformer<EdoCommitteesReady, EdoCommitteesReadyBo> toBo = new ModelObjectUtils.Transformer<EdoCommitteesReady, EdoCommitteesReadyBo>() {
126 public EdoCommitteesReadyBo transform(EdoCommitteesReady input) {
127 return EdoCommitteesReadyBo.from(input);
128 };
129 };
130 }