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.forms.modules.documentproducer.business.producerconfig;
35
36 import java.util.List;
37 import java.util.Locale;
38
39 import fr.paris.lutece.portal.service.plugin.Plugin;
40 import fr.paris.lutece.portal.service.spring.SpringContextService;
41
42 /**
43 * ConfigProducerHome
44 *
45 */
46 public final class ConfigProducerHome
47 {
48 private static IConfigProducerDAO _dao = SpringContextService.getBean( "configProducerDAO" );
49
50 /**
51 * Constructor
52 */
53 private ConfigProducerHome( )
54 {
55 }
56
57 /**
58 * This method add a new config with different forms entry selected by AdminUser
59 *
60 * @param plugin
61 * The plugin
62 * @param configProducer
63 * configuration
64 * @param listIdQuestion
65 * The list of entry id that appear in configuration
66 */
67 public static void addNewConfig( Plugin plugin, ConfigProducer configProducer, List<Integer> listIdQuestion )
68 {
69 _dao.addNewConfig( plugin, configProducer, listIdQuestion );
70 }
71
72 /**
73 * This method load a config
74 *
75 * @param plugin
76 * plugin
77 * @param nIdConfig
78 * config id
79 * @return ConfigProducer
80 */
81 public static ConfigProducer loadConfig( Plugin plugin, int nIdConfig )
82 {
83 return _dao.loadConfig( plugin, nIdConfig );
84 }
85
86 /**
87 * This method load a list of config by forms id and type
88 *
89 * @param plugin
90 * The plugin
91 * @param nIdForms
92 * The id of forms
93 * @return The ProducerConfig list
94 */
95 public static List<ConfigProducer> loadListProducerConfig( Plugin plugin, int nIdForms )
96 {
97 return _dao.loadListProducerConfig( plugin, nIdForms );
98 }
99
100 /**
101 * This method load a list of id Question by id config
102 *
103 * @param plugin
104 * The plugin
105 * @param nIdConfig
106 * The config id
107 * @return The id entry list
108 */
109 public static List<Integer> loadListConfigQuestion( Plugin plugin, int nIdConfig )
110 {
111 return _dao.loadListConfigQuestion( plugin, nIdConfig );
112 }
113
114 /**
115 * This method delete a config by id
116 *
117 * @param plugin
118 * plugin
119 * @param nIdConfigProducer
120 * id config producer
121 */
122 public static void deleteProducerConfig( Plugin plugin, int nIdConfigProducer )
123 {
124 _dao.deleteProducerConfig( plugin, nIdConfigProducer );
125 }
126
127 /**
128 * This method modify a config
129 *
130 * @param plugin
131 * plugin
132 * @param configProducer
133 * configuration
134 * @param listIdQuestion
135 * list of id entry
136 */
137 public static void modifyProducerConfig( Plugin plugin, ConfigProducer configProducer, List<Integer> listIdQuestion )
138 {
139 _dao.modifyProducerConfig( plugin, configProducer, listIdQuestion );
140 }
141
142 /**
143 * This method copy a config
144 *
145 * @param plugin
146 * plugin
147 * @param nIdConfig
148 * id configproduducer
149 * @param locale
150 * locale
151 */
152 public static void copyProducerConfig( Plugin plugin, int nIdConfig, Locale locale )
153 {
154 _dao.copyProducerConfig( plugin, nIdConfig, locale );
155 }
156
157 /**
158 * This method check if a config exists for a specific form
159 *
160 * @param plugin
161 * plugin
162 * @param nIdForm
163 * id of form
164 */
165 public static void deleteByForm( Plugin plugin, int nIdForm )
166 {
167 _dao.deleteByForm( plugin, nIdForm );
168 }
169
170 /**
171 * This method check if an entry is used by a config
172 *
173 * @param plugin
174 * plugin
175 * @param nIdQuestion
176 * id of entry
177 * @return true an entry is used by a config otherwise false
178 */
179 public static boolean checkQuestion( Plugin plugin, int nIdQuestion )
180 {
181 return _dao.checkQuestion( plugin, nIdQuestion );
182 }
183
184 /**
185 * This method loads a default config
186 *
187 * @param plugin
188 * plugin
189 * @param nIdForms
190 * id forms
191 * @param docType
192 * @return id config
193 */
194 public static ConfigProducer loadDefaultConfig( Plugin plugin, int nIdForms, DocumentType docType )
195 {
196 return _dao.loadDefaultConfig( plugin, nIdForms, docType );
197 }
198
199 /**
200 * This method loads a default config
201 *
202 * @param plugin
203 * plugin
204 * @param nIdForms
205 * id forms
206 * @return id config
207 */
208 public static List<ConfigProducer> loadDefaultConfigList( Plugin plugin, int nIdForms )
209 {
210 return _dao.loadDefaultConfigList( plugin, nIdForms );
211 }
212
213 /**
214 * This method add default config
215 *
216 * @param plugin
217 * plugin
218 * @param nIdForms
219 * id forms
220 * @param nIdConfig
221 * id config
222 * @param docType
223 */
224 public static void createDefaultConfig( Plugin plugin, int nIdForms, int nIdConfig, DocumentType docType )
225 {
226 _dao.createDefaultConfig( plugin, nIdForms, nIdConfig, docType );
227 }
228
229 /**
230 * This method update default config
231 *
232 * @param plugin
233 * plugin
234 * @param nIdForms
235 * id forms
236 * @param nIdConfig
237 * id config
238 * @param docType
239 */
240 public static void updateDefaultConfig( Plugin plugin, int nIdForms, int nIdConfig, DocumentType docType )
241 {
242 _dao.updateDefaultConfig( plugin, nIdForms, nIdConfig, docType );
243 }
244
245 /**
246 * Remove all the default config by given form id
247 *
248 * @param plugin
249 * The plugin
250 * @param nIdForm
251 * The id form
252 */
253 public static void removeAllDefaultConfigOfForm( Plugin plugin, int nIdForm )
254 {
255 _dao.removeAllDefaultConfigOfForm( plugin, nIdForm );
256 }
257 }