ref 18815: Accounting Dashboard Reminiscence

https://support.d4science.org/issues/18815

Updated detached REs support
This commit is contained in:
Giancarlo Panichi 2020-04-08 16:52:52 +02:00
parent 2081513f2f
commit 6b7d32fcbf
13 changed files with 193 additions and 4 deletions

View File

@ -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.error.ErrorPresenter;
import org.gcube.portlets.user.accountingdashboard.client.application.dialog.info.InfoPresenter; 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.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.HelloEvent;
import org.gcube.portlets.user.accountingdashboard.client.application.event.ReportEvent; import org.gcube.portlets.user.accountingdashboard.client.application.event.ReportEvent;
import org.gcube.portlets.user.accountingdashboard.client.application.event.ScopeDataEvent; 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.ReportData;
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; 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.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.options.TreeOptions;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
@ -111,6 +113,27 @@ public class Controller {
}); });
} }
public void getEnvironment() {
service.getEnvironment(new AsyncCallback<EnvironmentData>() {
@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() { public void getTree() {
service.getScopeData(treeOptions,new AsyncCallback<ScopeData>() { service.getScopeData(treeOptions,new AsyncCallback<ScopeData>() {

View File

@ -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<EnvironmentEvent.EnvironmentEventHandler> {
private EnvironmentData environmentData;
public interface EnvironmentEventHandler extends EventHandler {
void onInit(EnvironmentEvent event);
}
public static final Type<EnvironmentEventHandler> TYPE = new Type<>();
public EnvironmentEvent(EnvironmentData environmentData) {
this.environmentData = environmentData;
}
public static void fire(HasHandlers source, EnvironmentEvent event) {
source.fireEvent(event);
}
@Override
public Type<EnvironmentEventHandler> 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 + "]";
}
}

View File

@ -5,9 +5,11 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.gcube.portlets.user.accountingdashboard.client.application.controller.Controller; 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.client.application.event.ScopeDataEvent;
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; 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.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.options.TreeOptions;
import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat;
@ -30,6 +32,8 @@ public class FilterAreaPresenter extends PresenterWidget<FilterAreaPresenter.Fil
interface FilterAreaView extends View, HasUiHandlers<FilterAreaPresenter> { interface FilterAreaView extends View, HasUiHandlers<FilterAreaPresenter> {
void displayScopeData(ScopeData scopeData); void displayScopeData(ScopeData scopeData);
void setEnvironment(EnvironmentData environmentData);
} }
@ -62,12 +66,23 @@ public class FilterAreaPresenter extends PresenterWidget<FilterAreaPresenter.Fil
} }
}); });
controller.getEventBus().addHandler(EnvironmentEvent.TYPE, new EnvironmentEvent.EnvironmentEventHandler() {
@Override
public void onInit(EnvironmentEvent event) {
logger.log(Level.FINE, "EnvironmentEvent received");
getView().setEnvironment(event.getEnvironmentData());
}
});
} }
@Override @Override
protected void onBind() { protected void onBind() {
super.onBind(); super.onBind();
controller.getEnvironment();
controller.getTree(); controller.getTree();
} }

View File

