1 /*
2 * Copyright (c) 2002-2025, 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.planning;
35
36 import java.time.LocalDate;
37 import java.util.List;
38
39 import fr.paris.lutece.plugins.appointment.service.AppointmentPlugin;
40 import fr.paris.lutece.portal.service.plugin.Plugin;
41 import fr.paris.lutece.portal.service.plugin.PluginService;
42 import fr.paris.lutece.portal.service.spring.SpringContextService;
43
44 /**
45 * This class provides instances management methods for Closing Day objects
46 *
47 * @author Laurent Payen
48 *
49 */
50 public final class ClosingDayHome
51 {
52 // Static variable pointed at the DAO instance
53 private static IClosingDayDAO _dao = SpringContextService.getBean( "appointment.closingDayDAO" );
54 private static Plugin _plugin = PluginService.getPlugin( AppointmentPlugin.PLUGIN_NAME );
55
56 /**
57 * Private constructor - this class does not need to be instantiated
58 */
59 private ClosingDayHome( )
60 {
61 }
62
63 /**
64 * Create an instance of the Form class
65 *
66 * @param closingDay
67 * The instance of the ClosingDay which contains the informations to store
68 * @return The instance of the ClosingDay which has been created with its primary key.
69 */
70 public static ClosingDay/../../../../../../fr/paris/lutece/plugins/appointment/business/planning/ClosingDay.html#ClosingDay">ClosingDay create( ClosingDay closingDay )
71 {
72 _dao.insert( closingDay, _plugin );
73
74 return closingDay;
75 }
76
77 /**
78 * Update of the ClosingDay which is specified in parameter
79 *
80 * @param closingDay
81 * The instance of the ClosingDay which contains the data to store
82 * @return The instance of the ClosingDay which has been updated
83 */
84 public static ClosingDay/../../../../../../fr/paris/lutece/plugins/appointment/business/planning/ClosingDay.html#ClosingDay">ClosingDay update( ClosingDay closingDay )
85 {
86 _dao.update( closingDay, _plugin );
87
88 return closingDay;
89 }
90
91 /**
92 * Delete the ClosingDay whose identifier is specified in parameter
93 *
94 * @param nKey
95 * The ClosingDay Id
96 */
97 public static void delete( int nKey )
98 {
99 _dao.delete( nKey, _plugin );
100 }
101
102 /**
103 * Delete a record from the table
104 *
105 * @param nIdForm
106 * the Form Id
107 * @param dateOfCLosingDay
108 * the date of the closing day
109 */
110 public static void deleteByIdFormAndDateOfClosingDay( int nIdForm, LocalDate dateOfCLosingDay )
111 {
112 _dao.deleteByIdFormAndDateOfClosingDay( nIdForm, dateOfCLosingDay, _plugin );
113 }
114
115 /**
116 * Delete a record from the table
117 *
118 * @param nIdForm
119 * the Form Id
120 * @param dateOfCLosingDay
121 * the date of the closing day
122 */
123 public static void deleteByIdForm( int nIdForm )
124 {
125 _dao.deleteByIdForm( nIdForm, _plugin );
126 }
127
128 /**
129 * Returns an instance of the ClosingDay whose identifier is specified in parameter
130 *
131 * @param nKey
132 * The ClosingDay primary key
133 * @return an instance of the ClosingDay
134 */
135 public static ClosingDay findByPrimaryKey( int nKey )
136 {
137 return _dao.select( nKey, _plugin );
138 }
139
140 /**
141 * Returns all the Closing Days of a form
142 *
143 * @param nIdForm
144 * the form id
145 * @return the list of closing days of the form
146 */
147 public static List<ClosingDay> findByIdForm( int nIdForm )
148 {
149 return _dao.findByIdForm( nIdForm, _plugin );
150 }
151
152 /**
153 * Returns a list of closing days of the form on a period
154 *
155 * @param nIdForm
156 * the form Id
157 * @param startingDate
158 * the starting date
159 * @param endingDate
160 * the ending date
161 * @return a list of closing days matches the criteria
162 */
163 public static List<ClosingDay> findByIdFormAndDateRange( int nIdForm, LocalDate startingDate, LocalDate endingDate )
164 {
165 return _dao.findByIdFormAndDateRange( nIdForm, startingDate, endingDate, _plugin );
166 }
167
168 /**
169 * Returns the closing day
170 *
171 * @param nIdForm
172 * the Form Id
173 * @param dateOfClosingDay
174 * the date of the closing day
175 * @return an instance of the ClosingDay if it exists, null otherwise
176 */
177 public static ClosingDay findByIdFormAndDateOfCLosingDay( int nIdForm, LocalDate dateOfClosingDay )
178 {
179 return _dao.findByIdFormAndDateOfClosingDay( nIdForm, dateOfClosingDay, _plugin );
180 }
181 }