DBCassandraAstyanaxImpl (gCube Social Networking Library 1.0.2-SNAPSHOT API)
Date: 2013-04-03

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gcube.portal.databook.server
Class DBCassandraAstyanaxImpl

    java.lang.Object
      org.gcube.portal.databook.server.DBCassandraAstyanaxImpl

All Implemented Interfaces:
  DatabookStore

    public final class DBCassandraAstyanaxImpl

extends Object
implements DatabookStore

Version:
  1.0 Dec 2012 This class is used for querying and adding data to Cassandra via Astyanax High Level API
Author:
  Massimiliano Assante ISTI-CNR

Field Summary
`static String` | `APP_TIMELINE_FEEDS`
`static String` | `COMMENTS`
`static String` | `CONNECTIONS` Column Family names
`static String` | `FEEDS`
`static String` | `LIKES`
`static String` | `NOTIFICATIONS`
`static String` | `PENDING_CONNECTIONS_CF_NAME`
`static String` | `USER_LIKED_FEEDS`
`static String` | `USER_MESSAGES_NOTIFICATIONS`
`static String` | `USER_NOTIFICATIONS`
`static String` | `USER_NOTIFICATIONS_SETTINGS`
`static String` | `USER_TIMELINE_FEEDS`
`static String` | `VRE_TIMELINE_FEEDS`

Constructor Summary
`` | `DBCassandraAstyanaxImpl()` public constructor, no dropping schema is allowed
`protected` | `DBCassandraAstyanaxImpl(boolean dropSchema)` use this constructor carefully from test classes

Method Summary
`boolean` | `addComment(Comment comment)` add a comment to a feed
`boolean` | `approveFriendship(String from, String to)` userid from approves a friendship to userid to
`boolean` | `checkUnreadMessagesNotifications(String userid)`
`boolean` | `checkUnreadNotifications(String userid)`
`void` | `closeConnection()` close the connection to the underlying database
`boolean` | `deleteComment(String commentid, String feedid)` delete a comment
`boolean` | `deleteFeed(String feedId)` delete a Feed from the store
`boolean` | `denyFriendship(String from, String to)` userid from denies a friendship to userid to
`boolean` | `editComment(Comment comment2Edit)` edit a comment
`List<Comment>` | `getAllCommentByFeed(String feedid)`
`List<Feed>` | `getAllFeedsByApp(String appid)`
`List<Feed>` | `getAllFeedsByUser(String userid)`
`List<Feed>` | `getAllFeedsByVRE(String vreid)`
`List<String>` | `getAllLikedFeedIdsByUser(String userid)`
`List<Feed>` | `getAllLikedFeedsByUser(String userid, int limit)`
`List<Like>` | `getAllLikesByFeed(String feedid)`
`List<Notification>` | `getAllNotificationByUser(String userid, int limit)`
`List<Feed>` | `getAllPortalPrivacyLevelFeeds()` return all the feeds whose Level is PORTAL
`List<String>` | `getFriends(String userid)`
`List<String>` | `getPendingFriendRequests(String userid)`
`List<Feed>` | `getRecentFeedsByUser(String userid, int quantity)` return the most recent feeds for this user up to quantity param
`List<Feed>` | `getRecentFeedsByVRE(String vreid, int quantity)` return the most recent feeds for this vre up to quantity param
`List<Notification>` | `getUnreadNotificationMessagesByUser(String userid)` return the not yet read notification messages
`List<Notification>` | `getUnreadNotificationsByUser(String userid)` return the not yet read notifications (not including messages)
`List<NotificationChannelType>` | `getUserNotificationChannels(String userid)` return the channels a user chose for being notified
`boolean` | `like(Like like)` add a like to a feed
`Feed` | `readFeed(String feedid)` read a feed from a given id
`Notification` | `readNotification(String notificationid)` read a notification from a given id
`boolean` | `requestFriendship(String from, String to)` userid from requests a friendship to userid to
`boolean` | `saveAppFeed(Feed feed)` save a Feed instance in the store
`boolean` | `saveFeedToVRETimeline(String feedKey, String vreid)` save a Feed in the VRES TimeLine in the store
`boolean` | `saveNotification(Notification n)` save a Notification instance in the store
`boolean` | `saveUserFeed(Feed feed)` save a Feed instance in the store
`boolean` | `setAllNotificationReadByUser(String userid)` This is a fast way to set all notification to read quickly
`boolean` | `setNotificationRead(String notificationidToSet)` set an existing Notification instance in the to read
`boolean` | `setUserNotificationChannel(String userid, NotificationChannelType channel, boolean enabled)` enable or disable the channels to be used for notifying the user
`boolean` | `unlike(String likeid, String feedid)` unlike a feed

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CONNECTIONS

    public static final String CONNECTIONS

  Column Family names

  See Also:
    Constant Field Values

