1 /* 2 * Copyright (c) 2002-2021, City of 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.newsletter.business; 35 36 import fr.paris.lutece.portal.service.plugin.Plugin; 37 38 import java.util.Collection; 39 40 /** 41 * The interface representing the business methods of the subscriber 42 */ 43 public interface ISubscriberDAO 44 { 45 /** 46 * Insert a new record in the table. 47 * 48 * @param subscriber 49 * the object to be inserted 50 * @param plugin 51 * the Plugin 52 */ 53 void insert( Subscriber subscriber, Plugin plugin ); 54 55 /** 56 * Delete a record from the table 57 * 58 * @param nId 59 * the subscriber's identifier 60 * @param plugin 61 * the Plugin 62 */ 63 void delete( int nId, Plugin plugin ); 64 65 /** 66 * loads data from a subscriber's identifier 67 * 68 * @param nId 69 * the subscriber's identifier 70 * @param plugin 71 * the Plugin 72 * @return an object Subscriber 73 */ 74 Subscriber load( int nId, Plugin plugin ); 75 76 /** 77 * Loads the list of subscribers 78 * 79 * @param plugin 80 * the Plugin 81 * @return a collection of objects Subscriber 82 */ 83 Collection<Subscriber> selectAll( Plugin plugin ); 84 85 /** 86 * Finds a subscriber from his email 87 * 88 * @param strEmail 89 * the subscriber's email 90 * @param plugin 91 * the Plugin 92 * @return a subscriber object if it exists, null if not 93 */ 94 Subscriber selectByEmail( String strEmail, Plugin plugin ); 95 96 /** 97 * loads the list of subscribers for a newsletter 98 * 99 * @param nNewsLetterId 100 * the newsletter identifier 101 * @param plugin 102 * the Plugin 103 * @return a collection of subscribers 104 */ 105 Collection<Subscriber> selectSubscribers( int nNewsLetterId, Plugin plugin ); 106 107 /** 108 * loads the list of subscribers for a newsletter 109 * 110 * @param nNewsLetterId 111 * the newsletter identifier 112 * @param strSearchString 113 * gets all the subscribers if null or empty and gets the subscribers whith an email containing this string otherwise 114 * @param nBegin 115 * the rank of the first subscriber to return 116 * @param nEnd 117 * the maximum number of suscribers to return 118 * @param plugin 119 * the Plugin 120 * @return a collection of subscribers 121 */ 122 Collection<Subscriber> selectSubscribers( int nNewsLetterId, String strSearchString, int nBegin, int nEnd, Plugin plugin ); 123 124 /** 125 * loads the list of subscribers for a newsletter 126 * 127 * @param nNewsLetterId 128 * the newsletter identifier 129 * @param strSearchString 130 * gets all the subscribers if null or empty and gets the subscribers whith an email containing this string otherwise 131 * @param nBegin 132 * the rank of the first subscriber to return 133 * @param nEnd 134 * the maximum number of suscribers to return 135 * @param plugin 136 * the Plugin 137 * @return a collection of subscribers 138 */ 139 Collection<Subscriber> selectSubscribersForSending( int nNewsLetterId, String strSearchString, int nBegin, int nEnd, Plugin plugin ); 140 141 /** 142 * Returns, for a subscriber, the number of his subscriptions 143 * 144 * @param nSubscriberId 145 * the subscriber's identifier 146 * @param plugin 147 * the Plugin 148 * @return the number of subscriptions 149 */ 150 int selectNewsLetters( int nSubscriberId, Plugin plugin ); 151 152 /** 153 * loads the list of subscribers 154 * 155 * @param plugin 156 * the Plugin 157 * @return a collection of subscribers 158 */ 159 Collection<Subscriber> selectSubscribersList( Plugin plugin ); 160 }