added support to show feeds related to user's statistics

fixed time for comments/posts: the year is now present if the comment/post was made before the current one

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@130961 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-08-03 14:29:59 +00:00
parent 6c96eafa46
commit 4b3cd43ef4
8 changed files with 320 additions and 44 deletions

View File

@ -1,4 +1,13 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.news-feed.2-1-0"
date="2016-10-29">
<Change>Support to show feeds related to user's statistics added
</Change>
<Change>Fixed time for comments/posts: the year is present only if the
comment/post
was made before the current one
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.news-feed.2-0-0"
date="2016-06-29">
<Change>Updated for Liferay 6.2.5</Change>

View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>news-feed</artifactId>
<packaging>war</packaging>
<version>2.0.0-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<name>gCube News Feed Portlet</name>
<description>

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.EnhancedFeed;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.ShowUserStatisticAction;
import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean;
import org.gcube.portlets.user.newsfeed.shared.OperationResult;
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
@ -31,6 +32,8 @@ public interface NewsService extends RemoteService {
ArrayList<EnhancedFeed> getFeedsByQuery(String query, int from, int quantity);
ArrayList<EnhancedFeed> getFeedsRelatedToUserStatistics(ShowUserStatisticAction action, int from, int quantity);
MoreFeedsBean getMoreFeeds(int from, int quantity);
boolean like(String feedid, String feedText, String feedOwnerId);

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.EnhancedFeed;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.ShowUserStatisticAction;
import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean;
import org.gcube.portlets.user.newsfeed.shared.OperationResult;
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
@ -66,5 +67,8 @@ public interface NewsServiceAsync {
void getFeedsByQuery(String query, int from, int quantity,
AsyncCallback<ArrayList<EnhancedFeed>> callback);
void getFeedsRelatedToUserStatistics(ShowUserStatisticAction action, int from, int quantity,
AsyncCallback<ArrayList<EnhancedFeed>> callback);
}

View File

@ -17,6 +17,7 @@ import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.portal.databook.shared.ShowUserStatisticAction;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
import org.gcube.portlets.user.newsfeed.client.FilterType;
@ -123,6 +124,7 @@ public class NewsFeedPanel extends Composite {
public static final String COMMENT_LABEL = "Reply";
public static final String SHARE_FWD_LABEL = "Share";
private static final int SEARCHED_FEEDS_TO_SHOW = 10;
private static final int FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW = 10;
private String vreLabel;
@ -141,6 +143,12 @@ public class NewsFeedPanel extends Composite {
// the current query (if isSearch is true)
protected String currentQuery;
// is the user seeing her statistics?
private boolean isFeedsRelatedToStatistics = false;
// the feeds related to user statistics to show
protected ShowUserStatisticAction relatedFeedsToUserStatisticsToShow;
private LoadingText loadingIcon = new LoadingText();
private Image loadingImage;
private UserInfo myUserInfo;
@ -271,6 +279,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.add(loadingIcon);
CheckSession.getInstance().startPolling();
isSearch = false;
isFeedsRelatedToStatistics = false;
newsService.getUserSettings(new AsyncCallback<UserSettings>() {
@Override
@ -322,7 +331,21 @@ public class NewsFeedPanel extends Composite {
isSearch = true;
showFeedsSearch(query, 0, SEARCHED_FEEDS_TO_SHOW);
filterPanel.removeFilterSelected();
}
}else if(getShowUserStatisticParam() != null){
String action = "";
try {
action = Encoder.decode(getShowUserStatisticParam());
relatedFeedsToUserStatisticsToShow = ShowUserStatisticAction.valueOf(action);
} catch (Exception e) {
newsPanel.clear();
newsPanel.add(new HTML("<div class=\"nofeed-message\"><div style=\"padding-top: 90px;\">" +
"We're sorry, it seems you used an invalid character</div>"));
return;
}
isFeedsRelatedToStatistics = true;
showUserStatisticsRelatedFeeds(relatedFeedsToUserStatisticsToShow, 0, FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW);
filterPanel.removeFilterSelected();
}
else {
showAllUpdatesFeeds();
}
@ -334,8 +357,8 @@ public class NewsFeedPanel extends Composite {
showFeedTimelineSource = result.isShowTimelineSourceLabel();
isInfrastructure = true;
}
// else
// mainPanel.addStyleName("framed");
// else
// mainPanel.addStyleName("framed");
}
});
@ -399,6 +422,14 @@ public class NewsFeedPanel extends Composite {
return Window.Location.getParameter(Encoder.encode(GCubeSocialNetworking.HASHTAG_OID));
}
/**
* Check if some user statistic related feeds must be shown
* @return
*/
private String getShowUserStatisticParam(){
return Window.Location.getParameter(Encoder.encode(GCubeSocialNetworking.SHOW_STATISTICS_ACTION_OID));
}
/**
* check if it has to show the feeds given a query
* @return
@ -568,6 +599,85 @@ public class NewsFeedPanel extends Composite {
});
}
/**
* Called when a user wants to show some feeds related to her statistics
*/
private void showUserStatisticsRelatedFeeds(final ShowUserStatisticAction relatedFeedsToUserStatisticsToShow, final int from, final int to) {
// show loader while waiting
showLoader();
// stop asking for feeds
doStopFeedsTimer();
final String actionToPrint = relatedFeedsToUserStatisticsToShow.getHumanFriendlyAction();
newsService.getUserSettings(new AsyncCallback<UserSettings>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(UserSettings result) {
if (result.getUserInfo().getUsername().equals(NewsConstants.TEST_USER)) {
doShowSessionExpired();
} else {
/**
* this check avoids the 2 tabs open in 2 different scope, if the previous tab was open at VRE Level and then antoher
* is open at infra level the first tab stops checking for updates
*/
if (result.getCurrentScope().compareTo(currentScope) == 0) {
newsService.getFeedsRelatedToUserStatistics(relatedFeedsToUserStatisticsToShow, from, to, new AsyncCallback<ArrayList<EnhancedFeed>>() {
@Override
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
filterPanelWrapper.setVisible(false);
newsPanel.clear();
if (feeds != null) {
GWT.log("Retrieved " + feeds.size() + " hits for search.");
if (feeds.size() == 0) {
newsPanel.add(new ResultsFor("Results for ", actionToPrint));
newsPanel.add(new HTML("<div class=\"nofeed-message\" style=\"height: 200px;\">" +
"Sorry, looks like we found no match for action : " + actionToPrint +"</div>"));
}
else {
newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
newsPanel.add(new ResultsFor("Results for ", actionToPrint));
for (EnhancedFeed feed : feeds) {
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
// save them (they will be used when asking more feeds)
allUpdates.add(feed);
}
if (feeds.size() < 5) {
newsPanel.add(new Image(spacer));
}
// add widget to lookup more feeds: if the size of the returned data is less
// than the required disable this feature.
if(feeds.size() == FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW){
showMoreWidget = new ShowMoreFeeds(eventBus);
showMoreUpdatesPanel.add(showMoreWidget);
newsPanel.add(showMoreUpdatesPanel);
}
}
} else {
showProblems();
}
}
@Override
public void onFailure(Throwable caught) {
showProblems();
}
});
}
}
}
});
}
/**
* Called when a user search something
*/
@ -578,7 +688,7 @@ public class NewsFeedPanel extends Composite {
// stop asking for feeds
doStopFeedsTimer();
newsService.getUserSettings(new AsyncCallback<UserSettings>() {
@Override
public void onFailure(Throwable caught) {
@ -784,7 +894,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
for (EnhancedFeed feed : feeds) {
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
allUpdates.add(feed); //in the model
@ -850,7 +960,7 @@ public class NewsFeedPanel extends Composite {
// clear panel
showMoreUpdatesPanel.clear();
// check if we can ask for other data
if(feeds.size() == SEARCHED_FEEDS_TO_SHOW){
GWT.log("It seems there are no more feeds for this query. Stop asking further");
@ -870,6 +980,50 @@ public class NewsFeedPanel extends Composite {
"Please try again in a short while.</div>"));
}
});
}else if(isFeedsRelatedToStatistics){
GWT.log("Going to request more feeds for this user's statisics");
// start position
int start = allUpdates.size();
GWT.log("StartingPoint = " + start);
newsService.getFeedsRelatedToUserStatistics(relatedFeedsToUserStatisticsToShow, start, FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW , new AsyncCallback<ArrayList<EnhancedFeed>>() {
@Override
public void onSuccess(ArrayList<EnhancedFeed> feeds){
newsPanel.remove(showMoreUpdatesPanel);
if (feeds != null) {
GWT.log("There are " + feeds.size() + " more feeds");
for (EnhancedFeed feed : feeds) {
// avoid to insert same data
if(!isFeedPresent(feed)){
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
allUpdates.add(feed);
}
}
// clear panel
showMoreUpdatesPanel.clear();
// check if we can ask for other data
if(feeds.size() == FEEDS_RELATED_TO_USER_STATISTICS_TO_SHOW){
GWT.log("It seems there are no more feeds for this query. Stop asking further");
showMoreWidget = new ShowMoreFeeds(eventBus);
showMoreUpdatesPanel.add(showMoreWidget);
newsPanel.add(showMoreUpdatesPanel);
}else{
showMoreWidget = null;
}
}
}
@Override
public void onFailure(Throwable caught) {
showMoreUpdatesPanel.clear();
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
"Ops! There were problems while retrieving your feeds!. <br> " +
"Please try again in a short while.</div>"));
}
});
}
else{

View File

@ -1,7 +1,8 @@
package org.gcube.portlets.user.newsfeed.client.ui;
import java.util.Date;
import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.Comment;
@ -32,7 +33,7 @@ public class SingleComment extends Composite {
interface SingleCommentUiBinder extends UiBinder<Widget, SingleComment> {
}
private static final int MAX_SHOWTEXT_LENGTH = 450;
private boolean isUsers = false;
private TweetTemplate owner;
private String myCommentid;
@ -56,7 +57,7 @@ public class SingleComment extends Composite {
myCommentid = toShow.getKey();
avatarImage.setPixelSize(30, 30);
avatarImage.setUrl(toShow.getThumbnailURL());
//check if the user has his own avatar
if (toShow.getThumbnailURL().endsWith("img_id=0") || !toShow.getThumbnailURL().contains("?")) { //it means no avatar is set
avatarImage.setVisible(false);
@ -75,15 +76,15 @@ public class SingleComment extends Composite {
avatarReplacement.setInitials(toShow.getUserid(), f, s);
avatarReplacement.setVisible(true);
}
String commentToShow = toShow.getText();
//replace the < & and >
commentToShow = commentToShow.replaceAll("&lt;","<").replaceAll("&gt;",">");
commentToShow = commentToShow.replaceAll("&amp;","&");
if (commentToShow.length() > MAX_SHOWTEXT_LENGTH) {
final int TEXT_TO_SHOW_LENGHT = (commentToShow.length() < 700) ? (commentToShow.length() - (commentToShow.length() / 3)) : 700;
commentToShow = commentToShow.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
@ -92,14 +93,33 @@ public class SingleComment extends Composite {
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
commentText.setHTML("<a class=\"link\" href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(toShow.getUserid())+"\">"+toShow.getFullName()+
"</a> " + commentToShow);
if(toShow.isEdit())
timeArea.setHTML(DateTimeFormat.getFormat("MMMM dd, h:mm a").format(toShow.getTime()) +
" (Last edit on " + DateTimeFormat.getFormat("MMMM dd, h:mm a").format(toShow.getLastEditTime()) + ")");
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(toShow.getUserid())+"\">"+toShow.getFullName()+
"</a> " + commentToShow);
// Comment's data
Date now = new Date();
String formattedTime;
String formattedTimeEdit = null;
if(now.getYear() != toShow.getTime().getYear())
formattedTime = DateTimeFormat.getFormat("MMMM dd yyyy, h:mm a").format(toShow.getTime());
else
timeArea.setHTML(DateTimeFormat.getFormat("MMMM dd, h:mm a").format(toShow.getTime()));
formattedTime = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(toShow.getTime());
if(toShow.isEdit()){
if(now.getYear() != toShow.getLastEditTime().getYear())
formattedTimeEdit = DateTimeFormat.getFormat("MMMM dd yyyy, h:mm a").format(toShow.getLastEditTime());
else
formattedTimeEdit = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(toShow.getLastEditTime());
}
if(toShow.isEdit())
timeArea.setHTML(formattedTime +
" (Last edit on " + formattedTimeEdit + ")");
else
timeArea.setHTML(formattedTime);
if (isUsers) {
closeImage.setStyleName("closeImage");
closeImage.setTitle("Delete");
@ -107,24 +127,24 @@ public class SingleComment extends Composite {
editImage.setTitle("Edit");
}
}
@UiHandler("seeMore")
void onSeeMoreClick(ClickEvent e) {
String commentToShow = myComment.getText();
//replace the < & and >
commentToShow = commentToShow.replaceAll("&lt;","<").replaceAll("&gt;",">");
commentToShow = commentToShow.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
commentText.setHTML("<a class=\"link\" href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(myComment.getUserid())+"\">"+
myComment.getFullName()+"</a> " + commentToShow);
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(myComment.getUserid())+"\">"+
myComment.getFullName()+"</a> " + commentToShow);
seeMore.setHTML("");
}
@UiHandler("closeImage")
void onDeleteCommentClick(ClickEvent e) {
@ -161,6 +181,6 @@ public class SingleComment extends Composite {
public String getCommentKey() {
return myCommentid;
}
}

View File

@ -4,6 +4,7 @@
package org.gcube.portlets.user.newsfeed.client.ui;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@ -304,11 +305,11 @@ public class TweetTemplate extends Composite {
//replace the < & and >
feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">");
feedText = feedText.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
if (! isAppFeed) {
// sharePostArea.setHTML("<a>" + NewsFeedPanel.SHARE_FWD_LABEL + "</a>");
// sharePostArea.setHTML("<a>" + NewsFeedPanel.SHARE_FWD_LABEL + "</a>");
contentArea.setHTML("<a class=\"link\" href=\""+profilePageURL
+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
@ -357,7 +358,14 @@ public class TweetTemplate extends Composite {
try {
String formattedTime = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(feed.getTime());
Date now = new Date();
String formattedTime;
// TODO java.util.Calendar is not yet available in GWT
if(now.getYear() != feed.getTime().getYear())
formattedTime = DateTimeFormat.getFormat("MMMM dd yyyy, h:mm a").format(feed.getTime());
else
formattedTime = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(feed.getTime());
timeArea.setHTML(formattedTime);
String formattedTimeWithYear = DateTimeFormat.getFormat("dd MMMM yyyy h:mm a ").format(feed.getTime());
timeArea.setTitle(formattedTimeWithYear);
@ -446,10 +454,10 @@ public class TweetTemplate extends Composite {
//replace the < & and >
feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">");
feedText = feedText.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
contentArea.setHTML("<a class=\"link\"href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(myFeed.getFeed().getEntityId())+"\">"+

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@ -11,10 +12,10 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;
import java.util.Map.Entry;
import javax.servlet.ServletContext;
@ -37,6 +38,7 @@ import org.gcube.portal.databook.shared.EnhancedFeed;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.RangeFeeds;
import org.gcube.portal.databook.shared.ShowUserStatisticAction;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portal.databook.shared.ex.ColumnNameNotFoundException;
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
@ -101,7 +103,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
/**
* Elasticsearch client
*/
private ElasticSearchClientInterface el;
private ElasticSearchClientInterface escl;
private final static int MAX_FEEDS_NO = 45;
@ -109,10 +111,10 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
store = new DBCassandraAstyanaxImpl();
try {
el = new ElasticSearchClientImpl(null);
escl = new ElasticSearchClientImpl(null);
_log.info("Elasticsearch connection created");
} catch (Exception e) {
el = null;
escl = null;
_log.error("Unable to create elasticsearch client connection!!!", e);
}
@ -404,7 +406,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
public ArrayList<EnhancedFeed> getFeedsByQuery(String query, int from, int quantity) {
// TODO : check this error better
if(el == null){
if(escl == null){
_log.debug("There is no connection to elasticsearch, sorry.");
return null;
@ -442,7 +444,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
}
// query elastic search
List<EnhancedFeed> enhancedFeeds = el.searchInEnhancedFeeds(query, vres, from, quantity);
List<EnhancedFeed> enhancedFeeds = escl.searchInEnhancedFeeds(query, vres, from, quantity);
// retrieve the ids of liked feeds by the user
List<String> likedFeeds = store.getAllLikedFeedIdsByUser(userName);
@ -841,8 +843,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
ArrayList<EnhancedFeed> toReturn = new ArrayList<EnhancedFeed>();
ASLSession session = getASLSession();
String username = session.getUsername();
//patch needed for maintaining mention link backward compatibility (they point to /group/data-e-infrastructure-gateway/profile)
final String LINK_TO_REPLACE = "data-e-infrastructure-gateway";
String siteLandinPagePath = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest());
@ -1128,4 +1130,80 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
return toReturn;
}
@Override
public ArrayList<EnhancedFeed> getFeedsRelatedToUserStatistics(
ShowUserStatisticAction action, int from, int quantity) {
String userid = getASLSession().getUsername();
if(userid == NewsConstants.TEST_USER)
return null;
try{
ArrayList<EnhancedFeed> toReturn = new ArrayList<EnhancedFeed>();
// get reference time
Calendar oneYearAgo = Calendar.getInstance();
oneYearAgo.set(Calendar.YEAR, oneYearAgo.get(Calendar.YEAR) - 1);
ArrayList<Feed> feeds = null;
switch(action){
case POSTS_MADE_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
break;
case LIKES_MADE_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentLikedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
break;
case COMMENTS_MADE_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentCommentedFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
break;
case LIKES_GOT_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
Iterator<Feed> feedsIteratorLikes = feeds.iterator();
while (feedsIteratorLikes.hasNext()) {
Feed feed = (Feed) feedsIteratorLikes.next();
if(Integer.parseInt(feed.getLikesNo()) == 0)
feedsIteratorLikes.remove();
}
break;
case COMMENTS_GOT_BY_USER:
feeds = (ArrayList<Feed>) store.getRecentFeedsByUserAndDate(userid, oneYearAgo.getTimeInMillis());
Iterator<Feed> feedsIteratorComments = feeds.iterator();
while (feedsIteratorComments.hasNext()) {
Feed feed = (Feed) feedsIteratorComments.next();
if(Integer.parseInt(feed.getCommentsNo()) == 0)
feedsIteratorComments.remove();
}
break;
default : return toReturn;
}
// filter the feeds according the current context
Iterator<Feed> iteratorScope = feeds.iterator();
if(!isInfrastructureScope()){
String currentScope = getASLSession().getScope();
while (iteratorScope.hasNext()) {
Feed feed = (Feed) iteratorScope.next();
if(!feed.getVreid().equals(currentScope))
iteratorScope.remove();
}
}
// enhance retrieved feeds
Collections.sort(feeds, Collections.reverseOrder());
return enhanceFeeds(feeds, -1);
}catch(Exception e){
_log.error("Error while retrieving feeds for user " + userid + " and action " + action.toString(), e);
}
return null;
}
}