@ -14,8 +14,10 @@ import org.gcube.portlets.user.accountingdashboard.client.resources.AppResources
import org.gcube.portlets.user.accountingdashboard.client.resources.ScopeTreeResources; import org.gcube.portlets.user.accountingdashboard.client.resources.ScopeTreeResources;
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; 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.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.options.TreeOptions;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.RadioButton; import com.github.gwtbootstrap.client.ui.RadioButton;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
@ -65,6 +67,9 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
@UiField(provided = true) @UiField(provided = true)
ListBox monthEnd; ListBox monthEnd;
@UiField(provided = false)
ControlGroup cgDetachedREs;
@UiField(provided = true) @UiField(provided = true)
RadioButton btnShowDetachedREs; RadioButton btnShowDetachedREs;
@ -173,6 +178,8 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
logger.log(Level.FINE, "Configuring buttons DetachedREs"); logger.log(Level.FINE, "Configuring buttons DetachedREs");
//cgDetachedREs=new ControlGroup();
btnShowDetachedREs=new RadioButton("radioDetachedREs"); btnShowDetachedREs=new RadioButton("radioDetachedREs");
btnShowDetachedREs.addClickHandler(new ClickHandler() { btnShowDetachedREs.addClickHandler(new ClickHandler() {
@ -216,6 +223,31 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
logger.log(Level.FINE, "FilterAreaView init end"); 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 @Override
public void displayScopeData(ScopeData scopeData) { public void displayScopeData(ScopeData scopeData) {
logger.log(Level.FINE, "displayScopeData()"); logger.log(Level.FINE, "displayScopeData()");
@ -277,4 +309,6 @@ public class FilterAreaView extends ViewWithUiHandlers<FilterAreaPresenter>
} }
} }

View File

@ -36,7 +36,7 @@
<b:HelpBlock>Select the end date</b:HelpBlock> <b:HelpBlock>Select the end date</b:HelpBlock>
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup styleName="{res.uiDataCss.uiDataFiltersControlGroup}"> <b:ControlGroup ui:field="cgDetachedREs" styleName="{res.uiDataCss.uiDataFiltersControlGroup}">
<b:ControlLabel width="70px" for="detachedREs">Detached:</b:ControlLabel> <b:ControlLabel width="70px" for="detachedREs">Detached:</b:ControlLabel>
<b:Controls styleName="{res.uiDataCss.uiDataFiltersControls}"> <b:Controls styleName="{res.uiDataCss.uiDataFiltersControls}">
<b:RadioButton ui:field="btnShowDetachedREs" text="Show" /> <b:RadioButton ui:field="btnShowDetachedREs" text="Show" />

View File

@ -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.ReportData;
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; 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.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.exception.ServiceException;
import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; 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 ReportData getReport(RequestReportData requestReportdata, TreeOptions treeOptions) throws ServiceException;
public EnvironmentData getEnvironment() throws ServiceException;
} }

View File

@ -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.ReportData;
import org.gcube.portlets.user.accountingdashboard.shared.data.RequestReportData; 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.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.options.TreeOptions;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo;
@ -25,6 +26,8 @@ public interface AccountingDashboardServiceAsync {
void hello(AsyncCallback<UserInfo> callback); void hello(AsyncCallback<UserInfo> callback);
void getEnvironment(AsyncCallback<EnvironmentData> callback);
void getScopeData(TreeOptions treeOptions, AsyncCallback<ScopeData> callback); void getScopeData(TreeOptions treeOptions, AsyncCallback<ScopeData> callback);
void getReport(RequestReportData requestReportdata, TreeOptions treeOptions, void getReport(RequestReportData requestReportdata, TreeOptions treeOptions,

View File

@ -6,11 +6,12 @@ import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type; import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardService; 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.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.server.util.ServiceCredentials;
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData; 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.RequestReportData;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; 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.exception.ServiceException;
import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions;
import org.gcube.portlets.user.accountingdashboard.shared.session.UserInfo; 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 @Override
public ScopeData getScopeData(TreeOptions treeOptions) throws ServiceException { public ScopeData getScopeData(TreeOptions treeOptions) throws ServiceException {
@ -118,4 +136,6 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
} }
} }
} }

View File

@ -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.RequestReportData;
import org.gcube.portlets.user.accountingdashboard.shared.data.ScopeData; 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.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.exception.ServiceException;
import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions;
import org.slf4j.Logger; import org.slf4j.Logger;

View File

@ -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.is.BuildInfraNode;
import org.gcube.portlets.user.accountingdashboard.server.util.CocktailSort; 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.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.is.InfraNode;
import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions; import org.gcube.portlets.user.accountingdashboard.shared.options.TreeOptions;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.accountingdashboard.server.accounting; package org.gcube.portlets.user.accountingdashboard.shared.env;
/** /**
* *

View File

@ -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 + "]";
}
}

View File

@ -1,8 +1,8 @@
package org.gcube.portlets.user.accountingdashboard; package org.gcube.portlets.user.accountingdashboard;
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService; 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.Constants;
import org.gcube.portlets.user.accountingdashboard.shared.env.AccountingServiceType;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;