View Javadoc

1   /**
2    * Copyright 2005-2012 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.ken.service.impl;
17  
18  import org.kuali.rice.core.framework.persistence.dao.GenericDao;
19  import org.kuali.rice.ken.bo.NotificationChannelBo;
20  import org.kuali.rice.ken.service.NotificationChannelService;
21  
22  import java.util.Collection;
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  /**
27   * NotificationChannelService implementation - uses the businessObjectDao to get at data in the underlying database.
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  public class NotificationChannelServiceImpl implements NotificationChannelService {
31      private GenericDao businessObjectDao;
32  
33      /**
34       * Constructs a NotificationChannelServiceImpl.java.
35       * @param businessObjectDao
36       */
37      public NotificationChannelServiceImpl(GenericDao businessObjectDao) {
38          this.businessObjectDao = businessObjectDao;
39      }
40  
41      /**
42       * @see org.kuali.rice.ken.service.NotificationChannelService#getNotificationChannel(java.lang.String)
43       */
44      public NotificationChannelBo getNotificationChannel(String id) {
45          Map<String,  String> primaryKeys = new HashMap<String, String>();
46          primaryKeys.put("id", id);
47          return (NotificationChannelBo) businessObjectDao.findByPrimaryKey(NotificationChannelBo.class, primaryKeys);
48      }
49  
50      /**
51       * @see org.kuali.rice.ken.service.NotificationChannelService#getNotificationChannelByName(java.lang.String)
52       */
53      public NotificationChannelBo getNotificationChannelByName(String name) {
54          Map<String,  String> fields = new HashMap<String, String>();
55          fields.put("name", name);
56          Collection<NotificationChannelBo> found = businessObjectDao.findMatching(NotificationChannelBo.class, fields);
57          assert(found.size() <= 1);
58          if (found.size() == 0) return null;
59          return found.iterator().next();
60      }
61  
62      /**
63       * @see org.kuali.rice.ken.service.NotificationChannelService#getSubscribableChannels()
64       */
65      public Collection getSubscribableChannels() {
66          Map<String, Boolean> fieldValues = new HashMap<String, Boolean>();
67          String sortField = new String("name");
68          fieldValues.put("subscribable", true);
69          return businessObjectDao.findMatchingOrderBy(NotificationChannelBo.class, fieldValues, sortField, true);
70      }
71  
72      /**
73       * @see org.kuali.rice.ken.service.NotificationChannelService#getAllNotificationChannels()
74       */
75      public Collection getAllNotificationChannels() {
76          String sortField = new String("name");
77          return businessObjectDao.findAllOrderBy(NotificationChannelBo.class, sortField, true);
78      }
79  }