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} * {@inheritDoc}
*/ */
@Override @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 { public List<Notification> getUnreadNotificationMessagesByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException {
ArrayList<Notification> toReturn = new ArrayList<Notification>(); ArrayList<Notification> toReturn = new ArrayList<Notification>();
ArrayList<String> notificationsIDs = getUserMessagesNotificationsIds(userid); ArrayList<String> notificationsIDs = getUserMessagesNotificationsIds(userid);
@ -1342,5 +1361,6 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
_log.info("LikesNo update OK to: " + newCount); _log.info("LikesNo update OK to: " + newCount);
return true; return true;
} }
} }

View File

@ -94,7 +94,7 @@ public interface DatabookStore {
* @throws ColumnNameNotFoundException * @throws ColumnNameNotFoundException
*/ */
List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException; List<Feed> getAllFeedsByApp(String appid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException;
/** /**
* return all the feeds whose Level is PORTAL * return all the feeds whose Level is PORTAL
* @throws PrivacyLevelTypeNotFoundException * @throws PrivacyLevelTypeNotFoundException
@ -149,7 +149,7 @@ public interface DatabookStore {
* @throws {@link NotificationTypeNotFoundException} * @throws {@link NotificationTypeNotFoundException}
*/ */
Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException; Notification readNotification(String notificationid) throws NotificationIDNotFoundException, NotificationTypeNotFoundException, ColumnNameNotFoundException;
/** /**
* @param userid user identifier * @param userid user identifier
* @param limit set 0 to get everything, an int to get the most -limit- notifications * @param limit set 0 to get everything, an int to get the most -limit- notifications
@ -159,6 +159,15 @@ public interface DatabookStore {
*/ */
List<Notification> getAllNotificationByUser(String userid, int limit) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException; 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) * return the not yet read notifications (not including messages)
* @param userid user identifier * @param userid user identifier
@ -175,7 +184,7 @@ public interface DatabookStore {
* @throws ColumnNameNotFoundException * @throws ColumnNameNotFoundException
*/ */
List<Notification> getUnreadNotificationMessagesByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException; List<Notification> getUnreadNotificationMessagesByUser(String userid) throws NotificationTypeNotFoundException, ColumnNameNotFoundException, NotificationIDNotFoundException;
/** /**
* *
* @param userid user identifier * @param userid user identifier
@ -209,15 +218,15 @@ public interface DatabookStore {
* @param commentid the comment identifier to edit * @param commentid the comment identifier to edit
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException; boolean editComment(Comment comment) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
/** /**
* delete a comment * delete a comment
* @param commentid the comment identifier to delete * @param commentid the comment identifier to delete
* @parma feedid the feedid to shich the comment is associated * @parma feedid the feedid to shich the comment is associated
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException; boolean deleteComment(String commentid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, CommentIDNotFoundException, FeedIDNotFoundException;
/** /**
* add a like to a feed * add a like to a feed
* @param the like instance * @param the like instance
@ -230,7 +239,7 @@ public interface DatabookStore {
* @parma feedid the feedid to shich the comment is associated * @parma feedid the feedid to shich the comment is associated
* @return true if success, false otherwise * @return true if success, false otherwise
*/ */
boolean unlike(String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException; boolean unlike(String likeid, String feedid) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, ColumnNameNotFoundException, LikeIDNotFoundException, FeedIDNotFoundException;
/** /**
* @param userid user identifier * @param userid user identifier
* return all the feedids a user has liked * return all the feedids a user has liked
@ -241,7 +250,7 @@ public interface DatabookStore {
* return all the likes belonging to the feedid * return all the likes belonging to the feedid
*/ */
List<Like> getAllLikesByFeed(String feedid); List<Like> getAllLikesByFeed(String feedid);
/** /**
* close the connection to the underlying database * close the connection to the underlying database
*/ */