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