View Javadoc

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