Coverage Report - org.kuali.rice.ken.bo.Notification
 
Classes in this File Line Coverage Branch Coverage Complexity
Notification
0%
0/60
N/A
1
 
 1  
 /*
 2  
  * Copyright 2007 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.ken.bo;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.hibernate.annotations.GenericGenerator;
 20  
 import org.hibernate.annotations.Parameter;
 21  
 import org.kuali.rice.ken.util.NotificationConstants;
 22  
 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
 23  
 
 24  
 import javax.persistence.*;
 25  
 import java.sql.Timestamp;
 26  
 import java.util.ArrayList;
 27  
 import java.util.List;
 28  
 
 29  
 /**
 30  
  * This class represents an instace of a notification message that is received by the overall 
 31  
  * system.
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  
 @Entity
 35  
 @Table(name="KREN_NTFCTN_T")
 36  
 public class Notification extends PersistableBusinessObjectBase implements Lockable {
 37  
    
 38  
     @Id
 39  
     @GeneratedValue(generator="KREN_NTFCTN_S")
 40  
         @GenericGenerator(name="KREN_NTFCTN_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 41  
                         @Parameter(name="sequence_name",value="KREN_NTFCTN_S"),
 42  
                         @Parameter(name="value_column",value="id")
 43  
         })
 44  
         @Column(name="NTFCTN_ID")
 45  
         private Long id;
 46  
     @Column(name="DELIV_TYP", nullable=false)
 47  
         private String deliveryType;
 48  
         @Column(name="CRTE_DTTM", nullable=false)
 49  
         private Timestamp creationDateTime;
 50  
         @Column(name="SND_DTTM", nullable=true)
 51  
         private Timestamp sendDateTime;
 52  
         @Column(name="AUTO_RMV_DTTM", nullable=true)
 53  
         private Timestamp autoRemoveDateTime;
 54  
     @Column(name="TTL", nullable=true)
 55  
         private String title;
 56  
     @Lob
 57  
         @Basic(fetch=FetchType.LAZY)
 58  
         @Column(name="CNTNT", nullable=false)
 59  
         private String content;
 60  
     @Column(name="PROCESSING_FLAG", nullable=false)
 61  
         private String processingFlag;
 62  
         @Column(name="LOCKD_DTTM", nullable=true)
 63  
         private Timestamp lockedDate;
 64  
     /**
 65  
      * Lock column for OJB optimistic locking
 66  
      */
 67  
 //    @Version
 68  
 //        @Column(name="VER_NBR")
 69  
 //        private Integer lockVerNbr;
 70  
     
 71  
     // object references
 72  
     @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH})
 73  
         @JoinColumn(name="PRIO_ID")
 74  
         private NotificationPriority priority;
 75  
     @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH})
 76  
         @JoinColumn(name="CNTNT_TYP_ID")
 77  
         private NotificationContentType contentType;
 78  
     @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH})
 79  
         @JoinColumn(name="CHNL_ID")
 80  
         private NotificationChannel channel;
 81  
     @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH})
 82  
         @JoinColumn(name="PRODCR_ID")
 83  
         private NotificationProducer producer;
 84  
     
 85  
     // lists
 86  
     @OneToMany(cascade={CascadeType.ALL},
 87  
            targetEntity=org.kuali.rice.ken.bo.NotificationRecipient.class, mappedBy="notification")
 88  
     @OrderBy("id ASC")
 89  
         private List<NotificationRecipient> recipients;
 90  
     @OneToMany(cascade={CascadeType.ALL},
 91  
            targetEntity=org.kuali.rice.ken.bo.NotificationSender.class, mappedBy="notification")
 92  
         @OrderBy("id ASC")
 93  
     private List<NotificationSender> senders;
 94  
     
 95  
     /**
 96  
      * Constructs a Notification instance.
 97  
      */
 98  0
     public Notification() {
 99  0
         recipients = new ArrayList<NotificationRecipient>();
 100  0
         senders = new ArrayList<NotificationSender>();
 101  0
         processingFlag = NotificationConstants.PROCESSING_FLAGS.UNRESOLVED;
 102  0
     }
 103  
 
 104  
     /**
 105  
      * Returns when this Notification entry was created 
 106  
      * @return when this Notification entry was created
 107  
      */
 108  
     public Timestamp getCreationDateTime() {
 109  0
         return creationDateTime;
 110  
     }
 111  
 
 112  
     /**
 113  
      * Sets the creation date of this Notification entry
 114  
      * @param created the creation date of this Notification entry
 115  
      */
 116  
     public void setCreationDateTime(Timestamp created) {
 117  0
         this.creationDateTime = created;
 118  0
     }
 119  
 
 120  
     /**
 121  
      * Return value of lock column for OJB optimistic locking
 122  
      * @return value of lock column for OJB optimistic locking
 123  
      */
 124  
  // should discard this method and call super directly
 125  
     public Integer getLockVerNbr() {
 126  0
             return Integer.valueOf(super.getVersionNumber().intValue());
 127  
     }
 128  
 
 129  
     /**
 130  
      * Set value of lock column for OJB optimistic locking
 131  
      * @param lockVerNbr value of lock column for OJB optimistic locking
 132  
      */
 133  
  // should discard this method and call super directly
 134  
     public void setLockVerNbr(Integer lockVerNbr) {
 135  0
             super.setVersionNumber(lockVerNbr.longValue());
 136  0
     }
 137  
 
 138  
     /**
 139  
      * Gets the recipients attribute. 
 140  
      * @return Returns the recipients.
 141  
      */
 142  
     public List<NotificationRecipient> getRecipients() {
 143  0
         return recipients;
 144  
     }
 145  
 
 146  
     /**
 147  
      * Sets the recipients attribute value.
 148  
      * @param recipients The recipients to set.
 149  
      */
 150  
     public void setRecipients(List<NotificationRecipient> recipients) {
 151  0
         this.recipients = recipients;
 152  0
     }
 153  
 
 154  
     /**
 155  
      * Retrieves a recipient at the specified index
 156  
      * @param index the index in the recipients collection
 157  
      * @return the recipient if found or null
 158  
      */
 159  
     public NotificationRecipient getRecipient(int index) {
 160  0
         return (NotificationRecipient) recipients.get(index);
 161  
     }
 162  
     
 163  
     /**
 164  
      * Adds a recipient
 165  
      * @param recipient The recipient to add
 166  
      */
 167  
     public void addRecipient(NotificationRecipient recipient) {
 168  0
         recipients.add(recipient);
 169  0
     }
 170  
 
 171  
     /**
 172  
      * Gets the senders attribute. 
 173  
      * @return Returns the senders.
 174  
      */
 175  
     public List<NotificationSender> getSenders() {
 176  0
         return senders;
 177  
     }
 178  
 
 179  
     /**
 180  
      * Sets the senders attribute value.
 181  
      * @param senders The senders to set.
 182  
      */
 183  
     public void setSenders(List<NotificationSender> senders) {
 184  0
         this.senders = senders;
 185  0
     }
 186  
 
 187  
     /**
 188  
      * Retrieves a sender at the specified index
 189  
      * @param index the index in the senders collection
 190  
      * @return the sender if found or null
 191  
      */
 192  
     public NotificationSender getSender(int index) {
 193  0
         return (NotificationSender) senders.get(index);
 194  
     }
 195  
     /**
 196  
      * Adds a sender
 197  
      * @param sender The sender to add
 198  
      */
 199  
     public void addSender(NotificationSender sender) {
 200  0
         senders.add(sender);
 201  0
     }
 202  
 
 203  
     /**
 204  
      * Gets the autoRemoveDateTime attribute. 
 205  
      * @return Returns the autoRemoveDateTime.
 206  
      */
 207  
     public Timestamp getAutoRemoveDateTime() {
 208  0
         return autoRemoveDateTime;
 209  
     }
 210  
 
 211  
     /**
 212  
      * Sets the autoRemoveDateTime attribute value.
 213  
      * @param autoRemoveDateTime The autoRemoveDateTime to set.
 214  
      */
 215  
     public void setAutoRemoveDateTime(Timestamp autoRemoveDateTime) {
 216  0
         this.autoRemoveDateTime = autoRemoveDateTime;
 217  0
     }
 218  
 
 219  
     /**
 220  
      * Gets the channel attribute. 
 221  
      * @return Returns the channel.
 222  
      */
 223  
     public NotificationChannel getChannel() {
 224  0
         return channel;
 225  
     }
 226  
 
 227  
     /**
 228  
      * Sets the channel attribute value.
 229  
      * @param channel The channel to set.
 230  
      */
 231  
     public void setChannel(NotificationChannel channel) {
 232  0
         this.channel = channel;
 233  0
     }
 234  
 
 235  
     /**
 236  
      * Gets the content attribute. 
 237  
      * @return Returns the content.
 238  
      */
 239  
     public String getContent() {
 240  0
         return content;
 241  
     }
 242  
 
 243  
     /**
 244  
      * Sets the content attribute value.
 245  
      * @param content The content to set.
 246  
      */
 247  
     public void setContent(String content) {
 248  0
         this.content = content;
 249  0
     }
 250  
 
 251  
     /**
 252  
      * Gets the contentType attribute. 
 253  
      * @return Returns the contentType.
 254  
      */
 255  
     public NotificationContentType getContentType() {
 256  0
         return contentType;
 257  
     }
 258  
 
 259  
     /**
 260  
      * Sets the contentType attribute value.
 261  
      * @param contentType The contentType to set.
 262  
      */
 263  
     public void setContentType(NotificationContentType contentType) {
 264  0
         this.contentType = contentType;
 265  0
     }
 266  
 
 267  
     /**
 268  
      * Gets the deliveryType attribute. 
 269  
      * @return Returns the deliveryType.
 270  
      */
 271  
     public String getDeliveryType() {
 272  0
         return deliveryType;
 273  
     }
 274  
 
 275  
     /**
 276  
      * Sets the deliveryType attribute value.
 277  
      * @param deliveryType The deliveryType to set.
 278  
      */
 279  
     public void setDeliveryType(String deliveryType) {
 280  0
         this.deliveryType = deliveryType.toUpperCase();
 281  0
     }
 282  
 
 283  
     /**
 284  
      * Gets the id attribute. 
 285  
      * @return Returns the id.
 286  
      */
 287  
     public Long getId() {
 288  0
         return id;
 289  
     }
 290  
 
 291  
     /**
 292  
      * Sets the id attribute value.
 293  
      * @param id The id to set.
 294  
      */
 295  
     public void setId(Long id) {
 296  0
         this.id = id;
 297  0
     }
 298  
 
 299  
     /**
 300  
      * Gets the priority attribute. 
 301  
      * @return Returns the priority.
 302  
      */
 303  
     public NotificationPriority getPriority() {
 304  0
         return priority;
 305  
     }
 306  
 
 307  
     /**
 308  
      * Sets the priority attribute value.
 309  
      * @param priority The priority to set.
 310  
      */
 311  
     public void setPriority(NotificationPriority priority) {
 312  0
         this.priority = priority;
 313  0
     }
 314  
 
 315  
     /**
 316  
      * Gets the producer attribute. 
 317  
      * @return Returns the producer.
 318  
      */
 319  
     public NotificationProducer getProducer() {
 320  0
         return producer;
 321  
     }
 322  
 
 323  
     /**
 324  
      * Sets the producer attribute value.
 325  
      * @param producer The producer to set.
 326  
      */
 327  
     public void setProducer(NotificationProducer producer) {
 328  0
         this.producer = producer;
 329  0
     }
 330  
 
 331  
     /**
 332  
      * Gets the sendDateTime attribute. 
 333  
      * @return Returns the sendDateTime.
 334  
      */
 335  
     public Timestamp getSendDateTime() {
 336  0
         return sendDateTime;
 337  
     }
 338  
 
 339  
     /**
 340  
      * Sets the sendDateTime attribute value.
 341  
      * @param sendDateTime The sendDateTime to set.
 342  
      */
 343  
     public void setSendDateTime(Timestamp sendDateTime) {
 344  0
         this.sendDateTime = sendDateTime;
 345  0
     }
 346  
 
 347  
     /**
 348  
      * Gets the processingFlag attribute. 
 349  
      * @return Returns the processingFlag.
 350  
      */
 351  
     public String getProcessingFlag() {
 352  0
         return processingFlag;
 353  
     }
 354  
 
 355  
     /**
 356  
      * Sets the processingFlag attribute value.
 357  
      * @param processingFlag The processingFlag to set.
 358  
      */
 359  
     public void setProcessingFlag(String processingFlag) {
 360  0
         this.processingFlag = processingFlag;
 361  0
     }
 362  
     
 363  
     /**
 364  
      * Gets the lockedDate attribute. 
 365  
      * @return Returns the lockedDate.
 366  
      */
 367  
     public Timestamp getLockedDate() {
 368  0
         return lockedDate;
 369  
     }
 370  
     
 371  
     /**
 372  
      * Sets the lockedDate attribute value.
 373  
      * @param lockedDate The lockedDate to set.
 374  
      */
 375  
     public void setLockedDate(Timestamp lockedDate) {
 376  0
         this.lockedDate = lockedDate;
 377  0
     }
 378  
 
 379  
     /**
 380  
      * Gets the title
 381  
      * @return the title of this notification
 382  
      */
 383  
     public String getTitle() {
 384  0
         return title;
 385  
     }
 386  
 
 387  
     /**
 388  
      * Sets the title
 389  
      * @param title the title of this notification
 390  
      */
 391  
     public void setTitle(String title) {
 392  0
         this.title = title;
 393  0
     }
 394  
 
 395  
     /**
 396  
      * This method just uses StringUtils to get at the content of the <message> tag 
 397  
      * that exists in the notification content.
 398  
      * @return String
 399  
      */
 400  
     public String getContentMessage() {
 401  0
         return StringUtils.substringBetween(content, NotificationConstants.XML_MESSAGE_CONSTANTS.MESSAGE_OPEN, NotificationConstants.XML_MESSAGE_CONSTANTS.MESSAGE_CLOSE);        
 402  
     }
 403  
 }