001/**
002 * Copyright 2005-2017 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 */
016package org.kuali.rice.ken.bo;
017
018import org.kuali.rice.ken.api.notification.NotificationPriority;
019import org.kuali.rice.ken.api.notification.NotificationPriorityContract;
020import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
021import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
022
023import javax.persistence.Column;
024import javax.persistence.Entity;
025import javax.persistence.GeneratedValue;
026import javax.persistence.Id;
027import javax.persistence.Table;
028
029/**
030 * This class represents a priority for a notification - i.e. "High", "Medium", "Low", "Emergency", etc.
031 * In addition, it describes information about a priority such as its ranking order of priority.  Priority 
032 * order within the system is assumed to be ascending.  This by no means impacts the order of delivery 
033 * of a notification system message.
034 * @author Kuali Rice Team (rice.collab@kuali.org)
035 */
036@Entity
037@Table(name="KREN_PRIO_T")
038public class NotificationPriorityBo extends PersistableBusinessObjectBase implements NotificationPriorityContract {
039    @Id
040    @GeneratedValue(generator="KREN_PRIO_S")
041    @PortableSequenceGenerator(name="KREN_PRIO_S")
042        @Column(name="PRIO_ID")
043        private Long id;
044    @Column(name="NM", nullable=false)
045        private String name;
046    @Column(name="DESC_TXT", nullable=false)
047        private String description;
048    @Column(name="PRIO_ORD", nullable=false)
049        private Integer order;
050    
051    /**
052     * Constructs a NotificationPriority instance.
053     */
054    public NotificationPriorityBo() {
055    }
056
057    /**
058     * Gets the description attribute. 
059     * @return Returns the description.
060     */
061    public String getDescription() {
062            return description;
063    }
064
065    /**
066     * Sets the description attribute value.
067     * @param description The description to set.
068     */
069    public void setDescription(String description) {
070            this.description = description;
071    }
072
073    /**
074     * Gets the id attribute. 
075     * @return Returns the id.
076     */
077    public Long getId() {
078            return id;
079    }
080
081    /**
082     * Sets the id attribute value.
083     * @param id The id to set.
084     */
085    public void setId(Long id) {
086            this.id = id;
087    }
088
089    /**
090     * Gets the name attribute. 
091     * @return Returns the name.
092     */
093    public String getName() {
094            return name;
095    }
096
097    /**
098     * Sets the name attribute value.
099     * @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