mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
MOB-594 - user activities feed now returns all activities (including own) - also have optional filters to either exclude own or exclude others
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13764 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -44,7 +44,19 @@
|
||||
<result property="lastModified" column="last_modified"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- user feed - all sites - everyone -->
|
||||
<select id="select.activity.feed.for.feeduser" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, feed_user_id as feedUserId, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
where feed_user_id = #feedUserId#
|
||||
and activity_format = #activitySummaryFormat#
|
||||
order by post_date desc
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<!-- user feed - all sites - others (not me) -->
|
||||
<select id="select.activity.feed.for.feeduser.others" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, feed_user_id as feedUserId, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
@@ -55,7 +67,32 @@
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<!-- user feed - all sites - me only (not others) -->
|
||||
<select id="select.activity.feed.for.feeduser.me" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, feed_user_id as feedUserId, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
where feed_user_id = #feedUserId#
|
||||
and post_user_id = #feedUserId#
|
||||
and activity_format = #activitySummaryFormat#
|
||||
order by post_date desc
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<!-- user feed - given site - everyone -->
|
||||
<select id="select.activity.feed.for.feeduser.and.site" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, feed_user_id as feedUserId, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
where feed_user_id = #feedUserId#
|
||||
and site_network = #siteNetwork#
|
||||
and activity_format = #activitySummaryFormat#
|
||||
order by post_date desc
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<!-- user feed - given site - others (not me) -->
|
||||
<select id="select.activity.feed.for.feeduser.others.and.site" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, feed_user_id as feedUserId, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
@@ -67,6 +104,20 @@
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<!-- user feed - given site - me only (not others) -->
|
||||
<select id="select.activity.feed.for.feeduser.me.and.site" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, feed_user_id as feedUserId, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
from alf_activity_feed
|
||||
where feed_user_id = #feedUserId#
|
||||
and post_user_id = #feedUserId#
|
||||
and site_network = #siteNetwork#
|
||||
and activity_format = #activitySummaryFormat#
|
||||
order by post_date desc
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<!-- site feed - given site -->
|
||||
<select id="select.activity.feed.for.site" parameterClass="ActivityFeed" resultClass="ActivityFeed">
|
||||
<![CDATA[
|
||||
select id as id, activity_type as activityType, activity_format as activitySummaryFormat, activity_summary as activitySummary, post_user_id as postUserId, site_network as siteNetwork, post_date as postDate
|
||||
|
@@ -290,6 +290,14 @@ public class ActivityServiceImpl implements ActivityService
|
||||
* @see org.alfresco.service.cmr.activities.ActivityService#getUserFeedEntries(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public List<String> getUserFeedEntries(String feedUserId, String format, String siteId)
|
||||
{
|
||||
return getUserFeedEntries(feedUserId, format, siteId, false, false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.activities.ActivityService#getUserFeedEntries(java.lang.String, java.lang.String, java.lang.String, boolean, boolean)
|
||||
*/
|
||||
public List<String> getUserFeedEntries(String feedUserId, String format, String siteId, boolean excludeThisUser, boolean excludeOtherUsers)
|
||||
{
|
||||
// NOTE: siteId is optional
|
||||
ParameterCheck.mandatoryString("feedUserId", feedUserId);
|
||||
@@ -308,14 +316,10 @@ public class ActivityServiceImpl implements ActivityService
|
||||
if (siteId != null)
|
||||
{
|
||||
siteId = tenantService.getName(siteId);
|
||||
|
||||
activityFeeds = feedDaoService.selectUserFeedEntries(feedUserId, format, siteId);
|
||||
}
|
||||
else
|
||||
{
|
||||
activityFeeds = feedDaoService.selectUserFeedEntries(feedUserId, format);
|
||||
}
|
||||
|
||||
activityFeeds = feedDaoService.selectUserFeedEntries(feedUserId, format, siteId, excludeThisUser, excludeOtherUsers);
|
||||
|
||||
int count = 0;
|
||||
for (ActivityFeedDAO activityFeed : activityFeeds)
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -124,6 +124,26 @@ public class ActivityServiceImplTest extends BaseSpringTest
|
||||
|
||||
assertNotNull(userFeedEntries);
|
||||
assertTrue(userFeedEntries.isEmpty());
|
||||
|
||||
userFeedEntries = this.activityService.getUserFeedEntries("unknown user", "some format", "some site");
|
||||
|
||||
assertNotNull(userFeedEntries);
|
||||
assertTrue(userFeedEntries.isEmpty());
|
||||
|
||||
userFeedEntries = this.activityService.getUserFeedEntries("unknown user", "some format", "some site", true, false);
|
||||
|
||||
assertNotNull(userFeedEntries);
|
||||
assertTrue(userFeedEntries.isEmpty());
|
||||
|
||||
userFeedEntries = this.activityService.getUserFeedEntries("unknown user", "some format", "some site", false, true);
|
||||
|
||||
assertNotNull(userFeedEntries);
|
||||
assertTrue(userFeedEntries.isEmpty());
|
||||
|
||||
userFeedEntries = this.activityService.getUserFeedEntries("unknown user", "some format", "some site", true, true);
|
||||
|
||||
assertNotNull(userFeedEntries);
|
||||
assertTrue(userFeedEntries.isEmpty());
|
||||
}
|
||||
|
||||
public void testJSAPI() throws Exception
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -39,9 +39,7 @@ public interface ActivityFeedDaoService extends ActivityDaoService
|
||||
|
||||
public int deleteFeedEntries(Date keepDate) throws SQLException;
|
||||
|
||||
public List<ActivityFeedDAO> selectUserFeedEntries(String feedUserId, String format) throws SQLException;
|
||||
|
||||
public List<ActivityFeedDAO> selectUserFeedEntries(String feedUserId, String format, String siteId) throws SQLException;
|
||||
public List<ActivityFeedDAO> selectUserFeedEntries(String feedUserId, String format, String siteId, boolean excludeThisUser, boolean excludeOtherUsers) throws SQLException;
|
||||
|
||||
public List<ActivityFeedDAO> selectSiteFeedEntries(String siteUserId, String format) throws SQLException;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -25,9 +25,11 @@
|
||||
package org.alfresco.repo.activities.ibatis;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.activities.feed.ActivityFeedDAO;
|
||||
import org.alfresco.repo.activities.feed.ActivityFeedDaoService;
|
||||
|
||||
@@ -45,27 +47,66 @@ public class IBatisActivityFeedDaoServiceImpl extends IBatisSqlMapper implements
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ActivityFeedDAO> selectUserFeedEntries(String feedUserId, String format) throws SQLException
|
||||
public List<ActivityFeedDAO> selectUserFeedEntries(String feedUserId, String format, String siteId, boolean excludeThisUser, boolean excludeOtherUsers) throws SQLException
|
||||
{
|
||||
ActivityFeedDAO params = new ActivityFeedDAO();
|
||||
params.setFeedUserId(feedUserId);
|
||||
params.setActivitySummaryFormat(format);
|
||||
|
||||
// where feed user is me and post user is not me
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.feeduser", params);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ActivityFeedDAO> selectUserFeedEntries(String feedUserId, String format, String siteId) throws SQLException
|
||||
{
|
||||
ActivityFeedDAO params = new ActivityFeedDAO();
|
||||
params.setFeedUserId(feedUserId);
|
||||
params.setPostUserId(feedUserId);
|
||||
params.setActivitySummaryFormat(format);
|
||||
params.setSiteNetwork(siteId);
|
||||
if (siteId != null)
|
||||
{
|
||||
// given site
|
||||
params.setSiteNetwork(siteId);
|
||||
|
||||
if (excludeThisUser && excludeOtherUsers)
|
||||
{
|
||||
// effectively NOOP - return empty feed
|
||||
return new ArrayList<ActivityFeedDAO>(0);
|
||||
}
|
||||
if ((!excludeThisUser) && (!excludeOtherUsers))
|
||||
{
|
||||
// no excludes => everyone => where feed user is me
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.feeduser.and.site", params);
|
||||
}
|
||||
else if ((excludeThisUser) && (!excludeOtherUsers))
|
||||
{
|
||||
// exclude feed user => others => where feed user is me and post user is not me
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.feeduser.others.and.site", params);
|
||||
}
|
||||
else if ((excludeOtherUsers) && (!excludeThisUser))
|
||||
{
|
||||
// exclude others => me => where feed user is me and post user is me
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.feeduser.me.and.site", params);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// all sites
|
||||
|
||||
if (excludeThisUser && excludeOtherUsers)
|
||||
{
|
||||
// effectively NOOP - return empty feed
|
||||
return new ArrayList<ActivityFeedDAO>(0);
|
||||
}
|
||||
if (!excludeThisUser && !excludeOtherUsers)
|
||||
{
|
||||
// no excludes => everyone => where feed user is me
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.feeduser", params);
|
||||
}
|
||||
else if (excludeThisUser)
|
||||
{
|
||||
// exclude feed user => others => where feed user is me and post user is not me
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.feeduser.others", params);
|
||||
}
|
||||
else if (excludeOtherUsers)
|
||||
{
|
||||
// exclude others => me => where feed user is me and post user is me
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.feeduser.me", params);
|
||||
}
|
||||
}
|
||||
|
||||
// where feed user is me and post user is not me
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.feeduser.and.site", params);
|
||||
// belts-and-braces
|
||||
throw new AlfrescoRuntimeException("Unexpected: invalid arguments");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -75,7 +116,7 @@ public class IBatisActivityFeedDaoServiceImpl extends IBatisSqlMapper implements
|
||||
params.setSiteNetwork(siteId);
|
||||
params.setActivitySummaryFormat(format);
|
||||
|
||||
// where feed user is me and post user is not me
|
||||
// for given site
|
||||
return (List<ActivityFeedDAO>)getSqlMapClient().queryForList("select.activity.feed.for.site", params);
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -92,7 +92,9 @@ public interface ActivityService
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieve user feed
|
||||
* Retrieve user feed with optional site filter
|
||||
*
|
||||
* Will return activities for all users across all sites, or optionally for all users for specified site.
|
||||
*
|
||||
* @param userId - required
|
||||
* @param format - required
|
||||
@@ -101,6 +103,26 @@ public interface ActivityService
|
||||
*/
|
||||
public List<String> getUserFeedEntries(String userId, String format, String siteId);
|
||||
|
||||
/**
|
||||
* Retrieve user feed with optional site filter and optional user filters
|
||||
*
|
||||
* Will return activities for users across all sites, or optionally for users for specified site.
|
||||
*
|
||||
* User filters are:
|
||||
* - all user activities (excludeThisUser = false, excludeOtherUsers = false)
|
||||
* - other user activities (excludeThisUser = true, excludeOtherUsers = false)
|
||||
* - my user activities (excludeThisUser = false, excludeOtherUsers = true)
|
||||
* note: if both excludes are true then no activities will be returned.
|
||||
*
|
||||
* @param userId - required
|
||||
* @param format - required
|
||||
* @param siteId - optional, if set then will filter by given siteId else return all sites
|
||||
* @param excludeThisUser - if TRUE then will exclude activities for this user (hence returning other users only)
|
||||
* @param excludeOthersUsers - if TRUE then will exclude activities for other users (hence returning this user only)
|
||||
* @return list of JSON feed entries
|
||||
*/
|
||||
public List<String> getUserFeedEntries(String userId, String format, String siteId, boolean excludeThisUser, boolean excludeOtherUsers);
|
||||
|
||||
/**
|
||||
* Retrieve site feed
|
||||
*
|
||||
|
Reference in New Issue
Block a user