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.unittree.business.unit;
35  
36  import java.util.List;
37  
38  import fr.paris.lutece.portal.service.plugin.Plugin;
39  
40  /**
41   *
42   *
43   */
44  public interface IUnitDAO
45  {
46      /**
47       * Get new primary key
48       * 
49       * @param plugin
50       *            the plugin
51       * @return a new primary key
52       */
53      int newPrimaryKey( Plugin plugin );
54  
55      /**
56       * Load the unit
57       * 
58       * @param nIdUnit
59       *            the id unit
60       * @param plugin
61       *            the plugin
62       * @return an instance of {@link Unit}
63       */
64      Unit load( int nIdUnit, Plugin plugin );
65  
66      /**
67       * Load an unit by id user
68       * 
69       * @param nIdUser
70       *            the id user
71       * @param plugin
72       *            the plugin
73       * @return a list of {@link Unit}
74       */
75      List<Unit> selectByIdUser( int nIdUser, Plugin plugin );
76  
77      /**
78       * Select all units
79       * 
80       * @param plugin
81       *            the plugin
82       * @return a list of {@link Unit}
83       */
84      List<Unit> selectAll( Plugin plugin );
85  
86      /**
87       * Select the units by filter
88       * 
89       * @param uFilter
90       *            the filter
91       * @param plugin
92       *            the plugin
93       * @return a list of {@link Unit}
94       */
95      List<Unit> selectByFilter( UnitFilter uFilter, Plugin plugin );
96  
97      /**
98       * Select all ids user
99       * 
100      * @param plugin
101      *            the plugin
102      * @return a list of ids user
103      */
104     List<Integer> selectAllIdsUser( Plugin plugin );
105 
106     /**
107      * Select the ids user from a given id unit
108      * 
109      * @param nIdUnit
110      *            the id unit
111      * @param plugin
112      *            the plugin
113      * @return a list of ids user
114      */
115     List<Integer> selectIdsUser( int nIdUnit, Plugin plugin );
116 
117     /**
118      * Insert a new unit
119      * 
120      * @param unit
121      *            the unit
122      * @param plugin
123      *            the plugin
124      * @return the new primary key
125      */
126     int insert( Unit unit, Plugin plugin );
127 
128     /**
129      * Check if the given id unit has sub units or not
130      * 
131      * @param nIdUnit
132      *            the id unit
133      * @param plugin
134      *            the plugin
135      * @return true if the unit has sub units, false otherwise
136      */
137     boolean hasSubUnits( int nIdUnit, Plugin plugin );
138 
139     /**
140      * Remove a unit
141      * 
142      * @param nIdUnit
143      *            the id unit
144      * @param plugin
145      *            the plugin
146      */
147     void remove( int nIdUnit, Plugin plugin );
148 
149     /**
150      * Update a unit
151      * 
152      * @param unit
153      *            the unit
154      * @param plugin
155      *            the plugin
156      */
157     void update( Unit unit, Plugin plugin );
158 
159     /**
160      * Add an user to an unit
161      * 
162      * @param nIdUnit
163      *            the id unit
164      * @param nIdUser
165      *            the id user
166      * @param plugin
167      *            the plugin
168      */
169     void addUserToUnit( int nIdUnit, int nIdUser, Plugin plugin );
170 
171     /**
172      * Check if the user is in the unit
173      * 
174      * @param nIdUser
175      *            the id user
176      * @param nIdUnit
177      *            The id of the unit
178      * @param plugin
179      *            the plugin
180      * @return true if the user is in the unit, false otherwise
181      */
182     boolean isUserInUnit( int nIdUser, int nIdUnit, Plugin plugin );
183 
184     /**
185      * Remove a given user from the unit
186      * 
187      * @param nIdUser
188      *            the id user
189      * @param nIdUnit
190      *            The id of the unit
191      * @param plugin
192      *            the plugin
193      */
194     void removeUserFromUnit( int nIdUser, int nIdUnit, Plugin plugin );
195 
196     /**
197      * Remove users from a given id unit
198      * 
199      * @param nIdUnit
200      *            the id unit
201      * @param plugin
202      *            the plugin
203      */
204     void removeUsersFromUnit( int nIdUnit, Plugin plugin );
205 
206     /**
207      * Return all the Unit of the Sector
208      * 
209      * @param nIdSector
210      *            id sector
211      * @param plugin
212      *            the plugin
213      * @return all the Unit of the Sector
214      */
215     List<Unit> findBySectorId( int nIdSector, Plugin plugin );
216 
217     /**
218      * Return all the Unit with no children (level 0)
219      * 
220      * @param plugin
221      *            the plugin
222      * @return all the Unit with no children (level 0)
223      */
224     List<Unit> getUnitWithNoChildren( Plugin plugin );
225 
226     /**
227      * Update the parent of a unit
228      * 
229      * @param nIdUnitToMove
230      *            The id of the unit to change the parent of.
231      * @param nIdNewParent
232      *            The id of the new parent of the unit.
233      * @param plugin
234      *            The plugin
235      */
236     void updateParent( int nIdUnitToMove, int nIdNewParent, Plugin plugin );
237 
238     /**
239      * 
240      * @param plugin
241      * @return the sectors list
242      */
243     public List<Sector> selectAllSectors( Plugin plugin );
244 
245     List<String> selectAllSectorsGeo( Plugin _plugin );
246 
247     List<Unit> findBySectorIdWithoutChildren( int nIdSector, Plugin plugin );
248 }