View Javadoc
1   /*
2    * Copyright (c) 2002-2018, 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.appointment.modules.resource.business;
35  
36  import fr.paris.lutece.portal.service.plugin.Plugin;
37  
38  import java.sql.Date;
39  import java.sql.Timestamp;
40  import java.util.List;
41  
42  /**
43   * Interface of appointment resource DAO
44   */
45  public interface IAppointmentResourceDAO
46  {
47      /**
48       * NAme of the bean of the implementation of the DAO
49       */
50      String BEAN_NAME = "appointment-resource.appointmentResourceDAO";
51  
52      /**
53       * Insert a new appointment resource
54       * 
55       * @param resource
56       *            The appointment resource to insert
57       * @param plugin
58       *            The plugin
59       */
60      void insert( AppointmentResource resource, Plugin plugin );
61  
62      /**
63       * Find an appointment resource from its primary key
64       * 
65       * @param nIdAppointment
66       *            The id of the appointment
67       * @param nIdAppointmentFormResourceType
68       *            the id of the appointment form resource type
69       * @param plugin
70       *            The plugin
71       * @return The appointment resource, or null if no appointment resource has the given id
72       */
73      AppointmentResource findByPrimaryKey( int nIdAppointment, int nIdAppointmentFormResourceType, Plugin plugin );
74  
75      /**
76       * Find appointment resource associated with a given appointment
77       * 
78       * @param nIdAppointment
79       *            the id of the appointment
80       * @param plugin
81       *            The plugin
82       * @return The list of appointment resource associated with the given appointment, or an empty list if no appointment resource is associated with the
83       *         appointment
84       */
85      List<AppointmentResource> findByIdAppointment( int nIdAppointment, Plugin plugin );
86  
87      /**
88       * Update an appointment resource
89       * 
90       * @param resource
91       *            The appointment resource to update
92       * @param plugin
93       *            The plugin
94       */
95      void update( AppointmentResource resource, Plugin plugin );
96  
97      /**
98       * Delete an appointment resource
99       * 
100      * @param nIdAppointment
101      *            The id of the appointment of the appointment resource
102      * @param nIdAppointmentFormResourceType
103      *            The id of the appointment form resource type of the appointment resource
104      * @param plugin
105      *            The plugin
106      */
107     void delete( int nIdAppointment, int nIdAppointmentFormResourceType, Plugin plugin );
108 
109     /**
110      * Delete appointment resource associated with a given appointment
111      * 
112      * @param nIdAppointment
113      *            The id of the appointment
114      * @param plugin
115      *            The plugin
116      */
117     void deleteByIdAppointment( int nIdAppointment, Plugin plugin );
118 
119     /**
120      * Delete appointment resource associated with a given appointment form resource type
121      * 
122      * @param nIdAppointmentFormResourceType
123      *            The id of the appointment form resource type
124      * @param plugin
125      *            The plugin
126      */
127     void deleteByIdAppointmentFormResourceType( int nIdAppointmentFormResourceType, Plugin plugin );
128 
129     /**
130      * Check if a resource is available for a given period, or if it has already been associated with an appointment
131      * 
132      * @param strIdResource
133      *            The id of the resource
134      * @param strResourceTypeName
135      *            The type of the resource
136      * @param nStartingTime
137      *            The beginning time
138      * @param nEndingTime
139      *            the ending time
140      * @param plugin
141      *            the plugin
142      * @return True if the resource is available, false otherwise
143      */
144     boolean isResourceAvailable( String strIdResource, String strResourceTypeName, Timestamp nStartingTime, Timestamp nEndingTime, Plugin plugin );
145 
146     /**
147      * Get the list of id of appointments a resource is associated to between two given dates
148      * 
149      * @param strIdResource
150      *            The id of the resource
151      * @param strResourceType
152      *            The resource type
153      * @param dateMin
154      *            The minimum date
155      * @param dateMax
156      *            the maximum date
157      * @param plugin
158      *            The plugin
159      * @return The list of ids of appointments
160      */
161     List<Integer> findIdAppointmentsByResourceAndDate( String strIdResource, String strResourceType, Date dateMin, Date dateMax, Plugin plugin );
162 }