Accounting Fixed Month and Year aggregation bug for Service
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@131123 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
913c7b123e
commit
1955898fab
6
pom.xml
6
pom.xml
|
@ -91,17 +91,17 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Logger -->
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.S
|
|||
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
|
||||
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingPeriodMode;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
|
||||
|
@ -16,6 +17,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
|||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
|
||||
import com.github.highcharts4gwt.model.array.api.Array;
|
||||
import com.github.highcharts4gwt.model.array.api.ArrayNumber;
|
||||
import com.github.highcharts4gwt.model.array.api.ArrayString;
|
||||
import com.github.highcharts4gwt.model.factory.api.HighchartsOptionFactory;
|
||||
|
@ -23,6 +25,7 @@ import com.github.highcharts4gwt.model.factory.jso.JsoHighchartsOptionFactory;
|
|||
import com.github.highcharts4gwt.model.highcharts.option.api.ChartOptions;
|
||||
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesArea;
|
||||
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
|
||||
import com.github.highcharts4gwt.model.highcharts.option.api.seriescolumn.Data;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
|
@ -56,7 +59,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
||||
private static final String TIME_UNIT = "Time Unit";
|
||||
private static final String SINGLE_AXIS = "Single Axis";
|
||||
|
||||
|
||||
private EventBus eventBus;
|
||||
private AccountingClientStateData accountingStateData;
|
||||
private HighchartsLayoutPanel highchartsLayoutPanel;
|
||||
|
@ -83,10 +86,10 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
private String unitMeasureLabel = TimeUnitMeasure.MS;
|
||||
private TextButton unitButton;
|
||||
private ToggleButton toggleButton;
|
||||
|
||||
|
||||
public ServiceChartBasicPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
|
||||
this.eventBus=eventBus;
|
||||
public ServiceChartBasicPanel(EventBus eventBus,
|
||||
AccountingClientStateData accountingStateData) {
|
||||
this.eventBus = eventBus;
|
||||
this.accountingStateData = accountingStateData;
|
||||
forceLayoutOnResize = true;
|
||||
create();
|
||||
|
@ -252,7 +255,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
|
||||
AccountingManagerResources.INSTANCE.accountingFileSVG24());
|
||||
downloadSVGItem.setHeight(30);
|
||||
|
||||
|
||||
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -261,9 +264,8 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
downloadXMLItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -273,7 +275,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
downloadJSONItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -283,7 +285,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||
|
||||
@Override
|
||||
|
@ -320,7 +322,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
onDownloadSVG(id);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
menuDownload.add(downloadCSVItem);
|
||||
menuDownload.add(downloadXMLItem);
|
||||
menuDownload.add(downloadJSONItem);
|
||||
|
@ -331,26 +333,25 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
return menuDownload;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void onDownloadCSV() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.CSV, accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV,
|
||||
accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
|
||||
private void onDownloadXML() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.XML, accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(ExportType.XML,
|
||||
accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
private void onDownloadJSON() {
|
||||
ExportRequestEvent event = new ExportRequestEvent(
|
||||
ExportType.JSON, accountingStateData.getAccountingType());
|
||||
ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON,
|
||||
accountingStateData.getAccountingType());
|
||||
eventBus.fireEvent(event);
|
||||
}
|
||||
|
||||
|
||||
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
||||
|
||||
public static native void onDownloadPNG(String id) /*-{
|
||||
|
@ -414,23 +415,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
SeriesServiceBasic seriesServiceBasic = (SeriesServiceBasic) seriesService
|
||||
.getSerieServiceDefinition();
|
||||
|
||||
double minRange = ChartTimeMeasure
|
||||
.calculateMinRange(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod());
|
||||
|
||||
double interval = ChartTimeMeasure
|
||||
.calculateInterval(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod());
|
||||
|
||||
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod().getStartDate());
|
||||
|
||||
dateStart.setTime(dateStart.getTime()
|
||||
+ ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
|
||||
|
||||
Log.debug("BuildChart DateStart: "
|
||||
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL)
|
||||
.format(dateStart));
|
||||
|
||||
|
||||
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
|
||||
options = highchartsFactory.createChartOptions();
|
||||
|
@ -447,8 +432,6 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
// colors.setValue(0, "#cc0038");
|
||||
// colors.setValue(1, "#32cd32");
|
||||
|
||||
// xAxis
|
||||
options.xAxis().type("datetime").minRange(minRange);
|
||||
|
||||
// yAxis
|
||||
String multiAxis = "[{" + " \"id\": \""
|
||||
|
@ -491,8 +474,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
;
|
||||
|
||||
options.setFieldAsJsonObject("yAxis", multiAxis);
|
||||
|
||||
// does not seem to be working
|
||||
|
||||
String fillcolor = "{" + "\"linearGradient\": {" + "\"x1\": 0,"
|
||||
+ "\"y1\": 0," + "\"x2\": 0," + "\"y2\": 1" + "},"
|
||||
+ "\"stops\": [" + "[" + "0, \"#058DC7\"" + "]," + "["
|
||||
|
@ -509,21 +491,11 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
seriesOperationCount.color(colors.get(1));
|
||||
seriesOperationCount.type("column");
|
||||
|
||||
ArrayNumber dataOperationCount = seriesOperationCount
|
||||
.dataAsArrayNumber();
|
||||
|
||||
seriesOperationCount.pointInterval(interval).pointStart(
|
||||
dateStart.getTime());
|
||||
|
||||
SeriesArea seriesDuration = highchartsFactory.createSeriesArea();
|
||||
seriesDuration.name(ServiceChartMeasure.Duration.getLabel());
|
||||
seriesDuration.color(colors.get(0));
|
||||
seriesDuration.yAxisAsString(ServiceChartMeasure.Duration.name());
|
||||
|
||||
ArrayNumber dataDuration = seriesDuration.dataAsArrayNumber();
|
||||
|
||||
seriesDuration.pointInterval(interval).pointStart(dateStart.getTime());
|
||||
|
||||
SeriesArea seriesMaxInvocationTime = highchartsFactory
|
||||
.createSeriesArea();
|
||||
seriesMaxInvocationTime.name(ServiceChartMeasure.MaxInvocationTime
|
||||
|
@ -532,12 +504,6 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
seriesMaxInvocationTime
|
||||
.yAxisAsString(ServiceChartMeasure.MaxInvocationTime.name());
|
||||
|
||||
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
|
||||
.dataAsArrayNumber();
|
||||
|
||||
seriesMaxInvocationTime.pointInterval(interval).pointStart(
|
||||
dateStart.getTime());
|
||||
|
||||
SeriesArea seriesMinInvocationTime = highchartsFactory
|
||||
.createSeriesArea();
|
||||
seriesMinInvocationTime.name(ServiceChartMeasure.MinInvocationTime
|
||||
|
@ -545,30 +511,155 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
seriesMinInvocationTime.color(colors.get(3));
|
||||
seriesMinInvocationTime
|
||||
.yAxisAsString(ServiceChartMeasure.MinInvocationTime.name());
|
||||
|
||||
|
||||
if (accountingStateData.getSeriesRequest().getAccountingPeriod()
|
||||
.getPeriod().compareTo(AccountingPeriodMode.DAILY) == 0
|
||||
|| accountingStateData.getSeriesRequest().getAccountingPeriod()
|
||||
.getPeriod().compareTo(AccountingPeriodMode.HOURLY) == 0
|
||||
|| accountingStateData.getSeriesRequest().getAccountingPeriod()
|
||||
.getPeriod().compareTo(AccountingPeriodMode.MINUTELY) == 0) {
|
||||
|
||||
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
|
||||
.dataAsArrayNumber();
|
||||
double minRange = ChartTimeMeasure
|
||||
.calculateMinRange(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod());
|
||||
|
||||
seriesMinInvocationTime.pointInterval(interval).pointStart(
|
||||
dateStart.getTime());
|
||||
double interval = ChartTimeMeasure
|
||||
.calculateInterval(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod());
|
||||
|
||||
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest()
|
||||
.getAccountingPeriod().getStartDate());
|
||||
|
||||
dateStart.setTime(dateStart.getTime()
|
||||
+ ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
|
||||
|
||||
Log.debug("BuildChart DateStart: "
|
||||
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL)
|
||||
.format(dateStart));
|
||||
|
||||
// xAxis
|
||||
options.xAxis().type("datetime");
|
||||
options.xAxis().minRange(minRange);
|
||||
|
||||
ArrayNumber dataOperationCount = seriesOperationCount
|
||||
.dataAsArrayNumber();
|
||||
|
||||
seriesOperationCount.pointInterval(interval);
|
||||
seriesOperationCount.pointStart(dateStart.getTime());
|
||||
|
||||
ArrayNumber dataDuration = seriesDuration.dataAsArrayNumber();
|
||||
|
||||
seriesDuration.pointInterval(interval);
|
||||
seriesDuration.pointStart(dateStart.getTime());
|
||||
|
||||
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
|
||||
.dataAsArrayNumber();
|
||||
|
||||
seriesMaxInvocationTime.pointInterval(interval);
|
||||
seriesMaxInvocationTime.pointStart(dateStart.getTime());
|
||||
|
||||
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
|
||||
.dataAsArrayNumber();
|
||||
|
||||
seriesMinInvocationTime.pointInterval(interval);
|
||||
seriesMinInvocationTime.pointStart(dateStart.getTime());
|
||||
|
||||
for (SeriesServiceData seriesServiceData : seriesServiceBasic
|
||||
.getSeries()) {
|
||||
dataOperationCount.push(seriesServiceData.getOperationCount());
|
||||
dataDuration
|
||||
.push(seriesServiceData.getDuration() / unitMeasure);
|
||||
dataMaxInvocationTime.push(seriesServiceData
|
||||
.getMaxInvocationTime() / unitMeasure);
|
||||
dataMinInvocationTime.push(seriesServiceData
|
||||
.getMinInvocationTime() / unitMeasure);
|
||||
}
|
||||
|
||||
options.series().addToEnd(seriesOperationCount);
|
||||
options.series().addToEnd(seriesDuration);
|
||||
options.series().addToEnd(seriesMaxInvocationTime);
|
||||
options.series().addToEnd(seriesMinInvocationTime);
|
||||
|
||||
} else {
|
||||
// xAxis
|
||||
options.xAxis().type("datetime");
|
||||
|
||||
if (accountingStateData.getSeriesRequest().getAccountingPeriod()
|
||||
.getPeriod().compareTo(AccountingPeriodMode.MONTHLY) == 0){
|
||||
options.tooltip().xDateFormat("%b, %Y");
|
||||
//options.tooltip().xDateFormat("");
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
if (accountingStateData.getSeriesRequest().getAccountingPeriod()
|
||||
.getPeriod().compareTo(AccountingPeriodMode.YEARLY) == 0){
|
||||
options.tooltip().xDateFormat("%Y");
|
||||
//options.tooltip().xDateFormat("");
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Array<Data> arrayDataOperationCount = seriesOperationCount
|
||||
.dataAsArrayObject();
|
||||
Array<com.github.highcharts4gwt.model.highcharts.option.api.seriesarea.Data> arrayDataDuration = seriesDuration
|
||||
.dataAsArrayObject();
|
||||
Array<com.github.highcharts4gwt.model.highcharts.option.api.seriesarea.Data> arrayDataMaxInvocationTime = seriesMaxInvocationTime
|
||||
.dataAsArrayObject();
|
||||
Array<com.github.highcharts4gwt.model.highcharts.option.api.seriesarea.Data> arrayDataMinInvocationTime = seriesMinInvocationTime
|
||||
.dataAsArrayObject();
|
||||
|
||||
for (SeriesServiceData seriesServiceData : seriesServiceBasic
|
||||
.getSeries()) {
|
||||
long dateFrom1970=seriesServiceData.getDate().getTime();
|
||||
|
||||
Log.debug("SeriersServiceData: "+seriesServiceData.getDate());
|
||||
Log.debug("SeriersServiceData: "+dateFrom1970);
|
||||
//dateFrom1970=dateFrom1970+7200000;
|
||||
//Log.debug("SeriersServiceData: "+dateFrom1970);
|
||||
|
||||
Data dataOperationCount = highchartsFactory
|
||||
.createSeriesColumnData();
|
||||
dataOperationCount.x(dateFrom1970);
|
||||
dataOperationCount.y(seriesServiceData.getOperationCount()
|
||||
/ unitMeasure);
|
||||
arrayDataOperationCount.addToEnd(dataOperationCount);
|
||||
|
||||
com.github.highcharts4gwt.model.highcharts.option.api.seriesarea.Data dataDuration = highchartsFactory
|
||||
.createSeriesAreaData();
|
||||
dataDuration.x(dateFrom1970);
|
||||
dataDuration.y(seriesServiceData.getDuration()
|
||||
/ unitMeasure);
|
||||
arrayDataDuration.addToEnd(dataDuration);
|
||||
|
||||
com.github.highcharts4gwt.model.highcharts.option.api.seriesarea.Data dataMaxInvocationTime = highchartsFactory
|
||||
.createSeriesAreaData();
|
||||
dataMaxInvocationTime.x(dateFrom1970);
|
||||
dataMaxInvocationTime.y(seriesServiceData.getMaxInvocationTime()
|
||||
/ unitMeasure);
|
||||
arrayDataMaxInvocationTime.addToEnd(dataMaxInvocationTime);
|
||||
|
||||
com.github.highcharts4gwt.model.highcharts.option.api.seriesarea.Data dataMinInvocationTime = highchartsFactory
|
||||
.createSeriesAreaData();
|
||||
dataMinInvocationTime.x(dateFrom1970);
|
||||
dataMinInvocationTime.y(seriesServiceData.getMinInvocationTime()
|
||||
/ unitMeasure);
|
||||
arrayDataMinInvocationTime.addToEnd(dataMinInvocationTime);
|
||||
|
||||
}
|
||||
|
||||
options.series().addToEnd(seriesOperationCount);
|
||||
options.series().addToEnd(seriesDuration);
|
||||
options.series().addToEnd(seriesMaxInvocationTime);
|
||||
options.series().addToEnd(seriesMinInvocationTime);
|
||||
|
||||
for (SeriesServiceData seriesServiceData : seriesServiceBasic
|
||||
.getSeries()) {
|
||||
dataOperationCount.push(seriesServiceData.getOperationCount());
|
||||
dataDuration.push(seriesServiceData.getDuration() / unitMeasure);
|
||||
dataMaxInvocationTime.push(seriesServiceData.getMaxInvocationTime()
|
||||
/ unitMeasure);
|
||||
dataMinInvocationTime.push(seriesServiceData.getMinInvocationTime()
|
||||
/ unitMeasure);
|
||||
}
|
||||
|
||||
options.series().addToEnd(seriesOperationCount);
|
||||
options.series().addToEnd(seriesDuration);
|
||||
options.series().addToEnd(seriesMaxInvocationTime);
|
||||
options.series().addToEnd(seriesMinInvocationTime);
|
||||
|
||||
options.chart().showAxes(true);
|
||||
|
||||
options.legend().enabled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -675,7 +766,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
SeriesArea seriesDuration = highchartsFactory.createSeriesArea();
|
||||
seriesDuration.name(ServiceChartMeasure.Duration.getLabel());
|
||||
seriesDuration.color(colors.get(0));
|
||||
//seriesDuration.yAxisAsString("ServiceData");
|
||||
// seriesDuration.yAxisAsString("ServiceData");
|
||||
|
||||
ArrayNumber dataDuration = seriesDuration.dataAsArrayNumber();
|
||||
|
||||
|
@ -686,7 +777,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
seriesMaxInvocationTime.name(ServiceChartMeasure.MaxInvocationTime
|
||||
.getLabel());
|
||||
seriesMaxInvocationTime.color(colors.get(2));
|
||||
//seriesMaxInvocationTime.yAxisAsString("ServiceData");
|
||||
// seriesMaxInvocationTime.yAxisAsString("ServiceData");
|
||||
|
||||
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
|
||||
.dataAsArrayNumber();
|
||||
|
@ -699,7 +790,7 @@ public class ServiceChartBasicPanel extends SimpleContainer {
|
|||
seriesMinInvocationTime.name(ServiceChartMeasure.MinInvocationTime
|
||||
.getLabel());
|
||||
seriesMinInvocationTime.color(colors.get(3));
|
||||
//seriesMinInvocationTime.yAxisAsString("ServiceData");
|
||||
// seriesMinInvocationTime.yAxisAsString("ServiceData");
|
||||
|
||||
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
|
||||
.dataAsArrayNumber();
|
||||
|
|
|
@ -24,7 +24,8 @@ public class ChartTimeMeasure {
|
|||
Log.error("AccountingPeriodMode is null");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (accountingPeriod.getPeriod()) {
|
||||
case DAILY:
|
||||
// 1 day=24hour * 60min *60sec * 1000 millisec
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
|
||||
|
@ -41,9 +46,11 @@ import org.slf4j.LoggerFactory;
|
|||
*
|
||||
*/
|
||||
public class AccountingCallerTester implements AccountingCallerInterface {
|
||||
static Logger logger = LoggerFactory
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(AccountingCallerTester.class);
|
||||
|
||||
protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMMM dd");
|
||||
|
||||
public AccountingCallerTester() {
|
||||
super();
|
||||
}
|
||||
|
@ -125,6 +132,33 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
logger.debug("getSeries(): [AccountingType=" + accountingType
|
||||
+ " , seriesRequest=" + seriesRequest + "]");
|
||||
SeriesResponse seriesResponse = null;
|
||||
|
||||
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
|
||||
|
||||
try {
|
||||
startCalendar.setTime(sdf.parse(seriesRequest
|
||||
.getAccountingPeriod().getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
|
||||
|
||||
//GregorianCalendar endCalendar = new GregorianCalendar();
|
||||
//.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
|
||||
//GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
|
||||
try {
|
||||
endCalendar.setTime(sdf.parse(seriesRequest
|
||||
.getAccountingPeriod().getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
switch (accountingType) {
|
||||
case JOB:
|
||||
SeriesJobDefinition serieJobDefinition = null;
|
||||
|
@ -190,16 +224,55 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
if (seriesRequest.getAccountingFilterDefinition()
|
||||
.getChartType() != null) {
|
||||
ArrayList<SeriesServiceData> seriesServiceData = new ArrayList<>();
|
||||
for (int i = 0; i < 30; i++) {
|
||||
SeriesServiceData data = new SeriesServiceData(
|
||||
new Date(),
|
||||
new Double(50 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random()).longValue());
|
||||
seriesServiceData.add(data);
|
||||
switch (seriesRequest.getAccountingPeriod().getPeriod()) {
|
||||
case DAILY:
|
||||
case HOURLY:
|
||||
case MINUTELY:
|
||||
for (int i = 0; i < 30; i++) {
|
||||
SeriesServiceData data = new SeriesServiceData(
|
||||
new Date(),
|
||||
new Double(50 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random())
|
||||
.longValue(), new Double(
|
||||
10000 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random())
|
||||
.longValue());
|
||||
seriesServiceData.add(data);
|
||||
}
|
||||
break;
|
||||
case MONTHLY:
|
||||
while (startCalendar.compareTo(endCalendar) <= 0) {
|
||||
SeriesServiceData data = new SeriesServiceData(
|
||||
startCalendar.getTime(), new Double(
|
||||
50 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random())
|
||||
.longValue(), new Double(
|
||||
10000 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random())
|
||||
.longValue());
|
||||
seriesServiceData.add(data);
|
||||
startCalendar.add(Calendar.MONTH, 1);
|
||||
}
|
||||
break;
|
||||
case YEARLY:
|
||||
while (startCalendar.compareTo(endCalendar) <= 0) {
|
||||
SeriesServiceData data = new SeriesServiceData(
|
||||
startCalendar.getTime(), new Double(
|
||||
50 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random())
|
||||
.longValue(), new Double(
|
||||
10000 * Math.random()).longValue(),
|
||||
new Double(10000 * Math.random())
|
||||
.longValue());
|
||||
seriesServiceData.add(data);
|
||||
startCalendar.add(Calendar.YEAR, 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
switch (seriesRequest.getAccountingFilterDefinition()
|
||||
.getChartType()) {
|
||||
case Basic:
|
||||
|
@ -207,19 +280,70 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
seriesServiceData);
|
||||
break;
|
||||
case Top:
|
||||
|
||||
AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest
|
||||
.getAccountingFilterDefinition();
|
||||
ArrayList<SeriesServiceDataTop> seriesServiceDataTopList = new ArrayList<>();
|
||||
|
||||
if (accountingFilterTop.getShowOthers()) {
|
||||
for (int i = 0; i < 40; i++) {
|
||||
|
||||
try {
|
||||
startCalendar.setTime(sdf.parse(seriesRequest
|
||||
.getAccountingPeriod().getStartDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Start Date not valid!");
|
||||
}
|
||||
|
||||
SeriesServiceDataTop seriesServiceDataTop1 = new SeriesServiceDataTop(
|
||||
new FilterValue("User" + i),
|
||||
seriesServiceData);
|
||||
seriesServiceDataTopList
|
||||
.add(seriesServiceDataTop1);
|
||||
try {
|
||||
endCalendar.setTime(sdf.parse(seriesRequest
|
||||
.getAccountingPeriod().getEndDate()));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("End Date not valid!");
|
||||
}
|
||||
|
||||
int k=0;
|
||||
|
||||
switch (seriesRequest.getAccountingPeriod()
|
||||
.getPeriod()) {
|
||||
case DAILY:
|
||||
case HOURLY:
|
||||
case MINUTELY:
|
||||
for (int i = 0; i < 40; i++) {
|
||||
|
||||
SeriesServiceDataTop seriesServiceDataTop1 = new SeriesServiceDataTop(
|
||||
new FilterValue("User" + i),
|
||||
seriesServiceData);
|
||||
seriesServiceDataTopList
|
||||
.add(seriesServiceDataTop1);
|
||||
}
|
||||
break;
|
||||
case MONTHLY:
|
||||
k=0;
|
||||
while (startCalendar.compareTo(endCalendar) <= 0) {
|
||||
SeriesServiceDataTop seriesServiceDataTop1 = new SeriesServiceDataTop(
|
||||
new FilterValue("User" + k),
|
||||
seriesServiceData);
|
||||
seriesServiceDataTopList
|
||||
.add(seriesServiceDataTop1);
|
||||
startCalendar.add(Calendar.MONTH, 1);
|
||||
k++;
|
||||
}
|
||||
break;
|
||||
case YEARLY:
|
||||
k=0;
|
||||
while (startCalendar.compareTo(endCalendar) <= 0) {
|
||||
SeriesServiceDataTop seriesServiceDataTop1 = new SeriesServiceDataTop(
|
||||
new FilterValue("User" + k),
|
||||
seriesServiceData);
|
||||
seriesServiceDataTopList
|
||||
.add(seriesServiceDataTop1);
|
||||
startCalendar.add(Calendar.YEAR, 1);
|
||||
k++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
|
@ -324,5 +448,4 @@ public class AccountingCallerTester implements AccountingCallerInterface {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,16 +47,16 @@
|
|||
values="en" /> <extend-property name="locale" values="it" /> <extend-property
|
||||
name="locale" values="es" /> <set-property name="locale" value="en, it, es"
|
||||
/> <set-property-fallback name="locale" value="en" /> -->
|
||||
|
||||
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
/> -->
|
||||
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
|
||||
/> -->
|
||||
|
||||
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
|
|
Loading…
Reference in New Issue