Social Equity is a cool new feature in Liferay 6 or above version. Refer to Zsolt's blogs post Social Equity in Liferay.
Social Equity can be used to measure the contribution and participation of a user and the information value of an asset. The activities that award equities include, but not limited: adding contributions, rating, commenting, viewing content, searching and tagging.
Currently there are three portlets (Wiki, Blogs and Message Boards) that use the social equity service. The activities and their default values are configured in the /resource-actions/wiki.xml, blogs.xml, messageboards.xml.
Logically the Social Equity framework is assets agnostic. It operates on assets directly and uses action keys defined in resource-actions xml. Thus service calls need to be added to the respective services like Journal, Knowledge Base, etc.
As shown in following screenshot, Currently there are three portlets (Wiki, Blogs and Message Boards) that use the social equity service. The activities and their default values are configured in the /resource-actions/wiki.xml, blogs.xml, messageboards.xml.
For Wiki, configured activities are ADD_PAGE, VIEW, and ADD_DISCUSSION; for Blogs configured activities are ADD_ENTRY, VIEW, and ADD_DISCUSSION; and for Message Boards, configured activities are ADD_MESSAGE, ADD_VOTE, REPLY_MESSAGE, and VIEW. How do you add social equity services on custom assets like Knowledge base articles in plugins?
How to make it?
Abstracted from the book: Liferay User Interface Developement.
Supposed that configured activity is VIEW in Knowledge Base plugin, how do you make it? Loosely speaking, adding social equity capabilities in plugins should be simple in following steps.
First, you can configure the activities and their default values in the resource actions xml, that is, $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/src/resource-actions/default.xml. You can simply add following lines before the line </model-resource> of the model com.liferay.knowledgebase.model.Article.
<social-equity>
<social-equity-mapping>
<action-key>VIEW</action-key>
<information-value>1</information-value>
<information-lifespan>365</information-lifespan>
<participation-value>1</participation-value>
<participation-lifespan>365</participation-lifespan>
</social-equity-mapping>
</social-equity>
Then you should add social equity as references in $PLUGIN_SDK_HOME/knowledge-base-portlet/docroot/WEB-INF/service.xml as follows.
<reference package-path="com.liferay.portlet.social" entity="SocialEquityLog" />
It is time for you to re-build services by using ANT target build-service. That’s it. From now on, you would be able to see that Knowledge base Article is available under Control Panel | Social Equity | Settings, as shown in above screenshot.
What’s happening?
In fact, the portal has specified following social equity related properties by default in portal.properties. Of course, you would be able to override these properties in portal-ext.properties.
social.equity.equity.log.check.interval=1440
social.equity.equity.log.enabled=true
As shown in above code, social equity feature is enabled by default and can be turned off by setting the social.equity.equity.log.enabled property to false. The property social.equity.equity.log.check.interval sets the interval like 1140 minutes on which the CheckEquityLogMessageListener will run. The value is set in one minute increments.
Where do you find sample code?
You can download sample code from
knowledge-base-portlet-6.0.6.1.war
and deploy it.
Note that the WAR was generated based on the portal 6.0.10 (revision 63177 ).
Summary
As you can see, you would be able to add Social Equity services on any custom assets generated by Service-Builder in plugins. The asset Knowledge Base articles is one of them (custom assets).Try it now, you would be able to make Knowledge Base and / or your own portlet as one of Social Equity contributing portlets.
Last but not least, I'd like to send a ton of thanks to Zsolt Berentey, Brian Chan, Samuel Kong, and John Wayne Jiang, who did a great job to make Social Equity a reality in Liferay portal 6.

