From aca6fd95bd28768e7496612217eaa8fc8648fb34 Mon Sep 17 00:00:00 2001 From: "massimiliano.assante" Date: Tue, 4 Jun 2013 16:21:54 +0000 Subject: [PATCH] added notification config files, still need to create the VIEW over the Preferences Map git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@76761 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/NotificationsService.java | 6 ++- .../client/NotificationsServiceAsync.java | 9 ++-- .../client/view/NotificationSettings.java | 48 +++++------------ .../client/view/NotificationsPanel.java | 13 +++-- .../templates/NotificationPreference.java | 29 +++++++++++ .../templates/NotificationPreference.ui.xml | 13 +++++ .../server/NotificationsServiceImpl.java | 31 ++++++----- src/main/webapp/Notifications.css | 51 +++++++++++++++++++ .../NotificationTypeCategories.properties | 3 ++ .../NotificationTypeDescriptions.properties | 20 ++++++++ .../conf/NotificationTypeHumans.properties | 20 ++++++++ 11 files changed, 181 insertions(+), 62 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreference.java create mode 100644 src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreference.ui.xml create mode 100644 src/main/webapp/conf/NotificationTypeCategories.properties create mode 100644 src/main/webapp/conf/NotificationTypeDescriptions.properties create mode 100644 src/main/webapp/conf/NotificationTypeHumans.properties diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/NotificationsService.java b/src/main/java/org/gcube/portlets/user/notifications/client/NotificationsService.java index 196f349..d8a592a 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/NotificationsService.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/NotificationsService.java @@ -3,9 +3,11 @@ package org.gcube.portlets.user.notifications.client; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.Map; import org.gcube.portal.databook.shared.Notification; import org.gcube.portal.databook.shared.NotificationChannelType; +import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portal.databook.shared.UserInfo; import com.google.gwt.user.client.rpc.RemoteService; @@ -21,7 +23,7 @@ public interface NotificationsService extends RemoteService { boolean setAllUserNotificationsRead(); - ArrayList getNotificationChannels(); + HashMap getUserNotificationPreferences(); - boolean setNotificationChannels(HashMap newSettings); + boolean setUserNotificationPreferences(Map enabledChannels); } diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/NotificationsServiceAsync.java b/src/main/java/org/gcube/portlets/user/notifications/client/NotificationsServiceAsync.java index 9dfba3d..27099c6 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/NotificationsServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/NotificationsServiceAsync.java @@ -3,9 +3,11 @@ package org.gcube.portlets.user.notifications.client; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.Map; import org.gcube.portal.databook.shared.Notification; import org.gcube.portal.databook.shared.NotificationChannelType; +import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portal.databook.shared.UserInfo; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -19,11 +21,10 @@ public interface NotificationsServiceAsync { void setAllUserNotificationsRead(AsyncCallback callback); - void getNotificationChannels( - AsyncCallback> callback); + void getUserNotificationPreferences(AsyncCallback> callback); - void setNotificationChannels( - HashMap newSettings, + void setUserNotificationPreferences( + Map enabledChannels, AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationSettings.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationSettings.java index cf20f43..c9d319c 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationSettings.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationSettings.java @@ -4,8 +4,10 @@ import java.util.ArrayList; import java.util.HashMap; import org.gcube.portal.databook.shared.NotificationChannelType; +import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog; import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync; +import org.gcube.portlets.user.notifications.client.view.templates.NotificationPreference; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; @@ -43,15 +45,22 @@ public class NotificationSettings extends GCubeDialog { private Button cancel = new Button("Cancel"); private Button save = new Button("Save"); - public NotificationSettings(final ArrayList currentChannels, final NotificationsServiceAsync notificationService) { + private HashMap preferences; + + public NotificationSettings(final HashMap preferences, final NotificationsServiceAsync notificationService) { super(); + this.preferences = preferences; buttonsPanel.setWidth("100%"); buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); container.setStyleName("user-notification"); - container.setWidth("400px"); + container.setWidth("800px"); container.add(how); container.add(new HTML(" ")); + container.add(new NotificationPreference()); + + + container.add(portalCheckbox); container.add(emailCheckbox); @@ -63,44 +72,11 @@ public class NotificationSettings extends GCubeDialog { setText("Notification Settings"); setWidget(container); - if (currentChannels.contains(NotificationChannelType.EMAIL)) - emailCheckbox.setValue(true); - - if (currentChannels.contains(NotificationChannelType.PORTAL)) - portalCheckbox.setValue(true); save.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { - boolean portalChanged = (portalCheckbox.getValue() && !currentChannels.contains(NotificationChannelType.PORTAL) || - !portalCheckbox.getValue() && currentChannels.contains(NotificationChannelType.PORTAL)); - - boolean emailChanged = (emailCheckbox.getValue() && !currentChannels.contains(NotificationChannelType.EMAIL) || - !emailCheckbox.getValue() && currentChannels.contains(NotificationChannelType.EMAIL)); - - HashMap newSettings = new HashMap(); - if (portalChanged) { - newSettings.put(NotificationChannelType.PORTAL, portalCheckbox.getValue()); - } - if (emailChanged) { - newSettings.put(NotificationChannelType.EMAIL, emailCheckbox.getValue()); - } - - if (portalChanged || emailChanged) - notificationService.setNotificationChannels(newSettings, new AsyncCallback() { - @Override - public void onSuccess(Boolean result) { - showDeliveryResult(result); - - } - @Override - public void onFailure(Throwable caught) { - showDeliveryResult(false); - } - }); - else - showDeliveryResult(true); - + } }); 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 1347680..c3d2462 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 @@ -7,6 +7,7 @@ import java.util.HashMap; import org.gcube.portal.databook.shared.Notification; import org.gcube.portal.databook.shared.NotificationChannelType; +import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portal.databook.shared.UserInfo; import org.gcube.portlets.user.notifications.client.NotificationsService; import org.gcube.portlets.user.notifications.client.NotificationsServiceAsync; @@ -83,17 +84,21 @@ public class NotificationsPanel extends Composite { notificationSettings.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { - notificationService.getNotificationChannels(new AsyncCallback>() { + + notificationService.getUserNotificationPreferences(new AsyncCallback>() { @Override - public void onFailure(Throwable caught) { } + public void onFailure(Throwable caught) { + } @Override - public void onSuccess(ArrayList result) { + public void onSuccess(HashMap result) { NotificationSettings dlg = new NotificationSettings(result, notificationService); dlg.center(); - dlg.show(); + dlg.show(); } }); + + } }); } diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreference.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreference.java new file mode 100644 index 0000000..c2513ea --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreference.java @@ -0,0 +1,29 @@ +package org.gcube.portlets.user.notifications.client.view.templates; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +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.Window; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HasText; +import com.google.gwt.user.client.ui.Widget; + +public class NotificationPreference extends Composite { + + private static NotificationPreferenceUiBinder uiBinder = GWT + .create(NotificationPreferenceUiBinder.class); + + interface NotificationPreferenceUiBinder extends + UiBinder { + } + + public NotificationPreference() { + initWidget(uiBinder.createAndBindUi(this)); + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreference.ui.xml b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreference.ui.xml new file mode 100644 index 0000000..f2a27e2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/NotificationPreference.ui.xml @@ -0,0 +1,13 @@ + + + +
+
WP_FOLDER_SHARE
+
use to notify a user he got a workspace folder shared
+
+
+
+
+
+
\ No newline at end of file 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 89158b1..a2bb3a8 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 @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.Map; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; @@ -14,8 +15,10 @@ import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.portal.databook.server.DatabookStore; import org.gcube.portal.databook.shared.Notification; import org.gcube.portal.databook.shared.NotificationChannelType; +import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portal.databook.shared.UserInfo; import org.gcube.portal.databook.shared.ex.NotificationChannelTypeNotFoundException; +import org.gcube.portal.databook.shared.ex.NotificationTypeNotFoundException; import org.gcube.portlets.user.notifications.client.NotificationsService; import com.google.gwt.user.server.rpc.RemoteServiceServlet; @@ -61,7 +64,7 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); if (user == null) { user = "test.user"; - //user = "massimiliano.assante"; + user = "massimiliano.assante"; _log.warn("USER IS NULL setting "+user+" and Running OUTSIDE PORTAL"); withinPortal = false; @@ -152,27 +155,23 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No } return false; } - + @Override - public ArrayList getNotificationChannels() { - ArrayList toReturn = new ArrayList(); - try { - for (NotificationChannelType channel : store.getUserNotificationChannels(getASLSession().getUsername())) - toReturn.add(channel); - - } catch (NotificationChannelTypeNotFoundException e) { + public HashMap getUserNotificationPreferences() { + String userid = getASLSession().getUsername(); + HashMap toReturn = new HashMap(); + try { + toReturn.putAll(store.getUserNotificationPreferences(userid)); + } catch (Exception e) { + _log.error("While trying to get getUser Notification Preferences"); e.printStackTrace(); } return toReturn; } @Override - public boolean setNotificationChannels(HashMap newSettings) { - boolean toReturn = false; - for (NotificationChannelType type : newSettings.keySet()) { - _log.error("Trying to set User notification Setting: " + type + " to: " + newSettings.get(type)); - toReturn = store.setUserNotificationChannel(getASLSession().getUsername(), type, newSettings.get(type)); - } - return toReturn; + public boolean setUserNotificationPreferences(Map enabledChannels) { + return store.setUserNotificationPreferences(getASLSession().getUsername(), enabledChannels); } + } diff --git a/src/main/webapp/Notifications.css b/src/main/webapp/Notifications.css index 4314282..d25d26f 100644 --- a/src/main/webapp/Notifications.css +++ b/src/main/webapp/Notifications.css @@ -3,6 +3,57 @@ table { border-spacing: 0; } +#preferenceContainer { + border: 1px solid black; + position: relative; + height: 50px; +} + +#preferenceType { + border: 1px solid black; + position: absolute; + top: 0; + left: 0; + height: 50px; + width: 150px; +} + +#preferenceDesc { + border: 1px solid black; + position: absolute; + top: 0; + left: 150px; + height: 50px; + width: 500px; +} + +#preferenceSettingOff { + border: 1px solid black; + position: absolute; + top: 0; + left: 650px; + height: 50px; + width: 50px; +} + +#preferenceSettingPortal { + border: 1px solid black; + position: absolute; + top: 0; + left: 700px; + height: 50px; + width: 50px; +} + +#preferenceSettingEmail { + border: 1px solid black; + position: absolute; + top: 0; + left: 750px; + height: 50px; + width: 50px; +} + a.link,a.link:active,a.link:visited { font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif; diff --git a/src/main/webapp/conf/NotificationTypeCategories.properties b/src/main/webapp/conf/NotificationTypeCategories.properties new file mode 100644 index 0000000..4736f82 --- /dev/null +++ b/src/main/webapp/conf/NotificationTypeCategories.properties @@ -0,0 +1,3 @@ +Sharing=WP_FOLDER_SHARE,WP_FOLDER_ADDEDUSER,WP_FOLDER_REMOVEDUSER,WP_FOLDER_RENAMED,WP_ITEM_DELETE,WP_ITEM_UPDATED,WP_ITEM_RENAMED,WP_ITEM_NEW +Social=OWN_COMMENT,COMMENT,MENTION,LIKE,MESSAGE +DocumentWorkflows=DOCUMENT_WORKFLOW_EDIT,DOCUMENT_WORKFLOW_VIEW,DOCUMENT_WORKFLOW_STEP_REQUEST_TASK,DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT,DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER,DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER,DOCUMENT_WORKFLOW_STEP_FORWARD_PEER diff --git a/src/main/webapp/conf/NotificationTypeDescriptions.properties b/src/main/webapp/conf/NotificationTypeDescriptions.properties new file mode 100644 index 0000000..5a2d930 --- /dev/null +++ b/src/main/webapp/conf/NotificationTypeDescriptions.properties @@ -0,0 +1,20 @@ +WP_FOLDER_SHARE=sharing of workspace folders with you +WP_FOLDER_ADDEDUSER=someone added users one to one of your workspace shared folder +WP_FOLDER_REMOVEDUSER=someone removed users from one of your workspace shared folder +WP_FOLDER_RENAMED=someone renamed one of your workspace shared folder +WP_ITEM_DELETE=someone deleted an item in one of your workspace shared folder +WP_ITEM_UPDATED=someone updated an item in one of your workspace shared folder +WP_ITEM_RENAMED=someone renamed an item in one of your workspace shared folder +WP_ITEM_NEW=someone added an item in one of your workspace shared folder +OWN_COMMENT=someone replied to your post +COMMENT=someone replied too to a post you replied +MENTION=someone mentioned you in a post +LIKE=someone set favorite your post +MESSAGE=someone sent you a message +DOCUMENT_WORKFLOW_EDIT=a document workflow you created was editeded +DOCUMENT_WORKFLOW_VIEW=a document workflow you created was viewed +DOCUMENT_WORKFLOW_STEP_REQUEST_TASK=someone requested you to perform a task on his document workflow +DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT=someone involved you on his document workflow +DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER=a document workflow you created was forwarded to another step +DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER=a document workflow you created was forwarded to the another step by all the users involved in the step +DOCUMENT_WORKFLOW_STEP_FORWARD_PEER=someone completed his task on a document workflow where you still need to do yours diff --git a/src/main/webapp/conf/NotificationTypeHumans.properties b/src/main/webapp/conf/NotificationTypeHumans.properties new file mode 100644 index 0000000..55ff0ee --- /dev/null +++ b/src/main/webapp/conf/NotificationTypeHumans.properties @@ -0,0 +1,20 @@ +WP_FOLDER_SHARE=shared folder +WP_FOLDER_ADDEDUSER=user added to shared folder +WP_FOLDER_REMOVEDUSER=user removed from shared folder +WP_FOLDER_RENAMED=shared folder renamed +WP_ITEM_DELETE=shared item deleted +WP_ITEM_UPDATED=shared item updated +WP_ITEM_RENAMED=shared item renamed +WP_ITEM_NEW=shared item added +OWN_COMMENT=own replies +COMMENT=replies +MENTION=mentions +LIKE=favorites +MESSAGE=messages +DOCUMENT_WORKFLOW_EDIT=edit +DOCUMENT_WORKFLOW_VIEW=view +DOCUMENT_WORKFLOW_STEP_REQUEST_TASK=task request +DOCUMENT_WORKFLOW_FIRST_STEP_REQUEST_INVOLVMENT=involvement request +DOCUMENT_WORKFLOW_USER_FORWARD_TO_OWNER=forward +DOCUMENT_WORKFLOW_FORWARD_STEP_COMPLETED_OWNER=step completed +DOCUMENT_WORKFLOW_STEP_FORWARD_PEER=forward from peer