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.krad.messages; 017 018import javax.persistence.Column; 019import javax.persistence.Entity; 020import javax.persistence.Id; 021import javax.persistence.Table; 022import javax.persistence.UniqueConstraint; 023 024import org.kuali.rice.krad.bo.PersistableBusinessObjectBaseAdapter; 025 026/** 027 * Holds the text and metadata for a message that will be given by the system, including validation 028 * messages, UI text (labels, instructions), and other text that has been externalized from the 029 * system 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 */ 033@Entity 034@Table(name="KRAD_MSG_T",uniqueConstraints= { 035 @UniqueConstraint(name="KRAD_MSG_TC0",columnNames="OBJ_ID") 036}) 037public class Message extends PersistableBusinessObjectBaseAdapter { 038 private static final long serialVersionUID = -4827946497103099661L; 039 040 @Id 041 @Column(name="NMSPC_CD",length=20) 042 private String namespaceCode; 043 @Id 044 @Column(name="CMPNT_CD",length=100) 045 private String componentCode; 046 @Id 047 @Column(name="MSG_KEY",length=100) 048 private String key; 049 @Id 050 @Column(name="LOC",length=255) 051 private String locale; 052 053 @Column(name="MSG_DESC",length=255) 054 private String description; 055 @Column(name="TXT",length=4000) 056 private String text; 057 058 public Message() { 059 super(); 060 } 061 062 /** 063 * Namespace code (often an application or module code) that message is associated with, used for 064 * grouping messages 065 * 066 * @return String namespace code 067 */ 068 public String getNamespaceCode() { 069 return namespaceCode; 070 } 071 072 /** 073 * Setter for the namespace code the message should be associated with 074 * 075 * @param namespaceCode 076 */ 077 public void setNamespaceCode(String namespaceCode) { 078 this.namespaceCode = namespaceCode; 079 } 080 081 /** 082 * A code within the namespace that identifies a component or group, used for further grouping 083 * of messages within the namespace 084 * 085 * <p> 086 * Examples here could be a bean id, the class name of an object, or any application/module defined code 087 * </p> 088 * 089 * @return String representing a component code 090 */ 091 public String getComponentCode() { 092 return componentCode; 093 } 094 095 /** 096 * Setter for the component code the message should be associated with 097 * 098 * @param componentCode 099 */ 100 public void setComponentCode(String componentCode) { 101 this.componentCode = componentCode; 102 } 103 104 /** 105 * A key that uniquely identifies the message within the namespace and component 106 * 107 * <p> 108 * Within the UIF, this is generally used to indicate the property path the message is associated with 109 * (for example: "control.label"). For validation messages this is generally a combination that identifies 110 * the type of validation message and the validation performed (for example: "error.account.missing") 111 * </p> 112 * 113 * @return String message key 114 */ 115 public String getKey() { 116 return key; 117 } 118 119 /** 120 * Setter for the message key 121 * 122 * @param key 123 */ 124 public void setKey(String key) { 125 this.key = key; 126 } 127 128 /** 129 * Locale code the message is represented for, used for supporting messages in different 130 * languages 131 * 132 * @return message locale code 133 */ 134 public String getLocale() { 135 return locale; 136 } 137 138 /** 139 * Setter for the message locale code 140 * 141 * @param locale 142 */ 143 public void setLocale(String locale) { 144 this.locale = locale; 145 } 146 147 /** 148 * A description for the message 149 * 150 * <p> 151 * Not used by the framework, here for purposes of editing of messages and providing a description 152 * of the message to users 153 * </p> 154 * 155 * @return String message description 156 */ 157 public String getDescription() { 158 return description; 159 } 160 161 /** 162 * Setter for the message description 163 * 164 * @param description 165 */ 166 public void setDescription(String description) { 167 this.description = description; 168 } 169 170 /** 171 * Text value for the message 172 * 173 * <p> 174 * This holds the actual text for the message which is what will be displayed. Depending on how 175 * the message is being used it might contain parameters or other special syntax 176 * </p> 177 * 178 * @return String text for the message 179 */ 180 public String getText() { 181 return text; 182 } 183 184 /** 185 * Setter for the message text 186 * 187 * @param text 188 */ 189 public void setText(String text) { 190 this.text = text; 191 } 192 193 /** 194 * Generate toString using message key fields 195 * 196 * @return String representing the message object 197 */ 198 @Override 199 public final String toString() { 200 StringBuilder buffer = new StringBuilder(); 201 202 buffer.append("namespaceCode=" + this.namespaceCode); 203 buffer.append(",componentCode=" + this.componentCode); 204 buffer.append(",key=" + this.key); 205 buffer.append(",locale=" + this.locale); 206 207 return buffer.toString(); 208 } 209}