com.jalios.jcms.vote
Class VoteManager

java.lang.Object
  extended by com.jalios.jcms.db.BasicDBListener
      extended by com.jalios.jcms.vote.VoteManager
All Implemented Interfaces:
DBConstants, DBListener, PluginComponent, VoteConstants, JPropertiesListener

public class VoteManager
extends BasicDBListener
implements DBConstants, VoteConstants, JPropertiesListener

This class gives Utils to handle vote

Since:
jcms-8.0.0
Version:
$Revision: 48811 $
Author:
bransard

Nested Class Summary
 class VoteManager.CacheEntry
           
 
Field Summary
static String REVISION
           
 
Fields inherited from interface com.jalios.jcms.db.DBConstants
ALL_CATEGORIES_SET_FIELD, AUTH_GRP_SET_FIELD, AUTH_MBR_SET_FIELD, AUTHOR_ID_FIELD, CATEGORIES_SET_FIELD, CDATE_FIELD, CHANNEL_JCMSDB_PROP, DBDATA_URID, HAS_NO_READ_RIGHTS, HIBERNATE_MAPPING_ADATE, HIBERNATE_MAPPING_AUTHOR, HIBERNATE_MAPPING_CDATE, HIBERNATE_MAPPING_EDATE, HIBERNATE_MAPPING_MDATE, HIBERNATE_MAPPING_PDATE, HIBERNATE_MAPPING_PSTATUS, HIBERNATE_MAPPING_TITLE, HIBERNATE_MAPPING_WORKFLOW_ID, HIBERNATE_MAPPING_WORKSPACE_ID, MDATE_FIELD, PSTATUS_FIELD, ROW_ID_FIELD, SCROLL_FETCH_SIZE, WORKFLOW_ID_FIELD, WORKSPACE_ID_FIELD
 
Fields inherited from interface com.jalios.jcms.vote.VoteConstants
ALERT_DOMAIN, ALERT_NAME_NEGATIVE_VOTE, ALERT_NAME_POSITIVE_VOTE, ANONYMIZE_DOWNVOTE_PROP, ANONYMIZE_VOTE_PROP, CACHE_SIZE_PROP, DEFAULT_VOTE_TEMPLATE_PROP, DEFAULT_VOTELIST_TEMPLATE_PROP, ICON_VOTE_NEGATIVE_HL_PROP, ICON_VOTE_NEGATIVE_PROP, ICON_VOTE_POSITIVE_HL_PROP, ICON_VOTE_POSITIVE_PROP, PUBLICATION_ID_FIELD, RATING_FIELD, SEND_VOTE_NOTIFICATION_PROP, UI_VOTE_NEGATIVE, UI_VOTE_NEGATIVE_HL, UI_VOTE_POSITIVE, UI_VOTE_POSITIVE_HL, UNVOTABLE_TYPES_PROP, VOTE_DEFAULT_VALUE_PROP, VOTE_ENABLED_PROP, VOTE_TAG_USAGE_ACTION, VOTE_TAG_USAGE_VOTELIST
 
Method Summary
 Publication cancelVote(Publication pub, Member mbr)
          Cancel the vote bound on a Publication and a Member
 boolean canVote(Publication pub, Member mbr)
          Return true if given Member can Vote on given Publication
 Vote createVote(Publication pub, Member mbr, Map context, int rating)
          Creates a vote and returns it
 String getDefaultNegativeVoteHighlightIcon()
           
 String getDefaultNegativeVoteIcon()
           
 String getDefaultPositiveVoteHighlightIcon()
           
 String getDefaultPositiveVoteIcon()
           
 String getDefaultVoteListTemplateJsp()
           
 String getDefaultVoteTemplateJsp()
           