### PENDING_CONNECTIONS_CF_NAME

    public static final String PENDING_CONNECTIONS_CF_NAME

See Also:
  Constant Field Values

### NOTIFICATIONS

    public static final String NOTIFICATIONS

See Also:
  Constant Field Values

### FEEDS

    public static final String FEEDS

See Also:
  Constant Field Values

### COMMENTS

    public static final String COMMENTS

See Also:
  Constant Field Values

### LIKES

    public static final String LIKES

See Also:
  Constant Field Values

### VRE_TIMELINE_FEEDS

    public static final String VRE_TIMELINE_FEEDS

See Also:
  Constant Field Values

### USER_TIMELINE_FEEDS

    public static final String USER_TIMELINE_FEEDS

See Also:
  Constant Field Values

### APP_TIMELINE_FEEDS

    public static final String APP_TIMELINE_FEEDS

See Also:
  Constant Field Values

### USER_LIKED_FEEDS

    public static final String USER_LIKED_FEEDS

See Also:
  Constant Field Values

### USER_NOTIFICATIONS

    public static final String USER_NOTIFICATIONS

See Also:
  Constant Field Values

### USER_MESSAGES_NOTIFICATIONS

    public static final String USER_MESSAGES_NOTIFICATIONS

See Also:
  Constant Field Values

### USER_NOTIFICATIONS_SETTINGS

    public static final String USER_NOTIFICATIONS_SETTINGS

See Also:
  Constant Field Values

Constructor Detail

### DBCassandraAstyanaxImpl

    protected DBCassandraAstyanaxImpl(boolean dropSchema)

  use this constructor carefully from test classes

  Parameters:
    `dropSchema` - set true if you want do drop the current and set up new one

### DBCassandraAstyanaxImpl

    public DBCassandraAstyanaxImpl()

  public constructor, no dropping schema is allowed

Method Detail

### requestFriendship

    public boolean requestFriendship(String from,
                                     String to)

  userid from requests a friendship to userid to

  Specified by:
    `requestFriendship` in interface `DatabookStore`
  Returns:
    true if everything went fine

### approveFriendship

    public boolean approveFriendship(String from,
                                     String to)

  userid from approves a friendship to userid to

  Specified by:
    `approveFriendship` in interface `DatabookStore`
  Returns:
    true if everything went fine

### denyFriendship

    public boolean denyFriendship(String from,
                                  String to)

  userid from denies a friendship to userid to

  Specified by:
    `denyFriendship` in interface `DatabookStore`
  Returns:
    true if everything went fine

### getFriends

    public List<String> getFriends(String userid)

  Specified by:
    `getFriends` in interface `DatabookStore`
  Parameters:
    `userid` - the user id you want to know friends
  Returns:
    a List of userid representing the friends for the given userid

### getPendingFriendRequests

    public List<String> getPendingFriendRequests(String userid)

  Specified by:
    `getPendingFriendRequests` in interface `DatabookStore`
  Parameters:
    `userid` - the user id you want to know the pending friend requests
  Returns:
    a List of userid representing the friends for the given userid

### saveUserFeed

    public boolean saveUserFeed(Feed feed)

  save a Feed instance in the store

  Specified by:
    `saveUserFeed` in interface `DatabookStore`
  Returns:
    true if everything went fine

### saveAppFeed

    public boolean saveAppFeed(Feed feed)

  save a Feed instance in the store

  Specified by:
    `saveAppFeed` in interface `DatabookStore`
  Returns:
    true if everything went fine

### saveFeedToVRETimeline

    public boolean saveFeedToVRETimeline(String feedKey,
                                         String vreid)
                                  throws FeedIDNotFoundException

  save a Feed in the VRES TimeLine in the store

  Specified by:
    `saveFeedToVRETimeline` in interface `DatabookStore`
  Parameters:
    `feedKey` - feedKey
    `vreid` - vre identifier
  Returns:
  Throws:
    `FeedIDNotFoundException`

