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.myportal.business;
35  
36  import fr.paris.lutece.plugins.myportal.service.MyPortalPlugin;
37  import fr.paris.lutece.portal.service.plugin.Plugin;
38  import fr.paris.lutece.portal.service.plugin.PluginService;
39  import fr.paris.lutece.portal.service.spring.SpringContextService;
40  
41  import java.util.List;
42  
43  /**
44   *
45   * DefaultPageBuilderHome
46   *
47   */
48  public final class DefaultPageBuilderHome
49  {
50      // Static variable pointed at the DAO instance
51      private static final String BEAN_MYPORTAL_DEFAULTPAGEBUILDERDAO = "myportal.defaultPageBuilderDAO";
52      private static Plugin _plugin = PluginService.getPlugin( MyPortalPlugin.PLUGIN_NAME );
53      private static IDefaultPageBuilderDAO/../fr/paris/lutece/plugins/myportal/business/IDefaultPageBuilderDAO.html#IDefaultPageBuilderDAO">IDefaultPageBuilderDAO _dao = (IDefaultPageBuilderDAO) SpringContextService.getPluginBean( MyPortalPlugin.PLUGIN_NAME,
54              BEAN_MYPORTAL_DEFAULTPAGEBUILDERDAO );
55  
56      /**
57       * Private constructor - this class need not be instantiated
58       */
59      private DefaultPageBuilderHome( )
60      {
61      }
62  
63      /**
64       * Get a new PK
65       *
66       * @return the new PK
67       */
68      public static int newPrimaryKey( )
69      {
70          return _dao.newPrimaryKey( _plugin );
71      }
72  
73      /**
74       * Creation of an instance of widgetComponent
75       *
76       * @param widgetComponent
77       *            The instance of the widgetComponent which contains the informations to store
78       */
79      public static void create( WidgetComponent widgetComponent )
80      {
81          _dao.insert( widgetComponent, _plugin );
82      }
83  
84      /**
85       * Update of the widgetComponent which is specified in parameter
86       *
87       * @param widgetComponent
88       *            The instance of the widgetComponent which contains the informations to update
89       *
90       */
91      public static void update( WidgetComponent widgetComponent )
92      {
93          _dao.store( widgetComponent, _plugin );
94      }
95  
96      /**
97       * Remove the widgetComponent whose identifier is specified in parameter
98       *
99       * @param nIdWidgetComponent
100      *            The widgetComponent id
101      */
102     public static void remove( int nIdWidgetComponent )
103     {
104         _dao.delete( nIdWidgetComponent, _plugin );
105     }
106 
107     /**
108      * Delete the records that have a column > to the given nColumnMax
109      *
110      * @param nColumnMax
111      *            the column max
112      */
113     public static void removeByColumnMax( int nColumnMax )
114     {
115         _dao.deleteByColumnMax( nColumnMax, _plugin );
116     }
117 
118     /**
119      * Remove the widgetComponent whose identifier is specified in parameter
120      */
121     public static void removeAll( )
122     {
123         _dao.deleteAll( _plugin );
124     }
125 
126     // /////////////////////////////////////////////////////////////////////////
127     // Finders
128 
129     /**
130      * Returns an instance of a widgetComponent whose identifier is specified in parameter
131      *
132      * @param nIdWidgetComponent
133      *            The widgetComponent primary key
134      * @return an instance of widgetComponent
135      */
136     public static WidgetComponent findByPrimaryKey( int nIdWidgetComponent )
137     {
138         return _dao.load( nIdWidgetComponent, _plugin );
139     }
140 
141     /**
142      * Loads the data of all the widgetComponent
143      *
144      * @return the list which contains the data of all the widgetComponent
145      */
146     public static List<WidgetComponent> findAll( )
147     {
148         return _dao.selectAllWidgetComponents( _plugin );
149     }
150 
151     /**
152      * Loads the data of all the widgetComponent
153      * 
154      * @param filter
155      *            a search by criteria
156      * @return the list which contains the data of all the widgetComponent
157      */
158     public static List<WidgetComponent> findByFilter( WidgetComponentFilter filter )
159     {
160         return _dao.selectWidgetComponents( filter, _plugin );
161     }
162 
163     /**
164      * Finds the max order for all columns.
165      * 
166      * @return the max order
167      */
168     public static int findMaxOrder( )
169     {
170         return _dao.selectMaxOrder( _plugin );
171     }
172 
173     /**
174      * Finds the max order for the column.
175      * 
176      * @param nColumn
177      *            the column
178      * @return the max order
179      */
180     public static int findMaxOrder( int nColumn )
181     {
182         return _dao.selectMaxOrder( nColumn, _plugin );
183     }
184 
185     /**
186      * Find the columns list
187      * 
188      * @return a list of integer
189      */
190     public static List<Integer> findColumns( )
191     {
192         return _dao.selectColumns( _plugin );
193     }
194 
195     /**
196      * Return the widget ids list
197      * 
198      * @return the widget ids list
199      */
200     public static List<Integer> findWidgetIds( )
201     {
202         return _dao.selectWidgetIds( _plugin );
203     }
204 }