From b992dd4a1538094a0b3e8021b7f2d1b55eb5ba80 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Thu, 26 May 2016 12:06:59 +0000 Subject: [PATCH] integrated vre groups visualization git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/vre-members@128853 82a268e6-3cf1-43bd-a215-b396298e98cf --- pom.xml | 5 ++ .../vremembers/client/MembersService.java | 5 +- .../client/MembersServiceAsync.java | 6 +- .../client/panels/VREMembersPanel.java | 77 +++++++++++----- .../vremembers/server/MembersServiceImpl.java | 90 +++++++++++++++---- .../user/vremembers/shared/VREGroup.java | 68 ++++++++++++++ src/main/webapp/VreMembers.css | 20 ++++- 7 files changed, 226 insertions(+), 45 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/vremembers/shared/VREGroup.java diff --git a/pom.xml b/pom.xml index 1c29385..e5fd5a1 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,11 @@ + + org.gcube.common.portal + portal-manager + provided + com.google.gwt gwt-user diff --git a/src/main/java/org/gcube/portlets/user/vremembers/client/MembersService.java b/src/main/java/org/gcube/portlets/user/vremembers/client/MembersService.java index f8ebf2f..849ec61 100644 --- a/src/main/java/org/gcube/portlets/user/vremembers/client/MembersService.java +++ b/src/main/java/org/gcube/portlets/user/vremembers/client/MembersService.java @@ -3,6 +3,8 @@ package org.gcube.portlets.user.vremembers.client; import java.util.ArrayList; import org.gcube.portlets.user.vremembers.shared.BelongingUser; +import org.gcube.portlets.user.vremembers.shared.VREGroup; + import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -11,5 +13,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; */ @RemoteServiceRelativePath("memberservice") public interface MembersService extends RemoteService { - ArrayList getOrganizationUsers(); + ArrayList getSiteUsers(); + VREGroup getVREGroupUsers(String teamId); } diff --git a/src/main/java/org/gcube/portlets/user/vremembers/client/MembersServiceAsync.java b/src/main/java/org/gcube/portlets/user/vremembers/client/MembersServiceAsync.java index 297c5fa..b6d36bd 100644 --- a/src/main/java/org/gcube/portlets/user/vremembers/client/MembersServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/vremembers/client/MembersServiceAsync.java @@ -3,11 +3,13 @@ package org.gcube.portlets.user.vremembers.client; import java.util.ArrayList; import org.gcube.portlets.user.vremembers.shared.BelongingUser; - +import org.gcube.portlets.user.vremembers.shared.VREGroup; import com.google.gwt.user.client.rpc.AsyncCallback; public interface MembersServiceAsync { - void getOrganizationUsers(AsyncCallback> callback); + void getSiteUsers(AsyncCallback> callback); + + void getVREGroupUsers(String teamId, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/vremembers/client/panels/VREMembersPanel.java b/src/main/java/org/gcube/portlets/user/vremembers/client/panels/VREMembersPanel.java index 9e8c855..1f5d639 100644 --- a/src/main/java/org/gcube/portlets/user/vremembers/client/panels/VREMembersPanel.java +++ b/src/main/java/org/gcube/portlets/user/vremembers/client/panels/VREMembersPanel.java @@ -2,45 +2,82 @@ package org.gcube.portlets.user.vremembers.client.panels; import java.util.ArrayList; +import org.gcube.portal.databook.client.GCubeSocialNetworking; +import org.gcube.portal.databook.client.util.Encoder; import org.gcube.portlets.user.vremembers.client.MembersService; import org.gcube.portlets.user.vremembers.client.MembersServiceAsync; import org.gcube.portlets.user.vremembers.client.ui.DisplayBadge; import org.gcube.portlets.user.vremembers.shared.BelongingUser; +import org.gcube.portlets.user.vremembers.shared.VREGroup; -import com.github.gwtbootstrap.client.ui.Column; -import com.github.gwtbootstrap.client.ui.Row; +import com.github.gwtbootstrap.client.ui.PageHeader; import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.VerticalPanel; public class VREMembersPanel extends FlowPanel { private final MembersServiceAsync vreMemberService = GWT.create(MembersService.class); public VREMembersPanel() { - vreMemberService.getOrganizationUsers(new AsyncCallback>() { - @Override - public void onSuccess(ArrayList users) { - clear(); - if (users == null || users.isEmpty()) { - add(new HTML("
Ops, something went wrong. Please reload this page.
")); - } else { - for (int i = 0; i < users.size(); i++) { + //if showing a VRE Group + if (getGroupShowId() != null) { + String teamId = Encoder.decode(getGroupShowId()); + vreMemberService.getVREGroupUsers(teamId, new AsyncCallback() { - add(new DisplayBadge(users.get(i))); - } + @Override + public void onFailure(Throwable caught) { + add(new HTML("
" + + "Sorry, looks like something is broken with the server connection
" + + "Please check your connection and try refresh this page.
")); } - } - @Override - public void onFailure(Throwable caught) { - add(new HTML("
" + - "Sorry, looks like something is broken with the server connection
" + - "Please check your connection and try refresh this page.
")); + @Override + public void onSuccess(VREGroup group) { + clear(); + PageHeader toAdd = new PageHeader(); + toAdd.setText(group.getName()); + toAdd.setSubtext(group.getDescription()); + add(toAdd); + showMembers(group.getUsers()); + } + }); + + } else { //show all the VRE Members + vreMemberService.getSiteUsers(new AsyncCallback>() { + @Override + public void onSuccess(ArrayList users) { + clear(); + showMembers(users); + } + @Override + public void onFailure(Throwable caught) { + add(new HTML("
" + + "Sorry, looks like something is broken with the server connection
" + + "Please check your connection and try refresh this page.
")); + + } + }); + } + } + private void showMembers(ArrayList users) { + if (users == null || users.isEmpty()) { + add(new HTML("
")); + } else { + for (int i = 0; i < users.size(); i++) { + + add(new DisplayBadge(users.get(i))); } - }); + } + } + /** + * check if it has to show a group + * @return + */ + private String getGroupShowId() { + return Window.Location.getParameter(Encoder.encode(GCubeSocialNetworking.GROUP_MEMBERS_OID)); } } diff --git a/src/main/java/org/gcube/portlets/user/vremembers/server/MembersServiceImpl.java b/src/main/java/org/gcube/portlets/user/vremembers/server/MembersServiceImpl.java index 5a6a8ac..ac6570b 100644 --- a/src/main/java/org/gcube/portlets/user/vremembers/server/MembersServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/vremembers/server/MembersServiceImpl.java @@ -7,16 +7,25 @@ import java.util.List; import org.apache.commons.codec.binary.Base64; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; +import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean.Type; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portlets.user.vremembers.client.MembersService; import org.gcube.portlets.user.vremembers.shared.BelongingUser; +import org.gcube.portlets.user.vremembers.shared.VREGroup; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.UserManager; +import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; +import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault; +import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; +import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; +import org.gcube.vomanagement.usermanagement.model.GCubeGroup; +import org.gcube.vomanagement.usermanagement.model.GCubeTeam; import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,14 +77,55 @@ public class MembersServiceImpl extends RemoteServiceServlet implements MembersS return false; } } + @Override + public VREGroup getVREGroupUsers(String groupId) { + String scope = getASLSession().getScope(); + ArrayList groupUsers = new ArrayList(); + long teamId = -1; + try{ + teamId = Long.parseLong(groupId); + } catch (NumberFormatException e) { + _log.error("The groupId is not a valid long: " + groupId); + return null; + } + _log.info("Asking for members of team with id = " + groupId + " in scope: " + scope); + GCubeTeam team2Return = null; + GCubeGroup parent = null; + if (isWithinPortal()) { + List users = null; + try { + team2Return = new LiferayRoleManager().getTeam(teamId); + parent = new LiferayGroupManager().getGroup( team2Return.getGroupId()); + users = new LiferayUserManager().listUsersByTeam(teamId); + } catch (UserManagementSystemException | TeamRetrievalFault | UserRetrievalFault | GroupRetrievalFault e) { + e.printStackTrace(); + } + for (GCubeUser user : users) { + if (user.getUsername().compareTo("test.user") != 0) { //skip test.user + groupUsers.add( + new BelongingUser( + user.getUsername(), + user.getFullname(), + user.getUserAvatarURL(), + user.getJobTitle(), + user.getLocation_industry(), getUserProfileLink(user.getUsername() ), true)); + } + } + } else { //developmennt mode + _log.info("Returning test team members with id = " + groupId + " in scope: " + scope); + return new VREGroup(teamId, "TestTeam Name", "parent VRE", "Test Team Description", getTestUsers()); + } + return new VREGroup(teamId, team2Return.getTeamName(), parent.getGroupName(), team2Return.getDescription(), groupUsers); + } + /** * * @param session the Asl Session * @param withinPortal true when is on Liferay portal - * @return the users belonging to the current organization (scope) + * @return the users belonging to the current Site (VO/VRE) (scope) */ @Override - public ArrayList getOrganizationUsers() { + public ArrayList getSiteUsers() { ArrayList portalUsers = new ArrayList(); String scope = getASLSession().getScope(); if (scope == null) @@ -98,7 +148,7 @@ public class MembersServiceImpl extends RemoteServiceServlet implements MembersS users = um.listUsersByGroup(gm.getGroupId(orgName)); } else { - _log.error("Error, you must be in SCOPE VRE OR INFRASTURCTURE, you are in VO SCOPE returning no users"); + _log.error("Error, you must be in SCOPE VRE OR INFRASTRUCTURE, you are in VO SCOPE returning no users"); return portalUsers; } for (GCubeUser user : users) { @@ -115,16 +165,7 @@ public class MembersServiceImpl extends RemoteServiceServlet implements MembersS } else { //test users - portalUsers.add(new BelongingUser("massimiliano.assante", "Test User #1", "1111", "headline", "isti", "",false)); - portalUsers.add(new BelongingUser("pino.assante", "Test Second User #2", "1111", "headline1", "istitution complex", "",false)); - portalUsers.add(new BelongingUser("pino.pino", "With Photo Third User", "1111", "hard worker", "acme Ltd", "",true)); - portalUsers.add(new BelongingUser("giorgi.giorgi", "Test Fourth User", "1111", "hard worker 3", "isti3", "",false)); - portalUsers.add(new BelongingUser("pinetti.giorgi", "Test Fifth User", "1111", "hard worker 4", "super acme Inc.", "",false)); - portalUsers.add(new BelongingUser("massimiliano.pinetti", "Test Sixth User", "1111", "hard worker the5th", "istiw", "", false)); - portalUsers.add(new BelongingUser("giorgi.assante", "Ninth Testing User", "1111", "hard worker the9th", "istiw9", "",false)); - portalUsers.add(new BelongingUser("massimiliano.giorgi", "Eighth Testing User", "1111", "hard worker the8th", "istiw56", "", false)); - portalUsers.add(new BelongingUser("giogio.giorgi", "Seventh Test User", "1111", "hard worker the7th", "istiw7", "", false)); - portalUsers.add(new BelongingUser("pino.pinetti", "Tenth Testing User Photoed", "1111", "hard worker the10th", "istiw777", "",true)); + return getTestUsers(); } } catch (Exception e) { _log.error("Error in server get all contacts ", e); @@ -136,10 +177,23 @@ public class MembersServiceImpl extends RemoteServiceServlet implements MembersS private String getUserProfileLink(String username) { return (username.compareTo(getASLSession().getUsername()) != 0) ? - "profile?"+ new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+new String(Base64.encodeBase64(username.getBytes())) - : GCubeSocialNetworking.USER_PROFILE_LINK; + "profile?"+ new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+new String(Base64.encodeBase64(username.getBytes())) + : GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; } - - - + + private ArrayList getTestUsers() { + ArrayList portalUsers = new ArrayList(); + portalUsers.add(new BelongingUser("massimiliano.assante", "Test User #1", "http://placehold.it/200x200", "headline", "isti", "",false)); + portalUsers.add(new BelongingUser("pino.assante", "Test Second User #2", "http://placehold.it/200x200", "headline1", "istitution complex", "",false)); + portalUsers.add(new BelongingUser("pino.pino", "With Photo Third User", "http://placehold.it/200x200", "hard worker", "acme Ltd", "",true)); + portalUsers.add(new BelongingUser("giorgi.giorgi", "Test Fourth User", "http://placehold.it/200x200", "hard worker 3", "isti3", "",false)); + portalUsers.add(new BelongingUser("pinetti.giorgi", "Test Fifth User", "http://placehold.it/200x200", "hard worker 4", "super acme Inc.", "",false)); + portalUsers.add(new BelongingUser("massimiliano.pinetti", "Test Sixth User", "http://placehold.it/200x200", "hard worker the5th", "istiw", "", false)); + portalUsers.add(new BelongingUser("giorgi.assante", "Ninth Testing User", "http://placehold.it/200x200", "hard worker the9th", "istiw9", "",false)); + portalUsers.add(new BelongingUser("massimiliano.giorgi", "Eighth Testing User", "http://placehold.it/200x200", "hard worker the8th", "istiw56", "", false)); + portalUsers.add(new BelongingUser("giogio.giorgi", "Seventh Test User", "http://placehold.it/200x200", "hard worker the7th", "istiw7", "", false)); + portalUsers.add(new BelongingUser("pino.pinetti", "Tenth Testing User Photoed", "http://placehold.it/200x200", "hard worker the10th", "istiw777", "",true)); + return portalUsers; + } + } diff --git a/src/main/java/org/gcube/portlets/user/vremembers/shared/VREGroup.java b/src/main/java/org/gcube/portlets/user/vremembers/shared/VREGroup.java new file mode 100644 index 0000000..a615e8e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/vremembers/shared/VREGroup.java @@ -0,0 +1,68 @@ +package org.gcube.portlets.user.vremembers.shared; + +import java.io.Serializable; +import java.util.ArrayList; + +@SuppressWarnings("serial") +public class VREGroup implements Serializable{ + private long id; + private String name; + private String parentName; + private String description; + private ArrayList users; + public VREGroup() { + super(); + // TODO Auto-generated constructor stub + } + + public VREGroup(long id, String name, String parentName, + String description, ArrayList users) { + super(); + this.id = id; + this.name = name; + this.parentName = parentName; + this.description = description; + this.users = users; + } + + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getParentName() { + return parentName; + } + public void setParentName(String parentName) { + this.parentName = parentName; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + public ArrayList getUsers() { + return users; + } + + public void setUsers(ArrayList users) { + this.users = users; + } + + @Override + public String toString() { + return "VREGroup [id=" + id + ", name=" + name + ", parentName=" + + parentName + ", description=" + description + "]"; + } + + +} diff --git a/src/main/webapp/VreMembers.css b/src/main/webapp/VreMembers.css index 996c5ae..4b002c8 100644 --- a/src/main/webapp/VreMembers.css +++ b/src/main/webapp/VreMembers.css @@ -12,6 +12,21 @@ border: 1px solid #DBDBDB; } +.photo-details { + width: 200px; + text-align: center; +} + +/* For phones*/ +@media screen and (max-width: 520px) { + .framed { + width: 87%; + } + .photo-details { + width: 100%; + } +} + .frame { font-family: 'Helvetica Neue', Arial, sans-serif; padding: 10px; @@ -35,10 +50,7 @@ img.user-photo { float: left; } -.photo-details { - width: 200px; - text-align: center; -} + a.person-link { color: #444444;