Class CommentService

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BEAN_SERVICE
      The Constant BEAN_SERVICE.
    • Constructor Summary

      Constructors 
      Constructor Description
      CommentService()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int countByIdParent​(int nIdParent, boolean bPublishedOnly)
      Get the number of comments associated with a given parent
      void create​(Comment comment)
      Insert.
      void create​(Comment comment, javax.servlet.http.HttpServletRequest request)
      Insert.
      java.util.List<Comment> findByIdParent​(int nIdParent, boolean bPublishedOnly)
      Get comments from their parent
      java.util.List<Comment> findByIdParent​(int nIdParent, boolean bPublishedOnly, java.lang.String strSortedAttributeName, boolean bAscSort)
      Get comments from their parent
      java.util.List<Comment> findByListResource​(java.util.List<java.lang.String> listIdExtendableResource, java.lang.String strExtendableResourceType)
      Find comment list by resource
      Comment findByPrimaryKey​(int nIdComment)
      Load.
      java.util.List<Comment> findByResource​(java.lang.String strIdExtendableResource, java.lang.String strExtendableResourceType, boolean bPublishedOnly, boolean bAscSort)
      Select by resource.
      java.util.List<Comment> findByResource​(java.lang.String strIdExtendableResource, java.lang.String strExtendableResourceType, boolean bPublishedOnly, java.lang.String strSortedAttributeName, boolean bAscSort, int nItemsOffset, int nMaxItemsNumber, boolean bLoadSubComments)
      Get comments of a given resource
      java.util.List<Comment> findByResource​(java.lang.String strIdExtendableResource, java.lang.String strExtendableResourceType, CommentFilter commentFilter, int nItemsOffset, int nMaxItemsNumber, boolean bLoadSubComments)
      Get comments of a given resource
      java.util.List<Comment> findCommentsByLuteceUser​(java.lang.String strLuteceUserName)
      Load comments by lutece user name.
      java.util.List<Comment> findCommentsPinned​(java.lang.String strIdExtendableResource, java.lang.String strExtendableResourceType, int nNbComments, java.lang.Integer nCommentState, boolean bParentsOnly, boolean bGetNumberSubComments, java.lang.String strFilterUserName)
      Load comments pinned.
      java.util.List<java.lang.Integer> findIdMostCommentedResources​(java.lang.String strExtendableResourceType, boolean bPublishedOnly, int nItemsOffset, int nMaxItemsNumber)
      Get the ids of resources ordered by their number of comments
      java.util.List<java.lang.Integer> findIdsByResource​(java.lang.String strIdExtendableResource, java.lang.String strExtendableResourceType, boolean bPublishedOnly)
      Select ids of comments associated with a given resource
      java.util.List<Comment> findLastComments​(java.lang.String strIdExtendableResource, java.lang.String strExtendableResourceType, int nNbComments, boolean bPublishedOnly, boolean bParentsOnly, boolean bGetNumberSubComments, boolean bDisplaySubComments, boolean bSortedByDateCreation)
      Load last comments.
      int getCommentNb​(java.lang.String strIdExtendableResource, java.lang.String strExtendableResourceType, boolean bParentsOnly, boolean bPublishedOnly)
      Get the number of comment
      fr.paris.lutece.util.ReferenceList getRefListCommentStates​(java.util.Locale locale)
      return a referenceList of comment states
      fr.paris.lutece.util.ReferenceList getRefListFilterAsImportant​(java.util.Locale locale)
      return a referenceList containing the filter on the flag important
      fr.paris.lutece.util.ReferenceList getRefListFilterAsPinned​(java.util.Locale locale)
      return a referenceList containing the filter on the flag As Pinned
      java.lang.String getResourceType​(java.lang.String extendableResourceType)
      return resource type
      void remove​(int nIdComment)
      Delete.
      void removeByResource​(java.lang.String strIdExtendableResource, java.lang.String strExtendableResourceType)
      Delete by resource
      void update​(Comment comment)
      Store.
      void updateCommentPinned​(int nIdComment, boolean bPinned)
      Update flag important.
      void updateCommentStatus​(int nIdComment, boolean bPublished)
      Update comment status.
      void updateFlagImportant​(int nIdComment, boolean bImportant)
      Update flag important.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BEAN_SERVICE

        public static final java.lang.String BEAN_SERVICE
        The Constant BEAN_SERVICE.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CommentService

        public CommentService()
    • Method Detail

      • create

        @Transactional("extend-comment.transactionManager")
        public void create​(Comment comment,
                           javax.servlet.http.HttpServletRequest request)
        Insert.
        Specified by:
        create in interface ICommentService
        Parameters:
        comment - the comment
        request - the HTTP request
      • create

        @Transactional("extend-comment.transactionManager")
        public void create​(Comment comment)
        Insert.
        Specified by:
        create in interface ICommentService
        Parameters:
        comment - the comment
      • update

        @Transactional("extend-comment.transactionManager")
        public void update​(Comment comment)
        Store.
        Specified by:
        update in interface ICommentService
        Parameters:
        comment - the comment
      • updateCommentStatus

        @Transactional("extend-comment.transactionManager")
        public void updateCommentStatus​(int nIdComment,
                                        boolean bPublished)
        Update comment status.
        Specified by:
        updateCommentStatus in interface ICommentService
        Parameters:
        nIdComment - the n id comment
        bPublished - the b published
      • remove

        @Transactional("extend-comment.transactionManager")
        public void remove​(int nIdComment)
        Delete.
        Specified by:
        remove in interface ICommentService
        Parameters:
        nIdComment - the n id comment
      • removeByResource

        @Transactional("extend-comment.transactionManager")
        public void removeByResource​(java.lang.String strIdExtendableResource,
                                     java.lang.String strExtendableResourceType)
        Delete by resource
        Specified by:
        removeByResource in interface ICommentService
        Parameters:
        strIdExtendableResource - the str id extendable resource
        strExtendableResourceType - the str extendable resource type
      • findByPrimaryKey

        public Comment findByPrimaryKey​(int nIdComment)
        Load.
        Specified by:
        findByPrimaryKey in interface ICommentService
        Parameters:
        nIdComment - the n id comment
        Returns:
        the comment
      • findIdsByResource

        public java.util.List<java.lang.Integer> findIdsByResource​(java.lang.String strIdExtendableResource,
                                                                   java.lang.String strExtendableResourceType,
                                                                   boolean bPublishedOnly)
        Select ids of comments associated with a given resource
        Specified by:
        findIdsByResource in interface ICommentService
        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
        Returns:
        The list of comment ids, or an empty list if no comment is associated with the given resource
      • findByResource

        public java.util.List<Comment> findByResource​(java.lang.String strIdExtendableResource,
                                                      java.lang.String strExtendableResourceType,
                                                      boolean bPublishedOnly,
                                                      boolean bAscSort)
        Select by resource.
        Specified by:
        findByResource in interface ICommentService
        Parameters:
        strIdExtendableResource - the id of the extendable resource
        strExtendableResourceType - the extendable resource type
        bPublishedOnly - Get only published comments
        bAscSort - True if comments should be sorted ascendantly, false otherwise
        Returns:
        the list
      • getCommentNb

        public int getCommentNb​(java.lang.String strIdExtendableResource,
                                java.lang.String strExtendableResourceType,
                                boolean bParentsOnly,
                                boolean bPublishedOnly)
        Get the number of comment
        Specified by:
        getCommentNb in interface ICommentService
        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 get only published comments, false to get every comments
        Returns:
        the number of comments
      • findLastComments

        public java.util.List<Comment> findLastComments​(java.lang.String strIdExtendableResource,
                                                        java.lang.String strExtendableResourceType,
                                                        int nNbComments,
                                                        boolean bPublishedOnly,
                                                        boolean bParentsOnly,
                                                        boolean bGetNumberSubComments,
                                                        boolean bDisplaySubComments,
                                                        boolean bSortedByDateCreation)
        Load last comments.
        Specified by:
        findLastComments in interface ICommentService
        Parameters:
        strIdExtendableResource - the id of the extendable resource
        strExtendableResourceType - the extendable resource type
        nNbComments - the number of comments
        bPublishedOnly - True to get only published comments, false to get every comments
        bParentsOnly - True to get only parent comments, false to get every comments.
        bGetNumberSubComments - True to get the number of sub comments of each comment, false otherwise
        bDisplaySubComments - True if the mod display sub comments is enable
        bSortedByDateCreation - true if the list is sorted by date creation
        Returns:
        the list
      • findByResource

        public java.util.List<Comment> findByResource​(java.lang.String strIdExtendableResource,
                                                      java.lang.String strExtendableResourceType,
                                                      boolean bPublishedOnly,
                                                      java.lang.String strSortedAttributeName,
                                                      boolean bAscSort,
                                                      int nItemsOffset,
                                                      int nMaxItemsNumber,
                                                      boolean bLoadSubComments)
        Get comments of a given resource
        Specified by:
        findByResource in interface ICommentService
        Parameters:
        strIdExtendableResource - The id of the resource
        strExtendableResourceType - The type of the resource
        bPublishedOnly - True to consider only published comments
        strSortedAttributeName - The name of the attribute to sort, or null if no sort should be done
        bAscSort - True to sort ascendantly, false otherwise
        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
        bLoadSubComments - True if sub comments should be loaded, false if they should be ignored
        Returns:
        The list of comments associated with the given resource
      • findByResource

        public java.util.List<Comment> findByResource​(java.lang.String strIdExtendableResource,
                                                      java.lang.String strExtendableResourceType,
                                                      CommentFilter commentFilter,
                                                      int nItemsOffset,
                                                      int nMaxItemsNumber,
                                                      boolean bLoadSubComments)
        Get comments of a given resource
        Specified by:
        findByResource in interface ICommentService
        Parameters:
        strIdExtendableResource - The id of the resource
        strExtendableResourceType - The type of the resource
        commentFilter - The commentFilter Object
        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
        bLoadSubComments - True if sub comments should be loaded, false if they should be ignored
        Returns:
        The list of comments associated with the given resource
      • findByIdParent

        public java.util.List<Comment> findByIdParent​(int nIdParent,
                                                      boolean bPublishedOnly)
        Get comments from their parent
        Specified by:
        findByIdParent in interface ICommentService
        Parameters:
        nIdParent - The id of the parent of comments to get
        bPublishedOnly - True to consider only published comments
        Returns:
        The list of comments associated with the given parent
      • findByIdParent

        public java.util.List<Comment> findByIdParent​(int nIdParent,
                                                      boolean bPublishedOnly,
                                                      java.lang.String strSortedAttributeName,
                                                      boolean bAscSort)
        Get comments from their parent
        Specified by:
        findByIdParent in interface ICommentService
        Parameters:
        nIdParent - The id of the parent of comments to get
        bPublishedOnly - True to consider only published comments
        strSortedAttributeName - The name of the attribute to sort, or null if no sort should be done
        bAscSort - True to sort ascendantly, false otherwise
        Returns:
        The list of comments associated with the given parent
      • countByIdParent

        public int countByIdParent​(int nIdParent,
                                   boolean bPublishedOnly)
        Get the number of comments associated with a given parent
        Specified by:
        countByIdParent in interface ICommentService
        Parameters:
        nIdParent - The id of the parent of comments to count.
        bPublishedOnly - True to consider only published comments
        Returns:
        The number of comments associated with the given parent
      • findIdMostCommentedResources

        public java.util.List<java.lang.Integer> findIdMostCommentedResources​(java.lang.String strExtendableResourceType,
                                                                              boolean bPublishedOnly,
                                                                              int nItemsOffset,
                                                                              int nMaxItemsNumber)
        Get the ids of resources ordered by their number of comments
        Specified by:
        findIdMostCommentedResources in interface ICommentService
        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
        Returns:
        The list of ids of resources ordered by the number of associated comments
      • getRefListCommentStates

        public fr.paris.lutece.util.ReferenceList getRefListCommentStates​(java.util.Locale locale)
        return a referenceList of comment states
        Specified by:
        getRefListCommentStates in interface ICommentService
        Parameters:
        locale - the locale
        Returns:
        a referenceList of comment states
      • getRefListFilterAsImportant

        public fr.paris.lutece.util.ReferenceList getRefListFilterAsImportant​(java.util.Locale locale)
        return a referenceList containing the filter on the flag important
        Specified by:
        getRefListFilterAsImportant in interface ICommentService
        Parameters:
        locale - the locale
        Returns:
        a referenceList containing the filter on the flag important
      • getRefListFilterAsPinned

        public fr.paris.lutece.util.ReferenceList getRefListFilterAsPinned​(java.util.Locale locale)
        return a referenceList containing the filter on the flag As Pinned
        Specified by:
        getRefListFilterAsPinned in interface ICommentService
        Parameters:
        locale - the locale
        Returns:
        a referenceList containing the filter on the flag As Pinned
      • findCommentsPinned

        public java.util.List<Comment> findCommentsPinned​(java.lang.String strIdExtendableResource,
                                                          java.lang.String strExtendableResourceType,
                                                          int nNbComments,
                                                          java.lang.Integer nCommentState,
                                                          boolean bParentsOnly,
                                                          boolean bGetNumberSubComments,
                                                          java.lang.String strFilterUserName)
        Description copied from interface: ICommentService
        Load comments pinned.
        Specified by:
        findCommentsPinned in interface ICommentService
        Parameters:
        strIdExtendableResource - the id of the extendable resource
        strExtendableResourceType - the extendable resource type
        nNbComments - the number of comments
        bParentsOnly - True to get only parent comments, false to get every comments.
        bGetNumberSubComments - True to get the number of sub comments of each comment, false otherwise
        Returns:
        the list of comments pinned
      • updateFlagImportant

        @Transactional("extend-comment.transactionManager")
        public void updateFlagImportant​(int nIdComment,
                                        boolean bImportant)
        Description copied from interface: ICommentService
        Update flag important.
        Specified by:
        updateFlagImportant in interface ICommentService
        Parameters:
        nIdComment - the n id comment
        bImportant - true if the comment is important
      • updateCommentPinned

        @Transactional("extend-comment.transactionManager")
        public void updateCommentPinned​(int nIdComment,
                                        boolean bPinned)
        Description copied from interface: ICommentService
        Update flag important.
        Specified by:
        updateCommentPinned in interface ICommentService
        Parameters:
        nIdComment - the n id comment
        bPinned - true if the comment must be pinned
      • getResourceType

        public java.lang.String getResourceType​(java.lang.String extendableResourceType)
        Description copied from interface: ICommentService
        return resource type
        Specified by:
        getResourceType in interface ICommentService
        Returns:
      • findByListResource

        public java.util.List<Comment> findByListResource​(java.util.List<java.lang.String> listIdExtendableResource,
                                                          java.lang.String strExtendableResourceType)
        Description copied from interface: ICommentService
        Find comment list by resource
        Specified by:
        findByListResource in interface ICommentService
        strExtendableResourceType - the extendable resource type
        Returns:
        list of comments
      • findCommentsByLuteceUser

        public java.util.List<Comment> findCommentsByLuteceUser​(java.lang.String strLuteceUserName)
        Description copied from interface: ICommentService
        Load comments by lutece user name.
        Specified by:
        findCommentsByLuteceUser in interface ICommentService
        Parameters:
        strLuteceUserName - the name of the lutece user
        Returns:
        the list of comments by lutece user name