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