Package com.jalios.jcms.vote
Class VoteManager
- java.lang.Object
- 
- com.jalios.jcms.db.BasicDBListener
- 
- 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
- Author:
- bransard
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classVoteManager.CacheEntry
 - 
Field Summary- 
Fields inherited from interface com.jalios.jcms.db.DBConstantsALL_CATEGORIES_SET_FIELD, ATTACH_WS_SET_FIELD, AUTH_GRP_SET_FIELD, AUTH_MBR_SET_FIELD, AUTHOR_ID_FIELD, CATEGORIES_SET_FIELD, CDATE_FIELD, CHANNEL_JCMSDB_PROP, CLASSIFICATION_LEVEL_FIELD, DBDATA_URID, EXTENDED_READ_RIGHTS, HAS_ATTACH_WS_FIELD, HAS_NO_READ_RIGHTS, HIBERNATE_MAPPING_ADATE, HIBERNATE_MAPPING_AUTHOR, HIBERNATE_MAPPING_CDATE, HIBERNATE_MAPPING_EDATE, HIBERNATE_MAPPING_HAS_ATTACH_WS, HIBERNATE_MAPPING_HASNOREADRIGHTS, HIBERNATE_MAPPING_MAININSTANCE_ID, HIBERNATE_MAPPING_MAJORVERSION, HIBERNATE_MAPPING_MDATE, HIBERNATE_MAPPING_MERGE_DATE, HIBERNATE_MAPPING_MERGE_ID, HIBERNATE_MAPPING_MINORVERSION, HIBERNATE_MAPPING_OPAUTHOR, HIBERNATE_MAPPING_PDATE, HIBERNATE_MAPPING_PSTATUS, HIBERNATE_MAPPING_READ_ACK, HIBERNATE_MAPPING_READERCOUNT, HIBERNATE_MAPPING_RESTRICTIVE_UPDATE_RIGHTS, HIBERNATE_MAPPING_TITLE, HIBERNATE_MAPPING_TRACKED, HIBERNATE_MAPPING_UDATE, HIBERNATE_MAPPING_VOTECOUNT, HIBERNATE_MAPPING_VOTESCORE, HIBERNATE_MAPPING_WORKFLOW_ID, HIBERNATE_MAPPING_WORKSPACE_ID, MAX_HIBERNATE_MAPPING_PUBLICATION, MDATE_FIELD, OPAUTHOR_ID_FIELD, PSTATUS_FIELD, ROW_ID_FIELD, SCROLL_FETCH_SIZE, WORKFLOW_ID_FIELD, WORKSPACE_ID_FIELD
 - 
