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
This commit is contained in:
parent
d1286a27e4
commit
b992dd4a15
5
pom.xml
5
pom.xml
|
@ -46,6 +46,11 @@
|
|||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-user</artifactId>
|
||||
|
|
|
@ -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<BelongingUser> getOrganizationUsers();
|
||||
ArrayList<BelongingUser> getSiteUsers();
|
||||
VREGroup getVREGroupUsers(String teamId);
|
||||
}
|
||||
|
|
|
@ -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<ArrayList<BelongingUser>> callback);
|
||||
void getSiteUsers(AsyncCallback<ArrayList<BelongingUser>> callback);
|
||||
|
||||
void getVREGroupUsers(String teamId, AsyncCallback<VREGroup> callback);
|
||||
}
|
||||
|
|
|
@ -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<ArrayList<BelongingUser>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<BelongingUser> users) {
|
||||
clear();
|
||||
if (users == null || users.isEmpty()) {
|
||||
add(new HTML("<div class=\"frame\" style=\"font-size: 16px;\">Ops, something went wrong. Please <a href=\"javascript: location.reload();\">reload<a/> this page.</div>"));
|
||||
} 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<VREGroup>() {
|
||||
|
||||
add(new DisplayBadge(users.get(i)));
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
add(new HTML("<div class=\"nofeed-message\">" +
|
||||
"Sorry, looks like something is broken with the server connection<br> " +
|
||||
"Please check your connection and try refresh this page.</div>"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
add(new HTML("<div class=\"nofeed-message\">" +
|
||||
"Sorry, looks like something is broken with the server connection<br> " +
|
||||
"Please check your connection and try refresh this page.</div>"));
|
||||
@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<ArrayList<BelongingUser>>() {
|
||||
@Override
|
||||
public void onSuccess(ArrayList<BelongingUser> users) {
|
||||
clear();
|
||||
showMembers(users);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
add(new HTML("<div class=\"nofeed-message\">" +
|
||||
"Sorry, looks like something is broken with the server connection<br> " +
|
||||
"Please check your connection and try refresh this page.</div>"));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private void showMembers(ArrayList<BelongingUser> users) {
|
||||
if (users == null || users.isEmpty()) {
|
||||
add(new HTML("<div class=\"frame\" style=\"font-size: 16px;\">Ops, something went wrong. Please <a href=\"javascript: location.reload();\">reload<a/> this page.</div>"));
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<BelongingUser> groupUsers = new ArrayList<BelongingUser>();
|
||||
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<GCubeUser> 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<BelongingUser> getOrganizationUsers() {
|
||||
public ArrayList<BelongingUser> getSiteUsers() {
|
||||
ArrayList<BelongingUser> portalUsers = new ArrayList<BelongingUser>();
|
||||
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<BelongingUser> getTestUsers() {
|
||||
ArrayList<BelongingUser> portalUsers = new ArrayList<BelongingUser>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<BelongingUser> users;
|
||||
public VREGroup() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public VREGroup(long id, String name, String parentName,
|
||||
String description, ArrayList<BelongingUser> 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<BelongingUser> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(ArrayList<BelongingUser> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VREGroup [id=" + id + ", name=" + name + ", parentName="
|
||||
+ parentName + ", description=" + description + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue