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.forms.modules.template.business;
35
36 import java.util.List;
37 import java.util.Set;
38
39 import fr.paris.lutece.plugins.forms.business.Control;
40 import fr.paris.lutece.plugins.forms.business.ControlMapping;
41 import fr.paris.lutece.plugins.forms.business.ControlType;
42 import fr.paris.lutece.portal.service.plugin.Plugin;
43
44 /**
45 * IControlDAO Interface
46 */
47 public interface ITemplateControlDAO
48 {
49 /**
50 * Insert a new record in the table.
51 *
52 * @param control
53 * instance of the Control object to insert
54 * @param plugin
55 * the Plugin
56 */
57 void insert( Control control, Plugin plugin );
58
59 /**
60 * Insert a new record in the table.
61 *
62 * @param nIdcontrol
63 * id of the Control object to insert
64 * @param nIdQuestion
65 * the question id
66 * @param plugin
67 * the Plugin
68 */
69 void insert( int nIdControl, int nIdQuestion, Plugin plugin );
70
71 /**
72 * Insert a new record in the table.
73 *
74 * @param nIdcontrol
75 * id of the Control object to insert
76 * @param nIdQuestion
77 * the question id
78 * @param strValue
79 * the value
80 * @param plugin
81 * the Plugin
82 */
83 void insert( int nIdControl, int nIdQuestion, String strValue, Plugin plugin );
84
85 /**
86 * Update the record in the table
87 *
88 * @param control
89 * the reference of the Control
90 * @param plugin
91 * the Plugin
92 */
93 void store( Control control, Plugin plugin );
94
95 /**
96 * Delete a record from the table
97 *
98 * @param nKey
99 * The identifier of the Control to delete
100 * @param plugin
101 * the Plugin
102 */
103 void delete( int nKey, Plugin plugin );
104
105 /**
106 * Delete a record from the table
107 *
108 * @param nKey
109 * The identifier of the Control to delete
110 * @param plugin
111 * the Plugin
112 */
113 void deleteControlQuestion( int nControl, Plugin plugin );
114
115 /**
116 * Delete a record from the table
117 *
118 * @param nKey
119 * The identifier of the Control to delete
120 * @param plugin
121 * the Plugin
122 */
123 void deleteControlQuestionValue( int nControl, Plugin plugin );
124
125 /**
126 * Delete a record from the table by the control target
127 *
128 * @param nIdControlTarget
129 * The identifier of the Control target
130 * @param controlType
131 * The control type
132 * @param plugin
133 * the Plugin
134 */
135 void deleteByControlTarget( int nIdControlTarget, ControlType controlType, Plugin plugin );
136
137 // /////////////////////////////////////////////////////////////////////////
138 // Finders
139
140 /**
141 * Load the data from the table
142 *
143 * @param nKey
144 * The identifier of the control
145 * @param plugin
146 * the Plugin
147 * @return The instance of the control
148 */
149 Control load( int nKey, Plugin plugin );
150
151 /**
152 * Load the data from the table
153 *
154 * @param nIdControl
155 * The identifier of the control
156 * @param plugin
157 * the Plugin
158 * @return The list of id questions
159 */
160 Set<Integer> loadIdQuestions( int nIdControl, Plugin plugin );
161
162 /**
163 * Select a control for conditional display based on its attached display id
164 *
165 * @param nIdControlTarget
166 * the control target id
167 * @param controlType
168 * the control type
169 * @param plugin
170 * the Plugin
171 * @return The control
172 */
173 List<Control> selectControlByControlTargetAndType( int nIdControlTarget, ControlType controlType, Plugin plugin );
174
175 /**
176 * Select control list based on its attached question and control type
177 *
178 * @param nIdQuestion
179 * the question id
180 * @param strControlType
181 * the control type
182 * @param plugin
183 * the Plugin
184 * @return The control
185 */
186 List<Control> selectControlByQuestionAndType( int nIdQuestion, String strControlType, Plugin plugin );
187
188 /**
189 * Select control list based on its attached question and control type
190 *
191 * @param nIdQuestion
192 * the question id
193 * @param plugin
194 * the Plugin
195 * @return The control
196 */
197 List<Control> selectControlByQuestion( int nIdQuestion, Plugin plugin );
198
199 /**
200 * Load the data of all the control mapping and returns them as a List
201 *
202 * @param plugin
203 * the Plugin
204 * @return The referenceList which contains the data of all the control mapping object
205 */
206 List<ControlMapping> selectMappingControlList( int nIdControl, Plugin plugin );
207 }