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.mylutece.business.attribute;
35  
36  import fr.paris.lutece.portal.service.plugin.Plugin;
37  import fr.paris.lutece.portal.service.spring.SpringContextService;
38  
39  import java.util.List;
40  import java.util.Locale;
41  
42  /**
43   *
44   * MyLuteceUserFieldHome
45   *
46   */
47  public class MyLuteceUserFieldHome
48  {
49      private static IMyLuteceUserFieldDAO _dao = SpringContextService.getBean( "mylutece.myLuteceUserFieldDAO" );
50  
51      /**
52       * Load the user field
53       * 
54       * @param nIdUserField
55       *            ID
56       * @param locale
57       *            the locale
58       * @param plugin
59       *            The plugin
60       * @return MyLuteceUserField
61       */
62      public static MyLuteceUserField findByPrimaryKey( int nIdUserField, Locale locale, Plugin plugin )
63      {
64          return _dao.load( nIdUserField, locale, plugin );
65      }
66  
67      /**
68       * Insert a new user field
69       * 
70       * @param userField
71       *            the user field
72       * @param plugin
73       *            The plugin
74       */
75      public static void create( MyLuteceUserField userField, Plugin plugin )
76      {
77          _dao.insert( userField, plugin );
78      }
79  
80      /**
81       * Update an user field
82       * 
83       * @param userField
84       *            the user field
85       * @param plugin
86       *            The plugin
87       */
88      public static void update( MyLuteceUserField userField, Plugin plugin )
89      {
90          _dao.store( userField, plugin );
91      }
92  
93      /**
94       * Delete an attribute
95       * 
96       * @param nIdUserField
97       *            the ID of the user field
98       * @param plugin
99       *            The plugin
100      */
101     public static void remove( int nIdUserField, Plugin plugin )
102     {
103         _dao.delete( nIdUserField, plugin );
104     }
105 
106     /**
107      * Delete all user fields from given id field
108      * 
109      * @param nIdField
110      *            id field
111      * @param plugin
112      *            The plugin
113      */
114     public static void removeUserFieldsFromIdField( int nIdField, Plugin plugin )
115     {
116         _dao.deleteUserFieldsFromIdField( nIdField, plugin );
117     }
118 
119     /**
120      * Delete all user fields from given id user
121      * 
122      * @param nIdUser
123      *            id user
124      * @param plugin
125      *            The plugin
126      */
127     public static void removeUserFieldsFromIdUser( int nIdUser, Plugin plugin )
128     {
129         _dao.deleteUserFieldsFromIdUser( nIdUser, plugin );
130     }
131 
132     /**
133      * Delete all user fields from given id attribute
134      * 
135      * @param nIdAttribute
136      *            id attribute
137      * @param plugin
138      *            The plugin
139      */
140     public static void removeUserFieldsFromIdAttribute( int nIdAttribute, Plugin plugin )
141     {
142         _dao.deleteUserFieldsFromIdAttribute( nIdAttribute, plugin );
143     }
144 
145     /**
146      * Load all the user field by a given ID user and a given ID attribute
147      * 
148      * @param nIdUser
149      *            the ID user
150      * @param nIdAttribute
151      *            The id of the attribute
152      * @param plugin
153      *            The plugin
154      * @return a list of adminuserfield
155      */
156     public static List<MyLuteceUserField> selectUserFieldsByIdUserIdAttribute( int nIdUser, int nIdAttribute, Plugin plugin )
157     {
158         return _dao.selectUserFieldsByIdUserIdAttribute( nIdUser, nIdAttribute, plugin );
159     }
160 
161     /**
162      * Load users by a given filter
163      * 
164      * @param mlFieldFilter
165      *            the filter
166      * @param plugin
167      *            Plugin
168      * @return a list of users
169      */
170     public static List<Integer> findUsersByFilter( MyLuteceUserFieldFilter mlFieldFilter, Plugin plugin )
171     {
172         return _dao.selectUsersByFilter( mlFieldFilter, plugin );
173     }
174 }