filter of the posts related to the statistics per site added

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@132170 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-09-30 10:34:36 +00:00
parent cf6d6425e0
commit 3141795b1c
1 changed files with 28 additions and 10 deletions

View File

@ -146,7 +146,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
*/ */
public String getDevelopmentUser() { public String getDevelopmentUser() {
String user = NewsConstants.TEST_USER; String user = NewsConstants.TEST_USER;
// user = "costantino.perciante"; // user = "costantino.perciante";
return user; return user;
} }
/** /**
@ -1135,7 +1135,9 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
public ArrayList<EnhancedFeed> getFeedsRelatedToUserStatistics( public ArrayList<EnhancedFeed> getFeedsRelatedToUserStatistics(
ShowUserStatisticAction action, int from, int quantity) { ShowUserStatisticAction action, int from, int quantity) {
String userid = getASLSession().getUsername(); ASLSession session = getASLSession();
String userid = session.getUsername();
String scope = session.getScope();
if(userid == NewsConstants.TEST_USER) if(userid == NewsConstants.TEST_USER)
return null; return null;
@ -1179,19 +1181,35 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
default : return new ArrayList<EnhancedFeed>(); default : return new ArrayList<EnhancedFeed>();
} }
// filter the feeds according the current context
Iterator<Feed> iteratorScope = feeds.iterator(); List<String> contexts = new ArrayList<String>();
if(isInfrastructureScope()){
if(!isInfrastructureScope()){ LiferayGroupManager groupManager = new LiferayGroupManager();
long userIdLong = new LiferayUserManager().getUserId(userid);
String currentScope = getASLSession().getScope(); // filter for site
Set<GCubeGroup> vresInPortal = groupManager.listGroupsByUserAndSite(userIdLong, getThreadLocalRequest().getServerName());
_log.debug("Contexts in this site are " + vresInPortal);
while (iteratorScope.hasNext()) { // get the scopes associated with such groups
Feed feed = (Feed) iteratorScope.next(); for (GCubeGroup gCubeGroup : vresInPortal) {
if(!feed.getVreid().equals(currentScope)) contexts.add(groupManager.getInfrastructureScope(gCubeGroup.getGroupId()));
iteratorScope.remove();
} }
}else{
// just the current scope
contexts.add(scope);
}
// filter
Iterator<Feed> iteratorScope = feeds.iterator();
while (iteratorScope.hasNext()) {
Feed feed = (Feed) iteratorScope.next();
if(!contexts.contains(feed.getVreid()))
iteratorScope.remove();
} }
// sort the list, retrieve elements in the range and enhance the feeds // sort the list, retrieve elements in the range and enhance the feeds