Coverage Report - org.kuali.student.core.messages.service.impl.MessageServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageServiceImpl
10%
5/49
0%
0/26
2.7
 
 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.service.impl;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import javax.jws.WebService;
 21  
 import javax.jws.soap.SOAPBinding;
 22  
 
 23  
 import org.kuali.student.common.exceptions.DoesNotExistException;
 24  
 import org.kuali.student.common.messages.dto.LocaleKeyList;
 25  
 import org.kuali.student.common.messages.dto.Message;
 26  
 import org.kuali.student.common.messages.dto.MessageGroupKeyList;
 27  
 import org.kuali.student.common.messages.dto.MessageList;
 28  
 import org.kuali.student.common.messages.service.MessageService;
 29  
 import org.kuali.student.core.messages.dao.MessageManagementDAO;
 30  
 import org.kuali.student.core.messages.entity.MessageEntity;
 31  
 import org.slf4j.Logger;
 32  
 import org.slf4j.LoggerFactory;
 33  
 import org.springframework.transaction.annotation.Transactional;
 34  
 
 35  
 @WebService(endpointInterface = "org.kuali.student.common.messages.service.MessageService", serviceName = "MessageService", portName = "MessageService", targetNamespace = "http://student.kuali.org/wsdl/messages")
 36  
 @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
 37  
 public class MessageServiceImpl implements MessageService{
 38  
     
 39  1
         final static Logger logger = LoggerFactory.getLogger(MessageServiceImpl.class);
 40  
         
 41  
         private MessageManagementDAO messageDAO;
 42  
         
 43  2
         public MessageServiceImpl() {
 44  2
         }
 45  
         
 46  
     public MessageManagementDAO getMessageDAO() {
 47  0
         return messageDAO;
 48  
     }
 49  
 
 50  
     public void setMessageDAO(MessageManagementDAO messageDAO) {
 51  1
         this.messageDAO = messageDAO;
 52  1
     }
 53  
 
 54  
     @Transactional(readOnly=true)
 55  
         public LocaleKeyList getLocales() {
 56  
         
 57  0
                 List<String> locales = this.messageDAO.getLocales();
 58  
                 
 59  0
                 LocaleKeyList keyList = new LocaleKeyList();
 60  0
                 keyList.setLocales(locales);
 61  
   
 62  0
                 return keyList;
 63  
         }
 64  
         
 65  
     @Transactional(readOnly=true)
 66  
         public MessageGroupKeyList getMessageGroups() {
 67  0
                 List<String> groups = this.messageDAO.getMessageGroups();
 68  
                 
 69  0
                 MessageGroupKeyList keyList = new MessageGroupKeyList();
 70  0
                 keyList.setMessageGroupKeys(groups);
 71  
 
 72  0
                 return keyList;
 73  
         }
 74  
 
 75  
     @Transactional(readOnly=true)
 76  
         public Message getMessage(String localeKey, String messageGroupKey, String messageKey) {
 77  0
                 Message message = null;
 78  0
                 if(localeKey == null || messageGroupKey == null || messageKey == null){
 79  0
                         return null;
 80  
                 }
 81  
                 else{
 82  0
                         MessageEntity messageEntity = this.messageDAO.getMessage(localeKey, messageGroupKey, messageKey);
 83  0
                         if(messageEntity != null){
 84  0
                                 message = new Message();
 85  0
                                 MessageAssembler.toMessage(messageEntity,message); 
 86  
                         }
 87  
                 }
 88  0
                 return message;
 89  
         }
 90  
 
 91  
     @Transactional(readOnly=true)
 92  
         public MessageList getMessages(String localeKey, String messageGroupKey) {
 93  0
                 if(localeKey == null || messageGroupKey == null){
 94  0
                         return new MessageList();
 95  
                 }
 96  
                 else{
 97  0
                         List<MessageEntity> messages =  this.messageDAO.getMessages(localeKey, messageGroupKey);
 98  
                 
 99  0
                 MessageList messageList = new MessageList();
 100  0
                 List<Message> messageDTOs =  MessageAssembler.toMessageList(messages,Message.class);
 101  0
                 messageList.setMessages(messageDTOs);
 102  0
                         return messageList;
 103  
                 }
 104  
         }
 105  
 
 106  
     @Transactional(readOnly=true)
 107  
         public MessageList getMessagesByGroups(String localeKey, MessageGroupKeyList messageGroupKeyList) {
 108  0
                 if(localeKey == null || messageGroupKeyList == null){
 109  0
                         return new MessageList();
 110  
                 }
 111  
                 else{
 112  0
                         List<MessageEntity> messages =  this.messageDAO.getMessagesByGroups(localeKey, messageGroupKeyList.getMessageGroupKeys());
 113  0
                     MessageList messageList = new MessageList();
 114  0
                     List<Message> messageDTOs =  MessageAssembler.toMessageList(messages,Message.class);
 115  0
                     messageList.setMessages(messageDTOs);
 116  0
                         return messageList;
 117  
                 }
 118  
         }
 119  
 
 120  
         @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 121  
         public Message updateMessage(String localeKey, String messageGroupKey, String messageKey, Message messageInfo) {
 122  
                 
 123  0
                 if(localeKey == null || messageGroupKey == null || messageKey == null || messageInfo == null){
 124  0
                         return null;
 125  
                 }
 126  
                 else{
 127  0
                     MessageEntity messageEntity = new MessageEntity();    
 128  0
                     MessageAssembler.toMessageEntity( messageInfo, messageEntity);
 129  0
                     messageEntity =  messageDAO.updateMessage(localeKey, messageGroupKey, messageKey, messageEntity);
 130  0
                     MessageAssembler.toMessage( messageEntity,messageInfo);
 131  0
                     return messageInfo;
 132  
                 }        
 133  
         }
 134  
 
 135  
         @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 136  
         public Message addMessage(Message messageInfo) {
 137  0
                 if(messageInfo != null)        {
 138  0
                         MessageEntity messageEntity = new MessageEntity();    
 139  0
                         MessageAssembler.toMessageEntity(messageInfo, messageEntity);
 140  0
                         messageEntity =  messageDAO.addMessage(messageEntity);
 141  0
                         MessageAssembler.toMessage(messageEntity, messageInfo);
 142  
                 }
 143  0
                 return messageInfo;
 144  
         }
 145  
     
 146  
 }