partially implemented get more feeds but still buggy
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@93003 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8ccca59096
commit
fc97c11bba
|
@ -4,9 +4,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<dependent-module archiveName="wsmail-widget-1.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/wsmail-widget/wsmail-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="news-feed"/>
|
||||
</wb-module>
|
||||
|
|
|
@ -24,6 +24,8 @@ public interface NewsService extends RemoteService {
|
|||
|
||||
ArrayList<EnhancedFeed> getOnlyLikedFeeds();
|
||||
|
||||
ArrayList<EnhancedFeed> getMoreFeeds(int from, int quantity);
|
||||
|
||||
boolean like(String feedid, String feedText, String feedOwnerId);
|
||||
|
||||
boolean deleteComment(String commentid, String feedid);
|
||||
|
|
|
@ -47,4 +47,7 @@ public interface NewsServiceAsync {
|
|||
|
||||
void getSingleFeed(String feedKey, AsyncCallback<EnhancedFeed> callback);
|
||||
|
||||
void getMoreFeeds(int from, int quantity,
|
||||
AsyncCallback<ArrayList<EnhancedFeed>> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.portlets.user.newsfeed.client.event;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
||||
|
||||
public class ShowMoreUpdatesEvent extends GwtEvent<ShowMoreUpdatesEventHandler> {
|
||||
public static Type<ShowMoreUpdatesEventHandler> TYPE = new Type<ShowMoreUpdatesEventHandler>();
|
||||
|
||||
public ShowMoreUpdatesEvent() { }
|
||||
|
||||
@Override
|
||||
public Type<ShowMoreUpdatesEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(ShowMoreUpdatesEventHandler handler) {
|
||||
handler.onShowMoreUpdatesClick(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.gcube.portlets.user.newsfeed.client.event;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
public interface ShowMoreUpdatesEventHandler extends EventHandler {
|
||||
void onShowMoreUpdatesClick(ShowMoreUpdatesEvent event);
|
||||
}
|
|
@ -31,10 +31,13 @@ import org.gcube.portlets.user.newsfeed.client.event.SeeCommentsEvent;
|
|||
import org.gcube.portlets.user.newsfeed.client.event.SeeCommentsEventHandler;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEvent;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEventHandler;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.ShowMoreUpdatesEvent;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.ShowMoreUpdatesEventHandler;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEvent;
|
||||
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEventHandler;
|
||||
import org.gcube.portlets.user.newsfeed.client.templates.FilterPanel;
|
||||
import org.gcube.portlets.user.newsfeed.client.templates.NewFeedsAvailable;
|
||||
import org.gcube.portlets.user.newsfeed.client.templates.ShowMoreFeeds;
|
||||
import org.gcube.portlets.user.newsfeed.client.templates.SingleComment;
|
||||
import org.gcube.portlets.user.newsfeed.client.templates.TweetTemplate;
|
||||
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
||||
|
@ -78,6 +81,7 @@ public class NewsFeedPanel extends Composite {
|
|||
private HorizontalPanel filterPanelWrapper = new HorizontalPanel();
|
||||
private FilterPanel filterPanel;
|
||||
private SimplePanel newUpdatesPanel = new SimplePanel();
|
||||
private SimplePanel showMoreUpdatesPanel = new SimplePanel();
|
||||
private VerticalPanel newsPanel = new VerticalPanel();
|
||||
|
||||
private NewFeedsAvailable newsFeedAlert;
|
||||
|
@ -118,6 +122,12 @@ public class NewsFeedPanel extends Composite {
|
|||
* events binder
|
||||
*/
|
||||
private void bind() {
|
||||
eventBus.addHandler(ShowMoreUpdatesEvent.TYPE, new ShowMoreUpdatesEventHandler() {
|
||||
@Override
|
||||
public void onShowMoreUpdatesClick(ShowMoreUpdatesEvent event) {
|
||||
doShowMoreUpdates();
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(ShowNewUpdatesEvent.TYPE, new ShowNewUpdatesEventHandler() {
|
||||
@Override
|
||||
|
@ -357,6 +367,7 @@ public class NewsFeedPanel extends Composite {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* called when a user click on the are new updates
|
||||
*/
|
||||
|
@ -448,12 +459,19 @@ public class NewsFeedPanel extends Composite {
|
|||
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||||
for (EnhancedFeed feed : feeds) {
|
||||
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus));
|
||||
allUpdates.add(feed);
|
||||
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
|
||||
allUpdates.add(feed); //in the model
|
||||
}
|
||||
if (feeds.size() < 5) {
|
||||
newsPanel.add(new Image(spacer));
|
||||
}
|
||||
//if you are showing more than feedsNoPerCategory*3-1 feeds there is probably more
|
||||
//if (feeds.size() >= feedsNoPerCategory*3-1) {
|
||||
if (true) {
|
||||
GWT.log("Show MORE " + feedsNoPerCategory);
|
||||
showMoreUpdatesPanel.add(new ShowMoreFeeds(eventBus));
|
||||
newsPanel.add(showMoreUpdatesPanel);
|
||||
}
|
||||
isFirstTweet = false;
|
||||
}
|
||||
} else {
|
||||
|
@ -471,7 +489,38 @@ public class NewsFeedPanel extends Composite {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* called when a user click on show more updates
|
||||
*/
|
||||
protected void doShowMoreUpdates() {
|
||||
newsPanel.remove(showMoreUpdatesPanel);
|
||||
int from = allUpdates.size()+1;
|
||||
final int quantity = 5;
|
||||
GWT.log("AllUpdatesNo = " + from);
|
||||
newsService.getMoreFeeds(from, quantity, new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||
if (feeds != null) {
|
||||
int c = 1;
|
||||
for (EnhancedFeed feed : feeds) {
|
||||
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
|
||||
allUpdates.add(feed); //in the model
|
||||
c++;
|
||||
}
|
||||
if (c >= quantity) { //there could be more feeds
|
||||
GWT.log("there could be more feeds");
|
||||
newsPanel.add(showMoreUpdatesPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
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>"));
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Only User Connections
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package org.gcube.portlets.user.newsfeed.client.templates;
|
||||
|
||||
import org.gcube.portlets.user.newsfeed.client.event.ShowMoreUpdatesEvent;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
public class ShowMoreFeeds extends Composite {
|
||||
|
||||
private static NewFeedsAvailableUiBinder uiBinder = GWT
|
||||
.create(NewFeedsAvailableUiBinder.class);
|
||||
|
||||
interface NewFeedsAvailableUiBinder extends
|
||||
|
||||
UiBinder<Widget, ShowMoreFeeds> {
|
||||
}
|
||||
|
||||
private HandlerManager eventBus;
|
||||
|
||||
@UiField HTML caption;
|
||||
@UiField HTMLPanel panel;
|
||||
|
||||
|
||||
public ShowMoreFeeds(HandlerManager eventBus) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.eventBus = eventBus;
|
||||
panel.getElement().getStyle().setMarginTop(10, Unit.PX);
|
||||
caption.addStyleName("new-feeds-show");
|
||||
caption.getElement().getStyle().setBackgroundColor("transparent");
|
||||
caption.getElement().getStyle().setFontSize(14, Unit.PX);
|
||||
caption.setHTML("Show more feeds");
|
||||
}
|
||||
|
||||
@UiHandler("caption")
|
||||
void onClick(ClickEvent e) {
|
||||
eventBus.fireEvent(new ShowMoreUpdatesEvent());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||
<g:HTMLPanel ui:field="panel" styleName="new-feeds-container">
|
||||
<g:HTML ui:field="caption" styleName="new-feeds-available" />
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -98,7 +98,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
_log.warn("USER IS NULL setting testing user and Running OUTSIDE PORTAL");
|
||||
user = "test.user";
|
||||
user = "massimiliano.assante";
|
||||
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devVRE/testvrefolder2");
|
||||
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
|
||||
}
|
||||
else {
|
||||
withinPortal = true;
|
||||
|
@ -308,8 +308,36 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
}
|
||||
return new EnhancedFeed();
|
||||
}
|
||||
/**
|
||||
* @param strat the range start (most recent feeds for this vre) has to be greater than 0
|
||||
* @param quantity the number of most recent feeds for this vre starting from "start" param
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<EnhancedFeed> getMoreFeeds(int start, int quantity) {
|
||||
ArrayList<Feed> toMerge = new ArrayList<Feed>();
|
||||
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>();
|
||||
String vreid = getASLSession().getScope();
|
||||
_log.debug("Asking more feed for Timeline " + vreid + " from " + start + " get other " + quantity);
|
||||
ArrayList<Feed> OrganizationFeeds;
|
||||
try {
|
||||
OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVREAndRange(vreid, start, quantity);
|
||||
for (Feed feed : OrganizationFeeds) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
for (String key: feedsMap.keySet()) {
|
||||
toMerge.add(feedsMap.get(key));
|
||||
}
|
||||
//sort the feeds in reverse chronological order
|
||||
Collections.sort(toMerge, Collections.reverseOrder());
|
||||
|
||||
return enhanceFeeds(toMerge, 2);
|
||||
}
|
||||
/**
|
||||
* just for testing purposes
|
||||
*
|
||||
|
@ -324,29 +352,29 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
ArrayList<Feed> toMerge = new ArrayList<Feed>();
|
||||
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>();
|
||||
|
||||
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE("/gcube/devsec/devVRE", 10);
|
||||
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE("/gcube/devsec/devVRE", 5);
|
||||
for (Feed feed : OrganizationFeeds) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
_log.trace("Reading desc: " + feed.getDescription());
|
||||
}
|
||||
|
||||
if (! onlyConnections) {
|
||||
//User Own Feeds
|
||||
ArrayList<Feed> userFeeds = (ArrayList<Feed>) store.getRecentFeedsByUser(userName, 10);
|
||||
for (Feed feed : userFeeds)
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
// //Portal Feeds
|
||||
ArrayList<Feed> portalFeeds = (ArrayList<Feed>) store.getAllPortalPrivacyLevelFeeds();
|
||||
for (Feed feed : portalFeeds)
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
//UserFriends Feeds
|
||||
ArrayList<String> userFriendsIds = (ArrayList<String>)store.getFriends(userName);
|
||||
for (String userid : userFriendsIds) {
|
||||
for (Feed feed : store.getRecentFeedsByUser(userid, 10)) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
}
|
||||
// if (! onlyConnections) {
|
||||
// //User Own Feeds
|
||||
// ArrayList<Feed> userFeeds = (ArrayList<Feed>) store.getRecentFeedsByUser(userName, 10);
|
||||
// for (Feed feed : userFeeds)
|
||||
// feedsMap.put(feed.getKey(), feed);
|
||||
// // //Portal Feeds
|
||||
// ArrayList<Feed> portalFeeds = (ArrayList<Feed>) store.getAllPortalPrivacyLevelFeeds();
|
||||
// for (Feed feed : portalFeeds)
|
||||
// feedsMap.put(feed.getKey(), feed);
|
||||
// }
|
||||
// //UserFriends Feeds
|
||||
// ArrayList<String> userFriendsIds = (ArrayList<String>)store.getFriends(userName);
|
||||
// for (String userid : userFriendsIds) {
|
||||
// for (Feed feed : store.getRecentFeedsByUser(userid, 10)) {
|
||||
// feedsMap.put(feed.getKey(), feed);
|
||||
// }
|
||||
// }
|
||||
for (String key: feedsMap.keySet()) {
|
||||
toMerge.add(feedsMap.get(key));
|
||||
}
|
||||
|
@ -785,4 +813,6 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
return new CustomConfiguration(minutes, label, showTimelineSource);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,3 +8,5 @@ log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
|||
# Print only messages of level TRACE or above in the package org.gcube
|
||||
log4j.logger.org.gcube=TRACE
|
||||
log4j.logger.org.gcube.application.framework.core.session=INFO
|
||||
log4j.logger.org.gcube.common.scope.impl.DefaultScopeProvider=ERROR
|
||||
log4j.logger.com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor=ERROR
|
Loading…
Reference in New Issue