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