Using Liferay's Social Equity System

(Redirezionato da Using the social equity system)

This document is not valid for Liferay 6.1. Please refer to this post. #

Defining the actions #

To define certain actions that will award points to an asset's information equity or a user's participation equity, a new section must be added to the xml descriptor where the resource actions are defined. This is usually called default.xml and resides in WEB-INF/resource-actions.

The new section should be inside a model-resource tag, which also means that the classname for assets affected by these actions would be the model name configured here.

The section should look like this:

<social-equity>
	<social-equity-mapping>
		<action-key>ADD_MESSAGE</action-key>
		<participation-value>20</participation-value>
		<participation-lifespan>30</participation-lifespan>
	</social-equity-mapping>
	<social-equity-mapping>
		<action-key>ADD_VOTE</action-key>
		<information-value>10</information-value>
		<information-lifespan>365</information-lifespan>
		<information-daily-limit>5</information-daily-limit>
	</social-equity-mapping>
</social-equity>

In a social-equity-mapping tag both information and participation type values can be placed, but they would be evaluated as a separate setting.

The value is the amount of points that will be awarded to the appropriate equity, while lifespan is the number of days over which the rewarded points degrade to zero. Points for an action can be awarded to an asset or a user maximum "daily limit" times a day.

Methods to call #

To use the social equity service, portlets can call the following methods in SocialEquityLogLocalService:

  • addEquityLogs
  • deactivateEquityLogs

Calling the addEquityLogs method #

This method should be called when the user executes an action that is configured as a social equity action. The main signature of the method is

public void addEquityLogs(long userId, long assetEntryId, String actionId)

where userId is the acting user's id, assetEntryId is the asset's id the action targets and actionId is the string defined in the resource xml.

There is a convenience method that accepts a classname and a classPK instead of the asset's id:

public void addEquityLogs(long userId, String className, long classPK, String actionId)

Calling the deactivateEquityLogs method #

In case the points for an action should be revoked, the portlet should call one of the deactivateEquityLogs methods. The main signature is the same as for the addEquityLogs:

public void deactivateEquityLogs(long userId, long assetEntryId, String actionId)

and there is a convenience method that accepts className and classPK as well.

There is a third deactivateEquityLogs method that accepts only one parameter. This method is automatically called by the AssetEntryLocalService when an asset is deleted.

Built in actions #

There are a couple of actions are already wired to the social equity service that external portlets might want to use. AssetEntryLocalService calls the social equity service with the VIEW action whenever an asset is displayed. It also calls the service to clean up information equity values when an asset is deleted.

MessageEntryLocalService is also wired by the ADD_DISCUSSION action that is passed to the social equity service when a user adds a comment (discussion) to an asset.

RatingEntryLocalService class the social equity service with the ADD_VOTE action when a user votes on an asset.

To use these action, simply configure them in you portlet's resource actions xml under the appropriate model.

0 Allegati
6795 Visualizzazioni
Media (2 Voti)
La media del punteggio è 3.0 stelle su 5.
Commenti
Commenti Autore Data
I am testing this feature of liferay and wanted... Puj Z 21 novembre 2010 5.29
Hi everyone, I solved my problem. Here the... Puj Z 21 novembre 2010 9.55
i want to develop one social equity small... murali krishna 19 settembre 2011 22.15
i want to develop one social equity small... murali krishna 19 settembre 2011 22.15

I am testing this feature of liferay and wanted to add social equity to a custom portlet of us (this is used for sending invitations). I want a user to get some equity whenever he/she sends an invitation.

I added the default.xml with the above mentioned entry to add SEND_INVITATION to the social-equity system, however it is not appearing in the list of social equity admin page.

The only difference I see is that in this wiki the location of resource-actions folder is in WEB-INF, although it should be in WEB-INF/src (according to action-permissions-handling documentation)

Is this because the method addEquityLogs(long userId, long assetEntryId, String actionId)
has not yet been called? (I cannot call it as someone else is working on the entity-management stuff)
This means, should this addEquityLogs method be called once so that the actions appear in the social equity list? (which I doubt)
Or have I forgotten anything?

Here my default.xml in located in WEB-INF/resource-actions of our portlet:

I am testing this feature of liferay and wanted to add social equity to a custom portlet of us.
I added the default.xml with the above montioned entry for social-equity, however it is not appearing in the list of social equity admin page.
Is this because the method addEquityLogs(long userId, long assetEntryId, String actionId)
has not yet been called? (I cannot call it as someone else is working on the entity-mangement stuff)
Or have I fortgotton anything?

Here my default.xml,located in WEB-INF/src/resource-actions of our portlet (my-invitation-portlet):

<?xml version="1.0"?>

<resource-action-mapping>
<portlet-resource>
<portlet-name>my-i­nvitation-portlet</portlet-name>
<permissions>
<supports>
<actio­n-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</s­upports>
<community-defaults />
<guest-defaults />
<guest-unsupported>
<action-key>CONFIGURATION</action-key>
­ <action-key>VIEW</action-key>
</guest-unsupported>
</permissions>
</po­rtlet-resource>
<model-resource>
<model-name>com.hd.portlet.subscription.model­.Invitation</model-name>
<portlet-ref>
<portlet-name>my-invitation-portle­t</portlet-name>
</portlet-ref>
<permissions>
<supports>
<acti­on-key>SEND_INVITATION</action-key>
<action-key>VIEW_INVITATIONS</actio­n-key>
<action-key>DELETE_INVITATION</action-key>
</supports>
­ <community-defaults>
<action-key>VIEW_INVITATIONS</action-key>
</­community-defaults>
<guest-defaults />
<guest-unsupported>
<action-key>SEND_INVITATION</action-key>
­ <action-key>VIEW_INVITATIONS</action-key>
</guest-unsupported>
</permi­ssions>
<social-equity>
<social-equity-mapping>
<action-key>SEND­_INVITATION</action-key>
<information-value>1</information-value>
­ <information-lifespan>365</information-lifespan>
<participation-value>­2</participation-value>
<participation-lifespan>365</participation-life­span>
</social-equity-mapping>
</social-equity>
</model-resource>
</resour­ce-action-mapping>
Inviato il 21/11/10 5.29.
Hi everyone,

I solved my problem. Here the solution for those who might face the same:

I added portlet.properties under /src with the following content:
include-and-override=portlet-ext.properties
resource.actions.configs=reso­urce-actions/default.xml


The problem is also discussed here:
http://www.liferay.com/community/forums/-/message_boards/message/3673066

Che­ers
Inviato il 21/11/10 9.55 in risposta a Puj Z.
i want to develop one social equity small application how to develop give some idea.. and give code for that..
Inviato il 19/09/11 22.15.
i want to develop one social equity small application how to develop give some idea.. and give code for that..
Inviato il 19/09/11 22.15.