almost reimplemented with group of text values instead of relevances, integrated gwt bottstrao removed all the previous client code

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@117777 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-09-02 17:26:00 +00:00
parent 6482927a94
commit ad4a84dd58
19 changed files with 404 additions and 360 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/join-vre-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/join-vre-2.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/join-vre-1.1.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/join-vre-2.0.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,5 +1,5 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
jarsExcludedFromWebInfLib= jarsExcludedFromWebInfLib=
lastWarOutDir=/home/lucafrosini/workspace/join-vre/target/join-vre-1.0.0-SNAPSHOT lastWarOutDir=/Users/massi/Documents/workspace/join-vre/target/join-vre-2.0.0-SNAPSHOT
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>join-vre</artifactId> <artifactId>join-vre</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.1.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
<name>gCube Join VRE Portlet</name> <name>gCube Join VRE Portlet</name>
<description>Display the available VRE to Join</description> <description>Display the available VRE to Join</description>
@ -58,6 +58,11 @@
<version>${gwtVersion}</version> <version>${gwtVersion}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.github.gwtbootstrap</groupId>
<artifactId>gwt-bootstrap</artifactId>
<version>2.3.2.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.googlecode.gwtquery</groupId> <groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery</artifactId> <artifactId>gwtquery</artifactId>

View File

