1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.bo;
17
18 import org.kuali.rice.ken.api.notification.UserChannelSubscription;
19 import org.kuali.rice.ken.api.notification.UserChannelSubscriptionContract;
20 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
21 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
22
23 import javax.persistence.CascadeType;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.FetchType;
27 import javax.persistence.GeneratedValue;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.OneToOne;
31 import javax.persistence.Table;
32
33
34
35
36
37
38 @Entity
39 @Table(name="KREN_CHNL_SUBSCRP_T")
40 public class UserChannelSubscriptionBo extends PersistableBusinessObjectBase implements UserChannelSubscriptionContract {
41 @Id
42 @GeneratedValue(generator="KREN_CHNL_SUBSCRP_S")
43 @PortableSequenceGenerator(name="KREN_CHNL_SUBSCRP_S")
44 @Column(name="CHNL_SUBSCRP_ID")
45 private Long id;
46 @Column(name="PRNCPL_ID", nullable=false)
47 private String userId;
48
49 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.MERGE})
50 @JoinColumn(name="CHNL_ID")
51 private NotificationChannelBo channel;
52
53
54
55
56 public UserChannelSubscriptionBo() {
57 }
58
59
60
61
62
63 public NotificationChannelBo getChannel() {
64 return channel;
65 }
66
67
68
69
70
71 public void setChannel(NotificationChannelBo channel) {
72 this.channel = channel;
73 }
74
75
76
77
78
79 public Long getId() {
80 return id;
81 }
82
83
84
85
86
87 public void setId(Long id) {
88 this.id = id;
89 }
90
91
92
93
94
95 public String getUserId() {
96 return userId;
97 }
98
99
100
101
102
103 public void setUserId(String userId) {
104 this.userId = userId;
105 }
106
107
108
109
110
111
112 public static UserChannelSubscription to(UserChannelSubscriptionBo bo) {
113 if (bo == null) {
114 return null;
115 }
116
117 return UserChannelSubscription.Builder.create(bo).build();
118 }
119
120
121
122
123
124
125 public static UserChannelSubscriptionBo from(UserChannelSubscription im) {
126 if (im == null) {
127 return null;
128 }
129
130 UserChannelSubscriptionBo bo = new UserChannelSubscriptionBo();
131 bo.setId(im.getId());
132 bo.setVersionNumber(im.getVersionNumber());
133 bo.setObjectId(im.getObjectId());
134
135 bo.setUserId(im.getUserId());
136 bo.setChannel(im.getChannel() == null ? null : NotificationChannelBo.from(im.getChannel()));
137
138 return bo;
139 }
140 }
141