1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
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 | |
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
37 | |
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) |
38 | |
public class MessageServiceImpl implements MessageService{ |
39 | |
|
40 | 0 | final static Logger logger = LoggerFactory.getLogger(MessageServiceImpl.class); |
41 | |
|
42 | |
private MessageManagementDAO messageDAO; |
43 | |
|
44 | 0 | public MessageServiceImpl() { |
45 | 0 | } |
46 | |
|
47 | |
public MessageManagementDAO getMessageDAO() { |
48 | 0 | return messageDAO; |
49 | |
} |
50 | |
|
51 | |
public void setMessageDAO(MessageManagementDAO messageDAO) { |
52 | 0 | this.messageDAO = messageDAO; |
53 | 0 | } |
54 | |
|
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 | |
public MessageGroupKeyList getMessageGroups() { |
66 | 0 | List<String> groups = this.messageDAO.getMessageGroups(); |
67 | |
|
68 | 0 | MessageGroupKeyList keyList = new MessageGroupKeyList(); |
69 | 0 | keyList.setMessageGroupKeys(groups); |
70 | |
|
71 | 0 | return keyList; |
72 | |
} |
73 | |
|
74 | |
public Message getMessage(String localeKey, String messageGroupKey, String messageKey) { |
75 | 0 | Message message = null; |
76 | 0 | if(localeKey == null || messageGroupKey == null || messageKey == null){ |
77 | 0 | return null; |
78 | |
} |
79 | |
else{ |
80 | 0 | MessageEntity messageEntity = this.messageDAO.getMessage(localeKey, messageGroupKey, messageKey); |
81 | 0 | if(messageEntity != null){ |
82 | 0 | message = new Message(); |
83 | 0 | MessageAssembler.toMessage(messageEntity,message); |
84 | |
} |
85 | |
} |
86 | 0 | return message; |
87 | |
} |
88 | |
|
89 | |
public MessageList getMessages(String localeKey, String messageGroupKey) { |
90 | 0 | if(localeKey == null || messageGroupKey == null){ |
91 | 0 | return new MessageList(); |
92 | |
} |
93 | |
else{ |
94 | 0 | List<MessageEntity> messages = this.messageDAO.getMessages(localeKey, messageGroupKey); |
95 | |
|
96 | 0 | MessageList messageList = new MessageList(); |
97 | 0 | List<Message> messageDTOs = MessageAssembler.toMessageList(messages,Message.class); |
98 | 0 | messageList.setMessages(messageDTOs); |
99 | 0 | return messageList; |
100 | |
} |
101 | |
} |
102 | |
|
103 | |
public MessageList getMessagesByGroups(String localeKey, MessageGroupKeyList messageGroupKeyList) { |
104 | 0 | if(localeKey == null || messageGroupKeyList == null){ |
105 | 0 | return new MessageList(); |
106 | |
} |
107 | |
else{ |
108 | 0 | List<MessageEntity> messages = this.messageDAO.getMessagesByGroups(localeKey, messageGroupKeyList.getMessageGroupKeys()); |
109 | 0 | MessageList messageList = new MessageList(); |
110 | 0 | List<Message> messageDTOs = MessageAssembler.toMessageList(messages,Message.class); |
111 | 0 | messageList.setMessages(messageDTOs); |
112 | 0 | return messageList; |
113 | |
} |
114 | |
} |
115 | |
|
116 | |
@Transactional(readOnly=false) |
117 | |
public Message updateMessage(String localeKey, String messageGroupKey, String messageKey, Message messageInfo) { |
118 | |
|
119 | 0 | if(localeKey == null || messageGroupKey == null || messageKey == null || messageInfo == null){ |
120 | 0 | return null; |
121 | |
} |
122 | |
else{ |
123 | 0 | MessageEntity messageEntity = new MessageEntity(); |
124 | 0 | MessageAssembler.toMessageEntity( messageInfo, messageEntity); |
125 | 0 | messageEntity = messageDAO.updateMessage(localeKey, messageGroupKey, messageKey, messageEntity); |
126 | 0 | MessageAssembler.toMessage( messageEntity,messageInfo); |
127 | 0 | return messageInfo; |
128 | |
} |
129 | |
} |
130 | |
|
131 | |
@Transactional(readOnly=false) |
132 | |
public Message addMessage(Message messageInfo) { |
133 | 0 | if(messageInfo != null) { |
134 | 0 | MessageEntity messageEntity = new MessageEntity(); |
135 | 0 | MessageAssembler.toMessageEntity(messageInfo, messageEntity); |
136 | 0 | messageEntity = messageDAO.addMessage(messageEntity); |
137 | 0 | MessageAssembler.toMessage(messageEntity, messageInfo); |
138 | |
} |
139 | 0 | return messageInfo; |
140 | |
} |
141 | |
|
142 | |
} |