Compatible with social model 2.0.0

This commit is contained in:
Ahmed Salah Tawfik Ibrahim 2024-01-31 18:08:31 +01:00
parent 3b827f3004
commit fe1bc73108
7 changed files with 34 additions and 24 deletions

View File

@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Removed HomeLibrary - Removed HomeLibrary
- Updated GWT version to latest - Updated GWT version to latest
- Removed Social Networking Library dependency #26534
## [v2.3.0] - 2021-02-02 ## [v2.3.0] - 2021-02-02

12
pom.xml
View File

@ -112,10 +112,16 @@
<artifactId>gcube-widgets</artifactId> <artifactId>gcube-widgets</artifactId>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- should be provided -->
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.social-networking</groupId>
<artifactId>social-networking-library</artifactId> <artifactId>social-service-model</artifactId>
<scope>provided</scope> <version>[1.2.0-SNAPSHOT, 2.0.0]</version>
</dependency>
<dependency>
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>

View File

@ -1,8 +1,8 @@
package org.gcube.portlet.user.userstatisticsportlet.client; package org.gcube.portlet.user.userstatisticsportlet.client;
import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.social_networking.socialnetworking.model.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder; import org.gcube.social_networking.socialnetworking.model.client.util.Encoder;
import org.gcube.portal.databook.shared.ShowUserStatisticAction; import org.gcube.social_networking.socialnetworking.model.shared.ShowUserStatisticAction;
import org.gcube.portlet.user.userstatisticsportlet.client.events.PageBusEvents; import org.gcube.portlet.user.userstatisticsportlet.client.events.PageBusEvents;
import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEvent; import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEvent;
import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEventHandler; import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEventHandler;

View File

@ -1,6 +1,6 @@
package org.gcube.portlet.user.userstatisticsportlet.client.events; package org.gcube.portlet.user.userstatisticsportlet.client.events;
import org.gcube.portal.databook.shared.ShowUserStatisticAction; import org.gcube.social_networking.socialnetworking.model.shared.ShowUserStatisticAction;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;

View File

@ -1,6 +1,6 @@
package org.gcube.portlet.user.userstatisticsportlet.client.ui; package org.gcube.portlet.user.userstatisticsportlet.client.ui;
import org.gcube.portal.databook.shared.ShowUserStatisticAction; import org.gcube.social_networking.socialnetworking.model.shared.ShowUserStatisticAction;
import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEvent; import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEvent;
import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Button;

View File

