001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kcb.bo; 017 018 import java.sql.Timestamp; 019 020 import javax.persistence.Basic; 021 import javax.persistence.Column; 022 import javax.persistence.Entity; 023 import javax.persistence.FetchType; 024 import javax.persistence.Id; 025 import javax.persistence.Lob; 026 import javax.persistence.Table; 027 import javax.persistence.Version; 028 029 import org.apache.commons.lang.StringUtils; 030 import org.apache.commons.lang.builder.ToStringBuilder; 031 032 /** 033 * This class represents an abstract message that has been sent to a single user 034 * recipient and may result in several {@link MessageDelivery}s. 035 * @author Kuali Rice Team (rice.collab@kuali.org) 036 */ 037 // this class could possibly just extend the MessageDTO 038 @Entity 039 @Table(name="KREN_MSG_T") 040 public class Message { 041 /** 042 * Field names 043 */ 044 public static final String ID_FIELD = "id"; 045 public static final String ORIGINID_FIELD = "originId"; 046 047 @Id 048 @Column(name="MSG_ID") 049 private Long id; 050 /** 051 * The origin id is an id provided by the originating system that creates the message 052 */ 053 @Column(name="ORGN_ID", nullable=false) 054 private String originId; 055 @Column(name="DELIV_TYP", nullable=false) 056 private String deliveryType; 057 @Column(name="CHNL", nullable=false) 058 private String channel; 059 @Column(name="PRODCR", nullable=true) 060 private String producer; 061 @Column(name="CRTE_DTTM", nullable=false) 062 private Timestamp creationDateTime = new Timestamp(System.currentTimeMillis()); 063 @Column(name="TTL", nullable=true) 064 private String title; 065 @Lob 066 @Basic(fetch=FetchType.LAZY) 067 @Column(name="CNTNT", nullable=false) 068 private String content; 069 @Column(name="CNTNT_TYP", nullable=true) 070 private String contentType; 071 @Column(name="URL", nullable=true) 072 private String url; 073 @Column(name="RECIP_ID", nullable=false) 074 private String recipient; 075 076 /** 077 * Lock column for OJB optimistic locking 078 */ 079 @Version 080 @Column(name="VER_NBR") 081 private Integer lockVerNbr; 082 083 /** 084 * Normal no-arg constructor 085 */ 086 public Message() {} 087 088 /** 089 * Shallow-copy constructor 090 * @param m Message object to (shallow) copy 091 */ 092 public Message(Message m) { 093 this.id = m.id; 094 this.channel = m.channel; 095 this.content = m.content; 096 this.contentType = m.contentType; 097 this.creationDateTime = m.creationDateTime; 098 this.deliveryType = m.deliveryType; 099 this.lockVerNbr = m.lockVerNbr; 100 this.producer = m.producer; 101 this.recipient = m.recipient; 102 this.title = m.title; 103 } 104 105 /** 106 * Gets the id attribute. 107 * @return Returns the id. 108 */ 109 public Long getId() { 110 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 this.id = id; 119 } 120 121 /** 122 * Gets the origin id 123 * @return the origin id 124 */ 125 public String getOriginId() { 126 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 this.originId = originId; 135 } 136 137 /** 138 * Returns when this Notification entry was created 139 * @return when this Notification entry was created 140 */ 141 public Timestamp getCreationDateTime() { 142 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 this.creationDateTime = created; 151 } 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 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 this.lockVerNbr = lockVerNbr; 167 } 168 169 /** 170 * Gets the recipient attribute. 171 * @return Returns the recipient. 172 */ 173 public String getRecipient() { 174 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 this.recipient = recipient; 183 } 184 185 /** 186 * Gets the content attribute. 187 * @return Returns the content. 188 */ 189 public String getContent() { 190 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 this.content = content; 199 } 200 201 /** 202 * Gets the contentType attribute. 203 * @return Returns the contentType. 204 */ 205 public String getContentType() { 206 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 this.contentType = contentType; 215 } 216 217 /** 218 * @return the url 219 */ 220 public String getUrl() { 221 return this.url; 222 } 223 224 /** 225 * @param url the url 226 */ 227 public void setUrl(String url) { 228 this.url = url; 229 } 230 231 /** 232 * Gets the deliveryType attribute. 233 * @return Returns the deliveryType. 234 */ 235 public String getDeliveryType() { 236 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 this.deliveryType = deliveryType.toUpperCase(); 245 } 246 247 /** 248 * Gets the title 249 * @return the title of this notification 250 */ 251 public String getTitle() { 252 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 this.title = title; 261 } 262 263 /** 264 * Gets the channel 265 * @return the channel 266 */ 267 public String getChannel() { 268 return this.channel; 269 } 270 271 /** 272 * Sets the channel 273 * @param channel the channel 274 */ 275 public void setChannel(String channel) { 276 this.channel = channel; 277 } 278 279 /** 280 * Gets the producer 281 * @return the producer 282 */ 283 public String getProducer() { 284 return this.producer; 285 } 286 287 /** 288 * Sets the producer 289 * @param producer the producer 290 */ 291 public void setProducer(String producer) { 292 this.producer = producer; 293 } 294 295 /** 296 * @see java.lang.Object#toString() 297 */ 298 @Override 299 public String toString() { 300 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 }