001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.ken.service.impl; 017 018 import org.kuali.rice.core.framework.persistence.dao.GenericDao; 019 import org.kuali.rice.ken.bo.NotificationChannelBo; 020 import org.kuali.rice.ken.service.NotificationChannelService; 021 022 import java.util.Collection; 023 import java.util.HashMap; 024 import java.util.Map; 025 026 /** 027 * NotificationChannelService implementation - uses the businessObjectDao to get at data in the underlying database. 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030 public class NotificationChannelServiceImpl implements NotificationChannelService { 031 private GenericDao businessObjectDao; 032 033 /** 034 * Constructs a NotificationChannelServiceImpl.java. 035 * @param businessObjectDao 036 */ 037 public NotificationChannelServiceImpl(GenericDao businessObjectDao) { 038 this.businessObjectDao = businessObjectDao; 039 } 040 041 /** 042 * @see org.kuali.rice.ken.service.NotificationChannelService#getNotificationChannel(java.lang.String) 043 */ 044 public NotificationChannelBo getNotificationChannel(String id) { 045 Map<String, String> primaryKeys = new HashMap<String, String>(); 046 primaryKeys.put("id", id); 047 return (NotificationChannelBo) businessObjectDao.findByPrimaryKey(NotificationChannelBo.class, primaryKeys); 048 } 049 050 /** 051 * @see org.kuali.rice.ken.service.NotificationChannelService#getNotificationChannelByName(java.lang.String) 052 */ 053 public NotificationChannelBo getNotificationChannelByName(String name) { 054 Map<String, String> fields = new HashMap<String, String>(); 055 fields.put("name", name); 056 Collection<NotificationChannelBo> found = businessObjectDao.findMatching(NotificationChannelBo.class, fields); 057 assert(found.size() <= 1); 058 if (found.size() == 0) return null; 059 return found.iterator().next(); 060 } 061 062 /** 063 * @see org.kuali.rice.ken.service.NotificationChannelService#getSubscribableChannels() 064 */ 065 public Collection getSubscribableChannels() { 066 Map<String, Boolean> fieldValues = new HashMap<String, Boolean>(); 067 String sortField = new String("name"); 068 fieldValues.put("subscribable", true); 069 return businessObjectDao.findMatchingOrderBy(NotificationChannelBo.class, fieldValues, sortField, true); 070 } 071 072 /** 073 * @see org.kuali.rice.ken.service.NotificationChannelService#getAllNotificationChannels() 074 */ 075 public Collection getAllNotificationChannels() { 076 String sortField = new String("name"); 077 return businessObjectDao.findAllOrderBy(NotificationChannelBo.class, sortField, true); 078 } 079 }