View Javadoc
1   /**
2    * Copyright 2005-2015 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.krad.messages;
17  
18  import javax.persistence.Column;
19  import javax.persistence.Entity;
20  import javax.persistence.Id;
21  import javax.persistence.Table;
22  import javax.persistence.UniqueConstraint;
23  
24  import org.kuali.rice.krad.bo.PersistableBusinessObjectBaseAdapter;
25  
26  /**
27   * Holds the text and metadata for a message that will be given by the system, including validation
28   * messages, UI text (labels, instructions), and other text that has been externalized from the
29   * system
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  @Entity
34  @Table(name="KRAD_MSG_T",uniqueConstraints= {
35          @UniqueConstraint(name="KRAD_MSG_TC0",columnNames="OBJ_ID")
36  })
37  public class Message extends PersistableBusinessObjectBaseAdapter {
38      private static final long serialVersionUID = -4827946497103099661L;
39      
40      @Id
41      @Column(name="NMSPC_CD",length=20)
42      private String namespaceCode;
43      @Id
44      @Column(name="CMPNT_CD",length=100)
45      private String componentCode;
46      @Id
47      @Column(name="MSG_KEY",length=100)
48      private String key;
49      @Id
50      @Column(name="LOC",length=255)
51      private String locale;
52  
53      @Column(name="MSG_DESC",length=255)
54      private String description;
55      @Column(name="TXT",length=4000)
56      private String text;
57  
58      public Message() {
59          super();
60      }
61  
62      /**
63       * Namespace code (often an application or module code) that message is associated with, used for
64       * grouping messages
65       *
66       * @return String namespace code
67       */
68      public String getNamespaceCode() {
69          return namespaceCode;
70      }
71  
72      /**
73       * Setter for the namespace code the message should be associated with
74       *
75       * @param namespaceCode
76       */
77      public void setNamespaceCode(String namespaceCode) {
78          this.namespaceCode = namespaceCode;
79      }
80  
81      /**
82       * A code within the namespace that identifies a component or group, used for further grouping
83       * of messages within the namespace
84       *
85       * <p>
86       * Examples here could be a bean id, the class name of an object, or any application/module defined code
87       * </p>
88       *
89       * @return String representing a component code
90       */
91      public String getComponentCode() {
92          return componentCode;
93      }
94  
95      /**
96       * Setter for the component code the message should be associated with
97       *
98       * @param componentCode
99       */
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 }