Class CommentDAO

  • All Implemented Interfaces:
    ICommentDAO

    public class CommentDAO
    extends Object
    implements ICommentDAO
    This class provides Data Access methods for Comment objects.
    • Constructor Summary

      Constructors 
      Constructor Description
      CommentDAO()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int countByIdParent​(int nIdParent, boolean bPublishedOnly, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get the number of comments associated with a given parent
      void delete​(int nIdComment, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Delete.
      void deleteByResource​(String strIdExtendableResource, String strExtendableResourceType, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Delete by id hub resource.
      List<Comment> findByIdParent​(int nIdParent, CommentFilter commentFilter, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get comments from their parent
      List<Comment> findCommentsByLuteceUserName​(String strLuteceUserName, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get comments of a lutece user.
      List<Integer> findIdMostCommentedResources​(String strExtendableResourceType, boolean bPublishedOnly, int nItemsOffset, int nMaxItemsNumber, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get the ids of resources ordered by their number of comments
      List<Integer> findIdsByResource​(String strIdExtendableResource, String strExtendableResourceType, boolean bPublishedOnly, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Select ids of comments associated with a given resource
      List<Comment> findParentCommentsByResource​(String strIdExtendableResource, String strExtendableResourceType, CommentFilter commentFilter, int nItemsOffset, int nMaxItemsNumber, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get comments of a given resource.
      int getCommentNb​(String strIdExtendableResource, String strExtendableResourceType, boolean bParentsOnly, boolean bPublishedOnly, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Check comment nb.
      void insert​(Comment comment, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Insert.
      Comment load​(int nIdComment, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Load.
      List<Comment> selectByListResource​(List<String> listIdExtendableResource, String strExtendableResourceType, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Load comment list by resource
      List<Comment> selectLastComments​(String strIdExtendableResource, String strExtendableResourceType, int nNbComments, boolean bPublishedOnly, boolean bParentsOnly, fr.paris.lutece.portal.service.plugin.Plugin plugin, boolean bSortedByDateCreation)
      Load last comments.
      void store​(Comment comment, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Store.
      void updateCommentStatus​(int nIdComment, boolean bPublished, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update comment status.
    • Constructor Detail

      • CommentDAO

        public CommentDAO()
    • Method Detail

      • insert

        public void insert​(Comment comment,
                           fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Insert.
        Specified by:
        insert in interface ICommentDAO
        Parameters:
        comment - the comment
        plugin - the plugin
      • load

        public Comment load​(int nIdComment,
                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Load.
        Specified by:
        load in interface ICommentDAO
        Parameters:
        nIdComment - the n id comment
        plugin - the plugin
        Returns:
        the comment
      • delete

        public void delete​(int nIdComment,
                           fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Delete.
        Specified by:
        delete in interface ICommentDAO
        Parameters:
        nIdComment - the n id comment
        plugin - the plugin
      • deleteByResource

        public void deleteByResource​(String strIdExtendableResource,
                                     String strExtendableResourceType,
                                     fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Delete by id hub resource.
        Specified by:
        deleteByResource in interface ICommentDAO
        Parameters:
        strIdExtendableResource - the str id extendable resource
        strExtendableResourceType - the str extendable resource type
        plugin - the plugin
      • store

        public void store​(Comment comment,
                          fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Store.
        Specified by:
        store in interface ICommentDAO
        Parameters:
        comment - the comment
        plugin - the plugin
      • updateCommentStatus

        public void updateCommentStatus​(int nIdComment,
                                        boolean bPublished,
                                        fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update comment status.
        Specified by:
        updateCommentStatus in interface ICommentDAO
        Parameters:
        nIdComment - the n id comment
        bPublished - the b published
        plugin - the plugin
      • getCommentNb

        public int getCommentNb​(String strIdExtendableResource,
                                String strExtendableResourceType,
                                boolean bParentsOnly,
                                boolean bPublishedOnly,
                                fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Check comment nb.
        Specified by:
        getCommentNb in interface ICommentDAO
        Parameters:
        strIdExtendableResource - the id of the extendable resource
        strExtendableResourceType - the extendable resource type
        bParentsOnly - True to consider only comments with no parent, false otherwise
        bPublishedOnly - True to consider only published comments, false to consider every comments.
        plugin - the plugin
        Returns:
        the number of comments
      • selectLastComments

        public List<Comment> selectLastComments​(String strIdExtendableResource,
                                                String strExtendableResourceType,
                                                int nNbComments,
                                                boolean bPublishedOnly,
                                                boolean bParentsOnly,
                                                fr.paris.lutece.portal.service.plugin.Plugin plugin,
                                                boolean bSortedByDateCreation)
        Load last comments.
        Specified by:
        selectLastComments in interface ICommentDAO
        Parameters:
        strIdExtendableResource - the id of the extendable resource
        strExtendableResourceType - the extendable resource type
        nNbComments - the number of comments
        bPublishedOnly - the b published only
        bParentsOnly - True to get only parent comments, false to get every comments.
        plugin - the plugin
        bSortedByDateCreation - true if is sorted by date creation
        Returns:
        the list
      • selectByListResource

        public List<Comment> selectByListResource​(List<String> listIdExtendableResource,
                                                  String strExtendableResourceType,
                                                  fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Load comment list by resource
        Specified by:
        selectByListResource in interface ICommentDAO
        strExtendableResourceType - the extendable resource type
        plugin - the plugin
        Returns:
        list of comments
      • findParentCommentsByResource

        public List<Comment> findParentCommentsByResource​(String strIdExtendableResource,
                                                          String strExtendableResourceType,
                                                          CommentFilter commentFilter,
                                                          int nItemsOffset,
                                                          int nMaxItemsNumber,
                                                          fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get comments of a given resource. Only parents comments are returned.
        Specified by:
        findParentCommentsByResource in interface ICommentDAO
        Parameters:
        strIdExtendableResource - The id of the resource
        strExtendableResourceType - The type of the resource
        nItemsOffset - The offset of the items to get, or 0 to get items from the first one
        nMaxItemsNumber - The maximum number of items to return, or 0 to get every items
        plugin - The plugin
        Returns:
        The list of comments associated with the given resource
      • findByIdParent

        public List<Comment> findByIdParent​(int nIdParent,
                                            CommentFilter commentFilter,
                                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get comments from their parent
        Specified by:
        findByIdParent in interface ICommentDAO
        Parameters:
        nIdParent - The id of the parent of comments to get
        commentFilter - The comment filter
        plugin - The plugin
        Returns:
        The list of comments associated with the given parent
      • countByIdParent

        public int countByIdParent​(int nIdParent,
                                   boolean bPublishedOnly,
                                   fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the number of comments associated with a given parent
        Specified by:
        countByIdParent in interface ICommentDAO
        Parameters:
        nIdParent - The id of the parent of comments to count.
        bPublishedOnly - True to consider only published comments
        plugin - The plugin
        Returns:
        The number of comments associated with the given parent
      • findIdsByResource

        public List<Integer> findIdsByResource​(String strIdExtendableResource,
                                               String strExtendableResourceType,
                                               boolean bPublishedOnly,
                                               fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Select ids of comments associated with a given resource
        Specified by:
        findIdsByResource in interface ICommentDAO
        Parameters:
        strIdExtendableResource - The id of the extendable resource
        strExtendableResourceType - The extendable resource type
        bPublishedOnly - True to consider only published comments, false to consider every comment
        plugin - The plugin
        Returns:
        The list of comment ids, or an empty list if no comment is associated with the given resource
      • findIdMostCommentedResources

        public List<Integer> findIdMostCommentedResources​(String strExtendableResourceType,
                                                          boolean bPublishedOnly,
                                                          int nItemsOffset,
                                                          int nMaxItemsNumber,
                                                          fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the ids of resources ordered by their number of comments
        Specified by:
        findIdMostCommentedResources in interface ICommentDAO
        Parameters:
        strExtendableResourceType - The type of resources to consider
        bPublishedOnly - True to consider only published comments, false to consider every comments
        nItemsOffset - The offset of the items to get, or 0 to get items from the first one
        nMaxItemsNumber - The maximum number of items to return, or 0 to get every items
        plugin - The plugin
        Returns:
        The list of ids of resources ordered by the number of associated comments
      • findCommentsByLuteceUserName

        public List<Comment> findCommentsByLuteceUserName​(String strLuteceUserName,
                                                          fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get comments of a lutece user. Only parents comments are returned.
        Specified by:
        findCommentsByLuteceUserName in interface ICommentDAO
        Parameters:
        strLuteceUserName - The name of the lutece user
        plugin - The plugin
        Returns:
        The list of comments associated with the given resource