Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Message |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2007-2008 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.kcb.bo; | |
17 | ||
18 | import java.sql.Timestamp; | |
19 | ||
20 | import javax.persistence.Basic; | |
21 | import javax.persistence.Column; | |
22 | import javax.persistence.Entity; | |
23 | import javax.persistence.FetchType; | |
24 | import javax.persistence.Id; | |
25 | import javax.persistence.Lob; | |
26 | import javax.persistence.Table; | |
27 | import javax.persistence.Version; | |
28 | ||
29 | import org.apache.commons.lang.StringUtils; | |
30 | import org.apache.commons.lang.builder.ToStringBuilder; | |
31 | ||
32 | /** | |
33 | * This class represents an abstract message that has been sent to a single user | |
34 | * recipient and may result in several {@link MessageDelivery}s. | |
35 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
36 | */ | |
37 | // this class could possibly just extend the MessageDTO | |
38 | @Entity | |
39 | @Table(name="KREN_MSG_T") | |
40 | public class Message { | |
41 | /** | |
42 | * Field names | |
43 | */ | |
44 | public static final String ID_FIELD = "id"; | |
45 | public static final String ORIGINID_FIELD = "originId"; | |
46 | ||
47 | @Id | |
48 | @Column(name="MSG_ID") | |
49 | private Long id; | |
50 | /** | |
51 | * The origin id is an id provided by the originating system that creates the message | |
52 | */ | |
53 | @Column(name="ORGN_ID", nullable=false) | |
54 | private String originId; | |
55 | @Column(name="DELIV_TYP", nullable=false) | |
56 | private String deliveryType; | |
57 | @Column(name="CHNL", nullable=false) | |
58 | private String channel; | |
59 | @Column(name="PRODCR", nullable=true) | |
60 | private String producer; | |
61 | 0 | @Column(name="CRTE_DTTM", nullable=false) |
62 | private Timestamp creationDateTime = new Timestamp(System.currentTimeMillis()); | |
63 | @Column(name="TTL", nullable=true) | |
64 | private String title; | |
65 | @Lob | |
66 | @Basic(fetch=FetchType.LAZY) | |
67 | @Column(name="CNTNT", nullable=false) | |
68 | private String content; | |
69 | @Column(name="CNTNT_TYP", nullable=true) | |
70 | private String contentType; | |
71 | @Column(name="URL", nullable=true) | |
72 | private String url; | |
73 | @Column(name="RECIP_ID", nullable=false) | |
74 | private String recipient; | |
75 | ||
76 | /** | |
77 | * Lock column for OJB optimistic locking | |
78 | */ | |
79 | @Version | |
80 | @Column(name="VER_NBR") | |
81 | private Integer lockVerNbr; | |
82 | ||
83 | /** | |
84 | * Normal no-arg constructor | |
85 | */ | |
86 | 0 | public Message() {} |
87 | ||
88 | /** | |
89 | * Shallow-copy constructor | |
90 | * @param m Message object to (shallow) copy | |
91 | */ | |
92 | 0 | public Message(Message m) { |
93 | 0 | this.id = m.id; |
94 | 0 | this.channel = m.channel; |
95 | 0 | this.content = m.content; |
96 | 0 | this.contentType = m.contentType; |
97 | 0 | this.creationDateTime = m.creationDateTime; |
98 | 0 | this.deliveryType = m.deliveryType; |
99 | 0 | this.lockVerNbr = m.lockVerNbr; |
100 | 0 | this.producer = m.producer; |
101 | 0 | this.recipient = m.recipient; |
102 | 0 | this.title = m.title; |
103 | 0 | } |
104 | ||
105 | /** | |
106 | * Gets the id attribute. | |
107 | * @return Returns the id. | |
108 | */ | |
109 | public Long getId() { | |
110 | 0 | return id; |
111 | } | |
112 | ||
113 | /** | |
114 | * Sets the id attribute value. | |
115 | * @param id The id to set. | |
116 | */ | |
117 | public void setId(Long id) { | |
118 | 0 | this.id = id; |
119 | 0 | } |
120 | ||
121 | /** | |
122 | * Gets the origin id | |
123 | * @return the origin id | |
124 | */ | |
125 | public String getOriginId() { | |
126 | 0 | return this.originId; |
127 | } | |
128 | ||
129 | /** | |
130 | * Sets the origin id | |
131 | * @param originId the origin id | |
132 | */ | |
133 | public void setOriginId(String originId) { | |
134 | 0 | this.originId = originId; |
135 | 0 | } |
136 | ||
137 | /** | |
138 | * Returns when this Notification entry was created | |
139 | * @return when this Notification entry was created | |
140 | */ | |
141 | public Timestamp getCreationDateTime() { | |
142 | 0 | return creationDateTime; |
143 | } | |
144 | ||
145 | /** | |
146 | * Sets the creation date of this Notification entry | |
147 | * @param created the creation date of this Notification entry | |
148 | */ | |
149 | public void setCreationDateTime(Timestamp created) { | |
150 | 0 | this.creationDateTime = created; |
151 | 0 | } |
152 | ||
153 | /** | |
154 | * Return value of lock column for OJB optimistic locking | |
155 | * @return value of lock column for OJB optimistic locking | |
156 | */ | |
157 | public Integer getLockVerNbr() { | |
158 | 0 | return lockVerNbr; |
159 | } | |
160 | ||
161 | /** | |
162 | * Set value of lock column for OJB optimistic locking | |
163 | * @param lockVerNbr value of lock column for OJB optimistic locking | |
164 | */ | |
165 | public void setLockVerNbr(Integer lockVerNbr) { | |
166 | 0 | this.lockVerNbr = lockVerNbr; |
167 | 0 | } |
168 | ||
169 | /** | |
170 | * Gets the recipient attribute. | |
171 | * @return Returns the recipient. | |
172 | */ | |
173 | public String getRecipient() { | |
174 | 0 | return recipient; |
175 | } | |
176 | ||
177 | /** | |
178 | * Sets the recipient attribute value. | |
179 | * @param recipients The recipient to set. | |
180 | */ | |
181 | public void setRecipient(String recipient) { | |
182 | 0 | this.recipient = recipient; |
183 | 0 | } |
184 | ||
185 | /** | |
186 | * Gets the content attribute. | |
187 | * @return Returns the content. | |
188 | */ | |
189 | public String getContent() { | |
190 | 0 | return content; |
191 | } | |
192 | ||
193 | /** | |
194 | * Sets the content attribute value. | |
195 | * @param content The content to set. | |
196 | */ | |
197 | public void setContent(String content) { | |
198 | 0 | this.content = content; |
199 | 0 | } |
200 | ||
201 | /** | |
202 | * Gets the contentType attribute. | |
203 | * @return Returns the contentType. | |
204 | */ | |
205 | public String getContentType() { | |
206 | 0 | return contentType; |
207 | } | |
208 | ||
209 | /** | |
210 | * Sets the contentType attribute value. | |
211 | * @param contentType The contentType to set. | |
212 | */ | |
213 | public void setContentType(String contentType) { | |
214 | 0 | this.contentType = contentType; |
215 | 0 | } |
216 | ||
217 | /** | |
218 | * @return the url | |
219 | */ | |
220 | public String getUrl() { | |
221 | 0 | return this.url; |
222 | } | |
223 | ||
224 | /** | |
225 | * @param url the url | |
226 | */ | |
227 | public void setUrl(String url) { | |
228 | 0 | this.url = url; |
229 | 0 | } |
230 | ||
231 | /** | |
232 | * Gets the deliveryType attribute. | |
233 | * @return Returns the deliveryType. | |
234 | */ | |
235 | public String getDeliveryType() { | |
236 | 0 | return deliveryType; |
237 | } | |
238 | ||
239 | /** | |
240 | * Sets the deliveryType attribute value. | |
241 | * @param deliveryType The deliveryType to set. | |
242 | */ | |
243 | public void setDeliveryType(String deliveryType) { | |
244 | 0 | this.deliveryType = deliveryType.toUpperCase(); |
245 | 0 | } |
246 | ||
247 | /** | |
248 | * Gets the title | |
249 | * @return the title of this notification | |
250 | */ | |
251 | public String getTitle() { | |
252 | 0 | return title; |
253 | } | |
254 | ||
255 | /** | |
256 | * Sets the title | |
257 | * @param title the title of this notification | |
258 | */ | |
259 | public void setTitle(String title) { | |
260 | 0 | this.title = title; |
261 | 0 | } |
262 | ||
263 | /** | |
264 | * Gets the channel | |
265 | * @return the channel | |
266 | */ | |
267 | public String getChannel() { | |
268 | 0 | return this.channel; |
269 | } | |
270 | ||
271 | /** | |
272 | * Sets the channel | |
273 | * @param channel the channel | |
274 | */ | |
275 | public void setChannel(String channel) { | |
276 | 0 | this.channel = channel; |
277 | 0 | } |
278 | ||
279 | /** | |
280 | * Gets the producer | |
281 | * @return the producer | |
282 | */ | |
283 | public String getProducer() { | |
284 | 0 | return this.producer; |
285 | } | |
286 | ||
287 | /** | |
288 | * Sets the producer | |
289 | * @param producer the producer | |
290 | */ | |
291 | public void setProducer(String producer) { | |
292 | 0 | this.producer = producer; |
293 | 0 | } |
294 | ||
295 | /** | |
296 | * @see java.lang.Object#toString() | |
297 | */ | |
298 | @Override | |
299 | public String toString() { | |
300 | 0 | return new ToStringBuilder(this) |
301 | .append("id", id) | |
302 | .append("creationDateTime", creationDateTime) | |
303 | .append("deliveryType", deliveryType) | |
304 | .append("recipient", recipient) | |
305 | .append("title", title) | |
306 | .append("channel", channel) | |
307 | .append("producer", producer) | |
308 | .append("content", StringUtils.abbreviate(content, 100)) | |
309 | .append("contentType", contentType) | |
310 | .append("lockVerNbr", lockVerNbr) | |
311 | .toString(); | |
312 | } | |
313 | ||
314 | } |