@ -1,8 +1,11 @@
package org.gcube.portlets.user.joinvre.client; package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import org.gcube.portlets.user.joinvre.shared.VRE; import org.gcube.portlets.user.joinvre.shared.VRE;
import org.gcube.portlets.user.joinvre.shared.VRECategory;
import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -15,7 +18,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("JoinService") @RemoteServiceRelativePath("JoinService")
public interface JoinService extends RemoteService { public interface JoinService extends RemoteService {
ArrayList<VRE> getVREs(); LinkedHashMap<VRECategory, ArrayList<VRE>> getVREs();
Boolean joinVRE(Long vreID); Boolean joinVRE(Long vreID);

View File

@ -1,8 +1,11 @@
package org.gcube.portlets.user.joinvre.client; package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import org.gcube.portlets.user.joinvre.shared.VRE; import org.gcube.portlets.user.joinvre.shared.VRE;
import org.gcube.portlets.user.joinvre.shared.VRECategory;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
@ -12,7 +15,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
*/ */
public interface JoinServiceAsync { public interface JoinServiceAsync {
void getVREs(AsyncCallback<ArrayList<VRE>> callback); void getVREs(AsyncCallback< LinkedHashMap<VRECategory, ArrayList<VRE>>> callback);
void joinVRE(Long vreID, AsyncCallback<Boolean> callback); void joinVRE(Long vreID, AsyncCallback<Boolean> callback);
} }

View File

@ -1,19 +1,19 @@
package org.gcube.portlets.user.joinvre.client; package org.gcube.portlets.user.joinvre.client;
import org.gcube.portlets.user.joinvre.client.panels.JoinVREPanel; import org.gcube.portlets.user.joinvre.client.responsive.ResponsivePanel;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.RootPanel;
/** /**
* Entry point classes define <code>onModuleLoad()</code>.
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/ */
public class JoinVRE implements EntryPoint { public class JoinVRE implements EntryPoint {
public void onModuleLoad() { public void onModuleLoad() {
RootPanel.get("JoinVRE-Container").add(new JoinVREPanel()); GWT.log("onModuleLoad");
RootPanel.get("JoinVRE-Container").add(new ResponsivePanel());
} }
} }

View File

@ -1,99 +0,0 @@
package org.gcube.portlets.user.joinvre.client.panels;
import java.util.ArrayList;
import org.gcube.portlets.user.joinvre.client.JoinService;
import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
import org.gcube.portlets.user.joinvre.client.ui.DisplayVRE;
import org.gcube.portlets.user.joinvre.shared.VRE;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public class JoinVREPanel extends Composite {
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final JoinServiceAsync joinService = GWT.create(JoinService.class);
public static final String loading = GWT.getModuleBaseURL() + "../images/vre-loader.gif";
private VerticalPanel mainPanel;
public JoinVREPanel() {
super();
this.mainPanel = new VerticalPanel();
showLoader();
joinService.getVREs(new AsyncCallback<ArrayList<VRE>>() {
@Override
public void onSuccess(ArrayList<VRE> vres) {
mainPanel.clear();
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
if (vres == null || vres.isEmpty()) {
mainPanel.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 {
int panelSize = vres.get(vres.size()-1).getRelevance();
FlowPanel[] panels = new FlowPanel[panelSize];
int last = -1;
for (VRE vre : vres) {
int relevance = vre.getRelevance();
if(last < relevance){
panels[relevance] = new FlowPanel();
Label label = new Label(Relevance.values()[relevance].name().replace('_', ' '));
label.addStyleName("relevance");
if(relevance == 0){
label.addStyleName("first");
}
panels[relevance].add(label);
mainPanel.add(panels[relevance]);
last = relevance;
}
panels[relevance].add(new DisplayVRE(vre));
}
}
}
@Override
public void onFailure(Throwable caught) {
mainPanel.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>"));
}
});
initWidget(mainPanel);
}
private void showLoader() {
mainPanel.clear();
mainPanel.setWidth("100%");
mainPanel.setHeight("300px");
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
Image loadingImage = new Image(loading);
mainPanel.add(loadingImage);
}
}

View File

@ -0,0 +1,84 @@
package org.gcube.portlets.user.joinvre.client.responsive;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import org.gcube.portlets.user.joinvre.client.JoinService;
import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
import org.gcube.portlets.user.joinvre.shared.VRE;
import org.gcube.portlets.user.joinvre.shared.VRECategory;
import com.github.gwtbootstrap.client.ui.Column;
import com.github.gwtbootstrap.client.ui.Image;
import com.github.gwtbootstrap.client.ui.PageHeader;
import com.github.gwtbootstrap.client.ui.Row;
import com.github.gwtbootstrap.client.ui.ThumbnailLink;
import com.github.gwtbootstrap.client.ui.Thumbnails;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
public class ResponsivePanel extends Composite {
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final JoinServiceAsync joinService = GWT.create(JoinService.class);
public static final String loading = GWT.getModuleBaseURL() + "../images/vre-loader.gif";
private VerticalPanel mainPanel = new VerticalPanel();
public ResponsivePanel() {
GWT.log("ResponsivePanel()");
joinService.getVREs(new AsyncCallback<LinkedHashMap<VRECategory, ArrayList<VRE>>>() {
@Override
public void onSuccess(LinkedHashMap<VRECategory, ArrayList<VRE>> categories) {
mainPanel.clear();
if (categories == null || categories.isEmpty()) {
showError("Ops, something went wrong");
}
else {
for (VRECategory cat : categories.keySet()) {
GWT.log("cat: " + cat.getName());
PageHeader header = new PageHeader();
header.setText(cat.getName());
header.setSubtext(cat.getDescription());
mainPanel.add(header);
mainPanel.add(getVREThumbnails(categories, cat));
// }
}
}
}
@Override
public void onFailure(Throwable caught) {
showError("Sorry, looks like something is broken with the server connection");
}
});
initWidget(mainPanel);
}
private Thumbnails getVREThumbnails(LinkedHashMap<VRECategory, ArrayList<VRE>> categories, VRECategory category) {
ArrayList<VRE> vres = categories.get(category);
Thumbnails toReturn = new Thumbnails();
for (VRE vre : vres) {
VreThumbnail thumb = new VreThumbnail(vre);
toReturn.add(thumb);
}
return toReturn;
}
protected void showError(String message) {
mainPanel.clear();
mainPanel.add(new HTML("<div class=\"frame\" style=\"font-size: 16px;\">" + message + ". Please <a href=\"javascript: location.reload();\">reload</a> this page.</div>"));
}
}

View File

@ -0,0 +1,86 @@
package org.gcube.portlets.user.joinvre.client.responsive;
import org.gcube.portlets.user.joinvre.client.JoinService;
import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
import org.gcube.portlets.user.joinvre.client.ui.InfoDialog;
import org.gcube.portlets.user.joinvre.client.ui.InfoPanel;
import org.gcube.portlets.user.joinvre.shared.VRE;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Heading;
import com.github.gwtbootstrap.client.ui.Image;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class VreThumbnail extends Composite {
private static VreThumbnailUiBinder uiBinder = GWT
.create(VreThumbnailUiBinder.class);
interface VreThumbnailUiBinder extends UiBinder<Widget, VreThumbnail> {
}
private final JoinServiceAsync joinService = GWT.create(JoinService.class);
@UiField Heading vreName;
@UiField Image vreImage;
@UiField Button joinButton;
@UiField Button vreInfoButton;
private VRE myVre;
public VreThumbnail(VRE vre) {
initWidget(uiBinder.createAndBindUi(this));
this.myVre = vre;
String name = vre.getName();
if (name.length() > 22)
name = name.substring(0, 17) + "...";
vreName.setText(name);
if (vre.isUponRequest()) {
joinButton.setType(ButtonType.DEFAULT);
joinButton.setText("Request access");
} else {
joinButton.setType(ButtonType.PRIMARY);
joinButton.setText("Enter this VRE");
}
vreImage.setUrl(vre.getImageURL());
vreImage.setWidth("180px");
}
@UiHandler("joinButton")
void handleClick(ClickEvent e) {
joinService.joinVRE(myVre.getId(), new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
String error = "Error";
String errorDescription = "Error while trying to join to"
+ myVre.getName() + " VRE. Please Try again later. "
+ "If the problem persist contact system administrator";
Window.alert(errorDescription);
}
@Override
public void onSuccess(Boolean result) {
Window.open("/group/data-e-infrastructure-gateway/join-new?orgid="+myVre.getId(), "_self", "");
}
});
}
@UiHandler("vreInfoButton")
void infoClick(ClickEvent e) {
InfoPanel modal = new InfoPanel(myVre);
modal.show();
}
}

View File

@ -0,0 +1,20 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<b:Thumbnail size="3">
<b:Image ui:field="vreImage"/>
<!-- The Caption is optional -->
<b:Caption>
<b:Heading size="4" ui:field="vreName"></b:Heading>
<b:Paragraph ui:field="p">
<b:Button ui:field="joinButton"></b:Button>
<b:Button ui:field="vreInfoButton" type="INFO">Info</b:Button>
</b:Paragraph>
</b:Caption>
</b:Thumbnail>
</ui:UiBinder>

View File

@ -94,7 +94,7 @@ public class DisplayVRE extends Composite {
vreName.setText(name); vreName.setText(name);
vreName.addClickHandler(descriptionHandler); vreName.addClickHandler(descriptionHandler);
List<VRECategory> categories = vre.getCategories(); List<VRECategory> categories = null;
for(int i=0; i<categories.size(); i++){ for(int i=0; i<categories.size(); i++){
vreCategories.add(new Label(categories.get(i).getName())); vreCategories.add(new Label(categories.get(i).getName()));
if(i!=categories.size()-1){ if(i!=categories.size()-1){

View File

@ -0,0 +1,45 @@
package org.gcube.portlets.user.joinvre.client.ui;
import org.gcube.portlets.user.joinvre.shared.VRE;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.Modal;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
public class InfoPanel extends Composite {
private static InfoPanelUiBinder uiBinder = GWT.create(InfoPanelUiBinder.class);
interface InfoPanelUiBinder extends UiBinder<Widget, InfoPanel> {
}
@UiField Modal m;
@UiField HTML description;
@UiField Button close;
private VRE vre;
public InfoPanel(VRE toDisplay) {
initWidget(uiBinder.createAndBindUi(this));
vre = toDisplay;
}
public void show() {
m.setTitle("Scope of " + vre.getName());
description.setHTML(vre.getDescription());
m.add(description);
m.show();
}
@UiHandler("close")
void handleClick(ClickEvent e) {
m.hide();
}
}

View File

@ -0,0 +1,13 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<g:HTMLPanel>
<b:Modal ui:field="m" title="My Modal" backdrop="STATIC"
keyboard="true" animation="true">
<g:HTML ui:field="description"></g:HTML>
<b:ModalFooter>
<b:Button type="PRIMARY" ui:field="close">Close</b:Button>
</b:ModalFooter>
</b:Modal>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -21,6 +22,8 @@ import org.gcube.portlets.user.joinvre.shared.UserBelonging;
import org.gcube.portlets.user.joinvre.shared.VRE; import org.gcube.portlets.user.joinvre.shared.VRE;
import org.gcube.portlets.user.joinvre.shared.VRECategory; import org.gcube.portlets.user.joinvre.shared.VRECategory;
import java.util.HashMap;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
@ -46,7 +49,7 @@ import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil;
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class JoinServiceImpl extends RemoteServiceServlet implements JoinService { public class JoinServiceImpl extends RemoteServiceServlet implements JoinService {
private static Log _log = LogFactoryUtil.getLog(JoinServiceImpl.class); private static Log _log = LogFactoryUtil.getLog(JoinServiceImpl.class);
/** /**
@ -63,7 +66,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
} }
return SessionManager.getInstance().getASLSession(sessionID, user); return SessionManager.getInstance().getASLSession(sessionID, user);
} }
/** /**
* when packaging test will fail if the user is not set to test.user * when packaging test will fail if the user is not set to test.user
* @return . * @return .
@ -72,7 +75,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
String user = "test.user"; String user = "test.user";
return user; return user;
} }
/** /**
* *
* @return true if you're running into the portal, false if in development * @return true if you're running into the portal, false if in development
@ -93,15 +96,17 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
* @return the users belonging to the current organization (scope) * @return the users belonging to the current organization (scope)
*/ */
@Override @Override
public ArrayList<VRE> getVREs() { public LinkedHashMap<VRECategory, ArrayList<VRE>> getVREs() {
ArrayList<VRE> vres = new ArrayList<VRE>(); LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
try { try {
if (isWithinPortal()) { if (isWithinPortal()) {
vres = getPortalOrganizationMappedToVRE(); toReturn = getPortalOrganizationMappedToVRE();
} else { } else {
List<VRECategory> devsecCategories = new ArrayList<VRECategory>(); VRECategory devsecCategory = new VRECategory(1, "Development", "designed to apply Data Mining techniques to biological data. "
devsecCategories.add(new VRECategory(1, "Development")); + "The algorithms are executed in a distributed fashion on the e-Infrastructure nodes or on local multi-core machines.");
ArrayList<VRE> vres = new ArrayList<VRE>();
vres.add(new VRE(0, "BiodiversityLab", "" vres.add(new VRE(0, "BiodiversityLab", ""
+ "<h2>BiodiversityLab</h2>" + "<h2>BiodiversityLab</h2>"
+ "The BiodiversityLab is a VRE designed to provide a collection of applications that allow scholars to perform complete experiments about " + "The BiodiversityLab is a VRE designed to provide a collection of applications that allow scholars to perform complete experiments about "
@ -115,8 +120,8 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
+ "<li> cluster occurrence data;" + "<li> cluster occurrence data;"
+ "<li> estimate similarities among habitats." + "<li> estimate similarities among habitats."
+ "</ul>" + "</ul>"
+ "", "", "", "/group/devsec", devsecCategories, 0,UserBelonging.NOT_BELONGING, false)); + "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(0, "Scalable Data Mining", "" vres.add(new VRE(0, "Scalable Data", ""
+ "<h2>Scalable Data Mining</h2>" + "<h2>Scalable Data Mining</h2>"
+ "The Scalable Data Mining is a VRE designed to apply Data Mining techniques to biological data. The algorithms are executed in a distributed fashion on the e-Infrastructure nodes or on local multi-core machines. Scalability is thus meant as distributed data processing but even as services dynamically provided to the users. The system is scalable in the number of users and in the size of the data to process. Statistical data processing can be applied to perform Niche Modelling or Ecological Modelling experiments. Other applications can use general purpose techniques like Bayesian models. Time series of observations can be managed as well, in order to classify trends, catch anomaly patterns and perform simulations. The idea under the distributed computation for data mining techniques is to overcome common limitations that can happen when using statistical algorithms: " + "The Scalable Data Mining is a VRE designed to apply Data Mining techniques to biological data. The algorithms are executed in a distributed fashion on the e-Infrastructure nodes or on local multi-core machines. Scalability is thus meant as distributed data processing but even as services dynamically provided to the users. The system is scalable in the number of users and in the size of the data to process. Statistical data processing can be applied to perform Niche Modelling or Ecological Modelling experiments. Other applications can use general purpose techniques like Bayesian models. Time series of observations can be managed as well, in order to classify trends, catch anomaly patterns and perform simulations. The idea under the distributed computation for data mining techniques is to overcome common limitations that can happen when using statistical algorithms: "
+ "single individuals or groups of marine species. The VRE allows to: <ul> <li> inspect species maps;<li> produce a species distribution map by means of either an expert system (AquaMaps) or a machine learning model (e.g. Neural Networks);" + "single individuals or groups of marine species. The VRE allows to: <ul> <li> inspect species maps;<li> produce a species distribution map by means of either an expert system (AquaMaps) or a machine learning model (e.g. Neural Networks);"
@ -129,36 +134,35 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
+ "<li> cluster occurrence data;" + "<li> cluster occurrence data;"
+ "<li> estimate similarities among habitats." + "<li> estimate similarities among habitats."
+ "</ul>" + "</ul>"
+ "", "", "", "/group/devsec", devsecCategories, 0,UserBelonging.NOT_BELONGING, false)); + "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, true));
List<VRECategory> devVRECategories = new ArrayList<VRECategory>(devsecCategories); toReturn.put(devsecCategory, vres);
devVRECategories.add(new VRECategory(2, "Sailing"));
vres.add(new VRE(1, "devVRE", "devVRE VRE description", "", "", "/group/devVRE", devVRECategories, 1, UserBelonging.NOT_BELONGING, false)); devsecCategory = new VRECategory(2, "Sailing", "Sailing prod desc");
List<VRECategory> devmodeategories = new ArrayList<VRECategory>(devsecCategories); vres = new ArrayList<VRE>();
devmodeategories.add(new VRECategory(3, "Climbing")); vres.add(new VRE(1, "PerformanceEvaluationInAquaculture", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode", "devmode VRE description", "", "", "/group/devmode", devmodeategories, 2, UserBelonging.NOT_BELONGING, true)); vres.add(new VRE(2, "devmode", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(3, "devsec2", "devsec VRE description", "", "", "/group/devsec", devsecCategories, 0, UserBelonging.NOT_BELONGING, false)); vres.add(new VRE(1, "StrategicInvestmentAnalysis", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(4, "devsec3", "devsec VRE description", "", "", "/group/devsec", devsecCategories, 0, UserBelonging.NOT_BELONGING, false)); vres.add(new VRE(2, "devmode2", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(5, "devsec4", "devsec VRE description", "", "", "/group/devsec", devsecCategories, 1, UserBelonging.NOT_BELONGING, false)); vres.add(new VRE(1, "devVR3E", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode3", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE4", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode4", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE5", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode5", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE6", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode6", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE7", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmod76", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
toReturn.put(devsecCategory, vres);
} }
} catch (Exception e) { } catch (Exception e) {
_log.error("Error getting VREs", e); _log.error("Error getting VREs", e);
} }
// Ordering VREs by Name
Collections.sort(vres, new Comparator<VRE>(){ return toReturn;
@Override
public int compare(VRE vre1, VRE vre2) {
int relevanceDiff = vre1.getRelevance() - vre2.getRelevance();
if (relevanceDiff != 0) {
return relevanceDiff;
} else {
return vre1.getName().compareTo(vre2.getName());
}
}
});
return vres;
} }
private String getPortalBasicUrl() { private String getPortalBasicUrl() {
HttpServletRequest request = this.getThreadLocalRequest(); HttpServletRequest request = this.getThreadLocalRequest();
String protocol = (request.isSecure()) ? "https://" : "http://" ; String protocol = (request.isSecure()) ? "https://" : "http://" ;
@ -167,9 +171,9 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
_log.debug(String.format("getPortalBasicUrl : %s", portalBasicUrl)); _log.debug(String.format("getPortalBasicUrl : %s", portalBasicUrl));
return portalBasicUrl; return portalBasicUrl;
} }
private static final String REQUEST_BASED_GROUP = "Requestbasedgroup"; private static final String REQUEST_BASED_GROUP = "Requestbasedgroup";
public boolean requireAccessGrant(Organization organization) throws PortalException, SystemException { public boolean requireAccessGrant(Organization organization) throws PortalException, SystemException {
try { try {
long companyId = OrganizationsUtil.getCompany().getCompanyId(); long companyId = OrganizationsUtil.getCompany().getCompanyId();
@ -178,7 +182,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
_log.trace("Setting Permission ok!"); _log.trace("Setting Permission ok!");
if (organization.getExpandoBridge().getAttribute(REQUEST_BASED_GROUP) == null || organization.getExpandoBridge().getAttribute(REQUEST_BASED_GROUP).equals("")) { if (organization.getExpandoBridge().getAttribute(REQUEST_BASED_GROUP) == null || organization.getExpandoBridge().getAttribute(REQUEST_BASED_GROUP).equals("")) {
_log.trace(String.format("Attribute %s not initialized. In this case by default Access Grant is permitted", REQUEST_BASED_GROUP)); _log.trace(String.format("Attribute %s not initialized. In this case by default Access Grant is permitted", REQUEST_BASED_GROUP));
return true; return true;
@ -190,49 +194,37 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
return false; return false;
} }
} }
private static final String RELEVANCE = "Relevance"; private static final String CATEGORY = "Virtualgroup";
public int getRelevance(Organization organization){ public String getCategory(Organization organization){
try { try {
long companyId = OrganizationsUtil.getCompany().getCompanyId(); long companyId = OrganizationsUtil.getCompany().getCompanyId();
_log.trace("Setting Thread Permission"); _log.info("Setting Thread Permission");
User user = UserLocalServiceUtil.getUserByScreenName(companyId, ScopeHelper.getAdministratorUsername()); User user = UserLocalServiceUtil.getUserByScreenName(companyId, ScopeHelper.getAdministratorUsername());
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
PermissionThreadLocal.setPermissionChecker(permissionChecker); PermissionThreadLocal.setPermissionChecker(permissionChecker);
_log.trace("Setting Permission ok!"); _log.info("Setting Permission ok!");
if (organization.getExpandoBridge().getAttribute(RELEVANCE) == null || organization.getExpandoBridge().getAttribute(RELEVANCE).equals("")) { if (organization.getExpandoBridge().getAttribute(CATEGORY) == null || organization.getExpandoBridge().getAttribute(CATEGORY).equals("")) {
_log.trace(String.format("Attribute %s not initialized. In this case by default Access Grant is permitted", RELEVANCE)); _log.warn(String.format("Attribute %s not initialized.", CATEGORY));
return 0; return null;
} else { } else {
Integer relevanceValue = (Integer) organization.getExpandoBridge().getAttribute(RELEVANCE); String[] values = (String[]) organization.getExpandoBridge().getAttribute(CATEGORY);
int relevance = relevanceValue.intValue(); System.out.println("RITORNA QUESTO -> " + values.toString());
int maxAcceptableValue = Relevance.values().length - 1; return values[0];
if(relevance > maxAcceptableValue){
relevance = maxAcceptableValue;
}
return relevance;
} }
} catch (Exception e) { } catch (Exception e) {
return 0; e.printStackTrace();
return "Exception ";
} }
} }
public LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalOrganizationMappedToVRE() throws SystemException, PortalException {
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
public List<VRECategory> getCategory(Organization organization) throws SystemException{
List<VRECategory> categories = new ArrayList<VRECategory>();
long organizationPK = organization.getPrimaryKey();
List<AssetCategory> categoryList = AssetCategoryLocalServiceUtil.getCategories(Organization.class.getName(), organizationPK);
for(AssetCategory assetCategory : categoryList){
categories.add(new VRECategory(assetCategory.getCategoryId(), assetCategory.getName()));
}
return categories;
}
public ArrayList<VRE> getPortalOrganizationMappedToVRE() throws SystemException, PortalException {
ArrayList<VRE> vres = new ArrayList<VRE>();
List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount()); List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
Organization rootOrganization = null; Organization rootOrganization = null;
for (Organization organization : organizations) { for (Organization organization : organizations) {
@ -241,51 +233,65 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
break; break;
} }
} }
try { try {
_log.info("root: " + rootOrganization.getName() ); _log.info("root: " + rootOrganization.getName() );
} catch (NullPointerException e) { } catch (NullPointerException e) {
_log.error("Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder, unless your installing the Bundle"); _log.error("Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder, unless your installing the Bundle");
return new ArrayList<VRE>(); return toReturn;
} }
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
String imagePath = "/image"; String imagePath = "/image";
if(themeDisplay!=null){ if(themeDisplay!=null){
imagePath = themeDisplay.getPathImage(); imagePath = themeDisplay.getPathImage();
} /*If themeDisplay is null the user is not logged in. Needs to find a way to get it */ } /*If themeDisplay is null the user is not logged in. Needs to find a way to get it */
//for each root sub organizations (VO) //for each root sub organizations (VO)
for (Organization vOrg : rootOrganization.getSuborganizations()) { for (Organization vOrg : rootOrganization.getSuborganizations()) {
for (Organization vreOrganization : vOrg.getSuborganizations()) { for (Organization vreOrganization : vOrg.getSuborganizations()) {
long vreID = vreOrganization.getOrganizationId(); long vreID = vreOrganization.getOrganizationId();
String vreName = vreOrganization.getName(); String vreName = vreOrganization.getName();
String vreDescription = (vreOrganization.getComments()!=null) ? vreOrganization.getComments() : ""; String vreDescription = (vreOrganization.getComments()!=null) ? vreOrganization.getComments() : "";
long logoId = vreOrganization.getLogoId(); long logoId = vreOrganization.getLogoId();
String vreLogoURL = String.format("%s/organization_logo?img_id=%s&t=%s", imagePath, logoId, ImageServletTokenUtil.getToken(logoId)); String vreLogoURL = String.format("%s/organization_logo?img_id=%s&t=%s", imagePath, logoId, ImageServletTokenUtil.getToken(logoId));
String groupName = String.format("/%s/%s/%s", vOrg.getParentOrganization().getName(), vOrg.getName(), vreName); String groupName = String.format("/%s/%s/%s", vOrg.getParentOrganization().getName(), vOrg.getName(), vreName);
Group vreGroup = vreOrganization.getGroup(); Group vreGroup = vreOrganization.getGroup();
String friendlyURL = vreGroup.getPathFriendlyURL(true, themeDisplay) + vreGroup.getFriendlyURL(); String friendlyURL = vreGroup.getPathFriendlyURL(true, themeDisplay) + vreGroup.getFriendlyURL();
friendlyURL = String.format("%s%s", getPortalBasicUrl(), friendlyURL); friendlyURL = String.format("%s%s", getPortalBasicUrl(), friendlyURL);
boolean requireAccessGrant = requireAccessGrant(vreOrganization); boolean requireAccessGrant = requireAccessGrant(vreOrganization);
List<VRECategory> categories = getCategory(vreOrganization);
_log.debug(String.format("VRE preferences : %s", vreOrganization.getPreferences())); _log.debug(String.format("VRE preferences : %s", vreOrganization.getPreferences()));
int relevance = getRelevance(vreOrganization); String catName = getCategory(vreOrganization);
String[] splits = catName.split("\\|");
vres.add(new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,friendlyURL, categories, relevance, UserBelonging.NOT_BELONGING, requireAccessGrant)); catName = splits[0];
String description = splits[1];
VRECategory toLookFor = null;
for (VRECategory vre : toReturn.keySet()) {
if (vre.getName().compareTo(catName)==0)
toLookFor = vre;
}
System.out.println("\ngetCategory() ->" + catName);
if (toLookFor != null) {
ArrayList<VRE> toUpdate = toReturn.get(toLookFor);
toUpdate.add(new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,friendlyURL, UserBelonging.NOT_BELONGING, requireAccessGrant));
} else {
ArrayList<VRE> toCreate = new ArrayList<VRE>();
toCreate.add(new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,friendlyURL, UserBelonging.NOT_BELONGING, requireAccessGrant));
VRECategory cat = new VRECategory(1L, catName, description);
toReturn.put(cat, toCreate);
}
} }
} }
return vres; return toReturn;
} }
public static final String ROOT_ORG = "rootorganization"; public static final String ROOT_ORG = "rootorganization";
/** /**
* read the root VO name from a property file and retuns it * read the root VO name from a property file and retuns it
*/ */

View File

@ -12,8 +12,7 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable
protected boolean uponRequest; protected boolean uponRequest;
protected long id; protected long id;
protected List<VRECategory> categories;
protected int relevance;
public VRE() { public VRE() {
super(); super();
@ -31,13 +30,10 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable
* @param uponRequest * @param uponRequest
*/ */
public VRE(long id, String vreName, String description, String imageURL, public VRE(long id, String vreName, String description, String imageURL,
String vomsGroupName, String friendlyURL, List<VRECategory> categories, int relevance, String vomsGroupName, String friendlyURL, UserBelonging userBelonging, boolean uponRequest) {
UserBelonging userBelonging, boolean uponRequest) {
super(vreName, description, imageURL, vomsGroupName, friendlyURL, userBelonging); super(vreName, description, imageURL, vomsGroupName, friendlyURL, userBelonging);
this.uponRequest = uponRequest; this.uponRequest = uponRequest;
this.id = id; this.id = id;
this.categories = categories;
this.relevance = relevance;
} }
public boolean isUponRequest() { public boolean isUponRequest() {
@ -55,34 +51,6 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable
this.id = id; this.id = id;
} }
/**
* @return the relevance
*/
public int getRelevance() {
return relevance;
}
/**
* @param relevance the relevance to set
*/
public void setRelevance(int relevance) {
this.relevance = relevance;
}
/**
* @return the categories
*/
public List<VRECategory> getCategories() {
return categories;
}
/**
* @param categories the categories to set
*/
public void setCategories(List<VRECategory> categories) {
this.categories = categories;
}
@Override @Override
public String toString() { public String toString() {
return "VRE {" + getName() + ", "+ getFriendlyURL() + ", uponRequest=" + uponRequest+"}"; return "VRE {" + getName() + ", "+ getFriendlyURL() + ", uponRequest=" + uponRequest+"}";

View File

@ -14,46 +14,58 @@ public class VRECategory implements Serializable, Comparable<VRECategory> {
protected long categoryID; protected long categoryID;
protected String name; protected String name;
protected String description;
public VRECategory() { public VRECategory() {
super(); super();
} }
/**
* @param categoryID
* @param name public VRECategory(long categoryID, String name, String description) {
*/
public VRECategory(long categoryID, String name) {
super(); super();
this.categoryID = categoryID; this.categoryID = categoryID;
this.name = name; this.name = name;
this.description = description;
} }
/**
* @return the categoryID
*/
public long getCategoryID() { public long getCategoryID() {
return categoryID; return categoryID;
} }
/**
* @param categoryID the categoryID to set
*/
public void setCategoryID(long categoryID) { public void setCategoryID(long categoryID) {
this.categoryID = categoryID; this.categoryID = categoryID;
} }
/**
* @return the name
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* @param name the name to set
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int compareTo(VRECategory vreCategory) { public int compareTo(VRECategory vreCategory) {

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module rename-to='JoinVRE'> <module rename-to='JoinVRE'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.activity.Activity' />
<!-- <set-property name="user.agent" value="gecko1_8,safari" /> --> <inherits name="com.github.gwtbootstrap.Bootstrap" />
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' /> <set-property name="user.agent" value="gecko1_8,safari" />
<inherits name='com.google.gwt.query.Query'/>
<inherits name='com.google.gwt.query.Query' />
<!-- Other module inherits --> <!-- Other module inherits -->
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
@ -15,5 +15,5 @@
<!-- Specify the paths for translatable code --> <!-- Specify the paths for translatable code -->
<source path='client' /> <source path='client' />
<source path='shared' /> <source path='shared' />
<add-linker name="xsiframe" />
</module> </module>

View File

@ -1,106 +1,3 @@
.relevance { body {
color: #225f97; padding-top: 0px !important;
font-size: 22px;
font-weight: normal;
margin-top: 15px;
}
.relevance.first {
margin-top: 0;
}
.vreDesc {
padding: 0 3px;
font-size: 12px;
}
.frame-container {
display: inline-block;
}
.frame-container-border {
background: #FFF;
border-radius: 6px !important;
-moz-border-radius: 6px !important;
-webkit-border-radius: 6px !important;
border: 1px solid #9b9b9b;
margin: 3px;
}
.framed {
width: 160px;
padding: 10px;
margin: 5px;
background: #FFF;
border-radius: 6px !important;
-moz-border-radius: 6px !important;
-webkit-border-radius: 6px !important;
border: 1px solid #9b9b9b;
display: inline-block;
}
.framed:hover {
box-shadow: 5px 5px 10px 2px #9b9b9b;
box-shadow: 5px 5px 10px 2px #9b9b9b;
-webkit-box-shadow: 5px 5px 10px 2px #9b9b9b;
-moz-box-shadow: 5px 5px 10px 2px #9b9b9b;
}
.vreImageDetails {
width: 150px;
}
.vreImage {
border-radius: 6px !important;
-moz-border-radius: 6px !important;
-webkit-border-radius: 6px !important;
width: 146px;
height: 146px;
cursor:pointer;
}
.vreImage:hover, .vreName:hover {
opacity: 0.6;
filter: alpha(opacity=60);
}
.vreDetails {
padding: 5px;
}
.vreName {
color: #225f97;
font-size: 15px;
line-height: 18px;
padding: 2px 0;
cursor: pointer;
}
.vreCategories {
margin: 4px 0px;
font-size: 14px;
color: #9b9b9b;
line-height: 14px;
height: 28px;
}
.vreCategories > * {
display: inline-block;
}
.joinButton {
width: 100%;
margin: 0 !important;
font-weight: normal !important;
text-shadow: none !important;
color: #667 !important;
}
.freeAccessButton {
font-weight: normal !important;
text-shadow: none !important;
border-color: #B5D49B !important;
background-color: #d6e9c6 !important;
color: #3c763d !important;
} }

View File

@ -7,7 +7,8 @@
<portlet:defineObjects /> <portlet:defineObjects />
--%> --%>
<script type="text/javascript" src="<%=request.getContextPath()%>/JoinVRE/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/JoinVRE/js/bootstrap.min.js"></script>
<script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/JoinVRE/JoinVRE.nocache.js"></script> <script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/JoinVRE/JoinVRE.nocache.js"></script>
<div id="JoinVRE-Container"></div> <div id="JoinVRE-Container"></div>