diff --git a/.classpath b/.classpath index 4e26a04..6b27f71 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/com.google.gdt.eclipse.core.prefs b/.settings/com.google.gdt.eclipse.core.prefs index 0e7ca1a..356ce49 100644 --- a/.settings/com.google.gdt.eclipse.core.prefs +++ b/.settings/com.google.gdt.eclipse.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 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 warSrcDirIsOutput=false diff --git a/pom.xml b/pom.xml index ec53f29..3b5415a 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user join-vre war - 1.1.0-SNAPSHOT + 2.0.0-SNAPSHOT gCube Join VRE Portlet Display the available VRE to Join @@ -58,6 +58,11 @@ ${gwtVersion} provided + + com.github.gwtbootstrap + gwt-bootstrap + 2.3.2.0 + com.googlecode.gwtquery gwtquery diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java index 1edf58b..0c00b4b 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinService.java @@ -1,8 +1,11 @@ package org.gcube.portlets.user.joinvre.client; 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.VRECategory; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -15,7 +18,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @RemoteServiceRelativePath("JoinService") public interface JoinService extends RemoteService { - ArrayList getVREs(); + LinkedHashMap> getVREs(); Boolean joinVRE(Long vreID); diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java index 98df01b..746bf56 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinServiceAsync.java @@ -1,8 +1,11 @@ package org.gcube.portlets.user.joinvre.client; 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.VRECategory; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -12,7 +15,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback; */ public interface JoinServiceAsync { - void getVREs(AsyncCallback> callback); + void getVREs(AsyncCallback< LinkedHashMap>> callback); void joinVRE(Long vreID, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinVRE.java b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinVRE.java index 580e5df..ac3054a 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/JoinVRE.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/JoinVRE.java @@ -1,19 +1,19 @@ 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.GWT; import com.google.gwt.user.client.ui.RootPanel; /** - * Entry point classes define onModuleLoad(). * @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 void onModuleLoad() { - RootPanel.get("JoinVRE-Container").add(new JoinVREPanel()); + GWT.log("onModuleLoad"); + RootPanel.get("JoinVRE-Container").add(new ResponsivePanel()); } } diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/panels/JoinVREPanel.java b/src/main/java/org/gcube/portlets/user/joinvre/client/panels/JoinVREPanel.java deleted file mode 100644 index 800502b..0000000 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/panels/JoinVREPanel.java +++ /dev/null @@ -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>() { - - @Override - public void onSuccess(ArrayList vres) { - mainPanel.clear(); - mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); - mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); - - - if (vres == null || vres.isEmpty()) { - mainPanel.add(new HTML("
Ops, something went wrong. Please reload this page.
")); - } 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("
" + - "Sorry, looks like something is broken with the server connection
" + - "Please check your connection and try refresh this page.
")); - - } - - }); - 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); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/ResponsivePanel.java b/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/ResponsivePanel.java new file mode 100644 index 0000000..126a43f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/ResponsivePanel.java @@ -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>>() { + @Override + public void onSuccess(LinkedHashMap> 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> categories, VRECategory category) { + ArrayList 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("
")); + } +} + + + diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/VreThumbnail.java b/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/VreThumbnail.java new file mode 100644 index 0000000..f49497b --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/VreThumbnail.java @@ -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 { + } + 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() { + @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(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/VreThumbnail.ui.xml b/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/VreThumbnail.ui.xml new file mode 100644 index 0000000..a052d0a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/responsive/VreThumbnail.ui.xml @@ -0,0 +1,20 @@ + + + + .important { + font-weight: bold; + } + + + + + + + + + Info + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/DisplayVRE.java b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/DisplayVRE.java index 8409bb4..d57e3a8 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/DisplayVRE.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/DisplayVRE.java @@ -94,7 +94,7 @@ public class DisplayVRE extends Composite { vreName.setText(name); vreName.addClickHandler(descriptionHandler); - List categories = vre.getCategories(); + List categories = null; for(int i=0; i { + } + + @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(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/joinvre/client/ui/InfoPanel.ui.xml b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/InfoPanel.ui.xml new file mode 100644 index 0000000..b84b3d5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/joinvre/client/ui/InfoPanel.ui.xml @@ -0,0 +1,13 @@ + + + + + + + Close + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java b/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java index 219fb49..3e46b9c 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/server/JoinServiceImpl.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.LinkedHashMap; import java.util.List; 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.VRECategory; +import java.util.HashMap; + import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; @@ -46,7 +49,7 @@ import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil; */ @SuppressWarnings("serial") public class JoinServiceImpl extends RemoteServiceServlet implements JoinService { - + 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); } - + /** * when packaging test will fail if the user is not set to test.user * @return . @@ -72,7 +75,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService String user = "test.user"; return user; } - + /** * * @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) */ @Override - public ArrayList getVREs() { - ArrayList vres = new ArrayList(); + public LinkedHashMap> getVREs() { + LinkedHashMap> toReturn = new LinkedHashMap>(); try { if (isWithinPortal()) { - vres = getPortalOrganizationMappedToVRE(); + toReturn = getPortalOrganizationMappedToVRE(); } else { - List devsecCategories = new ArrayList(); - devsecCategories.add(new VRECategory(1, "Development")); + VRECategory devsecCategory = new VRECategory(1, "Development", "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."); + ArrayList vres = new ArrayList(); + vres.add(new VRE(0, "BiodiversityLab", "" + "

BiodiversityLab

" + "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 + "
  • cluster occurrence data;" + "
  • estimate similarities among habitats." + "" - + "", "", "", "/group/devsec", devsecCategories, 0,UserBelonging.NOT_BELONGING, false)); - vres.add(new VRE(0, "Scalable Data Mining", "" + + "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, false)); + vres.add(new VRE(0, "Scalable Data", "" + "

    Scalable Data Mining

    " + "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:
    • inspect species maps;
    • 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 + "
    • cluster occurrence data;" + "
    • estimate similarities among habitats." + "
    " - + "", "", "", "/group/devsec", devsecCategories, 0,UserBelonging.NOT_BELONGING, false)); - List devVRECategories = new ArrayList(devsecCategories); - devVRECategories.add(new VRECategory(2, "Sailing")); - vres.add(new VRE(1, "devVRE", "devVRE VRE description", "", "", "/group/devVRE", devVRECategories, 1, UserBelonging.NOT_BELONGING, false)); - List devmodeategories = new ArrayList(devsecCategories); - devmodeategories.add(new VRECategory(3, "Climbing")); - vres.add(new VRE(2, "devmode", "devmode VRE description", "", "", "/group/devmode", devmodeategories, 2, 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(4, "devsec3", "devsec VRE description", "", "", "/group/devsec", devsecCategories, 0, UserBelonging.NOT_BELONGING, false)); - vres.add(new VRE(5, "devsec4", "devsec VRE description", "", "", "/group/devsec", devsecCategories, 1, UserBelonging.NOT_BELONGING, false)); + + "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, true)); + toReturn.put(devsecCategory, vres); + + devsecCategory = new VRECategory(2, "Sailing", "Sailing prod desc"); + vres = new ArrayList(); + 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", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true)); + vres.add(new VRE(1, "StrategicInvestmentAnalysis", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", 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(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) { _log.error("Error getting VREs", e); } - - // Ordering VREs by Name - Collections.sort(vres, new Comparator(){ - @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; + + + return toReturn; } - + private String getPortalBasicUrl() { HttpServletRequest request = this.getThreadLocalRequest(); String protocol = (request.isSecure()) ? "https://" : "http://" ; @@ -167,9 +171,9 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService _log.debug(String.format("getPortalBasicUrl : %s", portalBasicUrl)); return portalBasicUrl; } - + private static final String REQUEST_BASED_GROUP = "Requestbasedgroup"; - + public boolean requireAccessGrant(Organization organization) throws PortalException, SystemException { try { long companyId = OrganizationsUtil.getCompany().getCompanyId(); @@ -178,7 +182,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false); PermissionThreadLocal.setPermissionChecker(permissionChecker); _log.trace("Setting Permission ok!"); - + 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)); return true; @@ -190,49 +194,37 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService return false; } } - - private static final String RELEVANCE = "Relevance"; - - public int getRelevance(Organization organization){ + + private static final String CATEGORY = "Virtualgroup"; + + public String getCategory(Organization organization){ try { long companyId = OrganizationsUtil.getCompany().getCompanyId(); - _log.trace("Setting Thread Permission"); + _log.info("Setting Thread Permission"); User user = UserLocalServiceUtil.getUserByScreenName(companyId, ScopeHelper.getAdministratorUsername()); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false); PermissionThreadLocal.setPermissionChecker(permissionChecker); - _log.trace("Setting Permission ok!"); - - if (organization.getExpandoBridge().getAttribute(RELEVANCE) == null || organization.getExpandoBridge().getAttribute(RELEVANCE).equals("")) { - _log.trace(String.format("Attribute %s not initialized. In this case by default Access Grant is permitted", RELEVANCE)); - return 0; + _log.info("Setting Permission ok!"); + + if (organization.getExpandoBridge().getAttribute(CATEGORY) == null || organization.getExpandoBridge().getAttribute(CATEGORY).equals("")) { + _log.warn(String.format("Attribute %s not initialized.", CATEGORY)); + return null; } else { - Integer relevanceValue = (Integer) organization.getExpandoBridge().getAttribute(RELEVANCE); - int relevance = relevanceValue.intValue(); - int maxAcceptableValue = Relevance.values().length - 1; - if(relevance > maxAcceptableValue){ - relevance = maxAcceptableValue; - } - return relevance; + String[] values = (String[]) organization.getExpandoBridge().getAttribute(CATEGORY); + System.out.println("RITORNA QUESTO -> " + values.toString()); + return values[0]; } } catch (Exception e) { - return 0; + e.printStackTrace(); + return "Exception "; } } + + + public LinkedHashMap> getPortalOrganizationMappedToVRE() throws SystemException, PortalException { + + LinkedHashMap> toReturn = new LinkedHashMap>(); - public List getCategory(Organization organization) throws SystemException{ - List categories = new ArrayList(); - long organizationPK = organization.getPrimaryKey(); - List categoryList = AssetCategoryLocalServiceUtil.getCategories(Organization.class.getName(), organizationPK); - for(AssetCategory assetCategory : categoryList){ - categories.add(new VRECategory(assetCategory.getCategoryId(), assetCategory.getName())); - } - return categories; - } - - public ArrayList getPortalOrganizationMappedToVRE() throws SystemException, PortalException { - - ArrayList vres = new ArrayList(); - List organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount()); Organization rootOrganization = null; for (Organization organization : organizations) { @@ -241,51 +233,65 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService break; } } - + try { _log.info("root: " + rootOrganization.getName() ); } 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"); - return new ArrayList(); + return toReturn; } - + ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); String imagePath = "/image"; if(themeDisplay!=null){ imagePath = themeDisplay.getPathImage(); } /*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 (Organization vOrg : rootOrganization.getSuborganizations()) { for (Organization vreOrganization : vOrg.getSuborganizations()) { long vreID = vreOrganization.getOrganizationId(); String vreName = vreOrganization.getName(); String vreDescription = (vreOrganization.getComments()!=null) ? vreOrganization.getComments() : ""; - + long logoId = vreOrganization.getLogoId(); 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); Group vreGroup = vreOrganization.getGroup(); String friendlyURL = vreGroup.getPathFriendlyURL(true, themeDisplay) + vreGroup.getFriendlyURL(); friendlyURL = String.format("%s%s", getPortalBasicUrl(), friendlyURL); - + boolean requireAccessGrant = requireAccessGrant(vreOrganization); - - List categories = getCategory(vreOrganization); + _log.debug(String.format("VRE preferences : %s", vreOrganization.getPreferences())); - int relevance = getRelevance(vreOrganization); - - vres.add(new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,friendlyURL, categories, relevance, UserBelonging.NOT_BELONGING, requireAccessGrant)); + String catName = getCategory(vreOrganization); + String[] splits = catName.split("\\|"); + 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 toUpdate = toReturn.get(toLookFor); + toUpdate.add(new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName,friendlyURL, UserBelonging.NOT_BELONGING, requireAccessGrant)); + } else { + ArrayList toCreate = new ArrayList(); + 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"; - + /** * read the root VO name from a property file and retuns it */ diff --git a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java index fbb1ad5..d6aca8d 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRE.java @@ -12,8 +12,7 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable protected boolean uponRequest; protected long id; - protected List categories; - protected int relevance; + public VRE() { super(); @@ -31,13 +30,10 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable * @param uponRequest */ public VRE(long id, String vreName, String description, String imageURL, - String vomsGroupName, String friendlyURL, List categories, int relevance, - UserBelonging userBelonging, boolean uponRequest) { + String vomsGroupName, String friendlyURL, UserBelonging userBelonging, boolean uponRequest) { super(vreName, description, imageURL, vomsGroupName, friendlyURL, userBelonging); this.uponRequest = uponRequest; this.id = id; - this.categories = categories; - this.relevance = relevance; } public boolean isUponRequest() { @@ -55,34 +51,6 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable 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 getCategories() { - return categories; - } - - /** - * @param categories the categories to set - */ - public void setCategories(List categories) { - this.categories = categories; - } - @Override public String toString() { return "VRE {" + getName() + ", "+ getFriendlyURL() + ", uponRequest=" + uponRequest+"}"; diff --git a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRECategory.java b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRECategory.java index e042dac..895f4a6 100644 --- a/src/main/java/org/gcube/portlets/user/joinvre/shared/VRECategory.java +++ b/src/main/java/org/gcube/portlets/user/joinvre/shared/VRECategory.java @@ -14,46 +14,58 @@ public class VRECategory implements Serializable, Comparable { protected long categoryID; protected String name; + protected String description; public VRECategory() { super(); } - /** - * @param categoryID - * @param name - */ - public VRECategory(long categoryID, String name) { + + + public VRECategory(long categoryID, String name, String description) { super(); this.categoryID = categoryID; this.name = name; + this.description = description; } - - /** - * @return the categoryID - */ + + public long getCategoryID() { return categoryID; } - /** - * @param categoryID the categoryID to set - */ + + + public void setCategoryID(long categoryID) { this.categoryID = categoryID; } - /** - * @return the name - */ + + + public String getName() { return name; } - /** - * @param name the name to set - */ + + + public void setName(String name) { this.name = name; } + + + public String getDescription() { + return description; + } + + + + public void setDescription(String description) { + this.description = description; + } + + + /** {@inheritDoc} */ @Override public int compareTo(VRECategory vreCategory) { diff --git a/src/main/resources/org/gcube/portlets/user/joinvre/JoinVRE.gwt.xml b/src/main/resources/org/gcube/portlets/user/joinvre/JoinVRE.gwt.xml index 58eef52..0471e0c 100644 --- a/src/main/resources/org/gcube/portlets/user/joinvre/JoinVRE.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/joinvre/JoinVRE.gwt.xml @@ -1,12 +1,12 @@ - - - + + - - + + + @@ -15,5 +15,5 @@ - + diff --git a/src/main/webapp/JoinVRE.css b/src/main/webapp/JoinVRE.css index 716bbfb..38e56ff 100644 --- a/src/main/webapp/JoinVRE.css +++ b/src/main/webapp/JoinVRE.css @@ -1,106 +1,3 @@ -.relevance { - color: #225f97; - 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; +body { + padding-top: 0px !important; } \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/JoinVRE_view.jsp b/src/main/webapp/WEB-INF/jsp/JoinVRE_view.jsp index 7b6adec..18be2e2 100644 --- a/src/main/webapp/WEB-INF/jsp/JoinVRE_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/JoinVRE_view.jsp @@ -7,7 +7,8 @@ --%> - + +