Added Default Show to Accounting Manager

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@117356 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-07-20 14:44:13 +00:00
parent ee8d5f95bc
commit 012eb588cb
10 changed files with 161 additions and 28 deletions

View File

@ -108,6 +108,7 @@ public class AccountingManager implements EntryPoint {
bind(mainPanelLayout); bind(mainPanelLayout);
controller.setMainPanelLayout(mainPanelLayout); controller.setMainPanelLayout(mainPanelLayout);
controller.restoreUISession(); controller.restoreUISession();
} }
protected void bind(BorderLayoutContainer mainWidget) { protected void bind(BorderLayoutContainer mainWidget) {

View File

@ -16,6 +16,8 @@ import org.gcube.portlets.admin.accountingmanager.client.type.StateChangeType;
import org.gcube.portlets.admin.accountingmanager.client.type.UIStateType; import org.gcube.portlets.admin.accountingmanager.client.type.UIStateType;
import org.gcube.portlets.admin.accountingmanager.client.utils.UtilsGXT3; import org.gcube.portlets.admin.accountingmanager.client.utils.UtilsGXT3;
import org.gcube.portlets.admin.accountingmanager.shared.Constants; import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriod;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriodMode;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
@ -30,6 +32,7 @@ import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.datepicker.client.CalendarUtil;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer; import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
/** /**
@ -155,7 +158,7 @@ public class AccountingManagerController {
// //
public void restoreUISession() { public void restoreUISession() {
checkLocale(); checkLocale();
showDefault();
} }
// Bind Controller to events on bus // Bind Controller to events on bus
@ -206,25 +209,90 @@ public class AccountingManagerController {
case STORAGE: case STORAGE:
case TASK: case TASK:
case JOB: case JOB:
Log.debug("AccountingType: "+event.getAccountingType()); Log.debug("AccountingType: " + event.getAccountingType());
accountingType = event.getAccountingType();
accountingStateData = accountingState.getState(event accountingStateData = accountingState.getState(event
.getAccountingType()); .getAccountingType());
if (accountingStateData == null) { if (accountingStateData == null) {
accountingStateData = new AccountingStateData( createDefaultChart(event.getAccountingType());
event.getAccountingType(), null, null); } else {
accountingState.setState(event.getAccountingType(), accountingType = event.getAccountingType();
accountingStateData); StateChangeEvent stateChangeEvent = new StateChangeEvent(
StateChangeType.Restore, accountingStateData);
eventBus.fireEvent(stateChangeEvent);
} }
StateChangeEvent stateChangeEvent = new StateChangeEvent(
StateChangeType.Restore, accountingStateData);
eventBus.fireEvent(stateChangeEvent);
break; break;
default: default:
break; break;
} }
} }
public void showDefault(){
createDefaultChart(AccountingType.STORAGE);
}
private void createDefaultChart(AccountingType accountingType) {
accountingMonitor = new AccountingMonitor();
Date d=new Date();
CalendarUtil.addMonthsToDate(d, -1);
SeriesRequest seriesRequest=new SeriesRequest(
new AccountingPeriod(d,new Date(),AccountingPeriodMode.DAILY));
this.accountingType = accountingType;
AccountingStateData accountingStateData = new AccountingStateData(
accountingType, seriesRequest, null);
accountingState.setState(accountingType,
accountingStateData);
callDefaultSeriesRequest(accountingStateData);
}
private void callDefaultSeriesRequest(final AccountingStateData accountingStateData) {
AccountingManagerServiceAsync.INSTANCE.getSeries(
accountingStateData.getAccountingType(),
accountingStateData.getSeriesRequest(),
new AsyncCallback<SeriesResponse>() {
@Override
public void onSuccess(SeriesResponse seriesResponse) {
Log.debug("SeriesResponse: " + seriesResponse);
accountingStateData.setSeriesResponse(seriesResponse);
accountingState.setState(accountingType,
accountingStateData);
StateChangeEvent stateChangeEvent = new StateChangeEvent(
StateChangeType.Restore, accountingStateData);
eventBus.fireEvent(stateChangeEvent);
accountingMonitor.hide();
}
@Override
public void onFailure(Throwable caught) {
accountingMonitor.hide();
if (caught instanceof AccountingManagerSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error:" + caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
caught.getLocalizedMessage());
StateChangeEvent stateChangeEvent = new StateChangeEvent(
StateChangeType.Restore, accountingStateData);
eventBus.fireEvent(stateChangeEvent);
}
}
});
}
private void doFiltersChangeCommand(FiltersChangeEvent event) { private void doFiltersChangeCommand(FiltersChangeEvent event) {
if (event == null || event.getFiltersChangeType() == null) { if (event == null || event.getFiltersChangeType() == null) {
@ -236,7 +304,7 @@ public class AccountingManagerController {
AccountingStateData accountingStateData = accountingState AccountingStateData accountingStateData = accountingState
.getState(accountingType); .getState(accountingType);
if (accountingStateData != null) { if (accountingStateData != null) {
accountingMonitor=new AccountingMonitor(); accountingMonitor = new AccountingMonitor();
accountingStateData.setSeriesRequest(seriesRequest); accountingStateData.setSeriesRequest(seriesRequest);
accountingState.setState(accountingType, accountingStateData); accountingState.setState(accountingType, accountingStateData);
callSeriesRequest(accountingStateData); callSeriesRequest(accountingStateData);

View File

@ -206,7 +206,7 @@ public class HightChartPanel extends FramedPanel {
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
ChartOptions options = highchartsFactory.createChartOptions(); ChartOptions options = highchartsFactory.createChartOptions();
options.chart().zoomType("x"); options.chart().zoomType("xy");
options.title().text("Accounting Storage"); options.title().text("Accounting Storage");
@ -223,6 +223,8 @@ public class HightChartPanel extends FramedPanel {
// yAxis // yAxis
// options.yAxis().title().text("Exchange rate"); // options.yAxis().title().text("Exchange rate");
// Highcharts.getOptions().colors[0] // Highcharts.getOptions().colors[0]
String multiAxis = "[{" + " \"id\": \"OperationCount\"," String multiAxis = "[{" + " \"id\": \"OperationCount\","
+ " \"labels\": { " + " \"format\": \"{value}\"," + " \"labels\": { " + " \"format\": \"{value}\","
+ " \"style\": { " + " \"color\": \"" + " \"style\": { " + " \"color\": \""
@ -258,7 +260,7 @@ public class HightChartPanel extends FramedPanel {
+ " }," + " \"opposite\": \"true\"" + "}]"; + " }," + " \"opposite\": \"true\"" + "}]";
options.setFieldAsJsonObject("yAxis", multiAxis); options.setFieldAsJsonObject("yAxis", multiAxis);
// TODO does not seem to be working // TODO does not seem to be working
String fillcolor = "{" + "\"linearGradient\": {" + "\"x1\": 0," String fillcolor = "{" + "\"linearGradient\": {" + "\"x1\": 0,"
+ "\"y1\": 0," + "\"x2\": 0," + "\"y2\": 1" + "}," + "\"y1\": 0," + "\"x2\": 0," + "\"y2\": 1" + "},"
@ -354,7 +356,7 @@ public class HightChartPanel extends FramedPanel {
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
ChartOptions options = highchartsFactory.createChartOptions(); ChartOptions options = highchartsFactory.createChartOptions();
options.chart().zoomType("x"); options.chart().zoomType("xy");
options.title().text("Accounting Service"); options.title().text("Accounting Service");
@ -371,6 +373,48 @@ public class HightChartPanel extends FramedPanel {
// yAxis // yAxis
// options.yAxis().title().text("Exchange rate"); // options.yAxis().title().text("Exchange rate");
// Highcharts.getOptions().colors[0] // Highcharts.getOptions().colors[0]
/*
String multiAxis = "[{" + " \"id\": \"OperationCount\","
+ " \"labels\": { " + " \"format\": \"{value}\","
+ " \"style\": { " + " \"color\": \""
+ colors.get(1)
+ "\""
+ " }"
+ " },"
+ " \"title\": { "
+ " \"text\": \"Operation Count\","
+ " \"style\": {"
+ " \"color\": \""
+ colors.get(1)
+ "\""
+ " }"
+ " }"
+ "} , {"
+ " \"id\": \"ServiceData\", "
+ " \"linkedTo\": \"0\","
+" \"gridLineWidth\": \"0\","
+ " \"title\": {"
+ " \"text\": \"\","
+ " \"style\": {"
+ " \"color\": \""
+ colors.get(1)
+ "\""
+ " }"
+ " },"
+ " \"labels\": {"
+ " \"format\": \"{value} ms\","
+ " \"style\": {"
+ " \"color\": \""
+ colors.get(1)
+ "\""
+ " }"
+ " }," + " \"opposite\": \"true\""
//+ ", \"showFirstLabel\": \"false\""
+ "}]";
*/
String multiAxis = "[{" + " \"id\": \"OperationCount\"," String multiAxis = "[{" + " \"id\": \"OperationCount\","
+ " \"labels\": { " + " \"format\": \"{value}\"," + " \"labels\": { " + " \"format\": \"{value}\","
+ " \"style\": { " + " \"color\": \"" + " \"style\": { " + " \"color\": \""
@ -404,6 +448,7 @@ public class HightChartPanel extends FramedPanel {
+ "\"" + "\""
+ " }" + " }"
+ " }," + " \"opposite\": \"true\"" + " }," + " \"opposite\": \"true\""
+ ", \"showFirstLabel\": \"false\""
+ "} , {" + "} , {"
+ " \"id\": \"MaxInvocationTime\", " + " \"id\": \"MaxInvocationTime\", "
+ " \"title\": {" + " \"title\": {"
@ -422,6 +467,7 @@ public class HightChartPanel extends FramedPanel {
+ "\"" + "\""
+ " }" + " }"
+ " }," + " \"opposite\": \"true\"" + " }," + " \"opposite\": \"true\""
+ ", \"showFirstLabel\": \"false\""
+ "} , {" + "} , {"
+ " \"id\": \"MinInvocationTime\", " + " \"id\": \"MinInvocationTime\", "
+ " \"title\": {" + " \"title\": {"
@ -439,10 +485,12 @@ public class HightChartPanel extends FramedPanel {
+ colors.get(3) + colors.get(3)
+ "\"" + "\""
+ " }" + " }"
+ " }," + " \"opposite\": \"true\"" + "}]" + " }," + " \"opposite\": \"true\""
+ ", \"showFirstLabel\": \"false\""
+ "}]"
; ;
options.setFieldAsJsonObject("yAxis", multiAxis); options.setFieldAsJsonObject("yAxis", multiAxis);
// TODO does not seem to be working // TODO does not seem to be working
@ -496,7 +544,6 @@ public class HightChartPanel extends FramedPanel {
seriesMinInvocationTime.color(colors.get(3)); seriesMinInvocationTime.color(colors.get(3));
seriesMinInvocationTime.yAxisAsString("MinInvocationTime"); seriesMinInvocationTime.yAxisAsString("MinInvocationTime");
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime.dataAsArrayNumber(); ArrayNumber dataMinInvocationTime = seriesMinInvocationTime.dataAsArrayNumber();
@ -568,7 +615,7 @@ public class HightChartPanel extends FramedPanel {
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
ChartOptions options = highchartsFactory.createChartOptions(); ChartOptions options = highchartsFactory.createChartOptions();
options.chart().zoomType("x"); options.chart().zoomType("xy");
options.title().text("Accounting Portlet"); options.title().text("Accounting Portlet");
@ -714,7 +761,7 @@ public class HightChartPanel extends FramedPanel {
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
ChartOptions options = highchartsFactory.createChartOptions(); ChartOptions options = highchartsFactory.createChartOptions();
options.chart().zoomType("x"); options.chart().zoomType("xy");
options.title().text("Accounting Task"); options.title().text("Accounting Task");
@ -861,7 +908,7 @@ public class HightChartPanel extends FramedPanel {
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
ChartOptions options = highchartsFactory.createChartOptions(); ChartOptions options = highchartsFactory.createChartOptions();
options.chart().zoomType("x"); options.chart().zoomType("xy");
options.title().text("Accounting Job"); options.title().text("Accounting Job");

View File

@ -68,7 +68,7 @@ public class AccountingCaller {
throw new AccountingManagerServiceException( throw new AccountingManagerServiceException(
"Error retrieving list of info: list is null!"); "Error retrieving list of info: list is null!");
} }
logger.debug("Retrived Infos"); logger.debug("Retrieved Infos");
SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder( SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder(
accountingType, infos); accountingType, infos);

View File

@ -27,7 +27,10 @@ public class SeriesResponse4Job extends SeriesResponseBuilder {
@Override @Override
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
logger.debug("Infos: "+infos); logger.debug("Infos: "+infos);
if(infos.size()<=0){
logger.error("Error creating series for job accounting: No data available!");
throw new AccountingManagerServiceException("No data available!");
}
SeriesResponse seriesResponse = new SeriesResponse(); SeriesResponse seriesResponse = new SeriesResponse();

View File

@ -28,7 +28,10 @@ public class SeriesResponse4Portlet extends SeriesResponseBuilder {
@Override @Override
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
logger.debug("Infos: "+infos); logger.debug("Infos: "+infos);
if(infos.size()<=0){
logger.error("Error creating series for portlet accounting: No data available!");
throw new AccountingManagerServiceException("No data available!");
}
SeriesResponse seriesResponse = new SeriesResponse(); SeriesResponse seriesResponse = new SeriesResponse();

View File

@ -33,7 +33,11 @@ public class SeriesResponse4Service extends SeriesResponseBuilder {
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
try { try {
logger.debug("Infos: " + infos); logger.debug("Infos: " + infos);
if(infos.size()<=0){
logger.error("Error creating series for service accounting: No data available!");
throw new AccountingManagerServiceException("No data available!");
}
ArrayList<SeriesServiceData> series=new ArrayList<SeriesServiceData>(); ArrayList<SeriesServiceData> series=new ArrayList<SeriesServiceData>();
for (Info info : infos) { for (Info info : infos) {
Date date = info.getDate(); Date date = info.getDate();

View File

@ -33,7 +33,11 @@ public class SeriesResponse4Storage extends SeriesResponseBuilder {
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
try { try {
logger.debug("Infos: " + infos); logger.debug("Infos: " + infos);
if(infos.size()<=0){
logger.error("Error creating series for storage accounting: No data available!");
throw new AccountingManagerServiceException("No data available!");
}
ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>(); ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>();
for (Info info : infos) { for (Info info : infos) {
Date date = info.getDate(); Date date = info.getDate();

View File

@ -27,7 +27,10 @@ public class SeriesResponse4Task extends SeriesResponseBuilder {
@Override @Override
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
logger.debug("Infos: "+infos); logger.debug("Infos: "+infos);
if(infos.size()<=0){
logger.error("Error creating series for task accounting: No data available!");
throw new AccountingManagerServiceException("No data available!");
}
SeriesResponse seriesResponse = new SeriesResponse(); SeriesResponse seriesResponse = new SeriesResponse();

View File

@ -13,8 +13,8 @@ public class Constants {
public static final String AM_LANG_COOKIE = "AMLangCookie"; public static final String AM_LANG_COOKIE = "AMLangCookie";
public static final String AM_LANG = "AMLang"; public static final String AM_LANG = "AMLang";
public final static String DEFAULT_USER = "test.user"; public final static String DEFAULT_USER = "test.user";
public final static String DEFAULT_SCOPE = "/gcube/devNext"; //public final static String DEFAULT_SCOPE = "/gcube/devNext";
//public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE"; public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
} }