Coverage Report - org.kuali.student.core.messages.bo.MessageEntity
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageEntity
0%
0/27
0%
0/4
1.154
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 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.krad.service.KRADServiceLocator;
 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  0
 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  
 // now handled with reflection    
 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  0
         Map<String, Object> criteria = new HashMap<String, Object>();
 67  0
         criteria.put("enumerationId", enumerationId);
 68  0
         criteria.put("code", enumerationCode);
 69  
         
 70  0
         return (EnumeratedValue) KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(EnumeratedValue.class, criteria);
 71  
     }
 72  
     
 73  
     
 74  
     public String getLocale() {
 75  0
         return locale;
 76  
     }
 77  
 
 78  
     public void setLocale(String locale) {
 79  0
         this.locale = locale;
 80  0
     }
 81  
 
 82  
     public String getGroupName() {
 83  0
         return groupName;
 84  
     }
 85  
 
 86  
     public void setGroupName(String groupName) {
 87  0
         this.groupName = groupName;
 88  0
     }
 89  
 
 90  
     public String getMessageId() {
 91  0
         return messageId;
 92  
     }
 93  
 
 94  
     public void setMessageId(String messageId) {
 95  0
         this.messageId = messageId;
 96  0
     }
 97  
 
 98  
     public String getValue() {
 99  0
         return value;
 100  
     }
 101  
 
 102  
     public void setValue(String value) {
 103  0
         this.value = value;
 104  0
     }
 105  
 
 106  
 
 107  
     public EnumeratedValue getLocaleEnumValue() {
 108  0
         if(localeEnumValue == null) {
 109  0
             localeEnumValue = retrieveEnumeratedValue(LOCALE_ENUMERATION, this.locale);            
 110  
         }
 111  
         
 112  0
         return localeEnumValue;
 113  
     }
 114  
 
 115  
     public void setLocaleEnumValue(EnumeratedValue localeEnumValue) {
 116  0
         this.localeEnumValue = localeEnumValue;
 117  0
     }
 118  
 
 119  
     public EnumeratedValue getGroupNameEnumValue() {
 120  0
         if(groupNameEnumValue == null) {
 121  0
             groupNameEnumValue = retrieveEnumeratedValue(GROUP_NAME_ENUMERATION, this.groupName);
 122  
         }
 123  
         
 124  0
         return groupNameEnumValue;
 125  
     }
 126  
 
 127  
     public void setGroupNameEnumValue(EnumeratedValue groupNameEnumValue) {
 128  0
         this.groupNameEnumValue = groupNameEnumValue;
 129  0
     }
 130  
 
 131  
 }