View Javadoc
1   /*
2    * Copyright (c) 2002-2017, 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.myapps.modules.database.business;
35  
36  import fr.paris.lutece.plugins.myapps.business.MyApps;
37  import fr.paris.lutece.portal.service.image.ImageResource;
38  import fr.paris.lutece.portal.service.plugin.Plugin;
39  import fr.paris.lutece.util.ReferenceList;
40  
41  import java.util.List;
42  
43  /**
44   *
45   * IMyAppsDatabaseDAO
46   *
47   */
48  public interface IMyAppsDatabaseDAO
49  {
50      /**
51       * Get a new primary key
52       *
53       * @param plugin
54       *            {@link Plugin}
55       * @return a new primary key
56       */
57      int newPrimaryKey( Plugin plugin );
58  
59      /**
60       * Insert a new record in the table.
61       *
62       * @param myApp
63       *            instance of the MyApps object to insert
64       * @param plugin
65       *            the Plugin
66       */
67      void insert( MyAppsDatabase myApp, Plugin plugin );
68  
69      /**
70       * Update the record in the table
71       *
72       * @param myApp
73       *            the reference of the MyApps
74       * @param bUpdateIcon
75       *            true if the icon must also be updated, false otherwise
76       * @param plugin
77       *            the Plugin
78       */
79      void store( MyAppsDatabase myApp, boolean bUpdateIcon, Plugin plugin );
80  
81      /**
82       * Delete a record from the table
83       *
84       * @param nMyAppId
85       *            int identifier of the MyApps to delete
86       * @param plugin
87       *            the Plugin
88       */
89      void delete( int nMyAppId, Plugin plugin );
90  
91      /**
92       * load the data of the right from the table
93       *
94       * @param nMyAppId
95       *            The identifier of the myApps
96       * @param plugin
97       *            the Plugin
98       * @return The instance of the myApps
99       */
100     MyApps load( int nMyAppId, Plugin plugin );
101 
102     /**
103      * Loads all the myapps
104      * 
105      * @param filter
106      *            the app filter
107      * @param plugin
108      *            the Plugin
109      * @return the list which contains the myApps
110      */
111     List<MyApps> selectMyAppsList( MyAppsDatabaseFilter filter, Plugin plugin );
112 
113     /**
114      * Loads all the myapps belonging to a filter
115      *
116      * @param filter
117      *            the app filter
118      * @param bIsAscSort
119      *            true if it is sorted ascendly, false otherwise
120      * @param plugin
121      *            the Plugin
122      * @return the list which contains the myApps
123      */
124     List<MyApps> selectMyAppsListByFilter( MyAppsDatabaseFilter filter, boolean bIsAscSort, Plugin plugin );
125 
126     /**
127      * Loads all the myapps belonging to a user ordered by the order specify by the user
128      *
129      * @param strUserName
130      *            the name of the user
131      * @param plugin
132      *            the Plugin
133      * @return the list which contains the myApps of the user ordered
134      */
135     List<MyApps> selectMyAppsListByUser( String strUserName, Plugin plugin );
136 
137     /**
138      * Loads the icon representing the favorite application
139      *
140      * @param nMyAppId
141      *            int identifier of the MyApps to fetch
142      * @param plugin
143      *            the Plugin
144      * @return the image resource
145      */
146     ImageResource getIconResource( int nMyAppId, Plugin plugin );
147 
148     /**
149      * Get the list of my apps
150      *
151      * @param plugin
152      *            {@link Plugin}
153      * @return a list of {@link MyAppsDatabase}
154      */
155     ReferenceList getMyAppsList( Plugin plugin );
156 
157     /**
158      * Check if the Myapps has an icon or not
159      *
160      * @param nMyAppId
161      *            the ID of the MyApp
162      * @param plugin
163      *            {@link Plugin}
164      * @return true if it has an icon, false otherwise
165      */
166     boolean hasIcon( int nMyAppId, Plugin plugin );
167 }