static VoteManager getInstance()
           
 String getJcmsId(String sentence)
          Returns the jcmsId from a given sentence for the ttCard "ttLike"
 List<Vote> getPositiveVoteList(Publication pub)
          Return the positive vote List for given Publication
 Set<Member> getPublicationVoteAllMemberSet(Publication pub)
          Returns the Set of all Members who have voted on given Publication
 Set<Member> getPublicationVoteMemberSet(Publication pub, boolean positive)
          Return the Set who have voted on given Publication, depending on vote anonymization choices
 Vote getVote(Publication pub, Member mbr)
          Return a Vote bound on given Publication and given Member
 int getVoteCount(Publication pub)
          Returns the count of vote on the given publication
 int[] getVoteCountFromVoteTable(Publication pub)
           
 String getVoteIcon(int iconType)
           
 List<Vote> getVoteList(Publication pub)
          Return the vote List for given Publication
 int getVoteScore(Publication pub)
          Return the voteScore of given Publication and update the voteCountMap if not in map
 boolean hasVote(Publication pub)
          Returns true if the given publication has been voted.
 boolean hasVoted(Publication pub, Member mbr)
          Returns true if given Member has already voted for given Publication
 void invalidateVoteCountMap(String pubId)
          Invalidate the count of comment on the given publication.
 boolean isDownVoteAnonymized()
           
 boolean isSendVoteNotification()
           
 boolean isUnvotableType(Class clazz)
          Returns true if the given class is unvotable
 boolean isVotable(Publication pub)
           
 boolean isVoteAnonymized()
           
 boolean isVoteEnabled()
           
 void notifyAuthor(Vote vote)
          Notifies the Publication's author that he has received a new vote
 void onPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime)
           
 void onPostInsert(DBData data, org.hibernate.event.PostInsertEvent event, boolean firstTime)
           
 void onPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime)
           
 Object[] performVote(Publication pub, Member mbr, boolean positiveVote)
           
 void propertiesChange(JProperties properties)
          Invoked after properties have been modified in JCMS and save on disk.
 void recomputePublicationVote(Publication pub)
          Recompute the Publication voteCount & voteScore by querying all its votes
 void updateVoteMap(String pubId)
          Recompute the count of comment on the given publication.
 void updateVoteMapValue(String pubId, VoteManager.CacheEntry cacheEntry)
          Update values for a given Publication id in the cache vote map
 
Methods inherited from class com.jalios.jcms.db.BasicDBListener
getAdateFromState, getAuthorIdFromState, getCdateFromState, getEdateFromState, getMdateFromState, getPdateFromState, getPrePstatus, getPrePstatus, getPstatusFromState, hasNoChange, hasNoChange, init, onPreUpdate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values
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.

Specified by:
propertiesChange in interface JPropertiesListener
Parameters:
properties - the properties which have been modified (may not contain all JCMS properties)

getPositiveVoteList

public 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

getVoteList

public 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

getPublicationVoteAllMemberSet

public Set<Member> getPublicationVoteAllMemberSet(Publication pub)
Returns the Set of all Members who have voted on given Publication

Parameters:
pub - the Publication
Returns:
a Set who have voted on given Publication
Since:
jcms-8.0.0

getPublicationVoteMemberSet

public Set<Member> getPublicationVoteMemberSet(Publication pub,
                                               boolean positive)
Return the Set 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 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(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

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 Object[] performVote(Publication pub,
                            Member mbr,
                            boolean positiveVote)
Parameters:
pub - the voted Publication
mbr - the voter Member
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:
mbr - the Member
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,
                       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 & 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

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(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(String pubId)
Recompute the count of comment on the given publication.

Parameters:
pubId - the id of the publication
Since:
jcms-8.0.0

updateVoteMapValue

public void updateVoteMapValue(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 & voteScore by querying all its votes

Parameters:
pub - the Publication
Since:
jcms-8.0.0

getDefaultVoteTemplateJsp

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

getDefaultVoteListTemplateJsp

public 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 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 String getDefaultPositiveVoteIcon()
Returns:
the default icon for like
Since:
jcms-8.0.0

getDefaultPositiveVoteHighlightIcon

public String getDefaultPositiveVoteHighlightIcon()
Returns:
the default icon for dislike
Since:
jcms-8.0.0

getDefaultNegativeVoteIcon

public String getDefaultNegativeVoteIcon()
Returns:
the default icon for like
Since:
jcms-8.0.0

getDefaultNegativeVoteHighlightIcon

public String getDefaultNegativeVoteHighlightIcon()
Returns:
the default icon for dislike
Since:
jcms-8.0.0

getJcmsId

public String getJcmsId(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

onPostInsert

public void onPostInsert(DBData data,
                         org.hibernate.event.PostInsertEvent event,
                         boolean firstTime)
Specified by:
onPostInsert in interface DBListener
Overrides:
onPostInsert in class BasicDBListener
See Also:
DBListener.onPostInsert(DBData, PostInsertEvent, boolean)

onPostUpdate

public void onPostUpdate(DBData data,
                         org.hibernate.event.PostUpdateEvent event,
                         boolean firstTime)
Specified by:
onPostUpdate in interface DBListener
Overrides:
onPostUpdate in class BasicDBListener
See Also:
DBListener.onPostUpdate(DBData, PostUpdateEvent, boolean)

onPostDelete

public void onPostDelete(DBData data,
                         org.hibernate.event.PostDeleteEvent event,
                         boolean firstTime)
Specified by:
onPostDelete in interface DBListener
Overrides:
onPostDelete in class BasicDBListener
See Also:
DBListener.onPostDelete(DBData, PostDeleteEvent, boolean)


Copyright © 2001-2010 Jalios SA. All Rights Reserved.