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 import fr.paris.lutece.util.ReferenceList; 38 39 import java.sql.Timestamp; 40 import java.util.Collection; 41 42 /* 43 * The interface defining the business methods used by the newsletter plugin 44 */ 45 46 /** 47 * The interface representing the business methods data layer must implement 48 */ 49 public interface INewsLetterDAO 50 { 51 /** 52 * Insert a new record in the table. 53 * 54 * @param newsLetter 55 * the object to insert 56 * @param plugin 57 * the Plugin 58 */ 59 void insert( NewsLetter newsLetter, Plugin plugin ); 60 61 /** 62 * Remove a record from the table 63 * 64 * @param nNewsLetterId 65 * the newsletter identifier 66 * @param plugin 67 * the Plugin 68 */ 69 void delete( int nNewsLetterId, Plugin plugin ); 70 71 /** 72 * loads the data of the newsletter from the table 73 * 74 * @param nNewsLetterId 75 * the newsletter identifier 76 * @param plugin 77 * the Plugin 78 * @return the object inserted 79 */ 80 NewsLetter load( int nNewsLetterId, Plugin plugin ); 81 82 /** 83 * Update the record in the table 84 * 85 * @param newsLetter 86 * the object to be updated 87 * @param plugin 88 * the Plugin 89 */ 90 void store( NewsLetter newsLetter, Plugin plugin ); 91 92 /** 93 * Check the unicity of the primary key 94 * 95 * @param nKey 96 * the key to be checked 97 * @param plugin 98 * the Plugin 99 * @return true if the identifier exist and false if not 100 */ 101 boolean checkPrimaryKey( int nKey, Plugin plugin ); 102 103 /** 104 * Checks whether a portlet uses the newsletter 105 * 106 * 107 * @return true if the newsletter is used 108 * @param nIdNewsletter 109 * the id of the newsletter 110 */ 111 boolean checkLinkedPortlet( int nIdNewsletter ); 112 113 /** 114 * Generate a new primary key to add a newsletter 115 * 116 * @param plugin 117 * the Plugin 118 * @return the new key 119 */ 120 int newPrimaryKey( Plugin plugin ); 121 122 /** 123 * Select the list of the newsletters available 124 * 125 * @param plugin 126 * the Plugin 127 * @return a collection of objects 128 */ 129 Collection<NewsLetter> selectAll( Plugin plugin ); 130 131 /** 132 * Select the list of the newsletters available 133 * 134 * @param plugin 135 * the Plugin 136 * @return a {@link ReferenceList} of id and name 137 */ 138 ReferenceList selectAllId( Plugin plugin ); 139 140 /** 141 * Gets a collection of NewsLetter associated with a given template 142 * 143 * @param nTemplateId 144 * The id of the template 145 * @param plugin 146 * the Plugin 147 * @return the collection of objects 148 */ 149 Collection<NewsLetter> selectAllByTemplateId( int nTemplateId, Plugin plugin ); 150 151 /** 152 * Insert a new subscriber for a newsletter 153 * 154 * @param nNewsLetterId 155 * the newsletter identifier 156 * @param nSubscriberId 157 * the subscriber identifier 158 * @param tToday 159 * The day 160 * @param plugin 161 * the Plugin 162 */ 163 void insertSubscriber( int nNewsLetterId, int nSubscriberId, Timestamp tToday, Plugin plugin ); 164 165 /** 166 * Performs confirm unsubscription process 167 * 168 * @param confirmLimitDate 169 * all unconfirmed subscriber which subscription date is below confirmLimitDate will be deleted 170 * @param plugin 171 * the plugin 172 */ 173 void deleteOldUnconfirmed( Timestamp confirmLimitDate, Plugin plugin ); 174 175 /** 176 * Insert a new subscriber for a newsletter 177 * 178 * @param nNewsLetterId 179 * the newsletter identifier 180 * @param nSubscriberId 181 * the subscriber identifier 182 * @param bValidate 183 * the validation status 184 * @param tToday 185 * The day 186 * @param plugin 187 * the Plugin 188 */ 189 void insertSubscriber( int nNewsLetterId, int nSubscriberId, boolean bValidate, Timestamp tToday, Plugin plugin ); 190 191 /** 192 * Updates a subscriber for a newsletter 193 * 194 * @param nNewsLetterId 195 * the newsletter identifier 196 * @param nSubscriberId 197 * the subscriber identifier 198 * @param plugin 199 * the Plugin 200 */ 201 void validateSubscriber( int nNewsLetterId, int nSubscriberId, Plugin plugin ); 202 203 /** 204 * Remove the subscriber's inscription to a newsletter 205 * 206 * @param nNewsLetterId 207 * the newsletter identifier 208 * @param nSubscriberId 209 * the subscriber identifier 210 * @param plugin 211 * the Plugin 212 */ 213 void deleteSubscriber( int nNewsLetterId, int nSubscriberId, Plugin plugin ); 214 215 /** 216 * check if the subscriber is not yet registered to a newsletter 217 * 218 * @param nNewsLetterId 219 * the newsletter identifier 220 * @param nSubscriberId 221 * the subscriber identifier 222 * @param plugin 223 * the Plugin 224 * @return true if he is registered and false if not 225 */ 226 boolean isRegistered( int nNewsLetterId, int nSubscriberId, Plugin plugin ); 227 228 /** 229 * controls that a template is used by a newsletter 230 * 231 * @param nTemplateId 232 * the template identifier 233 * @param plugin 234 * the Plugin 235 * @return true if the template is used, false if not 236 */ 237 boolean isTemplateUsed( int nTemplateId, Plugin plugin ); 238 239 /** 240 * Counts the subscribers for a newsletter 241 * 242 * @param nNewsLetterId 243 * the newsletter newsletter 244 * @param strSearchString 245 * the string to search in the subscriber's email 246 * @param plugin 247 * the Plugin 248 * @return the number of subscribers 249 */ 250 int selectNbrSubscribers( int nNewsLetterId, String strSearchString, Plugin plugin ); 251 252 /** 253 * Counts the active subscribers for a newsletter 254 * 255 * @param nNewsLetterId 256 * the newsletter newsletter 257 * @param strSearchString 258 * the string to search in the subscriber's email 259 * @param plugin 260 * the Plugin 261 * @return the number of subscribers 262 */ 263 int selectNbrActiveSubscribers( int nNewsLetterId, String strSearchString, Plugin plugin ); 264 265 }