From 82361090f754d59508d7396d79f4bccbf39e5c4f Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 7 Apr 2020 17:34:45 +0200 Subject: [PATCH 1/9] ref 18815: Accounting Dashboard Reminiscence https://support.d4science.org/issues/18815 Added detachedres-library --- .classpath | 6 +- .settings/org.eclipse.wst.common.component | 2 +- pom.xml | 12 +- .../application/controller/Controller.java | 16 ++- .../rpc/AccountingDashboardService.java | 5 +- .../rpc/AccountingDashboardServiceAsync.java | 6 +- .../AccountingDashboardServiceImpl.java | 9 +- .../server/accounting/AccountingService.java | 11 +- .../accounting/PortalContextTreeProvider.java | 105 ++++++++++++++---- .../shared/options/TreeOptions.java | 34 ++++++ .../AccountingServiceTest.java | 2 +- .../ISDetachedREsTest.java | 49 ++++++++ 12 files changed, 215 insertions(+), 42 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/accountingdashboard/shared/options/TreeOptions.java create mode 100644 src/test/java/org/gcube/portlets/user/accountingdashboard/ISDetachedREsTest.java diff --git a/.classpath b/.classpath index 5c0febd..38083dc 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -50,5 +50,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 822ca16..6d41532 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + diff --git a/pom.xml b/pom.xml index b8570ca..d83ea4b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,13 +7,13 @@ org.gcube.tools 1.1.0 - + 4.0.0 org.gcube.portlets.user accounting-dashboard - 1.2.0 + 1.3.0 war accounting-dashboard @@ -256,6 +256,14 @@ [1.0.0,2.0.0-SNAPSHOT) + + + org.gcube.infrastructure.detachedres + detachedres-library + [0.0.1,2.0.0-SNAPSHOT) + + + com.liferay.portal diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java index c67f751..4f8bb58 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java @@ -13,6 +13,7 @@ import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboar import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; +import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import com.google.gwt.event.shared.EventBus; @@ -37,6 +38,7 @@ public class Controller { private MonitorPresenter monitorPresenter; private ErrorPresenter errorPresenter; private InfoPresenter infoPresenter; + private TreeOptions treeOptions=null; @Inject Controller(@Named("ControllerEventBus") EventBus eventBus, AccountingDashboardServiceAsync service, @@ -47,6 +49,7 @@ public class Controller { this.errorPresenter = errorPresenter; this.infoPresenter = infoPresenter; //this.cache = new ApplicationCache(); + this.setTreeOptions(new TreeOptions(false)); } @@ -72,6 +75,14 @@ public class Controller { infoPresenter.infoMessage(info); } + public TreeOptions getTreeOptions() { + return treeOptions; + } + + public void setTreeOptions(TreeOptions treeOptions) { + this.treeOptions = treeOptions; + } + public void hello() { eventBus.fireEvent(new HelloEvent()); @@ -102,7 +113,7 @@ public class Controller { } public void getTree() { - service.getScopeData(new AsyncCallback() { + service.getScopeData(treeOptions,new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -123,7 +134,7 @@ public class Controller { public void getReport(RequestReportData requestReportData) { monitorPresenter.enable(true); - service.getReport(requestReportData, new AsyncCallback() { + service.getReport(requestReportData,treeOptions, new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -144,4 +155,5 @@ public class Controller { } + } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java index a44e87f..eeb4d41 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java @@ -4,6 +4,7 @@ import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException; +import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import com.google.gwt.user.client.rpc.RemoteService; @@ -26,8 +27,8 @@ public interface AccountingDashboardService extends RemoteService { */ public UserInfo hello() throws ServiceException; - public ScopeData getScopeData() throws ServiceException; + public ScopeData getScopeData(TreeOptions treeOptions) throws ServiceException; - public ReportData getReport(RequestReportData requestReportdata) throws ServiceException; + public ReportData getReport(RequestReportData requestReportdata, TreeOptions treeOptions) throws ServiceException; } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java index 51858d8..f5739b3 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java @@ -6,6 +6,7 @@ package org.gcube.portlets.user.accountingdashboard.client.rpc; import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; +import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import com.google.gwt.core.client.GWT; @@ -24,8 +25,9 @@ public interface AccountingDashboardServiceAsync { void hello(AsyncCallback callback); - void getScopeData(AsyncCallback callback); + void getScopeData(TreeOptions treeOptions, AsyncCallback callback); - void getReport(RequestReportData requestReportdata, AsyncCallback asyncCallback); + void getReport(RequestReportData requestReportdata, TreeOptions treeOptions, + AsyncCallback asyncCallback); } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java index ef56017..998c4e3 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java @@ -12,6 +12,7 @@ import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException; +import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,11 +66,11 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme } @Override - public ScopeData getScopeData() throws ServiceException { + public ScopeData getScopeData(TreeOptions treeOptions) throws ServiceException { try { logger.debug("AccountingDashboardServiceImpl getScopeData()"); ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest()); - AccountingService as = new AccountingService(getAccountingContext(serviceCredentials.getScope())); + AccountingService as = new AccountingService(getAccountingContext(serviceCredentials.getScope()),treeOptions); ScopeData scopeData = as.getTree(this.getThreadLocalRequest()); return scopeData; } catch (ServiceException e) { @@ -83,11 +84,11 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme } @Override - public ReportData getReport(RequestReportData requestReportData) throws ServiceException { + public ReportData getReport(RequestReportData requestReportData,TreeOptions treeOptions) throws ServiceException { try { logger.debug("AccountingDashboardServiceImpl getReport(): " + requestReportData); ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest()); - AccountingService as = new AccountingService(getAccountingContext(serviceCredentials.getScope())); + AccountingService as = new AccountingService(getAccountingContext(serviceCredentials.getScope()), treeOptions); ReportData reportData = as.getReport(this.getThreadLocalRequest(), requestReportData); return reportData; } catch (ServiceException e) { diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java index a6e07f9..0900edf 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java @@ -17,6 +17,7 @@ import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; import org.gcube.portlets.user.accountingdashboard.shared.data.SeriesData; import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException; +import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +32,7 @@ public class AccountingService { private AccountingDao dao; - public AccountingService(AccountingServiceType accountingServiceType) throws ServiceException { + public AccountingService(AccountingServiceType accountingServiceType, TreeOptions treeOptions) throws ServiceException { try { if (Constants.DEBUG_MODE) { return; @@ -41,6 +42,7 @@ public class AccountingService { logger.error("Invalid AccountingServiceType requested: null"); } + PortalContextTreeProvider portalContextTreeProvider=null; switch (accountingServiceType) { case CurrentScope: logger.debug("AccountingService: CurrentScope"); @@ -48,11 +50,14 @@ public class AccountingService { break; case PortalContex: logger.debug("AccountingService: PortalContext"); - dao = AccountingDao.get(new PortalContextTreeProvider(accountingServiceType)); + portalContextTreeProvider=new PortalContextTreeProvider(accountingServiceType); + dao = AccountingDao.get(portalContextTreeProvider); break; case Infrastructure: logger.debug("AccountingService: Infrastructure"); - dao = AccountingDao.get(new PortalContextTreeProvider(accountingServiceType)); + portalContextTreeProvider=new PortalContextTreeProvider(accountingServiceType); + portalContextTreeProvider.setTreeOptions(treeOptions); + dao = AccountingDao.get(portalContextTreeProvider); break; default: logger.debug("AccountingService: CurrentScope"); diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java index d58c2ae..eb85a09 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java @@ -13,8 +13,13 @@ import org.gcube.accounting.accounting.summary.access.impl.ContextTreeProvider; import org.gcube.accounting.accounting.summary.access.model.ScopeDescriptor; import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.PortalContext; +import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.DetachedREsBuilder; +import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs; +import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway; +import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO; import org.gcube.portlets.user.accountingdashboard.server.is.BuildInfraNode; import org.gcube.portlets.user.accountingdashboard.shared.is.InfraNode; +import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.model.GCubeGroup; @@ -42,8 +47,15 @@ public class PortalContextTreeProvider implements ContextTreeProvider { private static Logger logger = LoggerFactory.getLogger(PortalContextTreeProvider.class); private AccountingServiceType accountingServiceType; + private TreeOptions treeOptions; + public PortalContextTreeProvider(AccountingServiceType accountingServiceType) { this.accountingServiceType = accountingServiceType; + this.treeOptions = null; + } + + public void setTreeOptions(TreeOptions treeOptions){ + this.treeOptions=treeOptions; } static { @@ -74,7 +86,7 @@ public class PortalContextTreeProvider implements ContextTreeProvider { break; case Infrastructure: logger.debug("AccountingService: Infrastructure"); - root = recreateTreeForInfrastructure(request); + root = recreateTreeForInfrastructure(request, treeOptions); break; default: logger.debug("AccountingService: CurrentScope"); @@ -85,7 +97,7 @@ public class PortalContextTreeProvider implements ContextTreeProvider { return root; } - private ScopeDescriptor recreateTreeForInfrastructure(HttpServletRequest request) + private ScopeDescriptor recreateTreeForInfrastructure(HttpServletRequest request, TreeOptions treeOptions2) throws Exception, PortalException, SystemException { ScopeDescriptor infra = null; PortalContext portalContext = PortalContext.getConfiguration(); @@ -110,19 +122,19 @@ public class PortalContextTreeProvider implements ContextTreeProvider { currUser); if (infraNode != null) { - String scopeGroup=""; - if(gCubeGroup.getGroupName().toUpperCase().endsWith(" GATEWAY")){ - int l=gCubeGroup.getGroupName().length(); - scopeGroup=gCubeGroup.getGroupName().substring(0, l-8); + String scopeGroup = ""; + if (gCubeGroup.getGroupName().toUpperCase().endsWith(" GATEWAY")) { + int l = gCubeGroup.getGroupName().length(); + scopeGroup = gCubeGroup.getGroupName().substring(0, l - 8); } else { - scopeGroup=gCubeGroup.getGroupName(); + scopeGroup = gCubeGroup.getGroupName(); } - - StringBuilder gatewayScope=new StringBuilder(); + + StringBuilder gatewayScope = new StringBuilder(); gatewayScope.append(infrastructureScope); gatewayScope.append("/"); gatewayScope.append(scopeGroup); - + ScopeDescriptor infraNodeScopeDescriptor = createRelativeInfraNode(infraNode, gatewayScope.toString()); if (gatewayChildren != null) { gatewayChildren.addFirst(infraNodeScopeDescriptor); @@ -138,10 +150,59 @@ public class PortalContextTreeProvider implements ContextTreeProvider { infraChildren.add(gatewayScopeDescriptor); } + if (treeOptions != null && treeOptions.isShowDetachedREs()) { + logger.debug("Show DestachedREs"); + DetachedREs detachedREs = DetachedREsBuilder.build(infrastructureScope); + if (detachedREs != null && detachedREs.isEnabled()) { + logger.debug("DetachedREs is enabled"); + if (detachedREs.getGateways() != null && !detachedREs.getGateways().isEmpty()) { + for (String key : detachedREs.getGateways().keySet()) { + Gateway gateway = detachedREs.getGateways().get(key); + ScopeDescriptor getewaySD = new ScopeDescriptor(gateway.getName(), key); + LinkedList voChildren = retrieveVOChildren(gateway); + getewaySD.setChildren(voChildren); + infraChildren.add(getewaySD); + } + } + } else { + logger.debug("DetachedREs is disabled"); + } + } + infra.setChildren(infraChildren); return infra; } + private LinkedList retrieveVOChildren(Gateway gateway) { + if (gateway.getVos() != null && !gateway.getVos().isEmpty()) { + LinkedList vos = new LinkedList<>(); + for (String key : gateway.getVos().keySet()) { + VO vo = gateway.getVos().get(key); + ScopeDescriptor voSD = new ScopeDescriptor(vo.getName(), key); + LinkedList voChildren = retrieveVREChildren(vo); + voSD.setChildren(voChildren); + vos.add(voSD); + } + return vos; + } else { + return null; + } + } + + private LinkedList retrieveVREChildren(VO vo) { + if (vo.getVres() != null && !vo.getVres().isEmpty()) { + LinkedList vres = new LinkedList<>(); + for (String key : vo.getVres().keySet()) { + org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE vre = vo.getVres().get(key); + ScopeDescriptor vreSD = new ScopeDescriptor(vre.getName(), key); + vres.add(vreSD); + } + return vres; + } else { + return null; + } + } + private ScopeDescriptor createRelativeInfraNode(InfraNode infraNode, String scope) { StringBuilder absoluteScope = new StringBuilder(); absoluteScope.append(scope); @@ -164,28 +225,28 @@ public class PortalContextTreeProvider implements ContextTreeProvider { throws Exception, PortalException, SystemException { ScopeDescriptor root; - Group group=getSiteFromServletRequest(request); + Group group = getSiteFromServletRequest(request); long currentSiteGroupId = group.getGroupId(); - String gatewayName=group.getName(); - + String gatewayName = group.getName(); + PortalContext pContext = PortalContext.getConfiguration(); GCubeUser currUser = pContext.getCurrentUser(request); String portalScope = pContext.getCurrentScope(currentSiteGroupId + ""); - - String scopeGroup=""; - if(gatewayName.toUpperCase().endsWith(" GATEWAY")){ - int l=gatewayName.length(); - scopeGroup=gatewayName.substring(0, l-8); + + String scopeGroup = ""; + if (gatewayName.toUpperCase().endsWith(" GATEWAY")) { + int l = gatewayName.length(); + scopeGroup = gatewayName.substring(0, l - 8); } else { - scopeGroup=gatewayName; + scopeGroup = gatewayName; } - StringBuilder gatewayScope=new StringBuilder(); + StringBuilder gatewayScope = new StringBuilder(); gatewayScope.append(portalScope); gatewayScope.append("/"); gatewayScope.append(scopeGroup); - + InfraNode infraNode = BuildInfraNode.build(portalScope); - + LinkedList rootChildren = null; rootChildren = retrieveGatewayChildren(request, currentSiteGroupId, currUser); diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/options/TreeOptions.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/options/TreeOptions.java new file mode 100644 index 0000000..dad03bd --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/options/TreeOptions.java @@ -0,0 +1,34 @@ +package org.gcube.portlets.user.accountingdashboard.shared.options; + +import java.io.Serializable; + +/** + * + * @author Giancarlo Panichi + * + */ +public class TreeOptions implements Serializable { + + private static final long serialVersionUID = 730133583251742872L; + + private boolean showDetachedREs = false; + + public TreeOptions(boolean showDetachedREs) { + super(); + this.showDetachedREs = showDetachedREs; + } + + public boolean isShowDetachedREs() { + return showDetachedREs; + } + + public void setShowDetachedREs(boolean showDetachedREs) { + this.showDetachedREs = showDetachedREs; + } + + @Override + public String toString() { + return "TreeOptions [showDetachedREs=" + showDetachedREs + "]"; + } + +} diff --git a/src/test/java/org/gcube/portlets/user/accountingdashboard/AccountingServiceTest.java b/src/test/java/org/gcube/portlets/user/accountingdashboard/AccountingServiceTest.java index fe2fd99..96d12d2 100644 --- a/src/test/java/org/gcube/portlets/user/accountingdashboard/AccountingServiceTest.java +++ b/src/test/java/org/gcube/portlets/user/accountingdashboard/AccountingServiceTest.java @@ -24,7 +24,7 @@ public class AccountingServiceTest extends TestCase { try { AuthTest.setToken(); - new AccountingService(AccountingServiceType.CurrentScope); + new AccountingService(AccountingServiceType.CurrentScope,null); //accountingService.getTree(); assertTrue(true); diff --git a/src/test/java/org/gcube/portlets/user/accountingdashboard/ISDetachedREsTest.java b/src/test/java/org/gcube/portlets/user/accountingdashboard/ISDetachedREsTest.java new file mode 100644 index 0000000..bced63a --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/accountingdashboard/ISDetachedREsTest.java @@ -0,0 +1,49 @@ +/** + * + */ +package org.gcube.portlets.user.accountingdashboard; + +import org.gcube.infrastructure.detachedres.detachedreslibrary.server.DetachedREsClient; +import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs; +import org.gcube.portlets.user.accountingdashboard.shared.Constants; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import junit.framework.TestCase; + +/** + * + * @author Giancarlo Panichi + * + * + */ +public class ISDetachedREsTest extends TestCase { + + private static Logger logger = LoggerFactory.getLogger(ISDetachedREsTest.class); + + @Test + public void testAccountingDashboardResource() { + if (Constants.TEST_ENABLE) { + logger.debug("Test Enabled"); + + try { + DetachedREsClient detachedREsClient = new DetachedREsClient(Constants.DEFAULT_TOKEN); + DetachedREs detachedREs = detachedREsClient.getDetachedREsInScope(Constants.DEFAULT_SCOPE); + logger.debug("DetachedREs: " + detachedREs); + assertTrue(true); + + } catch (Exception e) { + logger.error(e.getLocalizedMessage(), e); + assertTrue("Error searching the resource!", false); + } + + } else { + logger.debug("Test Disabled"); + assertTrue(true); + } + } + + + +} From 4e5c3a9b4b470b776112843f31d88728ab84acbf Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 7 Apr 2020 17:56:56 +0200 Subject: [PATCH 2/9] ref 18815: Accounting Dashboard Reminiscence https://support.d4science.org/issues/18815 Added detachedres-library --- .../mainarea/filter/FilterAreaPresenter.java | 18 +++-- .../mainarea/filter/FilterAreaUiHandlers.java | 3 + .../mainarea/filter/FilterAreaView.java | 38 +++++++++ .../mainarea/filter/FilterAreaView.ui.xml | 78 +++++++++++-------- 4 files changed, 98 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java index 17f4782..d49c831 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java @@ -8,6 +8,7 @@ import org.gcube.portlets.user.accountingdashboard.client.application.controller import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; +import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.inject.Inject; @@ -47,7 +48,6 @@ public class FilterAreaPresenter extends PresenterWidget @UiField(provided = true) ListBox monthEnd; + @UiField(provided = true) + Button btnShowDetachedREs; + + @UiField(provided = true) + Button btnHideDetachedREs; + @UiField(provided = true) CellTree scopeTree; @@ -161,6 +171,30 @@ public class FilterAreaView extends ViewWithUiHandlers } }); + + logger.log(Level.FINE, "Configuring buttons DetachedREs"); + btnShowDetachedREs=new Button(); + btnShowDetachedREs.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + TreeOptions treeOptions=new TreeOptions(true); + getUiHandlers().updateTreeOptions(treeOptions); + } + }); + + btnHideDetachedREs=new Button(); + btnHideDetachedREs.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + TreeOptions treeOptions=new TreeOptions(false); + getUiHandlers().updateTreeOptions(treeOptions); + } + }); + + + logger.log(Level.FINE, "Configuring DataProvider"); dataProvider = new ListDataProvider(); RequestReportEventHandler handler = new RequestReportEventHandler() { @@ -177,10 +211,13 @@ public class FilterAreaView extends ViewWithUiHandlers ScopeTreeResources scopeTreeResources = GWT.create(ScopeTreeResources.class); scopeTree = new CellTree(scopeTreeModel, null, scopeTreeResources); scopeTree.setDefaultNodeSize(500); + + logger.log(Level.FINE, "FilterAreaView init end"); } @Override public void displayScopeData(ScopeData scopeData) { + logger.log(Level.FINE, "displayScopeData()"); ArrayList scopeDataList = new ArrayList<>(); scopeDataList.add(scopeData); this.scopeData = scopeData; @@ -194,6 +231,7 @@ public class FilterAreaView extends ViewWithUiHandlers } private void requestReport() { + logger.log(Level.FINE, "requestReport()"); String[] months = LocaleInfo.getCurrentLocale().getDateTimeFormatInfo().monthsFull(); logger.log(Level.FINE, "Months: " + months.length); diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml index 1cace33..4a661da 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml @@ -11,38 +11,50 @@ - Filters - - - - - From: - - - - - - Select the start date - - - - To: - - - - - - Select the end date - - - - - - - - + Filters + + + + + From: + + + + + + Select the start date + + + + To: + + + + + + Select the end date + + + + DetachedREs: + + + + + + + Show DetachedREs + + + + + + + + + From 3e0c975f914bc0a3bf773f0738e25ccbc95b11e7 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 7 Apr 2020 19:00:10 +0200 Subject: [PATCH 3/9] ref 18815: Accounting Dashboard Reminiscence https://support.d4science.org/issues/18815 Added detachedres-library --- .classpath | 6 +++--- .settings/org.eclipse.wst.common.component | 2 +- pom.xml | 2 +- .../mainarea/filter/FilterAreaView.java | 11 ++++++----- .../mainarea/filter/FilterAreaView.ui.xml | 16 ++++++++-------- .../client/resources/uiData.css | 2 +- .../shared/options/TreeOptions.java | 4 ++++ 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/.classpath b/.classpath index 38083dc..5c0febd 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -50,5 +50,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 6d41532..822ca16 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + diff --git a/pom.xml b/pom.xml index d83ea4b..5c90dc4 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ 4.0.0 org.gcube.portlets.user accounting-dashboard - 1.3.0 + 1.2.0 war accounting-dashboard diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.java index a200cae..d5dc7e0 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.java @@ -16,8 +16,8 @@ import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; -import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.RadioButton; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; @@ -67,10 +67,10 @@ public class FilterAreaView extends ViewWithUiHandlers ListBox monthEnd; @UiField(provided = true) - Button btnShowDetachedREs; + RadioButton btnShowDetachedREs; @UiField(provided = true) - Button btnHideDetachedREs; + RadioButton btnHideDetachedREs; @UiField(provided = true) CellTree scopeTree; @@ -173,7 +173,7 @@ public class FilterAreaView extends ViewWithUiHandlers logger.log(Level.FINE, "Configuring buttons DetachedREs"); - btnShowDetachedREs=new Button(); + btnShowDetachedREs=new RadioButton("radioDetachedREs"); btnShowDetachedREs.addClickHandler(new ClickHandler() { @Override @@ -183,7 +183,8 @@ public class FilterAreaView extends ViewWithUiHandlers } }); - btnHideDetachedREs=new Button(); + btnHideDetachedREs=new RadioButton("radioDetachedREs"); + btnHideDetachedREs.setValue(true); btnHideDetachedREs.addClickHandler(new ClickHandler() { @Override diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml index 4a661da..55f27eb 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml @@ -17,7 +17,7 @@ - From: + From: @@ -27,7 +27,7 @@ - To: + To: @@ -37,14 +37,14 @@ - DetachedREs: + Detached: - - - - + + + + - Show DetachedREs + Show Detached REs diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/uiData.css b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/uiData.css index bff001c..9a8f084 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/uiData.css +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/uiData.css @@ -41,7 +41,7 @@ } .uiDataFiltersControls { - margin-left: 60px; + margin-left: 80px; } .uiDataExploreTree { diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/options/TreeOptions.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/options/TreeOptions.java index dad03bd..5bed26e 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/options/TreeOptions.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/options/TreeOptions.java @@ -12,6 +12,10 @@ public class TreeOptions implements Serializable { private static final long serialVersionUID = 730133583251742872L; private boolean showDetachedREs = false; + + public TreeOptions() { + super(); + } public TreeOptions(boolean showDetachedREs) { super(); From e368c174ddee871fa396941a24d44091c6c4cfaf Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 7 Apr 2020 19:21:07 +0200 Subject: [PATCH 4/9] ref 18815: Accounting Dashboard Reminiscence https://support.d4science.org/issues/18815 Added detachedres-library --- .../application/mainarea/filter/FilterAreaView.ui.xml | 9 +++------ .../client/resources/AppResources.java | 2 ++ .../user/accountingdashboard/client/resources/uiData.css | 4 ++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml index 55f27eb..15fa6f1 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml @@ -16,7 +16,7 @@ styleName="{res.uiDataCss.uiDataFiltersPeriodPanel}"> - + From: @@ -26,7 +26,7 @@ Select the start date - + To: @@ -36,14 +36,11 @@ Select the end date - + Detached: - - - Show Detached REs diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/AppResources.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/AppResources.java index f0db263..5074505 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/AppResources.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/AppResources.java @@ -28,6 +28,8 @@ public interface AppResources extends ClientBundle { String uiDataFiltersTitle(); String uiDataFiltersFormPanel(); + + String uiDataFiltersControlGroup(); String uiDataFiltersControls(); diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/uiData.css b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/uiData.css index 9a8f084..54511a0 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/uiData.css +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/resources/uiData.css @@ -40,6 +40,10 @@ margin: 0px !important; } +.uiDataFiltersControlGroup { + margin-bottom: 10px; +} + .uiDataFiltersControls { margin-left: 80px; } From 2081513f2fa4fecc8fef6b71078aaa66a547122f Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 8 Apr 2020 12:30:28 +0200 Subject: [PATCH 5/9] ref 18815: Accounting Dashboard Reminiscence https://support.d4science.org/issues/18815 Updated detached REs support --- .../accounting/PortalContextTreeProvider.java | 61 +++++++++------- .../server/util/CocktailSort.java | 71 +++++++++++++++++++ 2 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/accountingdashboard/server/util/CocktailSort.java diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java index eb85a09..7b8666e 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java @@ -18,6 +18,8 @@ import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Detache import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway; import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO; import org.gcube.portlets.user.accountingdashboard.server.is.BuildInfraNode; +import org.gcube.portlets.user.accountingdashboard.server.util.CocktailSort; +import org.gcube.portlets.user.accountingdashboard.server.util.CocktailSort.Order; import org.gcube.portlets.user.accountingdashboard.shared.is.InfraNode; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.vomanagement.usermanagement.GroupManager; @@ -53,9 +55,9 @@ public class PortalContextTreeProvider implements ContextTreeProvider { this.accountingServiceType = accountingServiceType; this.treeOptions = null; } - - public void setTreeOptions(TreeOptions treeOptions){ - this.treeOptions=treeOptions; + + public void setTreeOptions(TreeOptions treeOptions) { + this.treeOptions = treeOptions; } static { @@ -86,7 +88,7 @@ public class PortalContextTreeProvider implements ContextTreeProvider { break; case Infrastructure: logger.debug("AccountingService: Infrastructure"); - root = recreateTreeForInfrastructure(request, treeOptions); + root = recreateTreeForInfrastructure(request); break; default: logger.debug("AccountingService: CurrentScope"); @@ -97,7 +99,7 @@ public class PortalContextTreeProvider implements ContextTreeProvider { return root; } - private ScopeDescriptor recreateTreeForInfrastructure(HttpServletRequest request, TreeOptions treeOptions2) + private ScopeDescriptor recreateTreeForInfrastructure(HttpServletRequest request) throws Exception, PortalException, SystemException { ScopeDescriptor infra = null; PortalContext portalContext = PortalContext.getConfiguration(); @@ -156,51 +158,60 @@ public class PortalContextTreeProvider implements ContextTreeProvider { if (detachedREs != null && detachedREs.isEnabled()) { logger.debug("DetachedREs is enabled"); if (detachedREs.getGateways() != null && !detachedREs.getGateways().isEmpty()) { - for (String key : detachedREs.getGateways().keySet()) { - Gateway gateway = detachedREs.getGateways().get(key); - ScopeDescriptor getewaySD = new ScopeDescriptor(gateway.getName(), key); - LinkedList voChildren = retrieveVOChildren(gateway); + ArrayList gatewaysList = new ArrayList(detachedREs.getGateways().values()); + Collections.sort(gatewaysList); + for (Gateway gateway : gatewaysList) { + ScopeDescriptor getewaySD = new ScopeDescriptor(gateway.getName(), gateway.getScope()); + LinkedList voChildren = retrieveVOChildren(infraNode, gateway); getewaySD.setChildren(voChildren); infraChildren.add(getewaySD); } + CocktailSort.sort(infraChildren,Order.DESC); } } else { logger.debug("DetachedREs is disabled"); } } - + infra.setChildren(infraChildren); return infra; } - private LinkedList retrieveVOChildren(Gateway gateway) { + private LinkedList retrieveVOChildren(InfraNode infraNode, Gateway gateway) { + LinkedList vos = new LinkedList<>(); + + if (infraNode != null) { + ScopeDescriptor infraNodeScopeDescriptor = createRelativeInfraNode(infraNode, gateway.getScope()); + vos.add(infraNodeScopeDescriptor); + } if (gateway.getVos() != null && !gateway.getVos().isEmpty()) { - LinkedList vos = new LinkedList<>(); - for (String key : gateway.getVos().keySet()) { - VO vo = gateway.getVos().get(key); - ScopeDescriptor voSD = new ScopeDescriptor(vo.getName(), key); + ArrayList vosList = new ArrayList(gateway.getVos().values()); + Collections.sort(vosList); + for (VO vo : vosList) { + ScopeDescriptor voSD = new ScopeDescriptor(vo.getName(), vo.getScope()); LinkedList voChildren = retrieveVREChildren(vo); voSD.setChildren(voChildren); vos.add(voSD); } - return vos; - } else { - return null; } + + return vos; } private LinkedList retrieveVREChildren(VO vo) { + LinkedList vres = new LinkedList<>(); + if (vo.getVres() != null && !vo.getVres().isEmpty()) { - LinkedList vres = new LinkedList<>(); - for (String key : vo.getVres().keySet()) { - org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE vre = vo.getVres().get(key); - ScopeDescriptor vreSD = new ScopeDescriptor(vre.getName(), key); + ArrayList vresList = new ArrayList( + vo.getVres().values()); + Collections.sort(vresList); + for (org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE vre : vresList) { + ScopeDescriptor vreSD = new ScopeDescriptor(vre.getName(), vre.getScope()); vres.add(vreSD); } - return vres; - } else { - return null; + } + return vres; } private ScopeDescriptor createRelativeInfraNode(InfraNode infraNode, String scope) { diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/util/CocktailSort.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/util/CocktailSort.java new file mode 100644 index 0000000..b8435e2 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/util/CocktailSort.java @@ -0,0 +1,71 @@ +package org.gcube.portlets.user.accountingdashboard.server.util; + +import java.util.List; + +import org.gcube.accounting.accounting.summary.access.model.ScopeDescriptor; + +public class CocktailSort { + + public enum Order { + ASC, DESC + } + + public static void sort(List list, Order order) { + if (list != null && list.size() > 1) { + + // `begin` ed `end` first and last index to check + int begin = -1; + int end = list.size() - 1; + boolean swapped; + do { + swapped = false; + // increases `begin` because the elements before `begin` are + // sorted correctly + begin = begin + 1; + for (int i = begin; i < end; i++) { + if (order == Order.ASC) { + if (list.get(i).getName().compareTo(list.get(i + 1).getName()) < 0) { + ScopeDescriptor sd = list.get(i); + list.set(i, list.get(i + 1)); + list.set(i + 1, sd); + swapped = true; + } + } else { + if (list.get(i).getName().compareTo(list.get(i + 1).getName()) > 0) { + ScopeDescriptor sd = list.get(i); + list.set(i, list.get(i + 1)); + list.set(i + 1, sd); + swapped = true; + } + } + + } + if (swapped == false) { + break; + } + swapped = false; + // decreases `end` because the elements after `end` are sorted + // correctly + end = end - 1; + for (int i = end; i > begin; i--) { + if (order == Order.ASC) { + if (list.get(i).getName().compareTo(list.get(i - 1).getName()) > 0) { + ScopeDescriptor sd = list.get(i); + list.set(i, list.get(i - 1)); + list.set(i - 1, sd); + swapped = true; + } + } else { + if (list.get(i).getName().compareTo(list.get(i - 1).getName()) < 0) { + ScopeDescriptor sd = list.get(i); + list.set(i, list.get(i - 1)); + list.set(i - 1, sd); + swapped = true; + } + } + } + } while (swapped); + } + } + +} From 6b7d32fcbf0b2cedd4cea3e3e12f9a456a332e03 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 8 Apr 2020 16:52:52 +0200 Subject: [PATCH 6/9] ref 18815: Accounting Dashboard Reminiscence https://support.d4science.org/issues/18815 Updated detached REs support --- .../application/controller/Controller.java | 23 +++++++++ .../application/event/EnvironmentEvent.java | 51 +++++++++++++++++++ .../mainarea/filter/FilterAreaPresenter.java | 15 ++++++ .../mainarea/filter/FilterAreaView.java | 34 +++++++++++++ .../mainarea/filter/FilterAreaView.ui.xml | 2 +- .../rpc/AccountingDashboardService.java | 3 ++ .../rpc/AccountingDashboardServiceAsync.java | 3 ++ .../AccountingDashboardServiceImpl.java | 22 +++++++- .../server/accounting/AccountingService.java | 1 + .../accounting/PortalContextTreeProvider.java | 1 + .../env}/AccountingServiceType.java | 2 +- .../shared/env/EnvironmentData.java | 38 ++++++++++++++ .../AccountingServiceTest.java | 2 +- 13 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/event/EnvironmentEvent.java rename src/main/java/org/gcube/portlets/user/accountingdashboard/{server/accounting => shared/env}/AccountingServiceType.java (64%) create mode 100644 src/main/java/org/gcube/portlets/user/accountingdashboard/shared/env/EnvironmentData.java diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java index 4f8bb58..0f6b577 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/controller/Controller.java @@ -6,6 +6,7 @@ import java.util.logging.Logger; import org.gcube.portlets.user.accountingdashboard.client.application.dialog.error.ErrorPresenter; import org.gcube.portlets.user.accountingdashboard.client.application.dialog.info.InfoPresenter; import org.gcube.portlets.user.accountingdashboard.client.application.dialog.monitor.MonitorPresenter; +import org.gcube.portlets.user.accountingdashboard.client.application.event.EnvironmentEvent; import org.gcube.portlets.user.accountingdashboard.client.application.event.HelloEvent; import org.gcube.portlets.user.accountingdashboard.client.application.event.ReportEvent; import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent; @@ -13,6 +14,7 @@ import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboar import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; +import org.gcube.portlets.user.accountingdashboard.shared.env.EnvironmentData; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; @@ -111,6 +113,27 @@ public class Controller { }); } + + public void getEnvironment() { + service.getEnvironment(new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + logger.log(Level.FINE, "Error in getEnvironment(): ", caught); + errorPresenter.errorMessage(caught.getLocalizedMessage()); + } + + @Override + public void onSuccess(EnvironmentData environmentData) { + logger.log(Level.FINE, "ScopeData: " + environmentData); + EnvironmentEvent event = new EnvironmentEvent(environmentData); + eventBus.fireEvent(event); + } + + }); + + } + public void getTree() { service.getScopeData(treeOptions,new AsyncCallback() { diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/event/EnvironmentEvent.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/event/EnvironmentEvent.java new file mode 100644 index 0000000..beb26bb --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/event/EnvironmentEvent.java @@ -0,0 +1,51 @@ +package org.gcube.portlets.user.accountingdashboard.client.application.event; + +import org.gcube.portlets.user.accountingdashboard.shared.env.EnvironmentData; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * + * @author Giancarlo Panichi + * + */ +public class EnvironmentEvent extends GwtEvent { + + private EnvironmentData environmentData; + + public interface EnvironmentEventHandler extends EventHandler { + void onInit(EnvironmentEvent event); + } + + public static final Type TYPE = new Type<>(); + + public EnvironmentEvent(EnvironmentData environmentData) { + this.environmentData = environmentData; + } + + public static void fire(HasHandlers source, EnvironmentEvent event) { + source.fireEvent(event); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(EnvironmentEventHandler handler) { + handler.onInit(this); + } + + public EnvironmentData getEnvironmentData() { + return environmentData; + } + + @Override + public String toString() { + return "EnvironmentEvent [environmentData=" + environmentData + "]"; + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java index d49c831..41b1af6 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaPresenter.java @@ -5,9 +5,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.gcube.portlets.user.accountingdashboard.client.application.controller.Controller; +import org.gcube.portlets.user.accountingdashboard.client.application.event.EnvironmentEvent; import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; +import org.gcube.portlets.user.accountingdashboard.shared.env.EnvironmentData; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import com.google.gwt.i18n.client.DateTimeFormat; @@ -30,6 +32,8 @@ public class FilterAreaPresenter extends PresenterWidget { void displayScopeData(ScopeData scopeData); + + void setEnvironment(EnvironmentData environmentData); } @@ -62,12 +66,23 @@ public class FilterAreaPresenter extends PresenterWidget @UiField(provided = true) ListBox monthEnd; + + @UiField(provided = false) + ControlGroup cgDetachedREs; @UiField(provided = true) RadioButton btnShowDetachedREs; @@ -173,6 +178,8 @@ public class FilterAreaView extends ViewWithUiHandlers logger.log(Level.FINE, "Configuring buttons DetachedREs"); + //cgDetachedREs=new ControlGroup(); + btnShowDetachedREs=new RadioButton("radioDetachedREs"); btnShowDetachedREs.addClickHandler(new ClickHandler() { @@ -216,6 +223,31 @@ public class FilterAreaView extends ViewWithUiHandlers logger.log(Level.FINE, "FilterAreaView init end"); } + @Override + public void setEnvironment(EnvironmentData environmentData) { + logger.log(Level.FINE, "displayScopeData()"); + if(environmentData!=null&&environmentData.getAccountingServiceType()!=null){ + switch(environmentData.getAccountingServiceType()){ + case CurrentScope: + cgDetachedREs.setVisible(false); + break; + case Infrastructure: + cgDetachedREs.setVisible(true); + break; + case PortalContex: + cgDetachedREs.setVisible(false); + break; + default: + cgDetachedREs.setVisible(false); + break; + + } + } else { + cgDetachedREs.setVisible(false); + } + } + + @Override public void displayScopeData(ScopeData scopeData) { logger.log(Level.FINE, "displayScopeData()"); @@ -277,4 +309,6 @@ public class FilterAreaView extends ViewWithUiHandlers } + + } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml index 15fa6f1..46b8e2f 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml @@ -36,7 +36,7 @@ Select the end date - + Detached: diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java index eeb4d41..29497e0 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardService.java @@ -3,6 +3,7 @@ package org.gcube.portlets.user.accountingdashboard.client.rpc; import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; +import org.gcube.portlets.user.accountingdashboard.shared.env.EnvironmentData; import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; @@ -31,4 +32,6 @@ public interface AccountingDashboardService extends RemoteService { public ReportData getReport(RequestReportData requestReportdata, TreeOptions treeOptions) throws ServiceException; + public EnvironmentData getEnvironment() throws ServiceException; + } diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java index f5739b3..228bce6 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/rpc/AccountingDashboardServiceAsync.java @@ -6,6 +6,7 @@ package org.gcube.portlets.user.accountingdashboard.client.rpc; import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; +import org.gcube.portlets.user.accountingdashboard.shared.env.EnvironmentData; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; @@ -25,6 +26,8 @@ public interface AccountingDashboardServiceAsync { void hello(AsyncCallback callback); + void getEnvironment(AsyncCallback callback); + void getScopeData(TreeOptions treeOptions, AsyncCallback callback); void getReport(RequestReportData requestReportdata, TreeOptions treeOptions, diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java index 998c4e3..4abba8d 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/AccountingDashboardServiceImpl.java @@ -6,11 +6,12 @@ import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean.Type; import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardService; import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService; -import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType; import org.gcube.portlets.user.accountingdashboard.server.util.ServiceCredentials; import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; +import org.gcube.portlets.user.accountingdashboard.shared.env.AccountingServiceType; +import org.gcube.portlets.user.accountingdashboard.shared.env.EnvironmentData; import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; @@ -64,6 +65,23 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme } } + + @Override + public EnvironmentData getEnvironment() throws ServiceException { + try { + logger.debug("AccountingDashboardServiceImpl getEnvironment()"); + ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest()); + AccountingServiceType accountingServiceType=getAccountingContext(serviceCredentials.getScope()); + EnvironmentData environmentData=new EnvironmentData(accountingServiceType); + return environmentData; + } catch (ServiceException e) { + logger.error(e.getLocalizedMessage(), e); + throw e; + } catch (Throwable e) { + logger.error("GetEnvironment(): " + e.getLocalizedMessage(), e); + throw new ServiceException("Error retrieving environment info: " + e.getLocalizedMessage(), e); + } + } @Override public ScopeData getScopeData(TreeOptions treeOptions) throws ServiceException { @@ -118,4 +136,6 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme } } + + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java index 0900edf..704fc3f 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingService.java @@ -16,6 +16,7 @@ import org.gcube.portlets.user.accountingdashboard.shared.data.ReportElementData import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; import org.gcube.portlets.user.accountingdashboard.shared.data.SeriesData; +import org.gcube.portlets.user.accountingdashboard.shared.env.AccountingServiceType; import org.gcube.portlets.user.accountingdashboard.shared.exception.ServiceException; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.slf4j.Logger; diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java index 7b8666e..a668c1a 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/PortalContextTreeProvider.java @@ -20,6 +20,7 @@ import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO; import org.gcube.portlets.user.accountingdashboard.server.is.BuildInfraNode; import org.gcube.portlets.user.accountingdashboard.server.util.CocktailSort; import org.gcube.portlets.user.accountingdashboard.server.util.CocktailSort.Order; +import org.gcube.portlets.user.accountingdashboard.shared.env.AccountingServiceType; import org.gcube.portlets.user.accountingdashboard.shared.is.InfraNode; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.vomanagement.usermanagement.GroupManager; diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingServiceType.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/env/AccountingServiceType.java similarity index 64% rename from src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingServiceType.java rename to src/main/java/org/gcube/portlets/user/accountingdashboard/shared/env/AccountingServiceType.java index 7570943..e52050d 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/server/accounting/AccountingServiceType.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/env/AccountingServiceType.java @@ -1,4 +1,4 @@ -package org.gcube.portlets.user.accountingdashboard.server.accounting; +package org.gcube.portlets.user.accountingdashboard.shared.env; /** * diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/env/EnvironmentData.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/env/EnvironmentData.java new file mode 100644 index 0000000..61b1933 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/shared/env/EnvironmentData.java @@ -0,0 +1,38 @@ +package org.gcube.portlets.user.accountingdashboard.shared.env; + +import java.io.Serializable; + +/** + * + * @author Giancarlo Panichi + * + */ +public class EnvironmentData implements Serializable { + + private static final long serialVersionUID = 5817114786613046203L; + + private AccountingServiceType accountingServiceType; + + public EnvironmentData() { + super(); + } + + public EnvironmentData(AccountingServiceType accountingServiceType) { + super(); + this.accountingServiceType = accountingServiceType; + } + + public AccountingServiceType getAccountingServiceType() { + return accountingServiceType; + } + + public void setAccountingServiceType(AccountingServiceType accountingServiceType) { + this.accountingServiceType = accountingServiceType; + } + + @Override + public String toString() { + return "EnvironmentData [accountingServiceType=" + accountingServiceType + "]"; + } + +} diff --git a/src/test/java/org/gcube/portlets/user/accountingdashboard/AccountingServiceTest.java b/src/test/java/org/gcube/portlets/user/accountingdashboard/AccountingServiceTest.java index 96d12d2..526e0c7 100644 --- a/src/test/java/org/gcube/portlets/user/accountingdashboard/AccountingServiceTest.java +++ b/src/test/java/org/gcube/portlets/user/accountingdashboard/AccountingServiceTest.java @@ -1,8 +1,8 @@ package org.gcube.portlets.user.accountingdashboard; import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService; -import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType; import org.gcube.portlets.user.accountingdashboard.shared.Constants; +import org.gcube.portlets.user.accountingdashboard.shared.env.AccountingServiceType; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; From 44cca496c98307604d667b05fe6b2ee2de0b7df5 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 8 Apr 2020 16:56:05 +0200 Subject: [PATCH 7/9] ref 18815: Accounting Dashboard Reminiscence https://support.d4science.org/issues/18815 Updated detached REs support --- .../client/application/mainarea/filter/FilterAreaView.ui.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml index 46b8e2f..5733f6f 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/filter/FilterAreaView.ui.xml @@ -41,7 +41,7 @@ - Show Detached REs + Detached REs From 68dc1588fb0d872bfb82c7dcf0c718893719cf69 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 8 Apr 2020 18:48:15 +0200 Subject: [PATCH 8/9] ref 18754: Dashboard: Alphabetically sort the tabs https://support.d4science.org/issues/18754 Added the alphabetically sort of the tabs --- changelog.xml | 5 ++++- .../client/application/mainarea/report/ReportAreaView.java | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/changelog.xml b/changelog.xml index e30161e..1a66224 100644 --- a/changelog.xml +++ b/changelog.xml @@ -1,7 +1,10 @@ + date="2020-04-08"> Updated export csv support with Firefox and Safari [ticket #18034] + Added Core Services support [ticket #18291] + Added Detached REs support [ticket #18815] + Added the alphabetically sort of the tabs [ticket #18754] diff --git a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/report/ReportAreaView.java b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/report/ReportAreaView.java index cc57ad3..42e2d23 100644 --- a/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/report/ReportAreaView.java +++ b/src/main/java/org/gcube/portlets/user/accountingdashboard/client/application/mainarea/report/ReportAreaView.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.logging.Logger; @@ -87,7 +88,11 @@ public class ReportAreaView extends ViewWithUiHandlers TabPanel tabPanel = new TabPanel(); tabPanel.addStyleName(resources.uiDataCss().uiDataReportTabPanel()); boolean first = true; - for (String category : categories.keySet()) { + ArrayList sortedKeys = + new ArrayList(categories.keySet()); + Collections.sort(sortedKeys); + + for (String category : sortedKeys) { Tab tab = new Tab(); tab.setHeading(category); HTMLPanel tabContent = new HTMLPanel(""); From c327d0b00c6c2399127f03e0d6d3e368cbe6fb85 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 8 Apr 2020 18:51:44 +0200 Subject: [PATCH 9/9] Branches: Future/18815, origin/Future/18815 ref 18754: Dashboard: Alphabetically sort the tabs https://support.d4science.org/issues/18754 Added the alphabetical sorting of the tabs --- changelog.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.xml b/changelog.xml index 1a66224..03d12fb 100644 --- a/changelog.xml +++ b/changelog.xml @@ -4,7 +4,7 @@ Updated export csv support with Firefox and Safari [ticket #18034] Added Core Services support [ticket #18291] Added Detached REs support [ticket #18815] - Added the alphabetically sort of the tabs [ticket #18754] + Added the alphabetical sorting of tabs [ticket #18754]