Coverage Report - org.kuali.rice.kcb.bo.MessageDelivery
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageDelivery
0%
0/38
0%
0/2
1.056
 
 1  
 /**
 2  
  * Copyright 2005-2011 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 javax.persistence.CascadeType;
 19  
 import javax.persistence.Column;
 20  
 import javax.persistence.Entity;
 21  
 import javax.persistence.FetchType;
 22  
 import javax.persistence.Id;
 23  
 import javax.persistence.JoinColumn;
 24  
 import javax.persistence.OneToOne;
 25  
 import javax.persistence.Table;
 26  
 import javax.persistence.Version;
 27  
 
 28  
 import org.apache.commons.lang.builder.ToStringBuilder;
 29  
 
 30  
 /**
 31  
  * This class represents an instance of a MessageDelivery.  A Message gets delivered to 
 32  
  * recipients, possibly in various ways.  For each delivery type that a recipient gets sent to them, 
 33  
  * they have an instance of this entity.
 34  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 35  
  */
 36  
 @Entity
 37  
 @Table(name="KREN_MSG_DELIV_T")
 38  
 public class MessageDelivery extends BaseLockable {
 39  0
     private static final Integer ZERO = Integer.valueOf(0);
 40  
 
 41  
     /**
 42  
      * Field names
 43  
      */
 44  
     public static final String ID_FIELD = "id";
 45  
     public static final String SYSTEMID_FIELD = "delivererSystemId";
 46  
     public static final String MESSAGEID_FIELD = "message";
 47  
     public static final String DELIVERY_STATUS = "deliveryStatus";
 48  
     public static final String PROCESS_COUNT = "processCount";
 49  
     
 50  
     @Id
 51  
         @Column(name="MSG_DELIV_ID")
 52  
         private Long id;
 53  
     @Column(name="TYP_NM", nullable=false)
 54  
         private String delivererTypeName;
 55  
     @Column(name="SYS_ID", nullable=true)
 56  
         private String delivererSystemId;  // can hold an identifier from the endpoint deliverer mechanism system (i.e. workflow id, SMS id, etc)
 57  0
     @Column(name="STAT_CD", nullable=true)
 58  
     private String deliveryStatus = MessageDeliveryStatus.UNDELIVERED.name();
 59  0
     @Column(name="PROC_CNT", nullable=true)
 60  
     private Integer processCount = ZERO;
 61  
 
 62  
     /**
 63  
      * This delivery's message
 64  
      */
 65  
     @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
 66  
         @JoinColumn(name="MSG_ID")
 67  
         private Message message;
 68  
 
 69  
     /**
 70  
      * Lock column for OJB optimistic locking
 71  
      */
 72  
     @Version
 73  
         @Column(name="VER_NBR")
 74  
         private Integer lockVerNbr;
 75  
     
 76  
     /**
 77  
      * Constructs a MessageDelivery instance.
 78  
      */
 79  0
     public MessageDelivery() {
 80  0
     }
 81  
 
 82  
     /**
 83  
      * Shallow-copy constructor
 84  
      * @param md MessageDelivery to (shallow) copy
 85  
      */
 86  0
     public MessageDelivery(MessageDelivery md) {
 87  0
         this.id = md.id;
 88  0
         this.delivererTypeName = md.delivererTypeName;
 89  0
         this.deliveryStatus = md.deliveryStatus;
 90  0
         this.delivererSystemId = md.delivererSystemId;
 91  0
         this.message = md.message;
 92  0
         this.lockVerNbr = md.lockVerNbr;
 93  0
     }
 94  
 
 95  
     /**
 96  
      * Gets the id attribute. 
 97  
      * @return Returns the id.
 98  
      */
 99  
     public Long getId() {
 100  0
         return id;
 101  
     }
 102  
 
 103  
     /**
 104  
      * Sets the id attribute value.
 105  
      * @param id The id to set.
 106  
      */
 107  
     public void setId(Long id) {
 108  0
         this.id = id;
 109  0
     }
 110  
 
 111  
 
 112  
     /**
 113  
      * Return value of lock column for OJB optimistic locking
 114  
      * @return value of lock column for OJB optimistic locking
 115  
      */
 116  
     public Integer getLockVerNbr() {
 117  0
         return lockVerNbr;
 118  
     }
 119  
 
 120  
     /**
 121  
      * Set value of lock column for OJB optimistic locking
 122  
      * @param lockVerNbr value of lock column for OJB optimistic locking
 123  
      */
 124  
     public void setLockVerNbr(Integer lockVerNbr) {
 125  0
         this.lockVerNbr = lockVerNbr;
 126  0
     }
 127  
 
 128  
     /**
 129  
      * Gets the deliveryStatus attribute. 
 130  
      * @return Returns the deliveryStatus.
 131  
      */
 132  
     public String getDeliveryStatus() {
 133  0
         return deliveryStatus;
 134  
     }
 135  
 
 136  
     /**
 137  
      * Convenience method that sets the delivery status in a typesafe manner.
 138  
      * This method is preferred to {@link #setDeliveryStatus(String)}
 139  
      * @param deliveryStatus the MessageDeliveryStatus enum constant
 140  
      */
 141  
     public void setDeliveryStatus(MessageDeliveryStatus deliveryStatus) {
 142  0
         this.deliveryStatus = deliveryStatus.name();
 143  0
     }
 144  
 
 145  
     /**
 146  
      * Sets the deliveryStatus attribute value.
 147  
      * @param deliveryStatus The deliveryStatus to set.
 148  
      */
 149  
     public void setDeliveryStatus(String deliveryStatus) {
 150  
         // Enums will throw an IllegalArgumentException from valueOf if there
 151  
         // is no matching enum
 152  0
         MessageDeliveryStatus.valueOf(deliveryStatus);
 153  0
         this.deliveryStatus = deliveryStatus;
 154  0
     }
 155  
 
 156  
     /**
 157  
      * @return the number of times processing has been attempted for this message
 158  
      */
 159  
     public Integer getProcessCount() {
 160  0
         return this.processCount;
 161  
     }
 162  
 
 163  
     /**
 164  
      * Sets the number of times processing has been attempted for this message
 165  
      * @param processCount the number of times processing has been attempted for this message
 166  
      */
 167  
     public void setProcessCount(Integer processCount) {
 168  0
         this.processCount = processCount;
 169  0
     }
 170  
 
 171  
     /**
 172  
      * Gets the delivererTypeName attribute. 
 173  
      * @return Returns the delivererTypeName.
 174  
      */
 175  
     public String getDelivererTypeName() {
 176  0
         return delivererTypeName;
 177  
     }
 178  
 
 179  
     /**
 180  
      * Sets the delivererTypeName attribute value.
 181  
      * @param delivererTypeName The delivererTypeName to set.
 182  
      */
 183  
     public void setDelivererTypeName(String delivererTypeName) {
 184  0
         this.delivererTypeName = delivererTypeName;
 185  0
     }
 186  
 
 187  
     /**
 188  
      * Gets the delivererSystemId attribute. 
 189  
      * @return Returns the delivererSystemId.
 190  
      */
 191  
     public String getDelivererSystemId() {
 192  0
         return delivererSystemId;
 193  
     }
 194  
 
 195  
     /**
 196  
      * Sets the delivererSystemId attribute value.
 197  
      * @param delivererSystemId The delivererSystemId to set.
 198  
      */
 199  
     public void setDelivererSystemId(String delivererSystemId) {
 200  0
         this.delivererSystemId = delivererSystemId;
 201  0
     }
 202  
 
 203  
     /**
 204  
      * @return this delivery's message
 205  
      */
 206  
     public Message getMessage() {
 207  0
         return this.message;
 208  
     }
 209  
 
 210  
     /**
 211  
      * Sets this delivery's message
 212  
      * @param message the message to set
 213  
      */
 214  
     public void setMessage(Message message) {
 215  0
         this.message = message;
 216  0
     }
 217  
 
 218  
     /**
 219  
      * @see java.lang.Object#toString()
 220  
      */
 221  
     @Override
 222  
     public String toString() {
 223  0
         return new ToStringBuilder(this)
 224  
                        .append("id", id)
 225  
                        .append("deliveryStatus", deliveryStatus)
 226  
                        .append("processCount", processCount)
 227  
                        .append("delivererTypename", delivererTypeName)
 228  
                        .append("delivererSystemId", delivererSystemId)
 229  
                        .append("message", message == null ? null : message.getId())
 230  
                        .toString();
 231  
     }
 232  
 }