Fields inherited from interface com.jalios.jcms.vote.VoteConstantsALERT_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 SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PublicationcancelVote(Publication pub, Member mbr)Cancel the vote bound on a Publication and a MemberbooleancanVote(Publication pub, Member mbr)Return true if given Member can Vote on given PublicationVotecreateVote(Publication pub, Member mbr, java.util.Map context, int rating)Creates a vote and returns itControllerStatusdeleteAllVote(Member mbr)Delete all votes of aMemberControllerStatusdeleteAllVote(Publication pub, Member mbr)Delete all votes of aPublicationjava.lang.StringgetDefaultNegativeVoteHighlightIcon()java.lang.StringgetDefaultNegativeVoteIcon()java.lang.StringgetDefaultPositiveVoteHighlightIcon()java.lang.StringgetDefaultPositiveVoteIcon()java.lang.StringgetDefaultVoteListTemplateJsp()java.lang.StringgetDefaultVoteTemplateJsp()static VoteManagergetInstance()java.lang.StringgetJcmsId(java.lang.String sentence)Returns the jcmsId from a given sentence for the ttCard "ttLike"java.util.List<Vote>getNegativeVoteList(Publication pub)Return the positive vote List for given Publicationjava.util.List<Vote>getPositiveVoteList(Publication pub)Return the positive vote List for given Publicationjava.util.Set<Member>getPublicationVoteAllMemberSet(Publication pub)Returns the Set of all Members who have voted on given Publicationjava.util.Set<Member>getPublicationVoteMemberSet(Publication pub, boolean positive)Return the Set<Member> who have voted on given Publication, depending on vote anonymization choicesVotegetVote(Publication pub, Member mbr)Return a Vote bound on given Publication and given MemberintgetVoteCount(Publication pub)Returns the count of vote on the given publicationintgetVoteCountFromDatabase(java.lang.String pubId)int[]getVoteCountFromVoteTable(Publication pub)java.lang.StringgetVoteIcon(int iconType)java.util.List<Vote>getVoteList(Publication pub)Return the vote List for given Publicationjava.util.List<Vote>getVoteList(Publication pub, java.lang.String orderBy)Return the vote List for given Publication with given orderintgetVoteScore(Publication pub)Return the voteScore of given Publication and update the voteCountMap if not in mapintgetVoteScoreFromDatabase(java.lang.String pubId)booleanhasVote(Publication pub)Returns true if the given publication has been voted.booleanhasVoted(Publication pub, Member mbr)Returns true if given Member has already voted for given PublicationvoidinvalidateVoteCountMap(java.lang.String pubId)Invalidate the count of comment on the given publication.booleanisDownVoteAnonymized()booleanisPointMode()booleanisSendVoteNotification()booleanisUnvotableType(java.lang.Class clazz)Returns true if the given class is unvotablebooleanisVotable(Publication pub)booleanisVoteAnonymized()booleanisVoteEnabled()voidnotifyAuthor(Vote vote)Notifies the Publication's author that he has received a new votevoidonPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime)This method is called after a DBData has been deleted.voidonPostInsert(DBData data, org.hibernate.event.PostInsertEvent event, boolean firstTime)This method is called after a DBData has been created.voidonPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime)This method is called after a DBData has been updated.java.lang.Object[]performVote(Publication pub, Member mbr, boolean positiveVote)voidpropertiesChange(JProperties properties)Invoked after properties have been modified in JCMS and save on disk.voidrecomputePublicationVote(Publication pub)Recompute the Publication voteCount and voteScore by querying all its votesvoidupdatePubVoteWorkspace(Publication pub)Update vote's Workspace if the Workspace of the Publication differs from the Workspace of votesvoidupdateVoteMap(java.lang.String pubId)Recompute the count of vote on the given publication.voidupdateVoteMapValue(java.lang.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.BasicDBListenergetAdateFromState, getAuthorIdFromState, getCdateFromState, getDateFromState, getEdateFromState, getMdateFromState, getPdateFromState, getPrePstatus, getPrePstatus, getPstatusFromState, hasNoChange, hasNoChange, init, onPreUpdate
 
- 
 
- 
- 
- 
Method Detail- 
getInstancepublic static VoteManager getInstance() 
 - 
propertiesChangepublic void propertiesChange(JProperties properties) Description copied from interface:JPropertiesListenerInvoked 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.getPropertiesorchannel.getProperty.- Specified by:
- propertiesChangein interface- JPropertiesListener
- Parameters:
- properties- the properties which have been submitted to change
 
 - 
getPositiveVoteListpublic 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
 
 - 
getNegativeVoteListpublic 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
 
 - 
getVoteListpublic 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
 
 - 
getVoteListpublic 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
 
 - 
getPublicationVoteAllMemberSetpublic 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
 
 - 
getPublicationVoteMemberSetpublic 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
 
 - 
isVotablepublic boolean isVotable(Publication pub) - Parameters:
- pub- the Publication
- Returns:
- true if given Publication can be voted
- Since:
- jcms-8.0.0
 
 - 
isUnvotableTypepublic 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
 
 - 
isVoteEnabledpublic boolean isVoteEnabled() - Returns:
- true if the property "vote.enabled.boolean" is set to true
- Since:
- jcms-8.0.0
 
 - 
isPointModepublic boolean isPointMode() - Returns:
- true if vote value is > 1
- Since:
- jcms-8.0.1
 
 - 
isVoteAnonymizedpublic boolean isVoteAnonymized() - Returns:
- true if the property "vote.anonymize-vote.boolean" is set to true
- Since:
- jcms-8.0.0
 
 - 
isDownVoteAnonymizedpublic boolean isDownVoteAnonymized() - Returns:
- true if the property "vote.anonymize-downvote.boolean" is set to true
- Since:
- jcms-8.0.0
 
 - 
isSendVoteNotificationpublic boolean isSendVoteNotification() - Returns:
- true if the property "vote.notification.vote-received.boolean" is set to true
- Since:
- jcms-8.0.0
 
 - 
canVotepublic 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
 
 - 
performVotepublic 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
 
 - 
deleteAllVotepublic ControllerStatus deleteAllVote(Member mbr) Delete all votes of aMember- Parameters:
- mbr- the- Member
- Returns:
- a ControllerStatus
 
 - 
deleteAllVotepublic ControllerStatus deleteAllVote(Publication pub, Member mbr) Delete all votes of aPublication- Parameters:
- pub- the- Publication
- mbr-- Memberdeleting the- Publication
- Returns:
- a ControllerStatus
 
 - 
cancelVotepublic 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
 
 - 
getVotepublic 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
 
 - 
createVotepublic 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
 
 - 
hasVotedpublic 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
 
 - 
getVoteCountFromVoteTablepublic int[] getVoteCountFromVoteTable(Publication pub) - Parameters:
- pub- the Publication
- Returns:
- the positive vote count and negative vote count for given Publication
 
 - 
getVoteCountpublic 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
 
 - 
getVoteScorepublic 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
 
 - 
getVoteScoreFromDatabasepublic int getVoteScoreFromDatabase(java.lang.String pubId) 
 - 
hasVotepublic 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
 
 - 
invalidateVoteCountMappublic 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
 
 - 
updateVoteMappublic 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
 
 - 
getVoteCountFromDatabasepublic int getVoteCountFromDatabase(java.lang.String pubId) 
 - 
updateVoteMapValuepublic 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.CacheEntryto update
- Since:
- jcms-8.0.0
 
 - 
recomputePublicationVotepublic void recomputePublicationVote(Publication pub) Recompute the Publication voteCount and voteScore by querying all its votes- Parameters:
- pub- the Publication
- Since:
- jcms-8.0.0
 
 - 
getDefaultVoteTemplateJsppublic java.lang.String getDefaultVoteTemplateJsp() - Returns:
- the default jsp template to display the vote link in front office
- Since:
- jcms-8.0.0
 
 - 
getDefaultVoteListTemplateJsppublic java.lang.String getDefaultVoteListTemplateJsp() - Returns:
- the default jsp template to display the vote link in front office
- Since:
- jcms-8.0.0
 
 - 
notifyAuthorpublic 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
 
 - 
getVoteIconpublic 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
 
 - 
getDefaultPositiveVoteIconpublic java.lang.String getDefaultPositiveVoteIcon() - Returns:
- the default icon for like
- Since:
- jcms-8.0.0
 
 - 
getDefaultPositiveVoteHighlightIconpublic java.lang.String getDefaultPositiveVoteHighlightIcon() - Returns:
- the default icon for dislike
- Since:
- jcms-8.0.0
 
 - 
getDefaultNegativeVoteIconpublic java.lang.String getDefaultNegativeVoteIcon() - Returns:
- the default icon for like
- Since:
- jcms-8.0.0
 
 - 
getDefaultNegativeVoteHighlightIconpublic java.lang.String getDefaultNegativeVoteHighlightIcon() - Returns:
- the default icon for dislike
- Since:
- jcms-8.0.0
 
 - 
getJcmsIdpublic 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
 
 - 
updatePubVoteWorkspacepublic 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
 
 - 
onPostInsertpublic void onPostInsert(DBData data, org.hibernate.event.PostInsertEvent event, boolean firstTime) Description copied from interface:DBListenerThis method is called after a DBData has been created.- Specified by:
- onPostInsertin interface- DBListener
- Overrides:
- onPostInsertin class- BasicDBListener
- Parameters:
- data- 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.onPostInsert(DBData, PostInsertEvent, boolean)
 
 - 
onPostUpdatepublic void onPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime) Description copied from interface:DBListenerThis method is called after a DBData has been updated.- Specified by:
- onPostUpdatein interface- DBListener
- Overrides:
- onPostUpdatein class- BasicDBListener
- Parameters:
- data- 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.onPostUpdate(DBData, PostUpdateEvent, boolean)
 
 - 
onPostDeletepublic void onPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime) Description copied from interface:DBListenerThis method is called after a DBData has been deleted.- Specified by:
- onPostDeletein interface- DBListener
- Overrides:
- onPostDeletein 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)
 
 
- 
 
-