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.extend.modules.comment.business;
35  
36  import fr.paris.lutece.portal.service.plugin.Plugin;
37  
38  import java.util.Collection;
39  import java.util.List;
40  
41  /**
42   * ICommentDAO.
43   */
44  public interface ICommentDAO
45  {
46      /**
47       * Delete.
48       * 
49       * @param nIdComment
50       *            the n id comment
51       * @param plugin
52       *            the plugin
53       */
54      void delete( int nIdComment, Plugin plugin );
55  
56      /**
57       * Delete by id hub resource.
58       * 
59       * @param strIdExtendableResource
60       *            the str id extendable resource
61       * @param strExtendableResourceType
62       *            the str extendable resource type
63       * @param plugin
64       *            the plugin
65       */
66      void deleteByResource( String strIdExtendableResource, String strExtendableResourceType, Plugin plugin );
67  
68      /**
69       * Insert.
70       * 
71       * @param comment
72       *            the comment
73       * @param plugin
74       *            the plugin
75       */
76      void insert( Comment comment, Plugin plugin );
77  
78      /**
79       * Load.
80       * 
81       * @param nIdComment
82       *            the n id comment
83       * @param plugin
84       *            the plugin
85       * @return the comment
86       */
87      Comment load( int nIdComment, Plugin plugin );
88  
89      /**
90       * Store.
91       * 
92       * @param comment
93       *            the comment
94       * @param plugin
95       *            the plugin
96       */
97      void store( Comment comment, Plugin plugin );
98  
99      /**
100      * Update comment status.
101      * 
102      * @param nIdComment
103      *            the n id comment
104      * @param bPublished
105      *            the b published
106      * @param plugin
107      *            the plugin
108      */
109     void updateCommentStatus( int nIdComment, boolean bPublished, Plugin plugin );
110 
111     /**
112      * Check comment nb.
113      * 
114      * @param strIdExtendableResource
115      *            the id of the extendable resource
116      * @param strExtendableResourceType
117      *            the extendable resource type
118      * @param bParentsOnly
119      *            True to consider only comments with no parent, false otherwise
120      * @param bPublishedOnly
121      *            True to consider only published comments, false to consider every comments.
122      * @param plugin
123      *            the plugin
124      * @return the number of comments
125      */
126     int getCommentNb( String strIdExtendableResource, String strExtendableResourceType, boolean bParentsOnly, boolean bPublishedOnly, Plugin plugin );
127 
128     /**
129      * Load last comments.
130      * 
131      * @param strIdExtendableResource
132      *            the id of the extendable resource
133      * @param strExtendableResourceType
134      *            the extendable resource type
135      * @param nNbComments
136      *            the number of comments
137      * @param bPublishedOnly
138      *            the b published only
139      * @param bParentsOnly
140      *            True to get only parent comments, false to get every comments.
141      * @param plugin
142      *            the plugin
143      * @param bSortedByDateCreation
144      *            true if is sorted by date creation
145      * @return the list
146      */
147     List<Comment> selectLastComments( String strIdExtendableResource, String strExtendableResourceType, int nNbComments, boolean bPublishedOnly,
148             boolean bParentsOnly, Plugin plugin, boolean bSortedByDateCreation );
149     /**
150      * Load comment list by resource
151      * @param strIdExtendableResource
152      *            the id of the extendable resource
153      * @param strExtendableResourceType
154      *            the extendable resource type
155      * @param plugin
156      *            the plugin
157      * @return list of comments
158      */
159     List<Comment> selectByListResource( List<String> listIdExtendableResource, String strExtendableResourceType, Plugin plugin );
160 
161     /**
162      * Get comments of a given resource. Only parents comments are returned.
163      * 
164      * @param strIdExtendableResource
165      *            The id of the resource
166      * @param strExtendableResourceType
167      *            The type of the resource
168      * @param CommentFilter
169      *            The commentFilter
170      * @param nItemsOffset
171      *            The offset of the items to get, or 0 to get items from the first one
172      * @param nMaxItemsNumber
173      *            The maximum number of items to return, or 0 to get every items
174      * @param plugin
175      *            The plugin
176      * @return The list of comments associated with the given resource
177      */
178     List<Comment> findParentCommentsByResource( String strIdExtendableResource, String strExtendableResourceType, CommentFilter commentFilter, int nItemsOffset,
179             int nMaxItemsNumber, Plugin plugin );
180 
181     /**
182      * Get comments from their parent
183      * 
184      * @param nIdParent
185      *            The id of the parent of comments to get
186      * @param commentFilter
187      *            The comment filter
188      * @param plugin
189      *            The plugin
190      * @return The list of comments associated with the given parent
191      */
192     List<Comment> findByIdParent( int nIdParent, CommentFilter commentFilter, Plugin plugin );
193 
194     /**
195      * Get the number of comments associated with a given parent
196      * 
197      * @param nIdParent
198      *            The id of the parent of comments to count.
199      * @param bPublishedOnly
200      *            True to consider only published comments
201      * @param plugin
202      *            The plugin
203      * @return The number of comments associated with the given parent
204      */
205     int countByIdParent( int nIdParent, boolean bPublishedOnly, Plugin plugin );
206 
207     /**
208      * Select ids of comments associated with a given resource
209      * 
210      * @param strIdExtendableResource
211      *            The id of the extendable resource
212      * @param strExtendableResourceType
213      *            The extendable resource type
214      * @param bPublishedOnly
215      *            True to consider only published comments, false to consider every comment
216      * @param plugin
217      *            The plugin
218      * @return The list of comment ids, or an empty list if no comment is associated with the given resource
219      */
220     List<Integer> findIdsByResource( String strIdExtendableResource, String strExtendableResourceType, boolean bPublishedOnly, Plugin plugin );
221 
222     /**
223      * Get the ids of resources ordered by their number of comments
224      * 
225      * @param strExtendableResourceType
226      *            The type of resources to consider
227      * @param bPublishedOnly
228      *            True to consider only published comments, false to consider every comments
229      * @param nItemsOffset
230      *            The offset of the items to get, or 0 to get items from the first one
231      * @param nMaxItemsNumber
232      *            The maximum number of items to return, or 0 to get every items
233      * @param plugin
234      *            The plugin
235      * @return The list of ids of resources ordered by the number of associated comments
236      */
237     List<Integer> findIdMostCommentedResources( String strExtendableResourceType, boolean bPublishedOnly, int nItemsOffset, int nMaxItemsNumber,
238             Plugin plugin );
239 
240     /**
241      * Get comments of a lutece user. Only parents comments are returned.
242      * 
243      * @param strLuteceUserName
244      *            The name of the lutece user
245      * @param nItemsOffset
246      *            The offset of the items to get, or 0 to get items from the first one
247      * @param nMaxItemsNumber
248      *            The maximum number of items to return, or 0 to get every items
249      * @param plugin
250      *            The plugin
251      * @return The list of comments associated with the given resource
252      */
253 	List<Comment> findCommentsByLuteceUserName(String strLuteceUserName, Plugin plugin);
254 
255 }