1 /* 2 * Copyright (c) 2002-2014, Mairie de Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package fr.paris.lutece.plugins.calendar.business; 35 36 import fr.paris.lutece.portal.service.plugin.Plugin; 37 38 import java.sql.Timestamp; 39 40 import java.util.List; 41 42 43 /** 44 * The interface representing the business methods of the subscriber 45 */ 46 public interface ICalendarSubscriberDAO 47 { 48 /** 49 * Insert a new record in the table. 50 * 51 * @param subscriber the object to be inserted 52 * @param plugin the Plugin 53 */ 54 void insert( CalendarSubscriber subscriber, Plugin plugin ); 55 56 /** 57 * Delete a record from the table 58 * 59 * @param nId the subscriber's identifier 60 * @param plugin the Plugin 61 */ 62 void delete( int nId, Plugin plugin ); 63 64 /** 65 * loads data from a subscriber's identifier 66 * 67 * @param nId the subscriber's identifier 68 * @param plugin the Plugin 69 * @return an object Subscriber 70 */ 71 CalendarSubscriber load( int nId, Plugin plugin ); 72 73 /** 74 * Update the record in the table 75 * 76 * @param subscriber the instance of subscriber class to be updated 77 * @param plugin the Plugin 78 */ 79 void store( CalendarSubscriber subscriber, Plugin plugin ); 80 81 /** 82 * Loads the list of subscribers 83 * 84 * @param plugin the Plugin 85 * @return a collection of objects Subscriber 86 */ 87 List<CalendarSubscriber> selectAll( Plugin plugin ); 88 89 /** 90 * Finds a subscriber from his email 91 * 92 * @param strEmail the subscriber's email 93 * @param plugin the Plugin 94 * @return a subscriber object if it exists, null if not 95 */ 96 CalendarSubscriber selectByEmail( String strEmail, Plugin plugin ); 97 98 /** 99 * loads the list of subscribers for a calendar 100 * 101 * @param nCalendarId the Calendar identifier 102 * @param plugin the Plugin 103 * @return a collection of subscribers 104 */ 105 List<CalendarSubscriber> selectSubscribers( int nCalendarId, Plugin plugin ); 106 107 /** 108 * loads the list of subscribers for a Calendar 109 * 110 * @param nCalendarId the Calendar identifier 111 * @param strSearchString gets all the subscribers if null or empty 112 * and gets the subscribers whith an email containing this string otherwise 113 * @param nBegin the rank of the first subscriber to return 114 * @param nEnd the maximum number of suscribers to return 115 * @param plugin the Plugin 116 * @return a collection of subscribers 117 */ 118 List<CalendarSubscriber> selectSubscribers( int nCalendarId, String strSearchString, int nBegin, int nEnd, 119 Plugin plugin ); 120 121 /** 122 * Returns, for a subscriber, the number of his subscriptions 123 * 124 * @param nCalendarId the Calendar identifier 125 * @param plugin the Plugin 126 * @return the number of subscriptions 127 */ 128 int selectSubscriberNumber( int nCalendarId, Plugin plugin ); 129 130 /** 131 * loads the list of subscribers 132 * 133 * @param plugin the Plugin 134 * @return a collection of subscribers 135 */ 136 List<CalendarSubscriber> selectSubscribersList( Plugin plugin ); 137 138 /** 139 * Remove the subscriber's inscription to a newsletter 140 * @param nSubscriberId the subscriber identifier 141 * @param nCalendarId the Calendar identifier 142 * @param plugin the Plugin 143 */ 144 void deleteSubscriber( int nSubscriberId, int nCalendarId, Plugin plugin ); 145 146 /** 147 * insert a new subscriber for a calendar 148 * 149 * @param nCalendarId the calendar identifier 150 * @param nSubscriberId the subscriber indentifier 151 * @param plugin the Plugin 152 * @param tToday the day 153 */ 154 void insertSubscriber( int nCalendarId, int nSubscriberId, Timestamp tToday, Plugin plugin ); 155 156 /** 157 * Check if the user is subscribed to any calendar 158 * @param nSubscriberId the ID of the subscriber 159 * @param plugin plugin 160 * @return true if the user is subscribed to any calendar, false otherwise 161 */ 162 boolean isUserSubscribed( int nSubscriberId, Plugin plugin ); 163 }