1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.core.messages.bo;
17
18 import java.util.HashMap;
19 import java.util.LinkedHashMap;
20 import java.util.Map;
21
22 import javax.persistence.Entity;
23 import javax.persistence.Table;
24 import javax.persistence.Transient;
25
26 import org.kuali.rice.kns.service.KNSServiceLocator;
27 import org.kuali.student.core.bo.KsBusinessObjectBase;
28 import org.kuali.student.core.enumerationmanagement.bo.EnumeratedValue;
29
30 @Entity
31 @Table(name = "KSMG_MESSAGE")
32 public class MessageEntity extends KsBusinessObjectBase {
33
34 public static final String GROUP_NAME_ENUMERATION = "ks.message.groupNames";
35 public static final String LOCALE_ENUMERATION = "ks.message.locales";
36
37 private static final long serialVersionUID = 1L;
38
39
40 private String messageId;
41 private String locale;
42 private String groupName;
43 private String value;
44
45 @Transient
46 private transient EnumeratedValue localeEnumValue;
47
48 @Transient
49 private transient EnumeratedValue groupNameEnumValue;
50
51
52 @Override
53 protected LinkedHashMap<String, Object> toStringMapper() {
54
55 LinkedHashMap<String, Object> map = super.toStringMapper();
56
57 map.put("locale", locale);
58 map.put("groupName", groupName);
59 map.put("messageId", messageId);
60
61 return map;
62
63 }
64
65 protected EnumeratedValue retrieveEnumeratedValue(String enumerationId, String enumerationCode) {
66 Map<String, Object> criteria = new HashMap<String, Object>();
67 criteria.put("enumerationId", enumerationId);
68 criteria.put("code", enumerationCode);
69
70 return (EnumeratedValue) KNSServiceLocator.getBusinessObjectService().findByPrimaryKey(EnumeratedValue.class, criteria);
71 }
72
73
74 public String getLocale() {
75 return locale;
76 }
77
78 public void setLocale(String locale) {
79 this.locale = locale;
80 }
81
82 public String getGroupName() {
83 return groupName;
84 }
85
86 public void setGroupName(String groupName) {
87 this.groupName = groupName;
88 }
89
90 public String getMessageId() {
91 return messageId;
92 }
93
94 public void setMessageId(String messageId) {
95 this.messageId = messageId;
96 }
97
98 public String getValue() {
99 return value;
100 }
101
102 public void setValue(String value) {
103 this.value = value;
104 }
105
106
107 public EnumeratedValue getLocaleEnumValue() {
108 if(localeEnumValue == null) {
109 localeEnumValue = retrieveEnumeratedValue(LOCALE_ENUMERATION, this.locale);
110 }
111
112 return localeEnumValue;
113 }
114
115 public void setLocaleEnumValue(EnumeratedValue localeEnumValue) {
116 this.localeEnumValue = localeEnumValue;
117 }
118
119 public EnumeratedValue getGroupNameEnumValue() {
120 if(groupNameEnumValue == null) {
121 groupNameEnumValue = retrieveEnumeratedValue(GROUP_NAME_ENUMERATION, this.groupName);
122 }
123
124 return groupNameEnumValue;
125 }
126
127 public void setGroupNameEnumValue(EnumeratedValue groupNameEnumValue) {
128 this.groupNameEnumValue = groupNameEnumValue;
129 }
130
131 }