### readFeed

    public Feed readFeed(String feedid)
                  throws PrivacyLevelTypeNotFoundException,
                         FeedTypeNotFoundException,
                         FeedIDNotFoundException,
                         ColumnNameNotFoundException

  read a feed from a given id

  Specified by:
    `readFeed` in interface `DatabookStore`
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `FeedIDNotFoundException`

### deleteFeed

    public boolean deleteFeed(String feedId)
                       throws FeedIDNotFoundException,
                              PrivacyLevelTypeNotFoundException,
                              FeedTypeNotFoundException,
                              ColumnNameNotFoundException

  delete a Feed from the store

  Specified by:
    `deleteFeed` in interface `DatabookStore`
  Returns:
    true if everything went fine
  Throws:
    `FeedIDNotFoundException`
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`

### getAllFeedsByUser

    public List<Feed> getAllFeedsByUser(String userid)
                                 throws PrivacyLevelTypeNotFoundException,
                                        FeedTypeNotFoundException,
                                        ColumnNameNotFoundException,
                                        FeedIDNotFoundException

  Specified by:
    `getAllFeedsByUser` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier return all the feeds belonging to the userid
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `FeedIDNotFoundException`

### getAllFeedsByApp

    public List<Feed> getAllFeedsByApp(String appid)
                                throws PrivacyLevelTypeNotFoundException,
                                       FeedTypeNotFoundException,
                                       ColumnNameNotFoundException,
                                       FeedIDNotFoundException

  Specified by:
    `getAllFeedsByApp` in interface `DatabookStore`
  Parameters:
    `appid` - application identifier return all the feeds belonging to the appid
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `FeedIDNotFoundException`

### getAllPortalPrivacyLevelFeeds

    public List<Feed> getAllPortalPrivacyLevelFeeds()
                                             throws FeedTypeNotFoundException,
                                                    ColumnNameNotFoundException,
                                                    PrivacyLevelTypeNotFoundException

  return all the feeds whose Level is PORTAL

  Specified by:
    `getAllPortalPrivacyLevelFeeds` in interface `DatabookStore`
  Throws:
    `ColumnNameNotFoundException`
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`

### getRecentFeedsByUser

    public List<Feed> getRecentFeedsByUser(String userid,
                                           int quantity)
                                    throws PrivacyLevelTypeNotFoundException,
                                           FeedTypeNotFoundException,
                                           ColumnNameNotFoundException,
                                           FeedIDNotFoundException

  return the most recent feeds for this user up to quantity param

  Specified by:
    `getRecentFeedsByUser` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
    `quantity` - the number of most recent feeds for this user
  Returns:
    a List of most recent feeds for this user
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `FeedIDNotFoundException`

### getAllFeedsByVRE

    public List<Feed> getAllFeedsByVRE(String vreid)
                                throws PrivacyLevelTypeNotFoundException,
                                       FeedTypeNotFoundException,
                                       ColumnNameNotFoundException,
                                       FeedIDNotFoundException

  Specified by:
    `getAllFeedsByVRE` in interface `DatabookStore`
  Parameters:
    `vreid` - vre identifier return all the feeds belonging to the userid
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `FeedIDNotFoundException`

### getRecentFeedsByVRE

    public List<Feed> getRecentFeedsByVRE(String vreid,
                                          int quantity)
                                   throws PrivacyLevelTypeNotFoundException,
                                          FeedTypeNotFoundException,
                                          ColumnNameNotFoundException,
                                          FeedIDNotFoundException

  return the most recent feeds for this vre up to quantity param

  Specified by:
    `getRecentFeedsByVRE` in interface `DatabookStore`
  Parameters:
    `vreid` - VRES identifier
    `quantity` - the number of most recent feeds for this vre
  Returns:
    a List of most recent feeds for this vre
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `FeedIDNotFoundException`

### saveNotification

    public boolean saveNotification(Notification n)

  save a Notification instance in the store

  Specified by:
    `saveNotification` in interface `DatabookStore`
  Returns:
    true if everything went fine

