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