implementation completed

This commit is contained in:
Massimiliano Assante 2019-10-24 17:35:57 +02:00
parent 7d761a9d3f
commit 9c5ece8131
9 changed files with 151 additions and 86 deletions

View File

@ -1,7 +1,12 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 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.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8 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.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning

23
.tern-project Normal file
View File

@ -0,0 +1,23 @@
{
"plugins": {
"guess-types": {
},
"outline": {
},
"liferay": {
},
"yui3": {
},
"aui2.0.x": {
}
},
"libs": [
"ecma5",
"browser"
]
}

20
pom.xml
View File

@ -146,26 +146,6 @@
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
<!-- SA Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -20,9 +20,11 @@ public class GatewaysConfigurationAction extends DefaultConfigurationAction {
PortletPreferences prefs = actionRequest.getPreferences(); PortletPreferences prefs = actionRequest.getPreferences();
String thematicGatewayIntro = prefs.getValue("thematicGatewayIntro", ""); 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 @Override

View File

@ -29,23 +29,22 @@ public class ThematicGateways extends MVCPortlet {
@Override @Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
groupsManager = new LiferayGroupManager(); groupsManager = new LiferayGroupManager();
LinkedHashMap<Group, ArrayList<String>> theGateways = getGateways(groupsManager); List<Gateway> theGateways = getGateways(groupsManager);
renderRequest.setAttribute("theGateways", theGateways); renderRequest.setAttribute("theGateways", theGateways);
super.render(renderRequest, renderResponse); super.render(renderRequest, renderResponse);
} }
public LinkedHashMap<Group, ArrayList<String>> getGateways(GroupManager groupsManager) { public List<Gateway> getGateways(GroupManager groupsManager) {
LinkedHashMap<Group, ArrayList<String>> toReturn = new LinkedHashMap<>(); List<Gateway> toReturn = new ArrayList<>();
try{ try{
List<Group> candidateGateways = GroupLocalServiceUtil.getGroups(ManagementUtils.getCompany().getCompanyId(), 0, true); List<Group> candidateGateways = GroupLocalServiceUtil.getGroups(ManagementUtils.getCompany().getCompanyId(), 0, true);
// real gateways have no children as well // real gateways have no children as well
for (Group group : candidateGateways) { for (Group group : candidateGateways) {
List<Group> children = group.getChildren(true); List<Group> children = group.getChildren(true);
if(children == null || children.isEmpty()) if(children == null || children.isEmpty())
if(! (group.getFriendlyURL().equals("/guest") || group.getFriendlyURL().equals("/global") if(! (group.getFriendlyURL().equals("/guest") || group.getFriendlyURL().equals("/global") )) {// skipping these sites
|| group.getName().equals("D4Science Developers")) ) {// skipping these sites
ArrayList<String> theVRENames = new ArrayList<>(); ArrayList<String> theVRENames = new ArrayList<>();
LinkedHashMap<VRECategory, ArrayList<VRE>> sites = getPortalSitesMappedToVRE(group.getGroupId()); LinkedHashMap<VRECategory, ArrayList<VRE>> sites = getPortalSitesMappedToVRE(group.getGroupId());
for (VRECategory cat : sites.keySet()) { for (VRECategory cat : sites.keySet()) {
@ -53,7 +52,7 @@ public class ThematicGateways extends MVCPortlet {
theVRENames.add(vre.getName()); theVRENames.add(vre.getName());
} }
} }
toReturn.put(group, theVRENames); toReturn.add(new Gateway(group, theVRENames));
_log.debug("Gateway " + group.getName() + " has " + theVRENames.size() + " VREs"); _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 * @return the Virtual groups with their VREs in the order estabilished in
* the LR Control Panel * the LR Control Panel
* @throws SystemException
* @throws PortalException
*/ */
private LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE(long currentSiteGroupId) throws Exception { private LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE(long currentSiteGroupId) throws Exception {

View File

@ -47,7 +47,7 @@
<%@ page import="com.liferay.portal.model.LayoutSet" %> <%@ page import="com.liferay.portal.model.LayoutSet" %>
<%@ page import="com.liferay.portal.webserver.WebServerServletTokenUtil" %> <%@ page import="com.liferay.portal.webserver.WebServerServletTokenUtil" %>
<%@ page import="com.liferay.portal.service.VirtualHostLocalServiceUtil" %> <%@ page import="com.liferay.portal.service.VirtualHostLocalServiceUtil" %>
<%@ page import="org.gcube.portlets.user.thematicgateways.*" %>
<portlet:defineObjects /> <portlet:defineObjects />

View File

@ -0,0 +1,9 @@
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<div class="alert alert-info">
<h4>Please select the farm you wish to operate</h4>
<strong>You are assigned to more than one company
Farm. You can work on one farm at a time.</strong>
</div>

View File

@ -6,18 +6,41 @@
Here you can customise the text to show on top 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 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));
%> %>
<aui:form action="<%=configurationURL%>" method="post" name="fm"> <aui:form action="<%=configurationURL%>" method="post" name="fm">
<aui:input name="<%=Constants.CMD%>" type="hidden" <aui:input name="<%=Constants.CMD%>" type="hidden"
value="<%=Constants.UPDATE%>" /> value="<%=Constants.UPDATE%>" />
<aui:input style="width: 100%;" name="preferences--thematicGatewayIntro--" type="text" <aui:input style="width: 100%;"
cssClass="text long-field" showRequiredLabel="true" label="Enter the text you want to display" name="preferences--thematicGatewayIntro--" type="text"
inlineField="false" inlineLabel="left" placeholder="thematic Gateway Introductory text" cssClass="text long-field" showRequiredLabel="true"
label="Enter the text you want to display" inlineField="false"
inlineLabel="left" placeholder="thematic Gateway Introductory text"
helpMessage="thematic Gateway Introductory text" helpMessage="thematic Gateway Introductory text"
value="<%=thematicGatewayIntro%>" required="false"> value="<%=thematicGatewayIntro_cfg%>" required="false">
</aui:input> </aui:input>
<aui:input style="width: 100%;" name="preferences--sitesIdToExclude--"
type="text" cssClass="text long-field" showRequiredLabel="true"
label="Enter the Site ID of the Sites to exclude" inlineField="false"
inlineLabel="left" placeholder="comma separated groupIds"
helpMessage="Enter the Site ID of the Sites (gateway Site) you want to exclude, comma separated"
value="<%=sitesIdToExclude_cfg%>" required="false">
</aui:input>
<aui:input
helpMessage="Check if you want to order the Gateways per number of VREs they contain (more on top)"
label="Order the Gateways per number of VREs (Default Alphabetically)"
name="preferences--orderPerVRENumber--" type="checkbox"
value="<%=orderPerVRENumber_cfg%>" />
<aui:button-row> <aui:button-row>
<aui:button type="submit" /> <aui:button type="submit" />
</aui:button-row> </aui:button-row>

View File

@ -4,56 +4,82 @@
pageContext.setAttribute("thematicGatewayIntro", pageContext.setAttribute("thematicGatewayIntro",
GetterUtil.getString(portletPreferences.getValue("thematicGatewayIntro", StringPool.BLANK))); GetterUtil.getString(portletPreferences.getValue("thematicGatewayIntro", StringPool.BLANK)));
LinkedHashMap<Group, ArrayList<String>> theGateways = (LinkedHashMap<Group, ArrayList<String>>) request.getAttribute("theGateways"); String sitesIdToExclude = GetterUtil.getString(portletPreferences.getValue("sitesIdToExclude", StringPool.BLANK));
List<Long> groupIds2Exclude = new ArrayList<Long>();
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<Gateway> theGateways = (List<Gateway>) request.getAttribute("theGateways");
if (sortByVRENumber)
Collections.sort(theGateways, new GatewayComparator());
Map<Group, ArrayList<String>> theGatewaysMap = new LinkedHashMap<Group, ArrayList<String>>();
List<Group> visibleGroups = new ArrayList<Group>(); List<Group> visibleGroups = new ArrayList<Group>();
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); PortletURL portletURL = PortletURLFactoryUtil.create(request, portletDisplay.getId(), plid, PortletRequest.RENDER_PHASE);
%> %>
<div class="lead"> <div class="lead">
${thematicGatewayIntro} ${thematicGatewayIntro}
</div>
<liferay-ui:search-container emptyResultsMessage="no-sites-were-found" iteratorURL="<%= portletURL %>"> </div>
<liferay-ui:search-container emptyResultsMessage="no-sites-were-found" iteratorURL="<%= portletURL %>">
<%
total = visibleGroups.size();
searchContainer.setTotal(total);
%>
<liferay-ui:search-container-results
results="<%= ListUtil.subList(visibleGroups, searchContainer.getStart(), searchContainer.getEnd()) %>" />
<liferay-ui:search-container-row className="com.liferay.portal.model.Group" modelVar="childGroup">
<%
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";
%>
<liferay-ui:app-view-entry
assetCategoryClassName="<%= Group.class.getName() %>"
assetCategoryClassPK="<%= childGroup.getGroupId() %>"
assetTagClassName="<%= Group.class.getName() %>"
assetTagClassPK="<%= childGroup.getGroupId() %>"
description="<%=theDescription%>"
displayStyle="descriptive" showCheckbox="<%= false %>"
thumbnailSrc='<%= themeDisplay.getPathImage() + "/layout_set_logo?img_id=" + layoutSet.getLogoId() + "&t=" + WebServerServletTokenUtil.getToken(layoutSet.getLogoId()) %>'
title="<%=theTitle %>"
url="<%= theURL %>" />
<% </liferay-ui:search-container-row>
total = visibleGroups.size();
searchContainer.setTotal(total); <liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
%> </liferay-ui:search-container>
<liferay-ui:search-container-results
results="<%= ListUtil.subList(visibleGroups, searchContainer.getStart(), searchContainer.getEnd()) %>" />
<liferay-ui:search-container-row className="com.liferay.portal.model.Group" modelVar="childGroup">
<%
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";
%>
<liferay-ui:app-view-entry
assetCategoryClassName="<%= Group.class.getName() %>"
assetCategoryClassPK="<%= childGroup.getGroupId() %>"
assetTagClassName="<%= Group.class.getName() %>"
assetTagClassPK="<%= childGroup.getGroupId() %>"
description="<%=theDescription%>"
displayStyle="descriptive" showCheckbox="<%= false %>"
thumbnailSrc='<%= themeDisplay.getPathImage() + "/layout_set_logo?img_id=" + layoutSet.getLogoId() + "&t=" + WebServerServletTokenUtil.getToken(layoutSet.getLogoId()) %>'
title="<%=theTitle %>"
url="<%= theURL %>" />
</liferay-ui:search-container-row>
<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
</liferay-ui:search-container>