### readNotification

    public Notification readNotification(String notificationid)
                                  throws NotificationIDNotFoundException,
                                         NotificationTypeNotFoundException,
                                         ColumnNameNotFoundException

  read a notification from a given id

  Specified by:
    `readNotification` in interface `DatabookStore`
  Throws:
    `NotificationIDNotFoundException`
    `NotificationTypeNotFoundException`
    `ColumnNameNotFoundException`

### setNotificationRead

    public boolean setNotificationRead(String notificationidToSet)
                                throws NotificationIDNotFoundException,
                                       NotificationTypeNotFoundException,
                                       ColumnNameNotFoundException

  set an existing Notification instance in the to read

  Specified by:
    `setNotificationRead` in interface `DatabookStore`
  Returns:
    true if everything went fine
  Throws:
    `NotificationIDNotFoundException`
    `NotificationTypeNotFoundException`
    `ColumnNameNotFoundException`

### getAllNotificationByUser

    public List<Notification> getAllNotificationByUser(String userid,
                                                       int limit)
                                                throws NotificationTypeNotFoundException,
                                                       ColumnNameNotFoundException,
                                                       NotificationIDNotFoundException

  Specified by:
    `getAllNotificationByUser` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
    `limit` - set 0 to get everything, an int to get the most recent -limit- notifications return all the notifications belonging to the userid up to limit, set 0 to get everything
  Throws:
    `NotificationTypeNotFoundException`
    `ColumnNameNotFoundException`
    `NotificationIDNotFoundException`

### getUnreadNotificationsByUser

    public List<Notification> getUnreadNotificationsByUser(String userid)
                                                    throws NotificationTypeNotFoundException,
                                                           ColumnNameNotFoundException,
                                                           NotificationIDNotFoundException

  return the not yet read notifications (not including messages)

  Specified by:
    `getUnreadNotificationsByUser` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
  Returns:
    a List of not yet read notifications for this user
  Throws:
    `NotificationTypeNotFoundException`
    `ColumnNameNotFoundException`
    `NotificationIDNotFoundException`

### setAllNotificationReadByUser

    public boolean setAllNotificationReadByUser(String userid)
                                         throws NotificationIDNotFoundException,
                                                NotificationTypeNotFoundException,
                                                ColumnNameNotFoundException

  This is a fast way to set all notification to read quickly

  Specified by:
    `setAllNotificationReadByUser` in interface `DatabookStore`
  Returns:
    true if everything went fine
  Throws:
    `NotificationIDNotFoundException`
    `NotificationTypeNotFoundException`
    `ColumnNameNotFoundException`

### getUnreadNotificationMessagesByUser

    public List<Notification> getUnreadNotificationMessagesByUser(String userid)
                                                           throws NotificationTypeNotFoundException,
                                                                  ColumnNameNotFoundException,
                                                                  NotificationIDNotFoundException

  return the not yet read notification messages

  Specified by:
    `getUnreadNotificationMessagesByUser` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
  Returns:
    a List of not yet read notifications for this user
  Throws:
    `NotificationTypeNotFoundException`
    `ColumnNameNotFoundException`
    `NotificationIDNotFoundException`

### checkUnreadNotifications

    public boolean checkUnreadNotifications(String userid)
                                     throws NotificationIDNotFoundException,
                                            NotificationTypeNotFoundException,
                                            ColumnNameNotFoundException

  Specified by:
    `checkUnreadNotifications` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
  Returns:
    true if there are unread notifications (not including messages), false if they are all read
  Throws:
    `NotificationIDNotFoundException`
    `NotificationTypeNotFoundException`
    `ColumnNameNotFoundException`

### checkUnreadMessagesNotifications

    public boolean checkUnreadMessagesNotifications(String userid)
                                             throws NotificationIDNotFoundException,
                                                    NotificationTypeNotFoundException,
                                                    ColumnNameNotFoundException

  Specified by:
    `checkUnreadMessagesNotifications` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
  Returns:
    true if there are unread messages notifications (including messages), false if they are all read
  Throws:
    `NotificationIDNotFoundException`
    `NotificationTypeNotFoundException`
    `ColumnNameNotFoundException`

### getUserNotificationChannels

    public List<NotificationChannelType> getUserNotificationChannels(String userid)
                                                              throws NotificationChannelTypeNotFoundException

  return the channels a user chose for being notified

  Specified by:
    `getUserNotificationChannels` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
  Returns:
    a list of NotificationChannelType that represents the channels this user wants to be notified
  Throws:
    `NotificationChannelTypeNotFoundException`

