View Javadoc

1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kcb.service.impl;
17  
18  import java.util.Collection;
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.kuali.rice.kcb.bo.Message;
23  import org.kuali.rice.kcb.service.MessageService;
24  
25  /**
26   * MessageService implementation 
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   *
30   */
31  public class MessageServiceImpl extends BusinessObjectServiceImpl implements MessageService {
32      /**
33       * @see org.kuali.rice.kcb.service.MessageService#deleteMessage(org.kuali.rice.kcb.bo.Message)
34       */
35      public void deleteMessage(Message message) {
36          dao.delete(message);
37      }
38  
39      /**
40       * @see org.kuali.rice.kcb.service.MessageService#getMessage(java.lang.Long)
41       */
42      public Message getMessage(Long id) {
43          Map<String, Object> fields = new HashMap<String, Object>(1);
44          fields.put(Message.ID_FIELD, id);
45          Message m = (Message) dao.findByPrimaryKey(Message.class, fields);
46          return m;
47      }
48  
49      /**
50       * @see org.kuali.rice.kcb.service.MessageService#getAllMessages()
51       */
52      public Collection<Message> getAllMessages() {
53          return dao.findAll(Message.class);
54      }
55  
56      /**
57       * @see org.kuali.rice.kcb.service.MessageService#saveMessage(org.kuali.rice.kcb.bo.Message)
58       */
59      public void saveMessage(Message message) {
60          dao.save(message);
61      }
62  
63      /**
64       * @see org.kuali.rice.kcb.service.MessageService#getMessageByOriginId(java.lang.String)
65       */
66      public Message getMessageByOriginId(String originId) {
67          Map<String, Object> fields = new HashMap<String, Object>(1);
68          fields.put(Message.ORIGINID_FIELD, originId);
69          Collection<Message> messages = dao.findMatching(Message.class, fields);
70          if (messages.size() == 0) {
71              return null;
72          }
73          return messages.iterator().next();
74      }
75  }