1 /**
2 * Copyright 2005-2006 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.businessobjects.reporting.persistence;
16
17 import org.figure8.join.core.persistence.HibernateObjectDao;
18 import org.figure8.join.businessobjects.reporting.Event;
19 import org.figure8.join.businessobjects.reporting.MailingList;
20 import org.figure8.join.util.LogUtil;
21
22 import org.apache.commons.logging.Log;
23
24 import java.util.List;
25 /**
26 * Implementation of MailingListDao using Hibernate ORM system.
27 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
28 * @version $Revision: 1.1 $
29 */
30 public class HibernateMailingListDao extends HibernateObjectDao implements MailingListDao{
31
32
33
34 /** Get a commons logger */
35 private static final Log log = LogUtil.getLog(HibernateMailingListDao.class);
36
37
38
39
40 /** Creates a new instance of HibernateMailingListDao */
41 public HibernateMailingListDao(){
42 }
43
44
45
46
47 /**
48 * Retrieve a mailing list using its name
49 * @param name The name of list to retrieve
50 * @return The mailing list corresponding or null if no list has specfied name
51 */
52 public MailingList getMailingList(String name){
53 MailingList result = (MailingList)findSingleObject(findNamedQueryStringParam("join.mailinglist_findByName", "mlName", name));
54 if (log.isDebugEnabled())
55 log.debug("Found a mailing list with name: " + name + " ? " + ((result != null) ? "true" : "false"));
56 return result;
57 }
58
59 /**
60 * Retrieve the mailing lists defined for given event
61 * @param event The event to get mailing lists for
62 * @return A list of {@code MailingList} objects for event
63 */
64 public List getMailingListsForEvent(Event event){
65 List result = findNamedQueryStringParam("join.mailinglist_findByEvent", "mlEvent", event);
66 if (log.isDebugEnabled())
67 log.debug("Found " + result.size() + " mailing lists corresponding to event " + event.getKey());
68 return result;
69 }
70
71
72
73
74 /** @return The org.figure8.join.businessobjects.reporting.MailingList class */
75 public Class getPersistentClass(){
76 return org.figure8.join.businessobjects.reporting.MailingList.class;
77 }
78 }