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.genericattributes.business;
35  
36  import fr.paris.lutece.portal.service.plugin.Plugin;
37  
38  import java.util.List;
39  import java.util.Map;
40  
41  /**
42   * IEntryDAO Interface
43   */
44  public interface IEntryDAO
45  {
46      /**
47       * Insert a new record in the table.
48       *
49       * @param entry
50       *            instance of the Entry object to insert
51       * @param plugin
52       *            the plugin
53       * @return the id of the new entry
54       */
55      int insert( Entry entry, Plugin plugin );
56  
57      /**
58       * Update the entry in the table
59       *
60       * @param entry
61       *            instance of the Entry object to update
62       * @param plugin
63       *            the plugin
64       */
65      void store( Entry entry, Plugin plugin );
66  
67      /**
68       * Delete a record from the table
69       *
70       * @param nIdEntry
71       *            The identifier of the entry
72       * @param plugin
73       *            the plugin
74       */
75      void delete( int nIdEntry, Plugin plugin );
76  
77      // /////////////////////////////////////////////////////////////////////////
78      // Finders
79  
80      /**
81       * Load the data of the entry from the table
82       *
83       * @param nIdEntry
84       *            The identifier of the entry
85       * @param plugin
86       *            the plugin
87       * @return the instance of the Entry
88       */
89      Entry load( int nIdEntry, Plugin plugin );
90  
91      /**
92       * Load the data of the entry from the table
93       *
94       * @param idList
95       *            The identifiers of the entries
96       * @param plugin
97       *            the plugin
98       * @return the instance of the Entry
99       */
100     List<Entry> loadMultiple( List<Integer> idList, Plugin plugin );
101 
102     /**
103      * Load the data of all the entry who verify the filter and returns them in a list
104      *
105      * @param filter
106      *            the filter
107      * @param plugin
108      *            the plugin
109      * @return the list of entry
110      */
111     List<Entry> selectEntryListByFilter( EntryFilter filter, Plugin plugin );
112 
113     /**
114      * Return the number of entry who verify the filter
115      *
116      * @param filter
117      *            the filter
118      * @param plugin
119      *            the plugin
120      * @return the number of entry who verify the filter
121      */
122     int selectNumberEntryByFilter( EntryFilter filter, Plugin plugin );
123 
124     /**
125      * Finds all the entries without any parent associated to a given resource
126      * 
127      * @param plugin
128      *            the plugin
129      * @param nIdResource
130      *            the id of the resource
131      * @param strResourceType
132      *            the resource type
133      * @return the list of all the entries without parent
134      */
135     List<Entry> findEntriesWithoutParent( Plugin plugin, int nIdResource, String strResourceType );
136 
137     /**
138      * Finds the entry (conditional question) with a given order, idDependField and the id of the resource
139      * 
140      * @param plugin
141      *            the plugin
142      * @param nOrder
143      *            the order
144      * @param nIdField
145      *            the id of the field
146      * @param nIdResource
147      *            the id of the resource
148      * @param strResourceType
149      *            The resource type of the entry to get
150      * @return the list of all the entries without parent
151      */
152     Entry findByOrderAndIdFieldAndIdResource( Plugin plugin, int nOrder, int nIdField, int nIdResource, String strResourceType );
153 
154     /**
155      * Decrements the order of all the entries (conditional questions) after the one which will be removed
156      * 
157      * @param plugin
158      *            The plugin
159      * @param nOrder
160      *            the order of the entry which will be removed
161      * @param nIdField
162      *            the id of the field
163      * @param nIdResource
164      *            the id of the resource
165      * @param strResourceType
166      *            The resource type
167      */
168     void decrementOrderByOne( Plugin plugin, int nOrder, int nIdField, int nIdResource, String strResourceType );
169 
170     /**
171      *
172      * @param plugin
173      *            The plugin
174      * @param nIdForm
175      *            if form
176      * @return
177      */
178     Map<Integer, String> findEntryByForm( Plugin plugin, int nIdForm );
179 
180     /**
181      *
182      * @param plugin
183      *            the plugin
184      * @param nIdEntry
185      *            id entry
186      * @param nIdResponse
187      *            id entry response
188      * @return entry value
189      */
190     String getEntryValueByIdResponse( Plugin plugin, int nIdEntry, int nIdResponse );
191 }