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.NotificationContentType; 019import org.kuali.rice.ken.api.notification.NotificationContentTypeContract; 020import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; 021import org.kuali.rice.krad.data.jpa.converters.BooleanTFConverter; 022import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator; 023 024import javax.persistence.Column; 025import javax.persistence.Convert; 026import javax.persistence.Entity; 027import javax.persistence.GeneratedValue; 028import javax.persistence.Id; 029import javax.persistence.Table; 030 031/** 032 * This class represents the different types of Notification content that the system can handle. 033 * For example, and instance of content type could be "Alert" or "Event". 034 * @author Kuali Rice Team (rice.collab@kuali.org) 035 */ 036@Entity 037@Table(name="KREN_CNTNT_TYP_T") 038public class NotificationContentTypeBo extends PersistableBusinessObjectBase implements NotificationContentTypeContract { 039 @Id 040 @GeneratedValue(generator="KREN_CNTNT_TYP_S") 041 @PortableSequenceGenerator(name="KREN_CNTNT_TYP_S") 042 @Column(name="CNTNT_TYP_ID", nullable=false) 043 private Long id; 044 @Column(name="NM", nullable=false) 045 private String name; 046 047 @Convert(converter = BooleanTFConverter.class) 048 @Column(name="CUR_IND", nullable=false) 049 private boolean current = true; 050 @Column(name="CNTNT_TYP_VER_NBR", nullable=false) 051 private Integer version = Integer.valueOf(0); 052 @Column(name="DESC_TXT", nullable=false) 053 private String description; 054 @Column(name="NMSPC_CD", nullable=false) 055 private String namespace; 056 @Column(name="XSD", nullable=false, length=4096) 057 private String xsd; 058 @Column(name="XSL", nullable=false, length=4096) 059 private String xsl; 060 061 /** 062 * Constructs a NotificationContentType instance. 063 */ 064 public NotificationContentTypeBo() { 065 } 066 067 /** 068 * Gets the description attribute. 069 * @return Returns the description. 070 */ 071 public String getDescription() { 072 return description; 073 } 074 075 /** 076 * Sets the description attribute value. 077 * @param description The description to set. 078 */ 079 public void setDescription(String description) { 080 this.description = description; 081 } 082 083 /** 084 * Gets the id attribute. 085 * @return Returns the id. 086 */ 087 public Long getId() { 088 return id; 089 } 090 091 /** 092 * Sets the id attribute value. 093 * @param id The id to set. 094 */ 095 public void setId(Long id) { 096 this.id = id; 097 } 098 099 /** 100 * Gets the name attribute. 101 * @return Returns the name. 102 */ 103 public String getName() { 104 return name; 105 } 106 107 /** 108 * @return whether this is the current version 109 */ 110 public boolean isCurrent() { 111 return this.current; 112 } 113 114 /** 115 * @param current whether this is the current version 116 */ 117 public void setCurrent(boolean current) { 118 this.current = current; 119 } 120 121 /** 122 * @return the version 123 */ 124 public Integer getVersion() { 125 return this.version; 126 } 127 128 /** 129 * @param version the version to set 130 */ 131 public void setVersion(Integer version) { 132 this.version = version; 133 } 134 135 /** 136 * Sets the name attribute value. 137 * @param name The name to set. 138 */ 139 public void setName(String name) { 140 this.name = name; 141 } 142 143 /** 144 * Gets the namespace attribute. 145 * @return Returns the namespace. 146 */ 147 public String getNamespace() { 148 return namespace; 149 } 150 151 /** 152 * Sets the namespace attribute value. 153 * @param namespace The namespace to set. 154 */ 155 public void setNamespace(String namespace) { 156 this.namespace = namespace; 157 } 158 159 /** 160 * Gets the xsd attribute. The value of this field is used to validate a notification's content field dynamically. 161 * @return Returns the xsd. 162 */ 163 public String getXsd() { 164 return xsd; 165 } 166 167 /** 168 * Sets the xsd attribute value. The value of this field is used to validate a notification's content field dynamically. 169 * @param xsd The xsd to set. 170 */ 171 public void setXsd(String xsd) { 172 this.xsd = xsd; 173 } 174 175 /** 176 * Gets the xsl attribute. The value of this field is used to render a notification's contents dynamically. 177 * @return Returns the xsl. 178 */ 179 public String getXsl() { 180 return xsl; 181 } 182 183 /** 184 * Sets the xsl attribute value. The value of this field is used to render a notification's contents dynamically. 185 * @param xsl The xsl to set. 186 */ 187 public void setXsl(String xsl) { 188 this.xsl = xsl; 189 } 190 191 /** 192 * Converts a mutable bo to its immutable counterpart 193 * @param bo the mutable business object 194 * @return the immutable object 195 */ 196 public static NotificationContentType to(NotificationContentTypeBo bo) { 197 if (bo == null) { 198 return null; 199 } 200 201 return NotificationContentType.Builder.create(bo).build(); 202 } 203 204 /** 205 * Converts a immutable object to its mutable counterpart 206 * @param im immutable object 207 * @return the mutable bo 208 */ 209 public static NotificationContentTypeBo from(NotificationContentType im) { 210 if (im == null) { 211 return null; 212 } 213 214 NotificationContentTypeBo bo = new NotificationContentTypeBo(); 215 bo.setId(im.getId()); 216 bo.setVersionNumber(im.getVersionNumber()); 217 bo.setObjectId(im.getObjectId()); 218 bo.setName(im.getName()); 219 bo.setDescription(im.getDescription()); 220 221 bo.setCurrent(im.isCurrent()); 222 bo.setVersion(im.getVersion()); 223 bo.setNamespace(im.getNamespace()); 224 bo.setXsd(im.getXsd()); 225 bo.setXsl(im.getXsl()); 226 return bo; 227 } 228}