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.core.messages.dao.MessageManagementDAO; |
24 | |
import org.kuali.student.core.messages.dto.LocaleKeyList; |
25 | |
import org.kuali.student.core.messages.dto.Message; |
26 | |
import org.kuali.student.core.messages.dto.MessageGroupKeyList; |
27 | |
import org.kuali.student.core.messages.dto.MessageList; |
28 | |
import org.kuali.student.core.messages.entity.MessageEntity; |
29 | |
import org.kuali.student.core.messages.service.MessageService; |
30 | |
import org.slf4j.Logger; |
31 | |
import org.slf4j.LoggerFactory; |
32 | |
import org.springframework.transaction.annotation.Transactional; |
33 | |
|
34 | |
@WebService(endpointInterface = "org.kuali.student.core.messages.service.MessageService", serviceName = "MessageService", portName = "MessageService", targetNamespace = "http://student.kuali.org/wsdl/messages") |
35 | |
@Transactional |
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 | |
public LocaleKeyList getLocales() { |
55 | |
|
56 | 1 | List<String> locales = this.messageDAO.getLocales(); |
57 | |
|
58 | 1 | LocaleKeyList keyList = new LocaleKeyList(); |
59 | 1 | keyList.setLocales(locales); |
60 | |
|
61 | 1 | return keyList; |
62 | |
} |
63 | |
|
64 | |
public MessageGroupKeyList getMessageGroups() { |
65 | 1 | List<String> groups = this.messageDAO.getMessageGroups(); |
66 | |
|
67 | 1 | MessageGroupKeyList keyList = new MessageGroupKeyList(); |
68 | 1 | keyList.setMessageGroupKeys(groups); |
69 | |
|
70 | 1 | return keyList; |
71 | |
} |
72 | |
|
73 | |
public Message getMessage(String localeKey, String messageGroupKey, String messageKey) { |
74 | 4 | Message message = null; |
75 | 4 | if(localeKey == null || messageGroupKey == null || messageKey == null){ |
76 | 0 | return null; |
77 | |
} |
78 | |
else{ |
79 | 4 | MessageEntity messageEntity = this.messageDAO.getMessage(localeKey, messageGroupKey, messageKey); |
80 | 4 | if(messageEntity != null){ |
81 | 3 | message = new Message(); |
82 | 3 | MessageAssembler.toMessage(messageEntity,message); |
83 | |
} |
84 | |
} |
85 | 4 | return message; |
86 | |
} |
87 | |
|
88 | |
public MessageList getMessages(String localeKey, String messageGroupKey) { |
89 | 3 | if(localeKey == null || messageGroupKey == null){ |
90 | 0 | return new MessageList(); |
91 | |
} |
92 | |
else{ |
93 | 3 | List<MessageEntity> messages = this.messageDAO.getMessages(localeKey, messageGroupKey); |
94 | |
|
95 | 3 | MessageList messageList = new MessageList(); |
96 | 3 | List<Message> messageDTOs = MessageAssembler.toMessageList(messages,Message.class); |
97 | 3 | messageList.setMessages(messageDTOs); |
98 | 3 | return messageList; |
99 | |
} |
100 | |
} |
101 | |
|
102 | |
public MessageList getMessagesByGroups(String localeKey, MessageGroupKeyList messageGroupKeyList) { |
103 | 2 | if(localeKey == null || messageGroupKeyList == null){ |
104 | 0 | return new MessageList(); |
105 | |
} |
106 | |
else{ |
107 | 2 | List<MessageEntity> messages = this.messageDAO.getMessagesByGroups(localeKey, messageGroupKeyList.getMessageGroupKeys()); |
108 | 2 | MessageList messageList = new MessageList(); |
109 | 2 | List<Message> messageDTOs = MessageAssembler.toMessageList(messages,Message.class); |
110 | 2 | messageList.setMessages(messageDTOs); |
111 | 2 | return messageList; |
112 | |
} |
113 | |
} |
114 | |
|
115 | |
public Message updateMessage(String localeKey, String messageGroupKey, String messageKey, Message messageInfo) { |
116 | |
|
117 | 1 | if(localeKey == null || messageGroupKey == null || messageKey == null || messageInfo == null){ |
118 | 0 | return null; |
119 | |
} |
120 | |
else{ |
121 | 1 | MessageEntity messageEntity = new MessageEntity(); |
122 | 1 | MessageAssembler.toMessageEntity( messageInfo, messageEntity); |
123 | 1 | messageEntity = messageDAO.updateMessage(localeKey, messageGroupKey, messageKey, messageEntity); |
124 | 1 | MessageAssembler.toMessage( messageEntity,messageInfo); |
125 | 1 | return messageInfo; |
126 | |
} |
127 | |
} |
128 | |
|
129 | |
public Message addMessage(Message messageInfo) { |
130 | 0 | if(messageInfo != null) { |
131 | 0 | MessageEntity messageEntity = new MessageEntity(); |
132 | 0 | MessageAssembler.toMessageEntity(messageInfo, messageEntity); |
133 | 0 | messageEntity = messageDAO.addMessage(messageEntity); |
134 | 0 | MessageAssembler.toMessage(messageEntity, messageInfo); |
135 | |
} |
136 | 0 | return messageInfo; |
137 | |
} |
138 | |
|
139 | |
} |