added new method setAllNotificationsRead fast

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@68542 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-01-29 23:54:50 +00:00
parent c0c84cb321
commit 5b777a06e9
3 changed files with 1126 additions and 8 deletions

File diff suppressed because it is too large Load Diff

View File

@ -818,6 +818,25 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
* {@inheritDoc}
*/
@Override
public boolean setAllNotificationReadByUser(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException {
ArrayList<String> notificationsIDs = getUserNotificationsIds(userid);
//need them in reverse order
for (int i = notificationsIDs.size()-1; i >= 0; i--) {
Notification toAdd = readNotification(notificationsIDs.get(i));
if ((!toAdd.isRead()) && (toAdd.getType() != NotificationType.MESSAGE) ) { //while I encounter unread notifications keep putting them to read, else exit
setNotificationRead(toAdd.getKey());
}
else {
break;
}
}
return true;
}
/**
* {@inheritDoc}
*/
@Override
public List<Notification> getUnreadNotificationMessagesByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
ArrayList<Notification> toReturn = new ArrayList<Notification>();
ArrayList<String> notificationsIDs = getUserMessagesNotificationsIds(userid);
@ -1343,4 +1362,5 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
return true;
}
}

View File

@ -159,6 +159,15 @@ public interface DatabookStore {
*/
List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
/**
* This is a fast way to set all notification to read quickly
* @param userid
* @return true if everything went fine
* @throws {@link ColumnNameNotFoundException}
* @throws {@link NotificationIDNotFoundException}
* @throws {@link NotificationTypeNotFoundException}
*/
boolean setAllNotificationReadByUser(String userid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
/**
* return the not yet read notifications (not including messages)
* @param userid user identifier