diff --git a/NotificationsTest-dev.launch b/NotificationsTest-dev.launch
index 67a5cc3..f046ef2 100644
--- a/NotificationsTest-dev.launch
+++ b/NotificationsTest-dev.launch
@@ -7,16 +7,16 @@
-
+
-
+
-
+
diff --git a/NotificationsTest-prod.launch b/NotificationsTest-prod.launch
index 74e15a0..a4d3111 100644
--- a/NotificationsTest-prod.launch
+++ b/NotificationsTest-prod.launch
@@ -7,16 +7,16 @@
-
+
-
+
-
+
diff --git a/distro/changelog.xml b/distro/changelog.xml
index 7b10d93..9800db1 100644
--- a/distro/changelog.xml
+++ b/distro/changelog.xml
@@ -1,7 +1,9 @@
- Added support for show notifications by range
+ date="2014-4-03">
+ Implemented automatic notifications scroll back in time
+ Updated description for post alerts
+ Made Notification Settings more evident
diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java
index 7b1f84f..7b9f32a 100644
--- a/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java
+++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java
@@ -49,7 +49,6 @@ public class NotificationsPanel extends Composite {
public static final String loading = GWT.getModuleBaseURL() + "../images/feeds-loader.gif";
private static final String spacer = GWT.getModuleBaseURL() + "../images/feeds-spacer.gif";
private static final String warning = GWT.getModuleBaseURL() + "../images/warning_blue.png";
- private UserInfo myUserInfo;
private Image loadingImage;
private ShowMoreNotifications showMoreWidget;
//needed to know the next range start
@@ -85,7 +84,6 @@ public class NotificationsPanel extends Composite {
public void onFailure(Throwable caught) {
}
public void onSuccess(UserInfo result) {
- myUserInfo = result;
if (result.getUsername().equals("test.user")) {
Window.alert("Your session has expired, please log out and login again");
}
@@ -174,7 +172,7 @@ public class NotificationsPanel extends Composite {
mainPanel.add(new Image(spacer));
//if you are showing more than NotificationConstants.NOTIFICATION_NUMBER
- if (notCounter >= NotificationConstants.NOTIFICATION_NUMBER) {
+ if (notCounter >= NotificationConstants.NOTIFICATION_NUMBER_PRE) {
GWT.log("Show MORE ");
showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
showMoreWidget = new ShowMoreNotifications();
@@ -193,15 +191,13 @@ public class NotificationsPanel extends Composite {
* called when a user scroll down the page to the bottom
*/
private void doShowMoreNotifications() {
- GWT.log("doShowMoreNotifications()");
showMoreNotificationsPanel.remove(0);
loadingImage.getElement().getStyle().setMargin(10, Unit.PX);
showMoreNotificationsPanel.add(loadingImage);
- int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER+1 : fromStartingPoint;
+ int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER_PRE+1 : fromStartingPoint;
fromStartingPoint = from;
- final int quantity = 10;
- GWT.log("StartingPoint = " + from);
-
+ final int quantity = NotificationConstants.NOTIFICATION_NUMBER_PER_REQUEST;
+
notificationService.getUserNotificationsByRange(from, quantity, new AsyncCallback>>() {
@Override
public void onSuccess(HashMap> notificationsPerDay) {
@@ -218,10 +214,8 @@ public class NotificationsPanel extends Composite {
notCounter++;
}
}
- fromStartingPoint += notCounter;
- GWT.log("StartingPoint incremented = " + fromStartingPoint);
+ fromStartingPoint += notCounter;
if (notCounter >= quantity) { //there could be more notifications
- GWT.log("Show MORE ");
showMoreNotificationsPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
showMoreWidget = new ShowMoreNotifications();
showMoreNotificationsPanel.clear();
diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/DayWrapper.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/DayWrapper.java
index 5d1c365..5771803 100644
--- a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/DayWrapper.java
+++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/DayWrapper.java
@@ -9,6 +9,7 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.datepicker.client.CalendarUtil;
/**
* @author Massimiliano Assante ISTI-CNR
@@ -27,12 +28,34 @@ public class DayWrapper extends Composite {
public DayWrapper(Date day) {
initWidget(uiBinder.createAndBindUi(this));
- String notificationDate = DateTimeFormat.getFormat("yyyy MMMM dd").format(day);
- String today = DateTimeFormat.getFormat("yyyy MMMM dd").format(new Date());
- if (notificationDate.equals(today))
- dayLabel.setHTML("Today");
- else
- dayLabel.setHTML(DateTimeFormat.getFormat("EE, dd MMMM").format(day));
+ Date now = new Date();
+ @SuppressWarnings("deprecation")
+ int currYear = now.getYear();
+ @SuppressWarnings("deprecation")
+ int notificationDateYear = day.getYear();
+
+
+
+ int dayInBetween = CalendarUtil.getDaysBetween(now, day);
+ String theDay = "";
+ switch (dayInBetween) {
+ case 0:
+ theDay = "Today";
+ break;
+ case -1:
+ theDay = "Yesterday";
+ break;
+ default:
+ if (currYear == notificationDateYear)
+ theDay = (DateTimeFormat.getFormat("EE, dd MMMM").format(day));
+ else {
+ theDay = (DateTimeFormat.getFormat("dd MMMM yyyy").format(day));
+ }
+ break;
+ }
+
+ this.dayLabel.setHTML(theDay);
+
}
}
diff --git a/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java b/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java
index 6983b5b..3dee671 100644
--- a/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java
@@ -74,9 +74,7 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
String sessionID = this.getThreadLocalRequest().getSession().getId();
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
if (user == null) {
- user = "test.user";
- //user = "massimiliano.assante";
-
+ user = getDevelopmentUser();
_log.warn("USER IS NULL setting "+user+" and Running OUTSIDE PORTAL");
withinPortal = false;
}
@@ -86,7 +84,11 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
System.out.println("SessionID = " + sessionID);
return SessionManager.getInstance().getASLSession(sessionID, user);
}
-
+ public String getDevelopmentUser() {
+ String user = "test.user";
+ user = "massimiliano.assante";
+ return user;
+ }
public UserInfo getUserInfo() {
try {
String username = getASLSession().getUsername();
@@ -121,7 +123,7 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
public HashMap> getUserNotifications() {
HashMap> toReturn = new HashMap>();
try {
- for (Notification notification : store.getAllNotificationByUser(getASLSession().getUsername(), NotificationConstants.NOTIFICATION_NUMBER)) {
+ for (Notification notification : store.getAllNotificationByUser(getASLSession().getUsername(), NotificationConstants.NOTIFICATION_NUMBER_PRE)) {
Date dateWithoutTime = removeTimePart(notification.getTime());
if (! toReturn.containsKey(dateWithoutTime)) {
ArrayList nots = new ArrayList();
diff --git a/src/main/java/org/gcube/portlets/user/notifications/shared/NotificationConstants.java b/src/main/java/org/gcube/portlets/user/notifications/shared/NotificationConstants.java
index fef904c..6979a90 100644
--- a/src/main/java/org/gcube/portlets/user/notifications/shared/NotificationConstants.java
+++ b/src/main/java/org/gcube/portlets/user/notifications/shared/NotificationConstants.java
@@ -1,5 +1,16 @@
package org.gcube.portlets.user.notifications.shared;
-
+/**
+ *
+ * @author Massimiliano Assante ISTI-CNR
+ *
+ */
public class NotificationConstants {
- public final static int NOTIFICATION_NUMBER = 70;
+ /**
+ * the initial number of notification to be loaded at startup
+ */
+ public final static int NOTIFICATION_NUMBER_PRE = 70;
+ /**
+ * the number of notification to be loaded each time after the startup
+ */
+ public final static int NOTIFICATION_NUMBER_PER_REQUEST = 15;
}
diff --git a/src/main/resources/clientlog4j.properties b/src/main/resources/clientlog4j.properties
index b98f952..39bfd3f 100644
--- a/src/main/resources/clientlog4j.properties
+++ b/src/main/resources/clientlog4j.properties
@@ -3,7 +3,8 @@ log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
# Print the date in ISO 8601 format
-log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+log4j.appender.A1.layout.ConversionPattern=[%-5p] %d %c - %m%n
# Print only messages of level TRACE or above in the package org.gcube
-log4j.logger.org.gcube=TRACE
\ No newline at end of file
+log4j.logger.org.gcube=TRACE
+log4j.logger.com.netflix.astyanax.connectionpool.impl=ERROR
\ No newline at end of file
diff --git a/src/test/java/org/gcube/portlets/user/notifications/test/TestForDeploy.java b/src/test/java/org/gcube/portlets/user/notifications/test/TestForDeploy.java
new file mode 100644
index 0000000..b0b01fb
--- /dev/null
+++ b/src/test/java/org/gcube/portlets/user/notifications/test/TestForDeploy.java
@@ -0,0 +1,19 @@
+package org.gcube.portlets.user.notifications.test;
+
+import static org.junit.Assert.assertTrue;
+
+import org.gcube.portlets.user.notifications.server.NotificationsServiceImpl;
+import org.junit.Test;
+
+public class TestForDeploy {
+
+ @Test
+ public void testUserIsTestUser() {
+ NotificationsServiceImpl serviceImpl = new NotificationsServiceImpl();
+ String username = serviceImpl.getDevelopmentUser();
+ System.out.println("username for deploy is: " + username);
+ assertTrue(username.compareTo("test.user") == 0);
+ System.out.println("Test OK!");
+ }
+
+}