Package com.jms.socialmedia.dataservice
Class DataServiceWithMetrics
- java.lang.Object
-
- com.jms.socialmedia.dataservice.DataServiceWithMetrics
-
- All Implemented Interfaces:
DataService
public class DataServiceWithMetrics extends Object implements DataService
-
-
Constructor Summary
Constructors Constructor Description DataServiceWithMetrics(DataService dataService, com.codahale.metrics.MetricRegistry metricRegistry)
DataServiceWithMetrics(DataService dataService, com.codahale.metrics.MetricRegistry metricRegistry, String metricsName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addComment(Comment comment)
boolean
addPost(Post post)
boolean
addUser(NewUser newUser)
boolean
addUserSession(int userId, String sessionId)
boolean
deleteComment(int commentId)
boolean
deletePost(int postId)
boolean
editComment(int commentId, String commentText)
boolean
editPassword(Integer userId, String hashedPassword)
boolean
editPost(int postId, String postText)
boolean
followUser(int followerUserId, int followingUserId)
Comment
getComment(int commentId)
Collection<Post>
getCommentedPostsByUserId(int userId)
Collection<Integer>
getCommentLikes(int commentId)
Collection<Comment>
getComments(int postId)
Collection<Comment>
getCommentsByUserId(int userId)
Collection<Integer>
getFollowerUserIds(int userId)
Collection<Integer>
getFollowingUserIds(int userId)
User
getHashedPasswordByUserId(Integer userId)
Collection<Post>
getLikedPostsByUserId(int userId)
Post
getPost(int postId)
Collection<Integer>
getPostLikes(int postId)
Collection<Post>
getPosts(Collection<Integer> userIds, String username, String tag, String onDate, String beforeDate, String afterDate, Integer sincePostId, String sortBy, boolean sortOrderAsc)
User
getUserBySessionId(String sessionId)
Integer
getUserIdByUsername(String username)
Integer
getUserIdFromCommentId(int commentId)
Integer
getUserIdFromPostId(int postId)
User
getUserLoginInfoByString(String usernameOrEmail)
Collection<User>
getUsernamesByIds(Collection<Integer> userIds)
UserPage
getUserPageInfoByName(String username)
Collection<User>
getUsersToFollow(int userId)
boolean
isEmailTaken(String email)
boolean
isUsernameTaken(String username)
boolean
likeComment(int commentId, int userId)
boolean
likePost(int postId, int userId)
void
removeSessionId(String sessionId)
boolean
unfollowUser(int followerUserId, int followingUserId)
boolean
unlikeComment(int commentId, int userId)
boolean
unlikePost(int postId, int userId)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jms.socialmedia.dataservice.DataService
getPosts, getPosts
-
-
-
-
Constructor Detail
-
DataServiceWithMetrics
public DataServiceWithMetrics(DataService dataService, com.codahale.metrics.MetricRegistry metricRegistry)
-
DataServiceWithMetrics
public DataServiceWithMetrics(DataService dataService, com.codahale.metrics.MetricRegistry metricRegistry, String metricsName)
-
-
Method Detail
-
getUserIdByUsername
public Integer getUserIdByUsername(String username)
- Specified by:
getUserIdByUsername
in interfaceDataService
-
getUserPageInfoByName
public UserPage getUserPageInfoByName(String username)
- Specified by:
getUserPageInfoByName
in interfaceDataService
-
getUserLoginInfoByString
public User getUserLoginInfoByString(String usernameOrEmail)
- Specified by:
getUserLoginInfoByString
in interfaceDataService
-
getHashedPasswordByUserId
public User getHashedPasswordByUserId(Integer userId)
- Specified by:
getHashedPasswordByUserId
in interfaceDataService
-
getUsernamesByIds
public Collection<User> getUsernamesByIds(Collection<Integer> userIds)
- Specified by:
getUsernamesByIds
in interfaceDataService
-
getUsersToFollow
public Collection<User> getUsersToFollow(int userId)
- Specified by:
getUsersToFollow
in interfaceDataService
-
isUsernameTaken
public boolean isUsernameTaken(String username)
- Specified by:
isUsernameTaken
in interfaceDataService
-
isEmailTaken
public boolean isEmailTaken(String email)
- Specified by:
isEmailTaken
in interfaceDataService
-
addUser
public boolean addUser(NewUser newUser)
- Specified by:
addUser
in interfaceDataService
-
editPassword
public boolean editPassword(Integer userId, String hashedPassword)
- Specified by:
editPassword
in interfaceDataService
-
getUserBySessionId
public User getUserBySessionId(String sessionId)
- Specified by:
getUserBySessionId
in interfaceDataService
-
addUserSession
public boolean addUserSession(int userId, String sessionId)
- Specified by:
addUserSession
in interfaceDataService
-
removeSessionId
public void removeSessionId(String sessionId)
- Specified by:
removeSessionId
in interfaceDataService
-
getPosts
public Collection<Post> getPosts(Collection<Integer> userIds, String username, String tag, String onDate, String beforeDate, String afterDate, Integer sincePostId, String sortBy, boolean sortOrderAsc)
- Specified by:
getPosts
in interfaceDataService
-
getPost
public Post getPost(int postId)
- Specified by:
getPost
in interfaceDataService
-
getUserIdFromPostId
public Integer getUserIdFromPostId(int postId)
- Specified by:
getUserIdFromPostId
in interfaceDataService
-
addPost
public boolean addPost(Post post)
- Specified by:
addPost
in interfaceDataService
-
editPost
public boolean editPost(int postId, String postText)
- Specified by:
editPost
in interfaceDataService
-
deletePost
public boolean deletePost(int postId)
- Specified by:
deletePost
in interfaceDataService
-
getCommentedPostsByUserId
public Collection<Post> getCommentedPostsByUserId(int userId)
- Specified by:
getCommentedPostsByUserId
in interfaceDataService
-
getLikedPostsByUserId
public Collection<Post> getLikedPostsByUserId(int userId)
- Specified by:
getLikedPostsByUserId
in interfaceDataService
-
getPostLikes
public Collection<Integer> getPostLikes(int postId)
- Specified by:
getPostLikes
in interfaceDataService
-
likePost
public boolean likePost(int postId, int userId)
- Specified by:
likePost
in interfaceDataService
-
unlikePost
public boolean unlikePost(int postId, int userId)
- Specified by:
unlikePost
in interfaceDataService
-
getComments
public Collection<Comment> getComments(int postId)
- Specified by:
getComments
in interfaceDataService
-
getCommentsByUserId
public Collection<Comment> getCommentsByUserId(int userId)
- Specified by:
getCommentsByUserId
in interfaceDataService
-
getComment
public Comment getComment(int commentId)
- Specified by:
getComment
in interfaceDataService
-
getUserIdFromCommentId
public Integer getUserIdFromCommentId(int commentId)
- Specified by:
getUserIdFromCommentId
in interfaceDataService
-
addComment
public boolean addComment(Comment comment)
- Specified by:
addComment
in interfaceDataService
-
editComment
public boolean editComment(int commentId, String commentText)
- Specified by:
editComment
in interfaceDataService
-
deleteComment
public boolean deleteComment(int commentId)
- Specified by:
deleteComment
in interfaceDataService
-
getCommentLikes
public Collection<Integer> getCommentLikes(int commentId)
- Specified by:
getCommentLikes
in interfaceDataService
-
likeComment
public boolean likeComment(int commentId, int userId)
- Specified by:
likeComment
in interfaceDataService
-
unlikeComment
public boolean unlikeComment(int commentId, int userId)
- Specified by:
unlikeComment
in interfaceDataService
-
getFollowerUserIds
public Collection<Integer> getFollowerUserIds(int userId)
- Specified by:
getFollowerUserIds
in interfaceDataService
-
getFollowingUserIds
public Collection<Integer> getFollowingUserIds(int userId)
- Specified by:
getFollowingUserIds
in interfaceDataService
-
followUser
public boolean followUser(int followerUserId, int followingUserId)
- Specified by:
followUser
in interfaceDataService
-
unfollowUser
public boolean unfollowUser(int followerUserId, int followingUserId)
- Specified by:
unfollowUser
in interfaceDataService
-
-