View Javadoc
1   /**
2    * Copyright 2005-2014 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.kuali.rice.ken.api.notification.NotificationPriority;
19  import org.kuali.rice.ken.api.notification.NotificationPriorityContract;
20  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
21  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
22  
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.GeneratedValue;
26  import javax.persistence.Id;
27  import javax.persistence.Table;
28  
29  /**
30   * This class represents a priority for a notification - i.e. "High", "Medium", "Low", "Emergency", etc.
31   * In addition, it describes information about a priority such as its ranking order of priority.  Priority 
32   * order within the system is assumed to be ascending.  This by no means impacts the order of delivery 
33   * of a notification system message.
34   * @author Kuali Rice Team (rice.collab@kuali.org)
35   */
36  @Entity
37  @Table(name="KREN_PRIO_T")
38  public class NotificationPriorityBo extends PersistableBusinessObjectBase implements NotificationPriorityContract {
39      @Id
40      @GeneratedValue(generator="KREN_PRIO_S")
41      @PortableSequenceGenerator(name="KREN_PRIO_S")
42  	@Column(name="PRIO_ID")
43  	private Long id;
44      @Column(name="NM", nullable=false)
45  	private String name;
46      @Column(name="DESC_TXT", nullable=false)
47  	private String description;
48      @Column(name="PRIO_ORD", nullable=false)
49  	private Integer order;
50      
51      /**
52       * Constructs a NotificationPriority instance.
53       */
54      public NotificationPriorityBo() {
55      }
56  
57      /**
58       * Gets the description attribute. 
59       * @return Returns the description.
60       */
61      public String getDescription() {
62  	    return description;
63      }
64  
65      /**
66       * Sets the description attribute value.
67       * @param description The description to set.
68       */
69      public void setDescription(String description) {
70  	    this.description = description;
71      }
72  
73      /**
74       * Gets the id attribute. 
75       * @return Returns the id.
76       */
77      public Long getId() {
78  	    return id;
79      }
80  
81      /**
82       * Sets the id attribute value.
83       * @param id The id to set.
84       */
85      public void setId(Long id) {
86  	    this.id = id;
87      }
88  
89      /**
90       * Gets the name attribute. 
91       * @return Returns the name.
92       */
93      public String getName() {
94  	    return name;
95      }
96  
97      /**
98       * Sets the name attribute value.
99       * @param name The name to set.
100      */
101     public void setName(String name) {
102 	    this.name = name;
103     }
104 
105     /**
106      * Gets the order attribute. 
107      * @return Returns the order.
108      */
109     public Integer getOrder() {
110 	    return order;
111     }
112 
113     /**
114      * Sets the order attribute value.
115      * @param order The order to set.
116      */
117     public void setOrder(Integer order) {
118 	    this.order = order;
119     }
120 
121     /**
122      * Converts a mutable bo to its immutable counterpart
123      * @param bo the mutable business object
124      * @return the immutable object
125      */
126     public static NotificationPriority to(NotificationPriorityBo bo) {
127         if (bo == null) {
128             return null;
129         }
130 
131         return NotificationPriority.Builder.create(bo).build();
132     }
133 
134     /**
135      * Converts a immutable object to its mutable counterpart
136      * @param im immutable object
137      * @return the mutable bo
138      */
139     public static NotificationPriorityBo from(NotificationPriority im) {
140         if (im == null) {
141             return null;
142         }
143 
144         NotificationPriorityBo bo = new NotificationPriorityBo();
145         bo.setId(im.getId());
146         bo.setVersionNumber(im.getVersionNumber());
147         bo.setObjectId(im.getObjectId());
148         bo.setName(im.getName());
149         bo.setDescription(im.getDescription());
150         bo.setOrder(im.getOrder());
151 
152         return bo;
153     }
154 }
155