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 Summary
Nested Classes -
Field Summary
Fields inherited from interface com.jalios.jcms.db.DBConstants
ALL_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_FIELDFields 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
Modifier and TypeMethodDescriptioncancelVote(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 PublicationcreateVote(Publication pub, Member mbr, Map context, int rating) Creates a vote and returns itdeleteAllVote(Member mbr) Delete all votes of aMemberdeleteAllVote(Publication pub, Member mbr) Delete all votes of aPublicationstatic VoteManagerReturns the jcmsId from a given sentence for the ttCard "ttLike"Return the positive vote List for given PublicationReturn the positive vote List for given PublicationReturns the Set of all Members who have voted on given PublicationgetPublicationVoteMemberSet(Publication pub, boolean positive) Return the Set<Member> who have voted on given Publication, depending on vote anonymization choicesgetVote(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(String pubId) int[]getVoteIcon(int iconType) getVoteList(Publication pub) Return the vote List for given PublicationgetVoteList(Publication pub, 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(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(String pubId) Invalidate the count of comment on the given publication.booleanbooleanbooleanbooleanisUnvotableType(Class clazz) Returns true if the given class is unvotablebooleanisVotable(Publication pub) booleanbooleanvoidnotifyAuthor(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.Object[]performVote(Publication pub, Member mbr, boolean positiveVote) voidpropertiesChange(JProperties properties) Invoked after properties have been modified in JCMS and save on disk.voidRecompute the Publication voteCount and voteScore by querying all its votesvoidUpdate vote's Workspace if the Workspace of the Publication differs from the Workspace of votesvoidupdateVoteMap(String pubId) Recompute the count of vote on the given publication.voidupdateVoteMapValue(String pubId, VoteManager.CacheEntry cacheEntry) Update values for a given Publication id in the cache vote mapMethods inherited from class com.jalios.jcms.db.BasicDBListener
getAdateFromState, getAuthorIdFromState, getCdateFromState, getDateFromState, getEdateFromState, getMdateFromState, getPdateFromState, getPrePstatus, getPrePstatus, getPstatusFromState, hasNoChange, hasNoChange, init, onPreUpdate
-
Method Details
-
getInstance
-
propertiesChange
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 interfaceJPropertiesListener- Parameters:
properties- the properties which have been submitted to change
-
getPositiveVoteList
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
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
Return the vote List for given Publication- Parameters:
pub- the Publication- Returns:
- the vote List for given Publication
- Since:
- jcms-8.0.0
-
getVoteList
Return the vote List for given Publication with given order- Parameters:
pub- the PublicationorderBy- the order of the query- Returns:
- the vote List for given Publication
- Since:
- jcms-9.0.2
-
getPublicationVoteAllMemberSet
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
Return the Set<Member> who have voted on given Publication, depending on vote anonymization choices- Parameters:
pub- the Publicationpositive- , 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
- Parameters:
pub- the Publication- Returns:
- true if given Publication can be voted
- Since:
- jcms-8.0.0
-
isUnvotableType
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
Return true if given Member can Vote on given Publication- Parameters:
pub- the Publicationmbr- the Member- Returns:
- true if given Member can Vote on given Publication
- Since:
- jcms-8.0.0
-
performVote
- Parameters:
pub- the votedPublicationmbr- the voterMemberpositiveVote- set true if positive vote- Returns:
- the voted Publication with updated rating(for DBData)
- Since:
- jcms-8.0.0
-
deleteAllVote
Delete all votes of aMember- Parameters:
mbr- theMember- Returns:
- a
ControllerStatus
-
deleteAllVote
Delete all votes of aPublication- Parameters:
pub- thePublicationmbr-Memberdeleting thePublication- Returns:
- a
ControllerStatus
-
cancelVote
Cancel the vote bound on a Publication and a Member- Parameters:
pub- the publicationmbr- the Member- Returns:
- the publication
- Since:
- jcms-8.0.0
-
getVote
Return a Vote bound on given Publication and given Member- Parameters:
pub- the Publicationmbr- the Member- Returns:
- a Vote bound on given Publication and given Member
- Since:
- jcms-8.0.0
-
createVote
Creates a vote and returns it- Parameters:
pub- the Publicationmbr- the Membercontext- the context Maprating- of the vote (pts)- Returns:
- a Vote after creating it
- Since:
- jcms-8.0.0
-
hasVoted
Returns true if given Member has already voted for given Publication- Parameters:
pub- the Publicationmbr- the Member- Returns:
- true if given Member has already voted for given Publication
- Since:
- jcms-8.0.0
-
getVoteCountFromVoteTable
- Parameters:
pub- the Publication- Returns:
- the positive vote count and negative vote count for given Publication
-
getVoteCount
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
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
-
hasVote
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
Invalidate the count of comment on the given publication.- Parameters:
pubId- the id of the publication- Since:
- jcms-8.0.0
-
updateVoteMap
Recompute the count of vote on the given publication.- Parameters:
pubId- the id of the publication- Since:
- jcms-8.0.0
-
getVoteCountFromDatabase
-
updateVoteMapValue
Update values for a given Publication id in the cache vote map- Parameters:
pubId- the Publication idcacheEntry- theVoteManager.CacheEntryto update- Since:
- jcms-8.0.0
-
recomputePublicationVote
Recompute the Publication voteCount and voteScore by querying all its votes- Parameters:
pub- the Publication- Since:
- jcms-8.0.0
-
getDefaultVoteTemplateJsp
- Returns:
- the default jsp template to display the vote link in front office
- Since:
- jcms-8.0.0
-
getDefaultVoteListTemplateJsp
- Returns:
- the default jsp template to display the vote link in front office
- Since:
- jcms-8.0.0
-
notifyAuthor
Notifies the Publication's author that he has received a new vote- Parameters:
vote- theVote- Since:
- jcms-8.0.0
-
getVoteIcon
- 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
- Returns:
- the default icon for like
- Since:
- jcms-8.0.0
-
getDefaultPositiveVoteHighlightIcon
- Returns:
- the default icon for dislike
- Since:
- jcms-8.0.0
-
getDefaultNegativeVoteIcon
- Returns:
- the default icon for like
- Since:
- jcms-8.0.0
-
getDefaultNegativeVoteHighlightIcon
- Returns:
- the default icon for dislike
- Since:
- jcms-8.0.0
-
getJcmsId
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
Update vote's Workspace if the Workspace of the Publication differs from the Workspace of votes- Parameters:
pub- thePublication- Since:
- jcms-9.0.1
-
onPostInsert
Description copied from interface:DBListenerThis method is called after a DBData has been created.- Specified by:
onPostInsertin interfaceDBListener- Overrides:
onPostInsertin classBasicDBListener- 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:
-
onPostUpdate
Description copied from interface:DBListenerThis method is called after a DBData has been updated.- Specified by:
onPostUpdatein interfaceDBListener- Overrides:
onPostUpdatein classBasicDBListener- 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:
-
onPostDelete
Description copied from interface:DBListenerThis method is called after a DBData has been deleted.- Specified by:
onPostDeletein interfaceDBListener- Overrides:
onPostDeletein classBasicDBListener- 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 eventfirstTime- true on the JSync replica on which the operation took place and false on the other replicas.- See Also:
-