View Javadoc
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.forms.service;
35  
36  import java.util.List;
37  
38  import fr.paris.lutece.plugins.forms.business.Control;
39  import fr.paris.lutece.plugins.forms.business.ControlGroup;
40  import fr.paris.lutece.plugins.forms.business.ControlGroupHome;
41  import fr.paris.lutece.plugins.forms.business.ControlHome;
42  import fr.paris.lutece.plugins.forms.business.ControlMapping;
43  import fr.paris.lutece.plugins.forms.business.FormDisplay;
44  import fr.paris.lutece.plugins.forms.business.FormDisplayHome;
45  import fr.paris.lutece.plugins.forms.business.Group;
46  import fr.paris.lutece.plugins.forms.business.GroupHome;
47  import fr.paris.lutece.plugins.forms.business.Question;
48  import fr.paris.lutece.plugins.forms.business.QuestionHome;
49  import fr.paris.lutece.plugins.forms.business.Step;
50  import fr.paris.lutece.plugins.forms.business.StepHome;
51  import fr.paris.lutece.plugins.genericattributes.business.Entry;
52  import fr.paris.lutece.plugins.genericattributes.business.EntryHome;
53  import fr.paris.lutece.plugins.genericattributes.business.Field;
54  import fr.paris.lutece.plugins.genericattributes.business.FieldHome;
55  import fr.paris.lutece.plugins.genericattributes.business.ReferenceItemFieldHome;
56  
57  public class FormDatabaseService implements IFormDatabaseService
58  {
59      public static final String BEAN_NAME = "forms.formDatabaseService";
60  
61      @Override
62      public void createEntry( Entry entry )
63      {
64          EntryHome.create( entry );
65      }
66  
67      @Override
68      public void createField( Field field )
69      {
70          FieldHome.create( field );
71      }
72  
73      @Override
74      public void createQuestion( Question question )
75      {
76          QuestionHome.create( question );
77      }
78  
79      @Override
80      public void createGroup( Group group )
81      {
82          GroupHome.create( group );
83      }
84  
85      @Override
86      public void updateGroup( Group group )
87      {
88          GroupHome.update( group );
89      }
90  
91      @Override
92      public Group findGroupByPrimaryKey( int idGroup )
93      {
94          return GroupHome.findByPrimaryKey( idGroup );
95      }
96  
97      @Override
98      public Step findStepByPrimaryKey( int idStep )
99      {
100         return StepHome.findByPrimaryKey( idStep );
101     }
102 
103     @Override
104     public void updateEntry( Entry entry )
105     {
106         EntryHome.update( entry );
107     }
108 
109     @Override
110     public void createFormDisplay( FormDisplay formDisplay )
111     {
112         FormDisplayHome.create( formDisplay );
113     }
114 
115     @Override
116     public List<Question> getListQuestionByForm( int nIdForm )
117     {
118         return QuestionHome.getListQuestionByIdForm( nIdForm );
119     }
120 
121     @Override
122     public Question findQuestionByPrimaryKey( int idQuestion )
123     {
124         return QuestionHome.findByPrimaryKey( idQuestion );
125     }
126 
127     @Override
128     public Entry findEntryByPrimaryKey( int idEntry )
129     {
130         return EntryHome.findByPrimaryKey( idEntry );
131     }
132 
133     @Override
134     public void updateField( Field field )
135     {
136         FieldHome.update( field );
137     }
138 
139     @Override
140     public Field findFieldByPrimaryKey( int idField )
141     {
142         return FieldHome.findByPrimaryKey( idField );
143     }
144 
145     @Override
146     public FormDisplay findDisplayByPrimaryKey( int idDisplay )
147     {
148         return FormDisplayHome.findByPrimaryKey( idDisplay );
149     }
150 
151     @Override
152     public void updateQuestion( Question question )
153     {
154         QuestionHome.update( question );
155     }
156 
157     @Override
158     public List<FormDisplay> getFormDisplayListByParent( int nIdStep, int nIdParent )
159     {
160         return FormDisplayHome.getFormDisplayListByParent( nIdStep, nIdParent );
161     }
162 
163     @Override
164     public void updateFormDisplay( FormDisplay formDisplay )
165     {
166         FormDisplayHome.update( formDisplay );
167     }
168 
169     @Override
170     public Entry copyEntry( Entry entry )
171     {
172         return EntryHome.copy( entry );
173     }
174 
175     @Override
176     public List<Control> getControlByQuestion( int nIdQuestion )
177     {
178         return ControlHome.getControlByQuestion( nIdQuestion );
179     }
180 
181     @Override
182     public FormDisplay getFormDisplayByFormStepAndComposite( int nIdForm, int nIdStep, int nIdComposite )
183     {
184         return FormDisplayHome.getFormDisplayByFormStepAndComposite( nIdForm, nIdStep, nIdComposite );
185     }
186 
187     @Override
188     public void createControl( Control control )
189     {
190         ControlHome.create( control );
191     }
192 
193     @Override
194     public void createControlGroup( ControlGroup controlGroup )
195     {
196         ControlGroupHome.create( controlGroup );
197     }
198 
199     @Override
200     public List<Group> getGroupsListByIdStepList( List<Integer> idStepList )
201     {
202         return GroupHome.getGroupsListByIdStepList( idStepList );
203     }
204 
205     @Override
206     public List<Question> getQuestionsListByStep( int nIdStep )
207     {
208         return QuestionHome.getQuestionsListByStep( nIdStep );
209     }
210 
211     @Override
212     public Integer findIdReferenceItemByIdField( int idField )
213     {
214         return ReferenceItemFieldHome.findIdItemByIdField( idField );
215     }
216 
217     @Override
218     public List<ControlMapping> getControlMappingListByIdControl( int nIdControl )
219     {
220         return ControlHome.getControlMappingListByIdControl( nIdControl );
221     }
222 
223     @Override
224     public void createStep( Step step )
225     {
226         StepHome.create( step );
227     }
228 
229     @Override
230     public void createMappingControl( int nIdcontrol, int nIdQuestion, String strValue )
231     {
232         ControlHome.createMappingControl( nIdcontrol, nIdQuestion, strValue );
233     }
234 }