Fórum

Question about SocialActivities

Klaus Bachmaier, modificado 7 Anos atrás.

Question about SocialActivities

Regular Member Postagens: 223 Data de Entrada: 30/09/13 Postagens Recentes
I need to write a portlet which returns all Social Activities from all Sites where a user is a member of. I use the code from the "members activities" portlet from the social networking plugin as a starting point.

My websites are in parent/child relationship, and when I use the original "members activities" portlet in a subsite it shows me the activities from there plus the activities from the parent site. Placed on a page in the parent site it shows only the activities from there, but not from any child sites.

The original code to retrieve the social activities from a site is:


List<socialactivity> activities = null;
activities = SocialActivityLocalServiceUtil.getGroupUsersActivities(group.getGroupId(), 0, max);
</socialactivity>


As said above this function not only retrieves the activities from the site whose groupId I provide as a parameter, but also the activities from the parent site if it's called from a child website. Initially I wanted to iterate on all groups where the user is a member of and sum up all results of SocialActivityLocalServiceUtil.getGroupUsersActivities() into a single List. But because getGroupUsersActivities() always also gets me the activities from the parent sites, these activities would be multiple times in my result. Sorting out already "known" activities from the array list is not possible as obviously the SocialActivity class has no hashCode() or equals() function.

Is there an easy way to retrieve a list of social activities from all sites where the current user is a member of?
Klaus Bachmaier, modificado 7 Anos atrás.

RE: Question about SocialActivities (Resposta)

Regular Member Postagens: 223 Data de Entrada: 30/09/13 Postagens Recentes
Sorry, had to look at the code of SocialActivityLocalServiceUtil to find out that getUserGroupsAndOrganizationsActivities(long userId, int start, int end) will do the job.

Solved!