From bc56343b1c9833deb330fdc482e2f4cabcad41de Mon Sep 17 00:00:00 2001 From: "massimiliano.assante" Date: Thu, 11 Jul 2013 15:25:21 +0000 Subject: [PATCH] added new method for shared calendar notification git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@78987 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 3 ++ .../ApplicationNotificationsManager.java | 34 +++++++++++++++++++ .../social/NotificationsManager.java | 11 ++++++ 3 files changed, 48 insertions(+) diff --git a/distro/changelog.xml b/distro/changelog.xml index 7edfc4f..0b35562 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -13,4 +13,7 @@ Modified delete item notifications. Distinguished the move from the delete in a shared folder + +Added support for Calendar Notifications + diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java index 3108bd4..bfa72ef 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/ApplicationNotificationsManager.java @@ -1,5 +1,6 @@ package org.gcube.applicationsupportlayer.social; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.UUID; @@ -576,4 +577,37 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen return saveNotification(not); } + /** + * {@inheritDoc} + */ + @Override + public boolean notifyNewCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate) { + SimpleDateFormat spf = new SimpleDateFormat("EEE dd MMMMM, yyyy"); + + String endDateToDisplay=""; + if (endingDate != null) { + endDateToDisplay = " to " + spf.format(endingDate); + } + + StringBuilder notificationText = new StringBuilder(); + notificationText.append("added the following event in the ").append(aslSession.getGroupName()).append(" shared calendar:
") // has done something + .append("
Summary: ").append(eventTitle).append("
") + .append("
Time: ").append(spf.format(startDate)).append(endDateToDisplay).append("
") + .append("
Category: ").append(eventType); + + Notification not = new Notification( + UUID.randomUUID().toString(), + NotificationType.CALENDAR_ADDED_EVENT, + userIdToNotify, //user no notify + "", // + new Date(), + getApplicationUrl(), + notificationText.toString(), + false, + aslSession.getUsername(), + aslSession.getUserFullName(), + aslSession.getUserAvatarId()); + + return saveNotification(not); + } } diff --git a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java index 5f72ebd..e876246 100644 --- a/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java +++ b/src/main/java/org/gcube/applicationsupportlayer/social/NotificationsManager.java @@ -1,5 +1,6 @@ package org.gcube.applicationsupportlayer.social; +import java.util.Date; import java.util.List; import org.gcube.portal.databook.shared.ApplicationProfile; @@ -105,6 +106,16 @@ public interface NotificationsManager { * @return true if the notification is correctly delivered, false otherwise */ boolean notifyMessageReceived(String userIdToNotify, String subject); + /** + * + * @param userIdToNotify the user you want to notify + * @param eventTitle the title of the event + * @param eventType the type of the event + * @param startDate staring date + * @param endingDate ending date + * @return true if the notification is correctly delivered, false otherwise + */ + boolean notifyNewCalendarEvent(String userIdToNotify, String eventTitle, String eventType, Date startDate, Date endingDate); /** * use to notify a user that someone commented on his post *