1 /* 2 * Copyright (c) 2002-2022, 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.appointment.business.slot; 35 36 import java.time.LocalDate; 37 import java.time.LocalDateTime; 38 import java.util.List; 39 40 import fr.paris.lutece.portal.service.plugin.Plugin; 41 42 /** 43 * Slot DAO Interface 44 * 45 * @author Laurent Payen 46 * 47 */ 48 public interface ISlotDAO 49 { 50 /** 51 * Insert a new record in the table 52 * 53 * @param slot 54 * instance of the Slot object to insert 55 * @param plugin 56 * the plugin 57 */ 58 void insert( Slot slot, Plugin plugin ); 59 60 /** 61 * Update the record in the table 62 * 63 * @param slot 64 * the reference of the Slot 65 * @param plugin 66 * the plugin 67 */ 68 void update( Slot slot, Plugin plugin ); 69 70 /** 71 * Delete a appointment from the table 72 * 73 * @param nIdSlot 74 * identifier of the Slot to delete 75 * @param plugin 76 * the plugin 77 */ 78 void delete( int nIdSlot, Plugin plugin ); 79 80 /** 81 * Delete a appointment from the table 82 * 83 * @param nIdForm 84 * identifier of the form 85 * @param plugin 86 * the plugin 87 */ 88 public void deleteByIdForm( int nIdForm, Plugin plugin ); 89 90 /** 91 * Load the data from the table 92 * 93 * @param nIdSlot 94 * the identifier of the Slot 95 * @param plugin 96 * the plugin 97 * @return the instance of the Slot 98 */ 99 Slot select( int nIdSlot, Plugin plugin ); 100 101 /** 102 * Returns all the slot for the date range 103 * 104 * @param nIdForm 105 * the Form Id 106 * @param startingDateTime 107 * the starting date 108 * @param endingDateTime 109 * the ending date 110 * @param plugin 111 * the plugin 112 * @return a list of slots whose dates are included in the given period 113 */ 114 List<Slot> findByIdFormAndDateRange( int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime, Plugin plugin ); 115 116 /** 117 * Returns all the slot containing an appointment for the date range 118 * 119 * @param nIdForm 120 * the Form Id 121 * @param startingDateTime 122 * the starting date 123 * @param endingDateTime 124 * the ending date 125 * @param plugin 126 * the plugin 127 * @return a list of slots whose dates are included in the given period and is containing an appointment 128 */ 129 List<Slot> findSlotWithAppointmentByDateRange( int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime, Plugin plugin ); 130 131 /** 132 * Returns all the specific slot for the form 133 * 134 * @param nIdForm 135 * the Form Id 136 * @param plugin 137 * the plugin 138 * @return a list of specific slots 139 */ 140 List<Slot> findIsSpecificByIdForm( int nIdForm, Plugin plugin ); 141 142 /** 143 * Returns all the slots of a form 144 * 145 * @param nIdForm 146 * the form id 147 * @param plugin 148 * the plugin 149 * @return a list of all the slots of the form 150 */ 151 List<Slot> findByIdForm( int nIdForm, Plugin plugin ); 152 153 /** 154 * Returns all the open slots for the given date range 155 * 156 * @param nIdForm 157 * the Form Id 158 * @param startingDateTime 159 * the starting date 160 * @param endingDateTime 161 * the ending date 162 * @param plugin 163 * the plugin 164 * @return a list of open slots whose dates are included in the given period 165 */ 166 List<Slot> findOpenSlotsByIdFormAndDateRange( int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime, Plugin plugin ); 167 168 /** 169 * Returns all the open slots 170 * 171 * @param nIdForm 172 * the Form Id 173 * @param plugin 174 * the plugin 175 * @return a list of open slots 176 */ 177 List<Slot> findOpenSlotsByIdForm( int nIdForm, Plugin plugin ); 178 179 /** 180 * Return the slot with the max date 181 * 182 * @param nIdForm 183 * the form id 184 * @param plugin 185 * the plugin 186 * @return the slot 187 */ 188 Slot findSlotWithMaxDate( int nIdForm, Plugin plugin ); 189 190 /** 191 * Returns all the slots of a form 192 * 193 * @param nIdAppointment 194 * the appointment id 195 * @param plugin 196 * the plugin 197 * @return a list of all the slots of the form 198 */ 199 List<Slot> findByIdAppointment( int nIdAppointment, Plugin plugin ); 200 201 /** 202 * update Potential Remaining Places 203 * 204 * @param nbPotentialRemainingPlaces 205 * @param nIdSlot 206 * @param plugin 207 */ 208 void updatePotentialRemainingPlaces( int nbPotentialRemainingPlaces, int nIdSlot, Plugin plugin ); 209 210 /** 211 * update the availabilities metrics 212 * 213 * @param plugin 214 * the plugin 215 */ 216 void resetPotentialRemainingPlaces( Plugin plugin ); 217 218 /** 219 * Return the specific slot dates from the form 220 * 221 * @param nIdForm 222 * the id Form 223 * @param plugin 224 * the plugin 225 * @return list of date 226 */ 227 List<LocalDate> findSpecificSlotDates( int nIdForm, Plugin plugin ); 228 229 }