@ -17,9 +17,8 @@ import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.dsl.StorageHubClient; import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.portal.custom.communitymanager.SiteManagerUtil; import org.gcube.portal.custom.communitymanager.SiteManagerUtil;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.social_networking.social_networking_client_library.LibClient;
import org.gcube.portal.databook.server.DatabookStore; import org.gcube.social_networking.socialnetworking.model.shared.Post;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portlet.user.userstatisticsportlet.client.UserStatisticsService; import org.gcube.portlet.user.userstatisticsportlet.client.UserStatisticsService;
import org.gcube.portlet.user.userstatisticsportlet.server.cache.UserInfrastructureQuotaStorageCache; import org.gcube.portlet.user.userstatisticsportlet.server.cache.UserInfrastructureQuotaStorageCache;
import org.gcube.portlet.user.userstatisticsportlet.server.cache.UserInfrastructureSpaceCache; import org.gcube.portlet.user.userstatisticsportlet.server.cache.UserInfrastructureSpaceCache;
@ -50,7 +49,7 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
// private static final org.slf4j.Logger logger = LoggerFactory.getLogger(UserStatisticsServiceImpl.class); // private static final org.slf4j.Logger logger = LoggerFactory.getLogger(UserStatisticsServiceImpl.class);
private static final Log logger = LogFactoryUtil.getLog(UserStatisticsServiceImpl.class); private static final Log logger = LogFactoryUtil.getLog(UserStatisticsServiceImpl.class);
private DatabookStore store; private LibClient libClient;
private String quotaServiceBaseUrl; private String quotaServiceBaseUrl;
private static final String CUSTOM_FIELD_NAME_USER_STATISTICS_VISIBILITY = "show_user_statistics_other_people"; private static final String CUSTOM_FIELD_NAME_USER_STATISTICS_VISIBILITY = "show_user_statistics_other_people";
private UserManager userManager = new LiferayUserManager(); private UserManager userManager = new LiferayUserManager();
@ -59,18 +58,22 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
@Override @Override
public void init() { public void init() {
logger.info("Getting connection to Cassandra.."); logger.info("Getting connection to Cassandra..");
store = new DBCassandraAstyanaxImpl(); try {
libClient = new LibClient();
} catch (Exception e) {
throw new RuntimeException(e);
}
ServerUtils.createUserCustomField(CUSTOM_FIELD_NAME_USER_STATISTICS_VISIBILITY, true); ServerUtils.createUserCustomField(CUSTOM_FIELD_NAME_USER_STATISTICS_VISIBILITY, true);
logger.info("Retrieving quota service endpoint"); logger.info("Retrieving quota service endpoint");
quotaServiceBaseUrl = DiscoverQuotaServiceEndPoint.discover(); quotaServiceBaseUrl = DiscoverQuotaServiceEndPoint.discover();
} }
@Override /*@Override
public void destroy(){ public void destroy(){
logger.info("Closing connection to Cassandra"); logger.info("Closing connection to Cassandra");
store.closeConnection(); store.closeConnection();
} }*/
@Override @Override
public QuotaInfo getQuotaStorage(String userid) { public QuotaInfo getQuotaStorage(String userid) {
@ -284,9 +287,9 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
try { try {
long userId = userManager.getUserId(statisticsOfUsername); long userId = userManager.getUserId(statisticsOfUsername);
List<Feed> userPosts = store.getRecentFeedsByUserAndDate(statisticsOfUsername, oneYearAgo.getTimeInMillis()); List<Post> userPosts = libClient.getRecentPostsByUserAndDateLib(statisticsOfUsername, oneYearAgo.getTimeInMillis());
logger.debug("store.getRecentFeedsByUserAndDate"); logger.debug("store.getRecentFeedsByUserAndDate");
List<Feed> recentLikedFeeds = store.getRecentLikedFeedsByUserAndDate(statisticsOfUsername, oneYearAgo.getTimeInMillis()); List<Post> recentLikedFeeds = libClient.getRecentLikedPostsByUserAndDateLib(statisticsOfUsername, oneYearAgo.getTimeInMillis());
logger.debug("store.getRecentLikedFeedsByUserAndDate"); logger.debug("store.getRecentLikedFeedsByUserAndDate");
// Evaluate the contexts to use // Evaluate the contexts to use
@ -304,17 +307,17 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
long postCreated = 0, likesGot = 0, commentsGot = 0, commentsMade = 0, likesMade = 0; long postCreated = 0, likesGot = 0, commentsGot = 0, commentsMade = 0, likesMade = 0;
for (Feed feed : userPosts) { for (Post post : userPosts) {
if(contexts.contains(feed.getVreid())){ if(contexts.contains(post.getVreid())){
postCreated ++; postCreated ++;
commentsGot += Integer.parseInt(feed.getCommentsNo()); commentsGot += Integer.parseInt(post.getCommentsNo());
likesGot += Integer.parseInt(feed.getLikesNo()); likesGot += Integer.parseInt(post.getLikesNo());
} }
} }
for (Feed feed : recentLikedFeeds) { for (Post post : recentLikedFeeds) {
if(contexts.contains(feed.getVreid())) if(contexts.contains(post.getVreid()))
likesMade ++; likesMade ++;
} }

View File

@ -5,7 +5,7 @@
<!-- Other module inherits --> <!-- Other module inherits -->
<!-- <inherits name='org.gcube.portlets.widgets.widgettour.WidgetTour' /> --> <!-- <inherits name='org.gcube.portlets.widgets.widgettour.WidgetTour' /> -->
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' /> <inherits name='org.gcube.social_networking.socialnetworking.model.GCubeSocialNetworking' />
<!-- Bootstrap import --> <!-- Bootstrap import -->
<inherits name="com.github.gwtbootstrap.Bootstrap" /> <inherits name="com.github.gwtbootstrap.Bootstrap" />