View Javadoc
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.genericalert.business;
35  
36  import fr.paris.lutece.portal.service.plugin.Plugin;
37  import fr.paris.lutece.portal.service.plugin.PluginService;
38  import fr.paris.lutece.portal.service.spring.SpringContextService;
39  
40  import java.util.Collection;
41  import java.util.List;
42  
43  /**
44   * This class provides instances management methods (create, find, ...) for TaskReminderConfig objects
45   */
46  
47  public final class TaskNotifyReminderConfigHome
48  {
49      // Static variable pointed at the DAO instance
50  
51      private static ITaskNotifyReminderConfigDAO _dao = SpringContextService.getBean( "genericalert.taskNotifyReminderConfigDAO" );
52      private static Plugin _plugin = PluginService.getPlugin( "genericalert" );
53  
54      /**
55       * Private constructor - this class need not be instantiated
56       */
57      private TaskNotifyReminderConfigHome( )
58      {
59      }
60  
61      /**
62       * Create an instance of the taskReminderConfig class
63       * 
64       * @param taskReminderConfig
65       *            The instance of the TaskReminderConfig which contains the informations to store
66       * @return The instance of taskReminderConfig which has been created with its primary key.
67       */
68      public static TaskNotifyReminderConfig./fr/paris/lutece/plugins/genericalert/business/TaskNotifyReminderConfig.html#TaskNotifyReminderConfig">TaskNotifyReminderConfig create( TaskNotifyReminderConfig taskReminderConfig )
69      {
70          _dao.insert( taskReminderConfig );
71  
72          return taskReminderConfig;
73      }
74  
75      /**
76       * Update of the taskReminderConfig which is specified in parameter
77       * 
78       * @param taskReminderConfig
79       *            The instance of the TaskReminderConfig which contains the data to store
80       * @return The instance of the taskReminderConfig which has been updated
81       */
82      public static TaskNotifyReminderConfig./fr/paris/lutece/plugins/genericalert/business/TaskNotifyReminderConfig.html#TaskNotifyReminderConfig">TaskNotifyReminderConfig update( TaskNotifyReminderConfig taskReminderConfig )
83      {
84          _dao.store( taskReminderConfig );
85  
86          return taskReminderConfig;
87      }
88  
89      /**
90       * Remove the taskReminderConfig whose identifier is specified in parameter
91       * 
92       * @param nKey
93       *            The taskReminderConfig Id
94       */
95      public static void remove( int nKey )
96      {
97          _dao.delete( nKey );
98      }
99  
100     // /////////////////////////////////////////////////////////////////////////
101     // Finders
102 
103     /**
104      * Returns an instance of a taskReminderConfig whose identifier is specified in parameter
105      * 
106      * @param nKey
107      *            The taskReminderConfig primary key
108      * @return an instance of TaskReminderConfig
109      */
110     public static TaskNotifyReminderConfig findByPrimaryKey( int nKey )
111     {
112         return _dao.load( nKey );
113     }
114 
115     /**
116      * Load the data of all the taskReminderConfig objects and returns them in form of a collection
117      * 
118      * @return the collection which contains the data of all the taskReminderConfig objects
119      */
120     public static Collection<TaskNotifyReminderConfig> getTaskReminderConfigsList( )
121     {
122         return _dao.selectTaskReminderConfigsList( _plugin );
123     }
124 
125     /**
126      * Load the id of all the taskReminderConfig objects and returns them in form of a collection
127      * 
128      * @return the collection which contains the id of all the taskReminderConfig objects
129      */
130     public static Collection<Integer> getIdTaskReminderConfigsList( )
131     {
132         return _dao.selectIdTaskReminderConfigsList( _plugin );
133     }
134 
135     /**
136      * Remove a Appointment Reminder
137      * 
138      * @param idTask
139      *            the id task
140      * @param nAppointmentFormId
141      *            id form appointment
142      * @param rank
143      *            the rank
144      * @param bool
145      *            to delete all reminders
146      */
147     public static void removeAppointmentReminder( int idTask, int nAppointmentFormId, int rank, boolean bool )
148     {
149         _dao.deleteReminderAppointment( idTask, nAppointmentFormId, rank, bool, _plugin );
150     }
151 
152     /**
153      * 
154      * @param idTask
155      *            the id task
156      * @param nAppointmentFormId
157      *            id form
158      * @return list ReminderAppointment
159      */
160     public static List<ReminderAppointment> loadListReminderAppointment( int idTask, int nAppointmentFormId )
161     {
162         return _dao.loadListReminderAppointment( idTask, nAppointmentFormId, _plugin );
163     }
164 
165     /**
166      * 
167      * @param nKey
168      *            id task
169      * @param idForm
170      *            id form
171      * @return TaskNotifyReminderConfig the config
172      */
173     public static TaskNotifyReminderConfig findByIdForm( int nKey, int idForm )
174     {
175         return _dao.loadByIdForm( nKey, idForm, _plugin );
176     }
177 
178     /**
179      * 
180      * @param idTask
181      *            the id task
182      * @return list TaskNotifyReminderConfig
183      */
184     public static List<TaskNotifyReminderConfig> loadListTaskNotifyConfig( int idTask )
185     {
186         return _dao.loadListTaskNotifyConfig( idTask, _plugin );
187     }
188 
189     /**
190      * 
191      * @param idForm
192      *            the id form
193      * @return TaskNotifyReminderConfig the config
194      */
195     public static TaskNotifyReminderConfig loadConfigByIdForm( int idForm )
196     {
197         return _dao.loadConfigByIdForm( idForm, _plugin );
198     }
199 }