diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 4e4a3ad..91ca62e 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning diff --git a/.tern-project b/.tern-project new file mode 100644 index 0000000..d7fbf24 --- /dev/null +++ b/.tern-project @@ -0,0 +1,23 @@ +{ + "plugins": { + "guess-types": { + + }, + "outline": { + + }, + "liferay": { + + }, + "yui3": { + + }, + "aui2.0.x": { + + } + }, + "libs": [ + "ecma5", + "browser" + ] +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4b63a5f..cd395b4 100644 --- a/pom.xml +++ b/pom.xml @@ -146,26 +146,6 @@ UTF-8 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2 - - - ${distroDirectory}/descriptor.xml - - - - - servicearchive - install - - single - - - - \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/thematicgateways/GatewaysConfigurationAction.java b/src/main/java/org/gcube/portlets/user/thematicgateways/GatewaysConfigurationAction.java index b8c864e..b17e4ad 100644 --- a/src/main/java/org/gcube/portlets/user/thematicgateways/GatewaysConfigurationAction.java +++ b/src/main/java/org/gcube/portlets/user/thematicgateways/GatewaysConfigurationAction.java @@ -20,9 +20,11 @@ public class GatewaysConfigurationAction extends DefaultConfigurationAction { PortletPreferences prefs = actionRequest.getPreferences(); String thematicGatewayIntro = prefs.getValue("thematicGatewayIntro", ""); - _log.info("thematicGatewayIntro = " + thematicGatewayIntro + " in GatewaysConfigurationAction.processAction() saved correctly"); - - + String sitesIdToExclude = prefs.getValue("sitesIdToExclude", ""); + String orderPerVRENumber = prefs.getValue("orderPerVRENumber","false"); + + _log.info("GatewaysConfigurationAction.processAction() saved correctly"); + } @Override diff --git a/src/main/java/org/gcube/portlets/user/thematicgateways/ThematicGateways.java b/src/main/java/org/gcube/portlets/user/thematicgateways/ThematicGateways.java index 4e99a2b..33a9b15 100644 --- a/src/main/java/org/gcube/portlets/user/thematicgateways/ThematicGateways.java +++ b/src/main/java/org/gcube/portlets/user/thematicgateways/ThematicGateways.java @@ -29,23 +29,22 @@ public class ThematicGateways extends MVCPortlet { @Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { groupsManager = new LiferayGroupManager(); - LinkedHashMap> theGateways = getGateways(groupsManager); + List theGateways = getGateways(groupsManager); renderRequest.setAttribute("theGateways", theGateways); super.render(renderRequest, renderResponse); } - public LinkedHashMap> getGateways(GroupManager groupsManager) { - LinkedHashMap> toReturn = new LinkedHashMap<>(); + public List getGateways(GroupManager groupsManager) { + List toReturn = new ArrayList<>(); try{ List candidateGateways = GroupLocalServiceUtil.getGroups(ManagementUtils.getCompany().getCompanyId(), 0, true); // real gateways have no children as well for (Group group : candidateGateways) { List children = group.getChildren(true); if(children == null || children.isEmpty()) - if(! (group.getFriendlyURL().equals("/guest") || group.getFriendlyURL().equals("/global") - || group.getName().equals("D4Science Developers")) ) {// skipping these sites + if(! (group.getFriendlyURL().equals("/guest") || group.getFriendlyURL().equals("/global") )) {// skipping these sites ArrayList theVRENames = new ArrayList<>(); LinkedHashMap> sites = getPortalSitesMappedToVRE(group.getGroupId()); for (VRECategory cat : sites.keySet()) { @@ -53,7 +52,7 @@ public class ThematicGateways extends MVCPortlet { theVRENames.add(vre.getName()); } } - toReturn.put(group, theVRENames); + toReturn.add(new Gateway(group, theVRENames)); _log.debug("Gateway " + group.getName() + " has " + theVRENames.size() + " VREs"); } } @@ -69,8 +68,6 @@ public class ThematicGateways extends MVCPortlet { * * @return the Virtual groups with their VREs in the order estabilished in * the LR Control Panel - * @throws SystemException - * @throws PortalException */ private LinkedHashMap> getPortalSitesMappedToVRE(long currentSiteGroupId) throws Exception { diff --git a/src/main/webapp/html/init.jsp b/src/main/webapp/html/init.jsp index 1d2fd3d..654c898 100644 --- a/src/main/webapp/html/init.jsp +++ b/src/main/webapp/html/init.jsp @@ -47,7 +47,7 @@ <%@ page import="com.liferay.portal.model.LayoutSet" %> <%@ page import="com.liferay.portal.webserver.WebServerServletTokenUtil" %> <%@ page import="com.liferay.portal.service.VirtualHostLocalServiceUtil" %> - +<%@ page import="org.gcube.portlets.user.thematicgateways.*" %> diff --git a/src/main/webapp/html/thematic-gateways-portlet/SortCriteria.jsp b/src/main/webapp/html/thematic-gateways-portlet/SortCriteria.jsp new file mode 100644 index 0000000..1b9f32d --- /dev/null +++ b/src/main/webapp/html/thematic-gateways-portlet/SortCriteria.jsp @@ -0,0 +1,9 @@ +<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %> + + + +
+

Please select the farm you wish to operate

+ You are assigned to more than one company + Farm. You can work on one farm at a time. +
\ No newline at end of file diff --git a/src/main/webapp/html/thematic-gateways-portlet/config.jsp b/src/main/webapp/html/thematic-gateways-portlet/config.jsp index 5263a2f..04471e4 100644 --- a/src/main/webapp/html/thematic-gateways-portlet/config.jsp +++ b/src/main/webapp/html/thematic-gateways-portlet/config.jsp @@ -6,18 +6,41 @@ Here you can customise the text to show on top <% String defaultText = "The following Infrastructure Gateways serve a number of Research Communities, each of which having a specific scientific domain and dedicated Virtual Research Environments / Virtual Laboratories."; - String thematicGatewayIntro = GetterUtil.getString(portletPreferences.getValue("thematicGatewayIntro", defaultText)); + String thematicGatewayIntro_cfg = GetterUtil + .getString(portletPreferences.getValue("thematicGatewayIntro", defaultText)); + + String sitesIdToExclude_cfg = GetterUtil + .getString(portletPreferences.getValue("sitesIdToExclude", StringPool.BLANK)); + + boolean orderPerVRENumber_cfg = GetterUtil + .getBoolean(portletPreferences.getValue("orderPerVRENumber", StringPool.FALSE)); %> + - + value="<%=thematicGatewayIntro_cfg%>" required="false"> + + + + diff --git a/src/main/webapp/html/thematic-gateways-portlet/thematic-gateways-portlet.jsp b/src/main/webapp/html/thematic-gateways-portlet/thematic-gateways-portlet.jsp index 267ceb7..5fb172c 100644 --- a/src/main/webapp/html/thematic-gateways-portlet/thematic-gateways-portlet.jsp +++ b/src/main/webapp/html/thematic-gateways-portlet/thematic-gateways-portlet.jsp @@ -4,56 +4,82 @@ pageContext.setAttribute("thematicGatewayIntro", GetterUtil.getString(portletPreferences.getValue("thematicGatewayIntro", StringPool.BLANK))); -LinkedHashMap> theGateways = (LinkedHashMap>) request.getAttribute("theGateways"); +String sitesIdToExclude = GetterUtil.getString(portletPreferences.getValue("sitesIdToExclude", StringPool.BLANK)); + +List groupIds2Exclude = new ArrayList(); +if (sitesIdToExclude != null && sitesIdToExclude.compareTo("") != 0) { + String[] groups2Exclude = sitesIdToExclude.split(","); + for (int i = 0; i < groups2Exclude.length; i++) { + groupIds2Exclude.add(Long.parseLong(groups2Exclude[i])); + } +} + +boolean sortByVRENumber = GetterUtil.getBoolean(portletPreferences.getValue("orderPerVRENumber", StringPool.FALSE)); + +List theGateways = (List) request.getAttribute("theGateways"); +if (sortByVRENumber) + Collections.sort(theGateways, new GatewayComparator()); + +Map> theGatewaysMap = new LinkedHashMap>(); List visibleGroups = new ArrayList(); -visibleGroups.addAll(theGateways.keySet()); +//this for constructs the (perhaps sorted list to show and exclude the groupIds of the sites specieified in the config) +for (Gateway gat : theGateways) { + if (!groupIds2Exclude.contains(gat.getSite().getGroupId())) { + theGatewaysMap.put(gat.getSite(), gat.getVres()); + visibleGroups.add(gat.getSite()); + } +} + PortletURL portletURL = PortletURLFactoryUtil.create(request, portletDisplay.getId(), plid, PortletRequest.RENDER_PHASE); %> -
-${thematicGatewayIntro} -
- +
+ ${thematicGatewayIntro} + +
+ + + <% + total = visibleGroups.size(); + searchContainer.setTotal(total); + %> + + + + + <% + LayoutSet layoutSet = null; + + if (childGroup.hasPublicLayouts()) { + layoutSet = childGroup.getPublicLayoutSet(); + } + else { + layoutSet = childGroup.getPrivateLayoutSet(); + } + int vresNumber = theGatewaysMap.get(childGroup).size(); + String labelVRE = (vresNumber > 1) ? "VREs / VLabs" : "VRE / VLab"; + String theTitle = HtmlUtil.escape(childGroup.getDescriptiveName(locale)) + ", " + vresNumber + " " + labelVRE; + String theDescription = HtmlUtil.escape(childGroup.getDescription()); + + final long companyId = PortalUtil.getDefaultCompanyId(); + long layoutSetId = layoutSet.getLayoutSetId(); + String vHost = VirtualHostLocalServiceUtil.getVirtualHost(companyId, layoutSetId).getHostname(); + String theURL = "https://"+vHost+"/explore"; + %> + + + - <% - total = visibleGroups.size(); - searchContainer.setTotal(total); - %> - - - - - <% - LayoutSet layoutSet = null; - - if (childGroup.hasPublicLayouts()) { - layoutSet = childGroup.getPublicLayoutSet(); - } - else { - layoutSet = childGroup.getPrivateLayoutSet(); - } - int vresNumber = theGateways.get(childGroup).size(); - String labelVRE = (vresNumber > 1) ? "VREs / VLabs" : "VRE / VLab"; - String theTitle = HtmlUtil.escape(childGroup.getDescriptiveName(locale)) + ", " + vresNumber + " " + labelVRE; - String theDescription = HtmlUtil.escape(childGroup.getDescription()); - - final long companyId = PortalUtil.getDefaultCompanyId(); - long layoutSetId = layoutSet.getLayoutSetId(); - String vHost = VirtualHostLocalServiceUtil.getVirtualHost(companyId, layoutSetId).getHostname(); - String theURL = "https://"+vHost+"/explore"; - %> - - - - - - \ No newline at end of file + + + +