### setUserNotificationChannel

    public boolean setUserNotificationChannel(String userid,
                                              NotificationChannelType channel,
                                              boolean enabled)

  enable or disable the channels to be used for notifying the user

  Specified by:
    `setUserNotificationChannel` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
    `channel` - the type of the channel
    `enabled` - is you want it to be enabled or not
  Returns:
    true if everything was fine

### addComment

    public boolean addComment(Comment comment)
                       throws FeedIDNotFoundException

  add a comment to a feed

  Specified by:
    `addComment` in interface `DatabookStore`
  Parameters:
    `comment` - the Comment instance to add
  Throws:
    `FeedIDNotFoundException`

### getAllCommentByFeed

    public List<Comment> getAllCommentByFeed(String feedid)

  Specified by:
    `getAllCommentByFeed` in interface `DatabookStore`
  Parameters:
    `feedid` - feed identifier return all the comments belonging to the feedid

### editComment

    public boolean editComment(Comment comment2Edit)
                        throws PrivacyLevelTypeNotFoundException,
                               FeedTypeNotFoundException,
                               ColumnNameNotFoundException,
                               CommentIDNotFoundException,
                               FeedIDNotFoundException

  edit a comment

  Specified by:
    `editComment` in interface `DatabookStore`
  Returns:
    true if success, false otherwise
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `CommentIDNotFoundException`
    `FeedIDNotFoundException`

### deleteComment

    public boolean deleteComment(String commentid,
                                 String feedid)
                          throws PrivacyLevelTypeNotFoundException,
                                 FeedTypeNotFoundException,
                                 ColumnNameNotFoundException,
                                 CommentIDNotFoundException,
                                 FeedIDNotFoundException

  delete a comment

  Specified by:
    `deleteComment` in interface `DatabookStore`
  Parameters:
    `commentid` - the comment identifier to delete
  Returns:
    true if success, false otherwise
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `CommentIDNotFoundException`
    `FeedIDNotFoundException`

### like

    public boolean like(Like like)
                 throws FeedIDNotFoundException

  add a like to a feed

  Specified by:
    `like` in interface `DatabookStore`
  Throws:
    `FeedIDNotFoundException`

### unlike

    public boolean unlike(String likeid,
                          String feedid)
                   throws PrivacyLevelTypeNotFoundException,
                          FeedTypeNotFoundException,
                          ColumnNameNotFoundException,
                          LikeIDNotFoundException,
                          FeedIDNotFoundException

  unlike a feed

  Specified by:
    `unlike` in interface `DatabookStore`
  Parameters:
    `likeid` - the like identifier to delete
    `feedid` - the feedid to shich the comment is associated
  Returns:
    true if success, false otherwise
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException`
    `ColumnNameNotFoundException`
    `LikeIDNotFoundException`
    `FeedIDNotFoundException`

### getAllLikedFeedIdsByUser

    public List<String> getAllLikedFeedIdsByUser(String userid)

  Specified by:
    `getAllLikedFeedIdsByUser` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier return all the feedids a user has liked

### getAllLikedFeedsByUser

    public List<Feed> getAllLikedFeedsByUser(String userid,
                                             int limit)
                                      throws PrivacyLevelTypeNotFoundException,
                                             FeedTypeNotFoundException,
                                             ColumnNameNotFoundException,
                                             FeedIDNotFoundException

  Specified by:
    `getAllLikedFeedsByUser` in interface `DatabookStore`
  Parameters:
    `userid` - user identifier
    `limit` - set 0 to get everything, an int to get the most recent -limit- liked feeds
  Throws:
    `PrivacyLevelTypeNotFoundException`
    `FeedTypeNotFoundException` - .
    `ColumnNameNotFoundException` - .
    `FeedIDNotFoundException` - .

### getAllLikesByFeed

    public List<Like> getAllLikesByFeed(String feedid)

  Specified by:
    `getAllLikesByFeed` in interface `DatabookStore`
  Parameters:
    `feedid` - feed identifier return all the likes belonging to the feedid

### closeConnection

    public void closeConnection()

  close the connection to the underlying database

  Specified by:
    `closeConnection` in interface `DatabookStore`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013. All Rights Reserved.