Class VoteManager

    • Method Detail

      • getInstance

        public static VoteManager getInstance()
      • propertiesChange

        public void propertiesChange​(JProperties properties)
        Description copied from interface: JPropertiesListener
        Invoked after properties have been modified in JCMS and save on disk.

        You cannot alter the value received in parameters.

        Note that properties parameter may be null, a limited set of site properties, or all site properties.

        To check that a property has been modified, reload the "current" property instead using channel.getProperties or channel.getProperty.

        Specified by:
        propertiesChange in interface JPropertiesListener
        Parameters:
        properties - the properties which have been submitted to change
      • getPositiveVoteList

        public java.util.List<Vote> getPositiveVoteList​(Publication pub)
        Return the positive vote List for given Publication
        Parameters:
        pub - the Publication
        Returns:
        the positive vote List for given Publication
        Since:
        jcms-8.0.0
      • getNegativeVoteList

        public java.util.List<Vote> getNegativeVoteList​(Publication pub)
        Return the positive vote List for given Publication
        Parameters:
        pub - the Publication
        Returns:
        the positive vote List for given Publication
        Since:
        jcms-8.0.2
      • getVoteList

        public java.util.List<Vote> getVoteList​(Publication pub)
        Return the vote List for given Publication
        Parameters:
        pub - the Publication
        Returns:
        the vote List for given Publication
        Since:
        jcms-8.0.0
      • getVoteList

        public java.util.List<Vote> getVoteList​(Publication pub,
                                                java.lang.String orderBy)
        Return the vote List for given Publication with given order
        Parameters:
        pub - the Publication
        orderBy - the order of the query
        Returns:
        the vote List for given Publication
        Since:
        jcms-9.0.2
      • getPublicationVoteAllMemberSet

        public java.util.Set<Member> getPublicationVoteAllMemberSet​(Publication pub)
        Returns the Set of all Members who have voted on given Publication
        Parameters:
        pub - the Publication
        Returns:
        a Set<Member> who have voted on given Publication
        Since:
        jcms-8.0.0
      • getPublicationVoteMemberSet

        public java.util.Set<Member> getPublicationVoteMemberSet​(Publication pub,
                                                                 boolean positive)
        Return the Set<Member> who have voted on given Publication, depending on vote anonymization choices
        Parameters:
        pub - the Publication
        positive - , if true, returns only members who has made a positive vote. If false, it returns only members who made a negative vote
        Returns:
        the Set<Member> who have voted on given Publication, depending on vote anonymization choices
        Since:
        jcms-8.0.0
      • isVotable

        public boolean isVotable​(Publication pub)
        Parameters:
        pub - the Publication
        Returns:
        true if given Publication can be voted
        Since:
        jcms-8.0.0
      • isUnvotableType

        public boolean isUnvotableType​(java.lang.Class clazz)
        Returns true if the given class is unvotable
        Parameters:
        clazz - the class to check
        Returns:
        boolean true if the given class is unvotable
      • isVoteEnabled

        public boolean isVoteEnabled()
        Returns:
        true if the property "vote.enabled.boolean" is set to true
        Since:
        jcms-8.0.0
      • isPointMode

        public boolean isPointMode()
        Returns:
        true if vote value is > 1
        Since:
        jcms-8.0.1
      • isVoteAnonymized

        public boolean isVoteAnonymized()
        Returns:
        true if the property "vote.anonymize-vote.boolean" is set to true
        Since:
        jcms-8.0.0
      • isDownVoteAnonymized

        public boolean isDownVoteAnonymized()
        Returns:
        true if the property "vote.anonymize-downvote.boolean" is set to true
        Since:
        jcms-8.0.0
      • isSendVoteNotification

        public boolean isSendVoteNotification()
        Returns:
        true if the property "vote.notification.vote-received.boolean" is set to true
        Since:
        jcms-8.0.0
      • canVote

        public boolean canVote​(Publication pub,
                               Member mbr)
        Return true if given Member can Vote on given Publication
        Parameters:
        pub - the Publication
        mbr - the Member
        Returns:
        true if given Member can Vote on given Publication
        Since:
        jcms-8.0.0
      • performVote

        public java.lang.Object[] performVote​(Publication pub,
                                              Member mbr,
                                              boolean positiveVote)
        Parameters:
        pub - the voted Publication
        mbr - the voter Member
        positiveVote - set true if positive vote
        Returns:
        the voted Publication with updated rating(for DBData)
        Since:
        jcms-8.0.0
      • cancelVote

        public Publication cancelVote​(Publication pub,
                                      Member mbr)
        Cancel the vote bound on a Publication and a Member
        Parameters:
        pub - the publication
        mbr - the Member
        Returns:
        the publication
        Since:
        jcms-8.0.0
      • getVote

        public Vote getVote​(Publication pub,
                            Member mbr)
        Return a Vote bound on given Publication and given Member
        Parameters:
        pub - the Publication
        mbr - the Member
        Returns:
        a Vote bound on given Publication and given Member
        Since:
        jcms-8.0.0
      • createVote

        public Vote createVote​(Publication pub,
                               Member mbr,
                               java.util.Map context,
                               int rating)
        Creates a vote and returns it
        Parameters:
        pub - the Publication
        mbr - the Member
        context - the context Map
        rating - of the vote (pts)
        Returns:
        a Vote after creating it
        Since:
        jcms-8.0.0
      • hasVoted

        public boolean hasVoted​(Publication pub,
                                Member mbr)
        Returns true if given Member has already voted for given Publication
        Parameters:
        pub - the Publication
        mbr - the Member
        Returns:
        true if given Member has already voted for given Publication
        Since:
        jcms-8.0.0
      • getVoteCountFromVoteTable

        public int[] getVoteCountFromVoteTable​(Publication pub)
        Parameters:
        pub - the Publication
        Returns:
        the positive vote count and negative vote count for given Publication
      • getVoteCount

        public int getVoteCount​(Publication pub)
        Returns the count of vote on the given publication
        Parameters:
        pub - the publication
        Returns:
        the count of vote on the given publication
        Since:
        jcms-8.0.0
      • getVoteScore

        public int getVoteScore​(Publication pub)
        Return the voteScore of given Publication and update the voteCountMap if not in map
        Parameters:
        pub - the Publication
        Returns:
        the voteScore of given Publication and update the voteCountMap if not in map
        Since:
        jcms-8.0.0
      • getVoteScoreFromDatabase

        public int getVoteScoreFromDatabase​(java.lang.String pubId)
      • hasVote

        public boolean hasVote​(Publication pub)
        Returns true if the given publication has been voted.
        Parameters:
        pub - the publication
        Returns:
        true if the given publication has been voted.
        Since:
        jcms-8.0.0
      • invalidateVoteCountMap

        public void invalidateVoteCountMap​(java.lang.String pubId)
        Invalidate the count of comment on the given publication.
        Parameters:
        pubId - the id of the publication
        Since:
        jcms-8.0.0
      • updateVoteMap

        public void updateVoteMap​(java.lang.String pubId)
        Recompute the count of vote on the given publication.
        Parameters:
        pubId - the id of the publication
        Since:
        jcms-8.0.0
      • getVoteCountFromDatabase

        public int getVoteCountFromDatabase​(java.lang.String pubId)
      • updateVoteMapValue

        public void updateVoteMapValue​(java.lang.String pubId,
                                       VoteManager.CacheEntry cacheEntry)
        Update values for a given Publication id in the cache vote map
        Parameters:
        pubId - the Publication id
        cacheEntry - the VoteManager.CacheEntry to update
        Since:
        jcms-8.0.0
      • recomputePublicationVote

        public void recomputePublicationVote​(Publication pub)
        Recompute the Publication voteCount and voteScore by querying all its votes
        Parameters:
        pub - the Publication
        Since:
        jcms-8.0.0
      • getDefaultVoteTemplateJsp

        public java.lang.String getDefaultVoteTemplateJsp()
        Returns:
        the default jsp template to display the vote link in front office
        Since:
        jcms-8.0.0
      • getDefaultVoteListTemplateJsp

        public java.lang.String getDefaultVoteListTemplateJsp()
        Returns:
        the default jsp template to display the vote link in front office
        Since:
        jcms-8.0.0
      • notifyAuthor

        public void notifyAuthor​(Vote vote)
        Notifies the Publication's author that he has received a new vote
        Parameters:
        vote - the Vote
        Since:
        jcms-8.0.0
      • getVoteIcon

        public java.lang.String getVoteIcon​(int iconType)
        Parameters:
        iconType - the type of the icon
        Returns:
        the like icon based on needed state to display in the jsp
        Since:
        jcms-8.0.0
      • getDefaultPositiveVoteIcon

        public java.lang.String getDefaultPositiveVoteIcon()
        Returns:
        the default icon for like
        Since:
        jcms-8.0.0
      • getDefaultPositiveVoteHighlightIcon

        public java.lang.String getDefaultPositiveVoteHighlightIcon()
        Returns:
        the default icon for dislike
        Since:
        jcms-8.0.0
      • getDefaultNegativeVoteIcon

        public java.lang.String getDefaultNegativeVoteIcon()
        Returns:
        the default icon for like
        Since:
        jcms-8.0.0
      • getDefaultNegativeVoteHighlightIcon

        public java.lang.String getDefaultNegativeVoteHighlightIcon()
        Returns:
        the default icon for dislike
        Since:
        jcms-8.0.0
      • getJcmsId

        public java.lang.String getJcmsId​(java.lang.String sentence)
        Returns the jcmsId from a given sentence for the ttCard "ttLike"
        Parameters:
        sentence - the String returned in context by the ttCard mechanism
        Returns:
        the jcmsId from a given sentence for the ttCard "ttLike"
        Since:
        jcms-8.0.0
      • updatePubVoteWorkspace

        public void updatePubVoteWorkspace​(Publication pub)
        Update vote's Workspace if the Workspace of the Publication differs from the Workspace of votes
        Parameters:
        pub - the Publication
        Since:
        jcms-9.0.1
      • onPostDelete

        public void onPostDelete​(DBData data,
                                 org.hibernate.event.PostDeleteEvent event,
                                 boolean firstTime)
        Description copied from interface: DBListener
        This method is called after a DBData has been deleted.
        Specified by:
        onPostDelete in interface DBListener
        Overrides:
        onPostDelete in class BasicDBListener
        Parameters:
        data - the deleted DBData. WARNING! In a JSync Cluster, when firstTime is false, this data will be null. In this case, to get information about this deleted data, you must use the event and in particular event.getId(), which returns the JPlatform ID of the data, and event.getDeletedState() which returns the attributes of the data.
        event - the event
        firstTime - true on the JSync replica on which the operation took place and false on the other replicas.
        See Also:
        DBListener.onPostDelete(DBData, PostDeleteEvent, boolean)