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.plugins.calendar.service.AgendaResource; 37 import fr.paris.lutece.portal.service.image.ImageResource; 38 import fr.paris.lutece.portal.service.plugin.Plugin; 39 import fr.paris.lutece.portal.service.util.AppException; 40 41 import java.util.Calendar; 42 import java.util.List; 43 44 45 /** 46 * AN interface used to access the calendar business layer 47 */ 48 public interface ICalendarDAO 49 { 50 /** 51 * Delete an Event from the table calendar_events 52 * @param nEventId The id of the event 53 * @param nAgendaId The Agenda Id 54 * @param plugin The Plugin using this data access service 55 */ 56 void deleteEvent( int nAgendaId, int nEventId, Plugin plugin ); 57 58 /** 59 * Delete a Agenda from the table calendar_agendas 60 * 61 * @param nAgendaId The agenda Id 62 * @param plugin The Plugin using this data access service 63 */ 64 void deleteAgenda( int nAgendaId, Plugin plugin ); 65 66 /** 67 * Insert a new event in the table calendar_events. 68 * @param event The event 69 * @param plugin The Plugin using this data access service 70 * @param strUserLogin user login 71 * @throws fr.paris.lutece.portal.service.util.AppException An AppException 72 * error 73 */ 74 void insertEvent( SimpleEvent event, Plugin plugin, String strUserLogin ) throws AppException; 75 76 /** 77 * Insert a new agenda in the table calendar_agendas. 78 * 79 * 80 * @param agenda The AgendaResource object 81 * @param plugin The Plugin using this data access service 82 */ 83 void insertAgenda( AgendaResource agenda, Plugin plugin ); 84 85 /** 86 * Load the data of AgendaResource from the table 87 * 88 * @return the instance of the AgendaResource 89 * @param nId The identifier of AgendaResource 90 * @param plugin The plugin 91 */ 92 AgendaResource loadAgenda( int nId, Plugin plugin ); 93 94 /** 95 * Load the data of SimpleEvent from the table 96 * @return the instance of the SimpleEvent 97 * @param nEventId The id of the event 98 * @param plugin The plugin 99 */ 100 SimpleEvent loadEvent( int nEventId, Plugin plugin ); 101 102 /** 103 * Load the list of AgendaResources 104 * 105 * 106 * @param plugin The plugin 107 * @return The Collection of the AgendaResources 108 */ 109 List<AgendaResource> selectAgendaResourceList( Plugin plugin ); 110 111 /** 112 * Load the list of Events 113 * @return The Collection of the Events 114 * @param nSortEvents Parameter used for event sorting 115 * @param plugin The plugin 116 * @param nAgendaId The identifier of the agenda 117 */ 118 List<SimpleEvent> selectEventsList( int nAgendaId, int nSortEvents, Plugin plugin ); 119 120 /** 121 * Load the list of Events 122 * @return The Collection of the Events 123 * @param nSortEvents An integer used for sorting issues 124 * @param plugin The plugin 125 * @param nAgendaId The identifier of the agenda 126 * @param strUserLogin user login 127 */ 128 List<SimpleEvent> selectEventsListByUserLogin( int nAgendaId, int nSortEvents, Plugin plugin, String strUserLogin ); 129 130 /** 131 * Update the agenda in the table calendar_agendas 132 * 133 * @param agenda The reference of AgendaResource 134 * @param plugin The Plugin using this data access service 135 */ 136 void storeAgenda( AgendaResource agenda, Plugin plugin ); 137 138 /** 139 * Update the event in the table calendar_event 140 * 141 * @param event The reference of SimpleEvent 142 * @param plugin The Plugin using this data access service 143 * @param periodiciteUpdated true if periodicity must be updated, 0 144 * otherwhise 145 * @throws fr.paris.lutece.portal.service.util.AppException An AppException 146 */ 147 void storeEvent( SimpleEvent event, Plugin plugin, boolean periodiciteUpdated ) throws AppException; 148 149 /** 150 * Returns the number of following days the event should be displayed 151 * @param nEventId The id of the event 152 * @param plugin Plugin 153 * @return The number of days 154 */ 155 int getRepetitionDays( int nEventId, Plugin plugin ); 156 157 /** 158 * Load the list of Occurrences 159 * @return The Collection of the Occurrences 160 * @param nSortEvents An integer used for sorting issues 161 * @param plugin The plugin 162 * @param nAgendaId The identifier of the agenda 163 * @param nEventId The identifier of an event 164 * 165 */ 166 List<OccurrenceEvent> selectOccurrencesList( int nAgendaId, int nEventId, int nSortEvents, Plugin plugin ); 167 168 /** 169 * Load the list of Occurrences 170 * @return The Collection of the Occurrences 171 * @param nSortEvents An integer used for sorting issues 172 * @param plugin The plugin 173 * @param nAgendaId The identifier of the agenda 174 * 175 */ 176 List<OccurrenceEvent> selectOccurrencesList( int nAgendaId, int nSortEvents, Plugin plugin ); 177 178 /** 179 * Load the list of Occurrences ordered by occurence id 180 * @return The Collection of the Occurrences 181 * @param plugin The plugin 182 * @param nAgendaId The identifier of the agenda 183 * 184 */ 185 List<OccurrenceEvent> selectOccurrencesByIdList( int nAgendaId, Plugin plugin ); 186 187 /** 188 * Load the data of SimpleEvent from the table 189 * @return the instance of the SimpleEvent 190 * @param nOccurenceId The id of the occurence 191 * @param plugin The plugin 192 */ 193 OccurrenceEvent loadOccurrence( int nOccurenceId, Plugin plugin ); 194 195 /** 196 * Update the occurrence in the table calendar_events_occurrences 197 * 198 * @param occurrence The reference of OccurrenceEvent 199 * @param plugin The Plugin using this data access service 200 */ 201 void storeOccurrence( OccurrenceEvent occurrence, Plugin plugin ); 202 203 /** 204 * Delete an Event from the table calendar_events_occurrences 205 * @param nEventId The id of the occurrence 206 * @param nAgendaId The agenda Id 207 * @param plugin The Plugin using this data access service 208 */ 209 void deleteAllOccurrence( int nAgendaId, int nEventId, Plugin plugin ); 210 211 /** 212 * Delete an Event from the table calendar_events_occurrences 213 * @param nEventId The id of the occurrence 214 * @param nOccurrenceId The occurrence Id 215 * @param nAgendaId the agenda id 216 * @param plugin The Plugin using this data access service 217 */ 218 void deleteOccurrence( int nOccurrenceId, int nEventId, int nAgendaId, Plugin plugin ); 219 220 /** 221 * UPDATE the occurrence number from the table calendar_events 222 * @param nEventId The id of the occurrence 223 * @param nAgendaId The agenda Id 224 * @param plugin The Plugin using this data access service 225 * @param nNewNumberOccurrence the new number of occurrence for the event 226 */ 227 void updateNumberOccurrence( int nEventId, int nAgendaId, Plugin plugin, int nNewNumberOccurrence ); 228 229 /** 230 * Return the occurrence number for an event 231 * @param nEventId The id of the event 232 * @param plugin Plugin 233 * @return the occurrence number 234 */ 235 int getOccurrenceNumber( int nEventId, Plugin plugin ); 236 237 /** 238 * Return the image resource corresponding to the category id 239 * @param nEventId The event id 240 * @param plugin Plugin 241 * @return The image resource 242 */ 243 ImageResource loadImageResource( int nEventId, Plugin plugin ); 244 245 /** 246 * Load the list of Events 247 * 248 * @return The Collection of the Events 249 * @param plugin The plugin 250 * @param filter The CalendarFilter Object 251 */ 252 List<Event> selectByFilter( CalendarFilter filter, Plugin plugin ); 253 254 /** 255 * Load the list of top Events 256 * @param plugin The plugin 257 * @return the list of eventw 258 */ 259 List<SimpleEvent> selectTopEventsList( Plugin plugin ); 260 261 /** 262 * Return 1 if the day contains an event 0 otherwise 263 * @param calendar The day 264 * @param plugin The plugin 265 * @return 1 if the day contains an event 0 otherwise 266 */ 267 boolean hasOccurenceEvent( Calendar calendar, Plugin plugin ); 268 269 /** 270 * Delete the link between event and user 271 * @param nEventId ID event 272 * @param plugin plugin 273 */ 274 void deleteEventUser( int nEventId, Plugin plugin ); 275 276 /** 277 * Load the list of events 278 * @param nAgendaId the agenda ID 279 * @param nSortEvents An integer used for sorting issues 280 * @param nNextDays the number of days 281 * @param plugin plugin 282 * @return the list of events 283 */ 284 List<SimpleEvent> selectEventsList( int nAgendaId, int nSortEvents, int nNextDays, Plugin plugin ); 285 286 /** 287 * Get the list of calendar IDs 288 * @param plugin {@link Plugin} 289 * @return the list of calendar ids 290 */ 291 List<Integer> selectCalendarIds( Plugin plugin ); 292 }