View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de 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.modules.wssodatabase.authentication.business;
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  
41  
42  /**
43   * This class provides instances management methods (create, find, ...) for
44   * WssoProfil objects
45   */
46  public final class WssoProfilHome
47  {
48      // Static variable pointed at the DAO instance
49      private static IWssoProfilDAO _dao = (IWssoProfilDAO) SpringContextService.getBean( 
50              "mylutece-wssodatabase.wssoProfilDAO" );
51  
52      /**
53       * Private constructor - this class need not be instantiated
54       */
55      private WssoProfilHome(  )
56      {
57      }
58  
59      /**
60       * Creation of an instance of wssoProfil
61       *
62       * @param wssoProfil The instance of the wssoProfil which contains the
63       *            informations to store
64       * @param plugin The current plugin using this method
65       * @return The instance of wssoProfil which has been created with its
66       *         primary key.
67       */
68      public static WssoProfil create( WssoProfil wssoProfil, Plugin plugin )
69      {
70          _dao.insert( wssoProfil, plugin );
71  
72          return wssoProfil;
73      }
74  
75      /**
76       * Update of the wssoProfil which is specified in parameter
77       *
78       * @param wssoProfil The instance of the wssoProfil which contains the data
79       *            to store
80       * @param plugin The current plugin using this method
81       * @return The instance of the wssoProfil which has been updated
82       */
83      public static WssoProfil update( WssoProfil wssoProfil, Plugin plugin )
84      {
85          _dao.store( wssoProfil, plugin );
86  
87          return wssoProfil;
88      }
89  
90      /**
91       * Remove the WssoProfil whose identifier is specified in parameter
92       *
93       * @param wssoProfil The WssoProfil object to remove
94       * @param plugin The current plugin using this method
95       */
96      public static void remove( WssoProfil wssoProfil, Plugin plugin )
97      {
98          _dao.delete( wssoProfil, plugin );
99      }
100 
101     // /////////////////////////////////////////////////////////////////////////
102     // Finders
103 
104     /**
105      * Returns an instance of a wssoProfil whose identifier is specified in
106      * parameter
107      *
108      * @param nKey The Primary key of the wssoProfil
109      * @param plugin The current plugin using this method
110      * @return An instance of wssoProfil
111      */
112     public static WssoProfil findWssoProfilByCode( String nKey, Plugin plugin )
113     {
114         return _dao.load( nKey, plugin );
115     }
116 
117     /**
118      * Returns a collection of wssoProfils objects
119      * @param plugin The current plugin using this method
120      * @return A collection of wssoProfils
121      */
122     public static List<WssoProfil> findWssoProfilsList( Plugin plugin )
123     {
124         return _dao.selectWssoProfilList( plugin );
125     }
126 
127     //	/**
128     //	 * Returns a collection of wssoProfils objects for a role
129     //	 * @param nIdRole The role id of the wssoProfil
130     //	 * @param plugin The current plugin using this method
131     //	 * @return A collection of wssoProfils
132     //	 */
133     //	public static Collection findWssoProfilsListForRole( int nIdRole, Plugin plugin )
134     //	{
135     //		return _dao.selectWssoProfilsListForRole( nIdRole, plugin );
136     //	}
137 
138     //	/**
139     //	 * Returns a collection of wssoProfils objects for a guid
140     //	 * @param strGuid The guid of the wssoProfil
141     //	 * @param plugin The current plugin using this method
142     //	 * @return A collection of wssoProfils
143     //	 */
144     //	public static Collection findWssoProfilsListForGuid( String strGuid, Plugin plugin )
145     //	{
146     //		return _dao.selectWssoProfilListForGuid( strGuid, plugin );
147     //	}
148 
149     //	 public static WssoProfil findWssoProfilByCode( String strCode, Plugin plugin ){
150     //		return _dao.findWssoProfilByCode( strCode, plugin );
151     //	 }
152 
153     /**
154      * Find profil by code and description
155      *
156      * @param strCode the code
157      * @param strDescription the description
158      * @param plugin the current plugin
159      * @return the profil
160      */
161     public static WssoProfil findWssoProfilByCodeAndDescription( String strCode, String strDescription, Plugin plugin )
162     {
163         return _dao.findWssoProfilByCodeAndDescription( strCode, strDescription, plugin );
164     }
165 
166     /**
167      * Find the profils by description
168      *
169      * @param strDescription the description
170      * @param plugin the current plugin
171      * @return the profil list for the description
172      */
173     public static List<WssoProfil> findWssoProfilsByDescription( String strDescription, Plugin plugin )
174     {
175         return _dao.findWssoProfilsByDescription( strDescription, plugin );
176     }
177 
178     /**
179      *
180      * Find profils for a user
181      *
182      * @param nWssoUserId the user id
183      * @param plugin the current plugin
184      * @return the profils's list for a user
185      */
186     public static List<String> findWssoProfilsForUser( int nWssoUserId, Plugin plugin )
187     {
188         return _dao.findWssoProfilsForUser( nWssoUserId, plugin );
189     }
190 
191     /**
192      * Check if the specified profil is assigned to a user
193      *
194      * @param strCode profil code
195      * @param plugin the current plugin
196      * @return true if the profil is assigned, else false
197      */
198     public static boolean checkProfilAssigned( String strCode, Plugin plugin )
199     {
200         return _dao.checkProfilAssigned( strCode, plugin );
201     }
202 }