Merge pull request 'feature/21354' (!3) from feature/21354 into master

Reviewed-on: #3
This commit is contained in:
Giancarlo Panichi 2021-11-30 14:36:40 +01:00
commit 109e04f8e8
82 changed files with 1711 additions and 7202 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/accounting-manager-1.13.0/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/accounting-manager-1.15.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/accounting-manager-1.13.0/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/accounting-manager-1.15.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -45,5 +45,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/accounting-manager-1.13.0/WEB-INF/classes"/> <classpathentry kind="output" path="target/accounting-manager-1.15.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="accounting-manager-1.13.0"> <wb-module deploy-name="accounting-manager-1.15.0-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>

View File

@ -3,6 +3,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for "accounting-manager" # Changelog for "accounting-manager"
## [v1.15.0-SNAPSHOT] - 2021-11-30
### Features
- Improve query support of the new persistence [#21354]
## [v1.14.0] - 2021-06-28 ## [v1.14.0] - 2021-06-28
### Fixes ### Fixes

View File

@ -1,4 +1,8 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-15-0"
date="2021-11-30">
<Change>Improve query support of the new persistence [#21354]</Change>
</Changeset>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-14-0" <Changeset component="org.gcube.portlets.admin.accounting-manager.1-14-0"
date="2021-06-28"> date="2021-06-28">
<Change>Fixed display errors generated in Root scope [#21729]</Change> <Change>Fixed display errors generated in Root scope [#21729]</Change>

22
pom.xml
View File

@ -15,7 +15,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.admin</groupId> <groupId>org.gcube.portlets.admin</groupId>
<artifactId>accounting-manager</artifactId> <artifactId>accounting-manager</artifactId>
<version>1.14.0</version> <version>1.15.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
@ -108,7 +108,7 @@
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-lib</artifactId> <artifactId>accounting-lib</artifactId>
<version>[4.0.0,5.0.0-SNAPSHOT)</version> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@ -235,6 +235,13 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Document Store Lib -->
<dependency>
<groupId>org.gcube.data.publishing</groupId>
<artifactId>document-store-lib</artifactId>
<scope>provided</scope>
</dependency>
<!-- Accounting Lib --> <!-- Accounting Lib -->
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
@ -246,14 +253,7 @@
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics</artifactId> <artifactId>accounting-analytics</artifactId>
<version>[3.0.0,4.0.0-SNAPSHOT)</version> <version>[4.0.0-SNAPSHOT,5.0.0-SNAPSHOT)</version>
</dependency>
<!-- Document Store Lib -->
<dependency>
<groupId>org.gcube.data.publishing</groupId>
<artifactId>document-store-lib</artifactId>
<scope>provided</scope>
</dependency> </dependency>
@ -261,7 +261,7 @@
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics-persistence-postgresql</artifactId> <artifactId>accounting-analytics-persistence-postgresql</artifactId>
<version>[1.0.0,2.0.0-SNAPSHOT)</version> <version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>

View File

@ -46,7 +46,8 @@
<!-- <set-configuration-property name="CssResource.style" value="pretty"/> --> <!-- <set-configuration-property name="CssResource.style" value="pretty"/> -->
<!-- <set-property name="log_DivLogger" value="ENABLED" /> <set-property <!--
<set-property name="log_DivLogger" value="ENABLED" /> <set-property
name="log_ConsoleLogger" value="ENABLED" /> <set-property name="log_GWTLogger" name="log_ConsoleLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED" value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> --> /> -->
@ -58,7 +59,6 @@
<set-property name="log_SystemLogger" value="DISABLED" /> <set-property name="log_SystemLogger" value="DISABLED" />
<!-- Specify the paths for translatable code --> <!-- Specify the paths for translatable code -->
<source path='client' /> <source path='client' />
<source path='shared' /> <source path='shared' />

View File

@ -430,6 +430,7 @@ public class AccountingManagerController {
AccountingClientStateData accountingStateData = accountingState.getState(accountingType); AccountingClientStateData accountingStateData = accountingState.getState(accountingType);
SeriesRequest seriesRequest = null; SeriesRequest seriesRequest = null;
Context defaultContext=availableContext;
switch (accountingType) { switch (accountingType) {
case JOB: case JOB:
@ -439,9 +440,8 @@ public class AccountingManagerController {
case TASK: case TASK:
seriesRequest = new SeriesRequest( seriesRequest = new SeriesRequest(
new AccountingPeriod(dtf.format(lastMonth), dtf.format(date), AccountingPeriodMode.DAILY), new AccountingPeriod(dtf.format(lastMonth), dtf.format(date), AccountingPeriodMode.DAILY),
new AccountingFilterBasic()); new AccountingFilterBasic(defaultContext));
Log.debug("DefaultSeriesRequest: " + seriesRequest); Log.debug("DefaultSeriesRequest: " + seriesRequest);
break; break;
case SPACE: case SPACE:
accountingStateData.setAvailableSpaces(spaces); accountingStateData.setAvailableSpaces(spaces);

View File

@ -92,7 +92,7 @@ public class FiltersPanel extends FramedPanel {
AccountingFilterDefinition accountingFilterDefinition = activeFiltersPanel AccountingFilterDefinition accountingFilterDefinition = activeFiltersPanel
.getActiveFilters(); .getActiveFilters();
if (accountingPeriod != null) { if (accountingPeriod != null && accountingFilterDefinition!=null) {
SeriesRequest seriesRequest = new SeriesRequest(accountingPeriod, SeriesRequest seriesRequest = new SeriesRequest(accountingPeriod,
accountingFilterDefinition); accountingFilterDefinition);
Log.debug("UpdateChart: " + seriesRequest); Log.debug("UpdateChart: " + seriesRequest);

View File

@ -1,7 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartContextPanel;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartTopPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartTopPanel;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
@ -13,7 +12,7 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
/** /**
* Accounting Chart 4 Job * Accounting Chart 4 Job
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
@ -22,8 +21,7 @@ public class AccountingChart4Job extends AccountingChartBuilder {
private AccountingClientStateData accountingStateData; private AccountingClientStateData accountingStateData;
private EventBus eventBus; private EventBus eventBus;
public AccountingChart4Job(EventBus eventBus, public AccountingChart4Job(EventBus eventBus, AccountingClientStateData accountingStateData) {
AccountingClientStateData accountingStateData) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }
@ -32,10 +30,8 @@ public class AccountingChart4Job extends AccountingChartBuilder {
public void buildChart() throws ChartDrawException { public void buildChart() throws ChartDrawException {
AccountingChartPanel accountingChartPanel = null; AccountingChartPanel accountingChartPanel = null;
if (accountingStateData == null if (accountingStateData == null || accountingStateData.getAccountingType() == null
|| accountingStateData.getAccountingType() == null || accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesResponse() == null) {
|| accountingStateData.getSeriesRequest() == null
|| accountingStateData.getSeriesResponse() == null) {
accountingChartSpec.setChart(accountingChartPanel); accountingChartSpec.setChart(accountingChartPanel);
return; return;
} }
@ -55,25 +51,18 @@ public class AccountingChart4Job extends AccountingChartBuilder {
private SimpleContainer createJobChartPanel() throws ChartDrawException { private SimpleContainer createJobChartPanel() throws ChartDrawException {
if (accountingStateData == null if (accountingStateData == null || accountingStateData.getSeriesRequest() == null
|| accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesRequest().getAccountingFilterDefinition() == null
|| accountingStateData.getSeriesRequest() || accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType() == null) {
.getAccountingFilterDefinition() == null
|| accountingStateData.getSeriesRequest()
.getAccountingFilterDefinition().getChartType() == null) {
return null; return null;
} }
switch (accountingStateData.getSeriesRequest() switch (accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType()) {
.getAccountingFilterDefinition().getChartType()) {
case Top: case Top:
return new JobChartTopPanel(eventBus, accountingStateData); return new JobChartTopPanel(eventBus, accountingStateData);
case Basic: case Basic:
return new JobChartBasicPanel(eventBus, accountingStateData); return new JobChartBasicPanel(eventBus, accountingStateData);
case Context:
return new JobChartContextPanel(eventBus, accountingStateData);
default: default:
return null; return null;
} }

View File

@ -1,7 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartBasicPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartBasicPanel;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartContextPanel;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartTopPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.service.ServiceChartTopPanel;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
@ -13,7 +12,7 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
/** /**
* Accounting Chart 4 Service * Accounting Chart 4 Service
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
@ -21,9 +20,8 @@ public class AccountingChart4Service extends AccountingChartBuilder {
private EventBus eventBus; private EventBus eventBus;
private AccountingClientStateData accountingStateData; private AccountingClientStateData accountingStateData;
public AccountingChart4Service(EventBus eventBus, AccountingClientStateData accountingStateData) { public AccountingChart4Service(EventBus eventBus, AccountingClientStateData accountingStateData) {
this.eventBus=eventBus; this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }
@ -31,10 +29,8 @@ public class AccountingChart4Service extends AccountingChartBuilder {
public void buildChart() throws ChartDrawException { public void buildChart() throws ChartDrawException {
AccountingChartPanel accountingChartPanel = null; AccountingChartPanel accountingChartPanel = null;
if (accountingStateData == null if (accountingStateData == null || accountingStateData.getAccountingType() == null
|| accountingStateData.getAccountingType() == null || accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesResponse() == null) {
|| accountingStateData.getSeriesRequest() == null
|| accountingStateData.getSeriesResponse() == null) {
accountingChartSpec.setChart(accountingChartPanel); accountingChartSpec.setChart(accountingChartPanel);
return; return;
} }
@ -52,28 +48,20 @@ public class AccountingChart4Service extends AccountingChartBuilder {
} }
private SimpleContainer createServiceChartPanel() private SimpleContainer createServiceChartPanel() throws ChartDrawException {
throws ChartDrawException {
if (accountingStateData == null if (accountingStateData == null || accountingStateData.getSeriesRequest() == null
|| accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesRequest().getAccountingFilterDefinition() == null
|| accountingStateData.getSeriesRequest() || accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType() == null) {
.getAccountingFilterDefinition() == null
|| accountingStateData.getSeriesRequest()
.getAccountingFilterDefinition().getChartType() == null) {
return null; return null;
} }
switch (accountingStateData.getSeriesRequest() switch (accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType()) {
.getAccountingFilterDefinition().getChartType()) {
case Top: case Top:
return new ServiceChartTopPanel(eventBus,accountingStateData); return new ServiceChartTopPanel(eventBus, accountingStateData);
case Basic: case Basic:
return new ServiceChartBasicPanel(eventBus, accountingStateData); return new ServiceChartBasicPanel(eventBus, accountingStateData);
case Context:
return new ServiceChartContextPanel(eventBus, accountingStateData);
default: default:
return null; return null;

View File

@ -1,7 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts; package org.gcube.portlets.admin.accountingmanager.client.maindata.charts;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartBasicPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartBasicPanel;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartContextPanel;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartTopPanel; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.storage.StorageChartTopPanel;
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData; import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
@ -13,7 +12,7 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
/** /**
* Accounting Chart 4 Storage * Accounting Chart 4 Storage
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
@ -21,8 +20,7 @@ public class AccountingChart4Storage extends AccountingChartBuilder {
private EventBus eventBus; private EventBus eventBus;
private AccountingClientStateData accountingStateData; private AccountingClientStateData accountingStateData;
public AccountingChart4Storage(EventBus eventBus, public AccountingChart4Storage(EventBus eventBus, AccountingClientStateData accountingStateData) {
AccountingClientStateData accountingStateData) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
} }
@ -31,10 +29,8 @@ public class AccountingChart4Storage extends AccountingChartBuilder {
public void buildChart() throws ChartDrawException { public void buildChart() throws ChartDrawException {
AccountingChartPanel accountingChartPanel = null; AccountingChartPanel accountingChartPanel = null;
if (accountingStateData == null if (accountingStateData == null || accountingStateData.getAccountingType() == null
|| accountingStateData.getAccountingType() == null || accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesResponse() == null) {
|| accountingStateData.getSeriesRequest() == null
|| accountingStateData.getSeriesResponse() == null) {
accountingChartSpec.setChart(accountingChartPanel); accountingChartSpec.setChart(accountingChartPanel);
return; return;
} }
@ -54,25 +50,18 @@ public class AccountingChart4Storage extends AccountingChartBuilder {
private SimpleContainer createStorageChartPanel() throws ChartDrawException { private SimpleContainer createStorageChartPanel() throws ChartDrawException {
if (accountingStateData == null if (accountingStateData == null || accountingStateData.getSeriesRequest() == null
|| accountingStateData.getSeriesRequest() == null || accountingStateData.getSeriesRequest().getAccountingFilterDefinition() == null
|| accountingStateData.getSeriesRequest() || accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType() == null) {
.getAccountingFilterDefinition() == null
|| accountingStateData.getSeriesRequest()
.getAccountingFilterDefinition().getChartType() == null) {
return null; return null;
} }
switch (accountingStateData.getSeriesRequest() switch (accountingStateData.getSeriesRequest().getAccountingFilterDefinition().getChartType()) {
.getAccountingFilterDefinition().getChartType()) {
case Top: case Top:
return new StorageChartTopPanel(eventBus, accountingStateData); return new StorageChartTopPanel(eventBus, accountingStateData);
case Basic: case Basic:
return new StorageChartBasicPanel(eventBus, accountingStateData); return new StorageChartBasicPanel(eventBus, accountingStateData);
case Context:
return new StorageChartContextPanel(eventBus, accountingStateData);
default: default:
return null; return null;

View File

@ -6,6 +6,7 @@ import java.util.Date;
import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent; import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartDateTimeData; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartDateTimeData;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ColorsPalette;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
@ -57,8 +58,7 @@ public class JobChartTopPanel extends SimpleContainer {
private static final String TIME_UNIT = "Time Unit"; private static final String TIME_UNIT = "Time Unit";
// private static final String MEASURE_TYPE = "Measure"; // private static final String MEASURE_TYPE = "Measure";
private DateTimeFormat dtf = DateTimeFormat private DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private EventBus eventBus; private EventBus eventBus;
private AccountingClientStateData accountingStateData; private AccountingClientStateData accountingStateData;
@ -96,8 +96,7 @@ public class JobChartTopPanel extends SimpleContainer {
private VerticalLayoutContainer vert; private VerticalLayoutContainer vert;
public JobChartTopPanel(EventBus eventBus, public JobChartTopPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
AccountingClientStateData accountingStateData) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
@ -109,8 +108,7 @@ public class JobChartTopPanel extends SimpleContainer {
ToolBar toolBar = new ToolBar(); ToolBar toolBar = new ToolBar();
toolBar.setSpacing(2); toolBar.setSpacing(2);
// Download // Download
final TextButton downloadButton = new TextButton( final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD,
DownloadConstants.DOWNLOAD,
AccountingManagerResources.INSTANCE.accountingDownload24()); AccountingManagerResources.INSTANCE.accountingDownload24());
// downloadButton.setScale(ButtonScale.MEDIUM); // downloadButton.setScale(ButtonScale.MEDIUM);
downloadButton.setIconAlign(IconAlign.RIGHT); downloadButton.setIconAlign(IconAlign.RIGHT);
@ -125,8 +123,7 @@ public class JobChartTopPanel extends SimpleContainer {
measureButton.setMenu(createMeasureMenu()); measureButton.setMenu(createMeasureMenu());
// Unit // Unit
unitButton = new TextButton(TIME_UNIT, unitButton = new TextButton(TIME_UNIT, AccountingManagerResources.INSTANCE.accountingUnitms24());
AccountingManagerResources.INSTANCE.accountingUnitms24());
unitButton.setIconAlign(IconAlign.RIGHT); unitButton.setIconAlign(IconAlign.RIGHT);
unitButton.setArrowAlign(ButtonArrowAlign.RIGHT); unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
unitButton.setMenu(createUnitMenu()); unitButton.setMenu(createUnitMenu());
@ -145,8 +142,7 @@ public class JobChartTopPanel extends SimpleContainer {
// //
vert = new VerticalLayoutContainer(); vert = new VerticalLayoutContainer();
vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, new Margins(0)));
new Margins(0)));
add(vert, new MarginData(0)); add(vert, new MarginData(0));
@ -265,14 +261,11 @@ public class JobChartTopPanel extends SimpleContainer {
// TODO // TODO
durationItem = new MenuItem(JobChartMeasure.Duration.getLabel()); durationItem = new MenuItem(JobChartMeasure.Duration.getLabel());
durationItem.setHeight(30); durationItem.setHeight(30);
operationCountItem = new MenuItem( operationCountItem = new MenuItem(JobChartMeasure.OperationCount.getLabel());
JobChartMeasure.OperationCount.getLabel());
operationCountItem.setHeight(30); operationCountItem.setHeight(30);
maxInvocationTimeItem = new MenuItem( maxInvocationTimeItem = new MenuItem(JobChartMeasure.MaxInvocationTime.getLabel());
JobChartMeasure.MaxInvocationTime.getLabel());
maxInvocationTimeItem.setHeight(30); maxInvocationTimeItem.setHeight(30);
minInvocationTimeItem = new MenuItem( minInvocationTimeItem = new MenuItem(JobChartMeasure.MinInvocationTime.getLabel());
JobChartMeasure.MinInvocationTime.getLabel());
minInvocationTimeItem.setHeight(30); minInvocationTimeItem.setHeight(30);
durationItem.addSelectionHandler(new SelectionHandler<Item>() { durationItem.addSelectionHandler(new SelectionHandler<Item>() {
@ -301,8 +294,7 @@ public class JobChartTopPanel extends SimpleContainer {
@Override @Override
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
measureButton.setText(JobChartMeasure.MaxInvocationTime measureButton.setText(JobChartMeasure.MaxInvocationTime.getLabel());
.getLabel());
measure = JobChartMeasure.MaxInvocationTime; measure = JobChartMeasure.MaxInvocationTime;
unitButton.setVisible(true); unitButton.setVisible(true);
updateChart(); updateChart();
@ -313,8 +305,7 @@ public class JobChartTopPanel extends SimpleContainer {
@Override @Override
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
measureButton.setText(JobChartMeasure.MinInvocationTime measureButton.setText(JobChartMeasure.MinInvocationTime.getLabel());
.getLabel());
measure = JobChartMeasure.MinInvocationTime; measure = JobChartMeasure.MinInvocationTime;
unitButton.setVisible(true); unitButton.setVisible(true);
updateChart(); updateChart();
@ -332,17 +323,13 @@ public class JobChartTopPanel extends SimpleContainer {
private Menu createUnitMenu() { private Menu createUnitMenu() {
Menu menuUnit = new Menu(); Menu menuUnit = new Menu();
msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS, msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS, AccountingManagerResources.INSTANCE.accountingUnitms24());
AccountingManagerResources.INSTANCE.accountingUnitms24());
msItem.setHeight(30); msItem.setHeight(30);
sItem = new MenuItem(TimeUnitMeasure.SECONDS, sItem = new MenuItem(TimeUnitMeasure.SECONDS, AccountingManagerResources.INSTANCE.accountingUnits24());
AccountingManagerResources.INSTANCE.accountingUnits24());
sItem.setHeight(30); sItem.setHeight(30);
mItem = new MenuItem(TimeUnitMeasure.MINUTES, mItem = new MenuItem(TimeUnitMeasure.MINUTES, AccountingManagerResources.INSTANCE.accountingUnitm24());
AccountingManagerResources.INSTANCE.accountingUnitm24());
mItem.setHeight(30); mItem.setHeight(30);
hItem = new MenuItem(TimeUnitMeasure.HOURS, hItem = new MenuItem(TimeUnitMeasure.HOURS, AccountingManagerResources.INSTANCE.accountingUnith24());
AccountingManagerResources.INSTANCE.accountingUnith24());
hItem.setHeight(30); hItem.setHeight(30);
msItem.addSelectionHandler(new SelectionHandler<Item>() { msItem.addSelectionHandler(new SelectionHandler<Item>() {
@ -351,8 +338,7 @@ public class JobChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
unitMeasure = TimeUnitMeasure.getMilliseconds(); unitMeasure = TimeUnitMeasure.getMilliseconds();
unitMeasureLabel = TimeUnitMeasure.MS; unitMeasureLabel = TimeUnitMeasure.MS;
unitButton.setIcon(AccountingManagerResources.INSTANCE unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitms24());
.accountingUnitms24());
updateChart(); updateChart();
} }
}); });
@ -363,8 +349,7 @@ public class JobChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
unitMeasure = TimeUnitMeasure.getSeconds(); unitMeasure = TimeUnitMeasure.getSeconds();
unitMeasureLabel = TimeUnitMeasure.S; unitMeasureLabel = TimeUnitMeasure.S;
unitButton.setIcon(AccountingManagerResources.INSTANCE unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnits24());
.accountingUnits24());
updateChart(); updateChart();
} }
}); });
@ -375,8 +360,7 @@ public class JobChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
unitMeasure = TimeUnitMeasure.getMinutes(); unitMeasure = TimeUnitMeasure.getMinutes();
unitMeasureLabel = TimeUnitMeasure.M; unitMeasureLabel = TimeUnitMeasure.M;
unitButton.setIcon(AccountingManagerResources.INSTANCE unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitm24());
.accountingUnitm24());
updateChart(); updateChart();
} }
}); });
@ -387,8 +371,7 @@ public class JobChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
unitMeasure = TimeUnitMeasure.getHours(); unitMeasure = TimeUnitMeasure.getHours();
unitMeasureLabel = TimeUnitMeasure.H; unitMeasureLabel = TimeUnitMeasure.H;
unitButton.setIcon(AccountingManagerResources.INSTANCE unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnith24());
.accountingUnith24());
updateChart(); updateChart();
} }
}); });
@ -402,20 +385,17 @@ public class JobChartTopPanel extends SimpleContainer {
} }
private void onDownloadCSV() { private void onDownloadCSV() {
ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV, ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV, accountingStateData.getAccountingType());
accountingStateData.getAccountingType());
eventBus.fireEvent(event); eventBus.fireEvent(event);
} }
private void onDownloadXML() { private void onDownloadXML() {
ExportRequestEvent event = new ExportRequestEvent(ExportType.XML, ExportRequestEvent event = new ExportRequestEvent(ExportType.XML, accountingStateData.getAccountingType());
accountingStateData.getAccountingType());
eventBus.fireEvent(event); eventBus.fireEvent(event);
} }
private void onDownloadJSON() { private void onDownloadJSON() {
ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON, ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON, accountingStateData.getAccountingType());
accountingStateData.getAccountingType());
eventBus.fireEvent(event); eventBus.fireEvent(event);
} }
@ -472,15 +452,13 @@ public class JobChartTopPanel extends SimpleContainer {
}-*/; }-*/;
private void createChart() { private void createChart() {
SeriesJob seriesJob = (SeriesJob) accountingStateData SeriesJob seriesJob = (SeriesJob) accountingStateData.getSeriesResponse();
.getSeriesResponse();
if (!(seriesJob.getSeriesJobDefinition() instanceof SeriesJobTop)) { if (!(seriesJob.getSeriesJobDefinition() instanceof SeriesJobTop)) {
Log.debug("Invalid SeriesJobTop!"); Log.debug("Invalid SeriesJobTop!");
return; return;
} }
SeriesJobTop seriesJobTop = (SeriesJobTop) seriesJob SeriesJobTop seriesJobTop = (SeriesJobTop) seriesJob.getSeriesJobDefinition();
.getSeriesJobDefinition();
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
@ -491,32 +469,28 @@ public class JobChartTopPanel extends SimpleContainer {
options.title().text("Accounting Job Top"); options.title().text("Accounting Job Top");
/* /*
* options.subtitle().text("Click and drag in the plot area to zoom in"); * options.subtitle().text("Click and drag in the plot area to zoom in"
* );
*/ */
ColorsPalette colorsPalette=new ColorsPalette();
ArrayString colors = options.colors(); ArrayString colors = options.colors();
colors=colorsPalette.getColorsPalette(colors);
options.colors(colors);
// colors.setValue(0, "#cc0038"); // colors.setValue(0, "#cc0038");
// colors.setValue(1, "#32cd32"); // colors.setValue(1, "#32cd32");
// yAxis // yAxis
options.setFieldAsJsonObject("yAxis", retrieveYAxis(colors)); options.setFieldAsJsonObject("yAxis", retrieveYAxis(colors));
options.plotOptions().setFieldAsJsonObject( options.plotOptions().setFieldAsJsonObject("column",
"column", "{ " + "\"stacking\": \"normal\"," + "\"dataLabels\": { " + " \"enabled\": \"true\","
"{ " + "\"stacking\": \"normal\"," + "\"dataLabels\": { "
+ " \"enabled\": \"true\","
+ " \"color\": \"white\", " + " \"style\": {" + " \"color\": \"white\", " + " \"style\": {"
+ " \"textShadow\": \"0 0 3px black\"" + " }" + " \"textShadow\": \"0 0 3px black\"" + " }" + " }" + " }");
+ " }" + " }");
ArrayList<SeriesColumn> seriesColumn = new ArrayList<>(); ArrayList<SeriesColumn> seriesColumn = new ArrayList<>();
if (seriesJobTop.getShowOthers()) { createSeriesColumnSimple(seriesJobTop, highchartsFactory, colors, seriesColumn);
createSeriesColumnShowOthers(seriesJobTop, highchartsFactory,
colors, seriesColumn);
} else {
createSeriesColumnSimple(seriesJobTop, highchartsFactory, colors,
seriesColumn);
}
for (SeriesColumn serie : seriesColumn) { for (SeriesColumn serie : seriesColumn) {
options.series().addToEnd(serie); options.series().addToEnd(serie);
@ -528,35 +502,28 @@ public class JobChartTopPanel extends SimpleContainer {
return; return;
} }
private void createSeriesColumnShowOthers(SeriesJobTop seriesJobTop, private void createSeriesColumnShowOthers(SeriesJobTop seriesJobTop, HighchartsOptionFactory highchartsFactory,
HighchartsOptionFactory highchartsFactory, ArrayString colors, ArrayString colors, ArrayList<SeriesColumn> seriesColumn) {
ArrayList<SeriesColumn> seriesColumn) {
Log.debug("Series ShowOthers"); Log.debug("Series ShowOthers");
if (accountingStateData.getSeriesRequest().getAccountingPeriod() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.DAILY) == 0 .compareTo(AccountingPeriodMode.DAILY) == 0
|| accountingStateData.getSeriesRequest().getAccountingPeriod() || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.HOURLY) == 0 .compareTo(AccountingPeriodMode.HOURLY) == 0
|| accountingStateData.getSeriesRequest().getAccountingPeriod() || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.MINUTELY) == 0) { .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
double minRange = ChartTimeMeasure double minRange = ChartTimeMeasure
.calculateMinRange(accountingStateData.getSeriesRequest() .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
.getAccountingPeriod());
double interval = ChartTimeMeasure double interval = ChartTimeMeasure
.calculateInterval(accountingStateData.getSeriesRequest() .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
.getAccountingPeriod());
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest() Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
.getAccountingPeriod().getStartDate());
dateStart.setTime(dateStart.getTime() dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
+ ChartTimeMeasure.timeZoneOffset()
* ChartTimeMeasure.MINUTE);
Log.debug("BuildChart DateStart: " Log.debug("BuildChart DateStart: "
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL) + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
.format(dateStart));
// xAxis // xAxis
options.xAxis().type("datetime"); options.xAxis().type("datetime");
@ -564,31 +531,25 @@ public class JobChartTopPanel extends SimpleContainer {
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
int i = 0; int i = 0;
for (; i < seriesJobTop.getSeriesJobDataTopList().size() for (; i < seriesJobTop.getSeriesJobDataTopList().size() && i < seriesJobTop.getTopNumber(); i++) {
&& i < seriesJobTop.getTopNumber(); i++) { SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
SeriesColumn seriesColumnData = highchartsFactory
.createSeriesColumn();
seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList() seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i).getFilterValue().getValue());
.get(i).getFilterValue().getValue());
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
ArrayNumber data = seriesColumnData.dataAsArrayNumber(); ArrayNumber data = seriesColumnData.dataAsArrayNumber();
for (SeriesJobData seriesJobData : seriesJobTop for (SeriesJobData seriesJobData : seriesJobTop.getSeriesJobDataTopList().get(i).getSeries()) {
.getSeriesJobDataTopList().get(i).getSeries()) {
switch (measure) { switch (measure) {
case Duration: case Duration:
data.push(seriesJobData.getDuration() / unitMeasure); data.push(seriesJobData.getDuration() / unitMeasure);
break; break;
case MaxInvocationTime: case MaxInvocationTime:
data.push(seriesJobData.getMaxInvocationTime() data.push(seriesJobData.getMaxInvocationTime() / unitMeasure);
/ unitMeasure);
break; break;
case MinInvocationTime: case MinInvocationTime:
data.push(seriesJobData.getMinInvocationTime() data.push(seriesJobData.getMinInvocationTime() / unitMeasure);
/ unitMeasure);
break; break;
case OperationCount: case OperationCount:
data.push(seriesJobData.getOperationCount()); data.push(seriesJobData.getOperationCount());
@ -601,77 +562,61 @@ public class JobChartTopPanel extends SimpleContainer {
} }
seriesColumnData.pointInterval(interval).pointStart( seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
dateStart.getTime());
seriesColumn.add(seriesColumnData); seriesColumn.add(seriesColumnData);
} }
if (i < seriesJobTop.getSeriesJobDataTopList().size()) { if (i < seriesJobTop.getSeriesJobDataTopList().size()) {
SeriesColumn seriesColumnData = highchartsFactory SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
.createSeriesColumn();
seriesColumnData.name("Others"); seriesColumnData.name("Others");
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
ArrayList<Long> othersData = new ArrayList<>(); ArrayList<Long> othersData = new ArrayList<>();
for (int j = i; j < seriesJobTop.getSeriesJobDataTopList() for (int j = i; j < seriesJobTop.getSeriesJobDataTopList().size(); j++) {
.size(); j++) {
Long value; Long value;
for (int k = 0; k < seriesJobTop.getSeriesJobDataTopList() for (int k = 0; k < seriesJobTop.getSeriesJobDataTopList().get(j).getSeries().size(); k++) {
.get(j).getSeries().size(); k++) { SeriesJobData seriesJobData = seriesJobTop.getSeriesJobDataTopList().get(j).getSeries().get(k);
SeriesJobData seriesJobData = seriesJobTop
.getSeriesJobDataTopList().get(j).getSeries()
.get(k);
if (j == i) { if (j == i) {
switch (measure) { switch (measure) {
case Duration: case Duration:
othersData.add(seriesJobData.getDuration() othersData.add(seriesJobData.getDuration() / unitMeasure);
/ unitMeasure);
break; break;
case MaxInvocationTime: case MaxInvocationTime:
othersData.add(seriesJobData othersData.add(seriesJobData.getMaxInvocationTime() / unitMeasure);
.getMaxInvocationTime() / unitMeasure);
break; break;
case MinInvocationTime: case MinInvocationTime:
othersData.add(seriesJobData othersData.add(seriesJobData.getMinInvocationTime() / unitMeasure);
.getMinInvocationTime() / unitMeasure);
break; break;
case OperationCount: case OperationCount:
othersData.add(seriesJobData othersData.add(seriesJobData.getOperationCount());
.getOperationCount());
break; break;
default: default:
othersData.add(seriesJobData.getDuration() othersData.add(seriesJobData.getDuration() / unitMeasure);
/ unitMeasure);
break; break;
} }
} else { } else {
switch (measure) { switch (measure) {
case Duration: case Duration:
value = (seriesJobData.getDuration() / unitMeasure) value = (seriesJobData.getDuration() / unitMeasure) + othersData.get(k);
+ othersData.get(k);
othersData.set(k, value); othersData.set(k, value);
break; break;
case MaxInvocationTime: case MaxInvocationTime:
value = (seriesJobData.getMaxInvocationTime() / unitMeasure) value = (seriesJobData.getMaxInvocationTime() / unitMeasure) + othersData.get(k);
+ othersData.get(k);
othersData.set(k, value); othersData.set(k, value);
break; break;
case MinInvocationTime: case MinInvocationTime:
value = (seriesJobData.getMinInvocationTime() / unitMeasure) value = (seriesJobData.getMinInvocationTime() / unitMeasure) + othersData.get(k);
+ othersData.get(k);
othersData.set(k, value); othersData.set(k, value);
break; break;
case OperationCount: case OperationCount:
value = seriesJobData.getOperationCount() value = seriesJobData.getOperationCount() + othersData.get(k);
+ othersData.get(k);
othersData.set(k, value); othersData.set(k, value);
break; break;
default: default:
value = (seriesJobData.getDuration() / unitMeasure) value = (seriesJobData.getDuration() / unitMeasure) + othersData.get(k);
+ othersData.get(k);
othersData.set(k, value); othersData.set(k, value);
break; break;
@ -688,8 +633,7 @@ public class JobChartTopPanel extends SimpleContainer {
data.push(value); data.push(value);
} }
seriesColumnData.pointInterval(interval).pointStart( seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
dateStart.getTime());
seriesColumn.add(seriesColumnData); seriesColumn.add(seriesColumnData);
} }
@ -697,16 +641,15 @@ public class JobChartTopPanel extends SimpleContainer {
// xAxis // xAxis
options.xAxis().type("datetime"); options.xAxis().type("datetime");
if (accountingStateData.getSeriesRequest().getAccountingPeriod() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.MONTHLY) == 0) { .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
//options.tooltip().xDateFormat("%b, %Y"); // options.tooltip().xDateFormat("%b, %Y");
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
} else { } else {
if (accountingStateData.getSeriesRequest() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getAccountingPeriod().getPeriod()
.compareTo(AccountingPeriodMode.YEARLY) == 0) { .compareTo(AccountingPeriodMode.YEARLY) == 0) {
//options.tooltip().xDateFormat("%Y"); // options.tooltip().xDateFormat("%Y");
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
} else { } else {
@ -716,20 +659,16 @@ public class JobChartTopPanel extends SimpleContainer {
} }
int i = 0; int i = 0;
for (; i < seriesJobTop.getSeriesJobDataTopList().size() for (; i < seriesJobTop.getSeriesJobDataTopList().size() && i < seriesJobTop.getTopNumber(); i++) {
&& i < seriesJobTop.getTopNumber(); i++) { SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
SeriesColumn seriesColumnData = highchartsFactory
.createSeriesColumn();
seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList() seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i).getFilterValue().getValue());
.get(i).getFilterValue().getValue());
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
Array<Data> arrayData = seriesColumnData.dataAsArrayObject(); Array<Data> arrayData = seriesColumnData.dataAsArrayObject();
for (SeriesJobData seriesJobData : seriesJobTop for (SeriesJobData seriesJobData : seriesJobTop.getSeriesJobDataTopList().get(i).getSeries()) {
.getSeriesJobDataTopList().get(i).getSeries()) {
long dateFrom1970 = seriesJobData.getDate().getTime(); long dateFrom1970 = seriesJobData.getDate().getTime();
Log.debug("SeriersJobData: " + seriesJobData.getDate()); Log.debug("SeriersJobData: " + seriesJobData.getDate());
@ -745,14 +684,12 @@ public class JobChartTopPanel extends SimpleContainer {
break; break;
case MaxInvocationTime: case MaxInvocationTime:
data.x(dateFrom1970); data.x(dateFrom1970);
data.y(seriesJobData.getMaxInvocationTime() data.y(seriesJobData.getMaxInvocationTime() / unitMeasure);
/ unitMeasure);
arrayData.addToEnd(data); arrayData.addToEnd(data);
break; break;
case MinInvocationTime: case MinInvocationTime:
data.x(dateFrom1970); data.x(dateFrom1970);
data.y(seriesJobData.getMinInvocationTime() data.y(seriesJobData.getMinInvocationTime() / unitMeasure);
/ unitMeasure);
arrayData.addToEnd(data); arrayData.addToEnd(data);
break; break;
case OperationCount: case OperationCount:
@ -775,94 +712,72 @@ public class JobChartTopPanel extends SimpleContainer {
} }
if (i < seriesJobTop.getSeriesJobDataTopList().size()) { if (i < seriesJobTop.getSeriesJobDataTopList().size()) {
SeriesColumn seriesColumnData = highchartsFactory SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
.createSeriesColumn();
seriesColumnData.name("Others"); seriesColumnData.name("Others");
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
ArrayList<ChartDateTimeData> othersData = new ArrayList<>(); ArrayList<ChartDateTimeData> othersData = new ArrayList<>();
for (int j = i; j < seriesJobTop.getSeriesJobDataTopList() for (int j = i; j < seriesJobTop.getSeriesJobDataTopList().size(); j++) {
.size(); j++) {
ChartDateTimeData chartDateTimeData; ChartDateTimeData chartDateTimeData;
for (int k = 0; k < seriesJobTop.getSeriesJobDataTopList() for (int k = 0; k < seriesJobTop.getSeriesJobDataTopList().get(j).getSeries().size(); k++) {
.get(j).getSeries().size(); k++) { SeriesJobData seriesJobData = seriesJobTop.getSeriesJobDataTopList().get(j).getSeries().get(k);
SeriesJobData seriesJobData = seriesJobTop
.getSeriesJobDataTopList().get(j).getSeries()
.get(k);
if (j == i) { if (j == i) {
switch (measure) { switch (measure) {
case Duration: case Duration:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(), seriesJobData.getDuration() / unitMeasure);
seriesJobData.getDuration()
/ unitMeasure);
othersData.add(chartDateTimeData); othersData.add(chartDateTimeData);
break; break;
case MaxInvocationTime: case MaxInvocationTime:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(), seriesJobData.getMaxInvocationTime() / unitMeasure);
seriesJobData.getMaxInvocationTime()
/ unitMeasure);
othersData.add(chartDateTimeData); othersData.add(chartDateTimeData);
break; break;
case MinInvocationTime: case MinInvocationTime:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(), seriesJobData.getMinInvocationTime() / unitMeasure);
seriesJobData.getMinInvocationTime()
/ unitMeasure);
othersData.add(chartDateTimeData); othersData.add(chartDateTimeData);
break; break;
case OperationCount: case OperationCount:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(),
seriesJobData.getOperationCount()); seriesJobData.getOperationCount());
othersData.add(chartDateTimeData); othersData.add(chartDateTimeData);
break; break;
default: default:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(), seriesJobData.getDuration() / unitMeasure);
seriesJobData.getDuration()
/ unitMeasure);
othersData.add(chartDateTimeData); othersData.add(chartDateTimeData);
break; break;
} }
} else { } else {
switch (measure) { switch (measure) {
case Duration: case Duration:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(), (seriesJobData.getDuration() / unitMeasure) + othersData.get(k).getValue());
(seriesJobData.getDuration() / unitMeasure)
+ othersData.get(k).getValue());
othersData.set(k, chartDateTimeData); othersData.set(k, chartDateTimeData);
break; break;
case MaxInvocationTime: case MaxInvocationTime:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(),
(seriesJobData.getMaxInvocationTime() / unitMeasure) (seriesJobData.getMaxInvocationTime() / unitMeasure)
+ othersData.get(k).getValue()); + othersData.get(k).getValue());
othersData.set(k, chartDateTimeData); othersData.set(k, chartDateTimeData);
break; break;
case MinInvocationTime: case MinInvocationTime:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(),
(seriesJobData.getMinInvocationTime() / unitMeasure) (seriesJobData.getMinInvocationTime() / unitMeasure)
+ othersData.get(k).getValue()); + othersData.get(k).getValue());
othersData.set(k, chartDateTimeData); othersData.set(k, chartDateTimeData);
break; break;
case OperationCount: case OperationCount:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(), seriesJobData.getOperationCount() + othersData.get(k).getValue());
seriesJobData.getOperationCount()
+ othersData.get(k).getValue());
othersData.set(k, chartDateTimeData); othersData.set(k, chartDateTimeData);
break; break;
default: default:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesJobData.getDate(),
seriesJobData.getDate(), (seriesJobData.getDuration() / unitMeasure) + othersData.get(k).getValue());
(seriesJobData.getDuration() / unitMeasure)
+ othersData.get(k).getValue());
othersData.set(k, chartDateTimeData); othersData.set(k, chartDateTimeData);
break; break;
@ -878,8 +793,7 @@ public class JobChartTopPanel extends SimpleContainer {
for (ChartDateTimeData chartDateTimeData : othersData) { for (ChartDateTimeData chartDateTimeData : othersData) {
long dateFrom1970 = chartDateTimeData.getDate().getTime(); long dateFrom1970 = chartDateTimeData.getDate().getTime();
Log.debug("SeriersOthersData: " Log.debug("SeriersOthersData: " + chartDateTimeData.getDate());
+ chartDateTimeData.getDate());
Log.debug("SeriersOthersData: " + dateFrom1970); Log.debug("SeriersOthersData: " + dateFrom1970);
Data data = highchartsFactory.createSeriesColumnData(); Data data = highchartsFactory.createSeriesColumnData();
@ -896,35 +810,28 @@ public class JobChartTopPanel extends SimpleContainer {
} }
} }
private void createSeriesColumnSimple(SeriesJobTop seriesJobTop, private void createSeriesColumnSimple(SeriesJobTop seriesJobTop, HighchartsOptionFactory highchartsFactory,
HighchartsOptionFactory highchartsFactory, ArrayString colors, ArrayString colors, ArrayList<SeriesColumn> seriesColumn) {
ArrayList<SeriesColumn> seriesColumn) {
Log.debug("Series Simple"); Log.debug("Series Simple");
if (accountingStateData.getSeriesRequest().getAccountingPeriod() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.DAILY) == 0 .compareTo(AccountingPeriodMode.DAILY) == 0
|| accountingStateData.getSeriesRequest().getAccountingPeriod() || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.HOURLY) == 0 .compareTo(AccountingPeriodMode.HOURLY) == 0
|| accountingStateData.getSeriesRequest().getAccountingPeriod() || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.MINUTELY) == 0) { .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
double minRange = ChartTimeMeasure double minRange = ChartTimeMeasure
.calculateMinRange(accountingStateData.getSeriesRequest() .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
.getAccountingPeriod());
double interval = ChartTimeMeasure double interval = ChartTimeMeasure
.calculateInterval(accountingStateData.getSeriesRequest() .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
.getAccountingPeriod());
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest() Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
.getAccountingPeriod().getStartDate());
dateStart.setTime(dateStart.getTime() dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
+ ChartTimeMeasure.timeZoneOffset()
* ChartTimeMeasure.MINUTE);
Log.debug("BuildChart DateStart: " Log.debug("BuildChart DateStart: "
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL) + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
.format(dateStart));
// xAxis // xAxis
options.xAxis().type("datetime"); options.xAxis().type("datetime");
@ -932,29 +839,24 @@ public class JobChartTopPanel extends SimpleContainer {
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList().size(); i++) { for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList().size(); i++) {
SeriesColumn seriesColumnData = highchartsFactory SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
.createSeriesColumn();
seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList() seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i).getFilterValue().getValue());
.get(i).getFilterValue().getValue());
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
ArrayNumber data = seriesColumnData.dataAsArrayNumber(); ArrayNumber data = seriesColumnData.dataAsArrayNumber();
for (SeriesJobData seriesJobData : seriesJobTop for (SeriesJobData seriesJobData : seriesJobTop.getSeriesJobDataTopList().get(i).getSeries()) {
.getSeriesJobDataTopList().get(i).getSeries()) {
switch (measure) { switch (measure) {
case Duration: case Duration:
data.push(seriesJobData.getDuration() / unitMeasure); data.push(seriesJobData.getDuration() / unitMeasure);
break; break;
case MaxInvocationTime: case MaxInvocationTime:
data.push(seriesJobData.getMaxInvocationTime() data.push(seriesJobData.getMaxInvocationTime() / unitMeasure);
/ unitMeasure);
break; break;
case MinInvocationTime: case MinInvocationTime:
data.push(seriesJobData.getMinInvocationTime() data.push(seriesJobData.getMinInvocationTime() / unitMeasure);
/ unitMeasure);
break; break;
case OperationCount: case OperationCount:
data.push(seriesJobData.getOperationCount()); data.push(seriesJobData.getOperationCount());
@ -967,8 +869,7 @@ public class JobChartTopPanel extends SimpleContainer {
} }
seriesColumnData.pointInterval(interval).pointStart( seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
dateStart.getTime());
seriesColumn.add(seriesColumnData); seriesColumn.add(seriesColumnData);
} }
@ -976,16 +877,15 @@ public class JobChartTopPanel extends SimpleContainer {
// xAxis // xAxis
options.xAxis().type("datetime"); options.xAxis().type("datetime");
if (accountingStateData.getSeriesRequest().getAccountingPeriod() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.MONTHLY) == 0) { .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
//options.tooltip().xDateFormat("%b, %Y"); // options.tooltip().xDateFormat("%b, %Y");
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
} else { } else {
if (accountingStateData.getSeriesRequest() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getAccountingPeriod().getPeriod()
.compareTo(AccountingPeriodMode.YEARLY) == 0) { .compareTo(AccountingPeriodMode.YEARLY) == 0) {
//options.tooltip().xDateFormat("%Y"); // options.tooltip().xDateFormat("%Y");
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
} else { } else {
@ -995,18 +895,15 @@ public class JobChartTopPanel extends SimpleContainer {
} }
for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList().size(); i++) { for (int i = 0; i < seriesJobTop.getSeriesJobDataTopList().size(); i++) {
SeriesColumn seriesColumnData = highchartsFactory SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
.createSeriesColumn();
seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList() seriesColumnData.name(seriesJobTop.getSeriesJobDataTopList().get(i).getFilterValue().getValue());
.get(i).getFilterValue().getValue());
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
Array<Data> arrayData = seriesColumnData.dataAsArrayObject(); Array<Data> arrayData = seriesColumnData.dataAsArrayObject();
for (SeriesJobData seriesJobData : seriesJobTop for (SeriesJobData seriesJobData : seriesJobTop.getSeriesJobDataTopList().get(i).getSeries()) {
.getSeriesJobDataTopList().get(i).getSeries()) {
long dateFrom1970 = seriesJobData.getDate().getTime(); long dateFrom1970 = seriesJobData.getDate().getTime();
Log.debug("SeriersJobData: " + seriesJobData.getDate()); Log.debug("SeriersJobData: " + seriesJobData.getDate());
@ -1022,14 +919,12 @@ public class JobChartTopPanel extends SimpleContainer {
break; break;
case MaxInvocationTime: case MaxInvocationTime:
data.x(dateFrom1970); data.x(dateFrom1970);
data.y(seriesJobData.getMaxInvocationTime() data.y(seriesJobData.getMaxInvocationTime() / unitMeasure);
/ unitMeasure);
arrayData.addToEnd(data); arrayData.addToEnd(data);
break; break;
case MinInvocationTime: case MinInvocationTime:
data.x(dateFrom1970); data.x(dateFrom1970);
data.y(seriesJobData.getMinInvocationTime() data.y(seriesJobData.getMinInvocationTime() / unitMeasure);
/ unitMeasure);
arrayData.addToEnd(data); arrayData.addToEnd(data);
break; break;
case OperationCount: case OperationCount:
@ -1057,68 +952,45 @@ public class JobChartTopPanel extends SimpleContainer {
private String retrieveYAxis(ArrayString colors) { private String retrieveYAxis(ArrayString colors) {
switch (measure) { switch (measure) {
case Duration: case Duration:
return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name() return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name() + "\"," + " \"labels\": {"
+ "\"," + " \"labels\": {" + " \"format\": \"{value} " + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ unitMeasureLabel + "\"," + " \"style\": {" + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ " \"color\": \"" + colors.get(1) + "\"" + " }" + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ " \"style\": {" + " \"fontWeight\": \"bold\"," + JobChartMeasure.Duration.getLabel() + "\"," + " \"style\": {" + " \"color\": \"#434348\""
+ " \"color\": \"gray\"" + " } " + " }," + " }" + " }" + "}]";
+ " \"title\": { " + " \"text\": \""
+ JobChartMeasure.Duration.getLabel() + "\","
+ " \"style\": {" + " \"color\": \""
+ colors.get(1) + "\"" + " }" + " }" + "}]";
case MaxInvocationTime: case MaxInvocationTime:
return "[{" + " \"id\": \"" return "[{" + " \"id\": \"" + JobChartMeasure.MaxInvocationTime.name() + "\"," + " \"labels\": {"
+ JobChartMeasure.MaxInvocationTime.name() + "\"," + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ " \"labels\": {" + " \"format\": \"{value} " + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ unitMeasureLabel + "\"," + " \"style\": {" + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ " \"color\": \"" + colors.get(1) + "\"" + " }" + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + JobChartMeasure.MaxInvocationTime.getLabel() + "\"," + " \"style\": {" + " \"color\": \"#434348\""
+ " \"style\": {" + " \"fontWeight\": \"bold\"," + " }" + " }" + "}]";
+ " \"color\": \"gray\"" + " } " + " },"
+ " \"title\": { " + " \"text\": \""
+ JobChartMeasure.MaxInvocationTime.getLabel() + "\","
+ " \"style\": {" + " \"color\": \""
+ colors.get(1) + "\"" + " }" + " }" + "}]";
case MinInvocationTime: case MinInvocationTime:
return "[{" + " \"id\": \"" return "[{" + " \"id\": \"" + JobChartMeasure.MinInvocationTime.name() + "\"," + " \"labels\": {"
+ JobChartMeasure.MinInvocationTime.name() + "\"," + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ " \"labels\": {" + " \"format\": \"{value} " + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ unitMeasureLabel + "\"," + " \"style\": {" + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ " \"color\": \"" + colors.get(1) + "\"" + " }" + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + JobChartMeasure.MinInvocationTime.getLabel() + "\"," + " \"style\": {" + " \"color\": \"#434348\""
+ " \"style\": {" + " \"fontWeight\": \"bold\"," + " }" + " }" + "}]";
+ " \"color\": \"gray\"" + " } " + " },"
+ " \"title\": { " + " \"text\": \""
+ JobChartMeasure.MinInvocationTime.getLabel() + "\","
+ " \"style\": {" + " \"color\": \""
+ colors.get(1) + "\"" + " }" + " }" + "}]";
case OperationCount: case OperationCount:
return "[{" + " \"id\": \"" + JobChartMeasure.OperationCount.name() return "[{" + " \"id\": \"" + JobChartMeasure.OperationCount.name() + "\"," + " \"labels\": { "
+ "\"," + " \"labels\": { " + " \"format\": \"{value}\"," + " \"style\": { " + " \"color\": \"#434348\""
+ " \"format\": \"{value}\"," + " \"style\": { " + " }" + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"style\": {"
+ " \"color\": \"" + colors.get(1) + "\"" + " }" + " \"fontWeight\": \"bold\"," + " \"color\": \"gray\"" + " } " + " },"
+ " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"title\": { " + " \"text\": \"" + JobChartMeasure.OperationCount.getLabel() + "\","
+ " \"style\": {" + " \"fontWeight\": \"bold\"," + " \"style\": {" + " \"color\": \"#434348\"" + " }" + " }" + "}]";
+ " \"color\": \"gray\"" + " } " + " },"
+ " \"title\": { " + " \"text\": \""
+ JobChartMeasure.OperationCount.getLabel() + "\","
+ " \"style\": {" + " \"color\": \""
+ colors.get(1) + "\"" + " }" + " }" + "}]";
default: default:
return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name() return "[{" + " \"id\": \"" + JobChartMeasure.Duration.name() + "\"," + " \"labels\": {"
+ "\"," + " \"labels\": {" + " \"format\": \"{value} " + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ unitMeasureLabel + "\"," + " \"style\": {" + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ " \"color\": \"" + colors.get(1) + "\"" + " }" + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ " \"style\": {" + " \"fontWeight\": \"bold\"," + JobChartMeasure.Duration.getLabel() + "\"," + " \"style\": {" + " \"color\": \"#434348\""
+ " \"color\": \"gray\"" + " } " + " }," + " }" + " }" + "}]";
+ " \"title\": { " + " \"text\": \""
+ JobChartMeasure.Duration.getLabel() + "\","
+ " \"style\": {" + " \"color\": \""
+ colors.get(1) + "\"" + " }" + " }" + "}]";
} }

View File

@ -7,6 +7,7 @@ import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEven
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ByteUnitMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ByteUnitMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartDateTimeData; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartDateTimeData;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ColorsPalette;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.StorageChartMeasure; import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.StorageChartMeasure;
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources; import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
@ -57,8 +58,7 @@ public class StorageChartTopPanel extends SimpleContainer {
private static final String DATA_VOLUME_UNIT = "Data Volume Unit"; private static final String DATA_VOLUME_UNIT = "Data Volume Unit";
// private static final String MEASURE_TYPE = "Measure"; // private static final String MEASURE_TYPE = "Measure";
private DateTimeFormat dtf = DateTimeFormat private DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
private EventBus eventBus; private EventBus eventBus;
private AccountingClientStateData accountingStateData; private AccountingClientStateData accountingStateData;
@ -94,8 +94,7 @@ public class StorageChartTopPanel extends SimpleContainer {
private VerticalLayoutContainer vert; private VerticalLayoutContainer vert;
public StorageChartTopPanel(EventBus eventBus, public StorageChartTopPanel(EventBus eventBus, AccountingClientStateData accountingStateData) {
AccountingClientStateData accountingStateData) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.accountingStateData = accountingStateData; this.accountingStateData = accountingStateData;
forceLayoutOnResize = true; forceLayoutOnResize = true;
@ -107,8 +106,7 @@ public class StorageChartTopPanel extends SimpleContainer {
ToolBar toolBar = new ToolBar(); ToolBar toolBar = new ToolBar();
toolBar.setSpacing(2); toolBar.setSpacing(2);
// Download // Download
final TextButton downloadButton = new TextButton( final TextButton downloadButton = new TextButton(DownloadConstants.DOWNLOAD,
DownloadConstants.DOWNLOAD,
AccountingManagerResources.INSTANCE.accountingDownload24()); AccountingManagerResources.INSTANCE.accountingDownload24());
// downloadButton.setScale(ButtonScale.MEDIUM); // downloadButton.setScale(ButtonScale.MEDIUM);
downloadButton.setIconAlign(IconAlign.RIGHT); downloadButton.setIconAlign(IconAlign.RIGHT);
@ -116,16 +114,14 @@ public class StorageChartTopPanel extends SimpleContainer {
downloadButton.setMenu(createDownloadMenu()); downloadButton.setMenu(createDownloadMenu());
// Measure // Measure
measureButton = new TextButton( measureButton = new TextButton(StorageChartMeasure.DataVolume.getLabel(),
StorageChartMeasure.DataVolume.getLabel(),
AccountingManagerResources.INSTANCE.accountingByte24()); AccountingManagerResources.INSTANCE.accountingByte24());
measureButton.setIconAlign(IconAlign.RIGHT); measureButton.setIconAlign(IconAlign.RIGHT);
measureButton.setArrowAlign(ButtonArrowAlign.RIGHT); measureButton.setArrowAlign(ButtonArrowAlign.RIGHT);
measureButton.setMenu(createMeasureMenu()); measureButton.setMenu(createMeasureMenu());
// Unit // Unit
unitButton = new TextButton(DATA_VOLUME_UNIT, unitButton = new TextButton(DATA_VOLUME_UNIT, AccountingManagerResources.INSTANCE.accountingUnitMB24());
AccountingManagerResources.INSTANCE.accountingUnitMB24());
unitButton.setIconAlign(IconAlign.RIGHT); unitButton.setIconAlign(IconAlign.RIGHT);
unitButton.setArrowAlign(ButtonArrowAlign.RIGHT); unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
unitButton.setMenu(createUnitMenu()); unitButton.setMenu(createUnitMenu());
@ -143,8 +139,7 @@ public class StorageChartTopPanel extends SimpleContainer {
// //
vert = new VerticalLayoutContainer(); vert = new VerticalLayoutContainer();
vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1, new Margins(0)));
new Margins(0)));
add(vert, new MarginData(0)); add(vert, new MarginData(0));
@ -273,8 +268,7 @@ public class StorageChartTopPanel extends SimpleContainer {
Menu menuMeasure = new Menu(); Menu menuMeasure = new Menu();
dataVolumeItem = new MenuItem(StorageChartMeasure.DataVolume.getLabel()); dataVolumeItem = new MenuItem(StorageChartMeasure.DataVolume.getLabel());
dataVolumeItem.setHeight(30); dataVolumeItem.setHeight(30);
operationCountItem = new MenuItem( operationCountItem = new MenuItem(StorageChartMeasure.OperationCount.getLabel());
StorageChartMeasure.OperationCount.getLabel());
operationCountItem.setHeight(30); operationCountItem.setHeight(30);
dataVolumeItem.addSelectionHandler(new SelectionHandler<Item>() { dataVolumeItem.addSelectionHandler(new SelectionHandler<Item>() {
@ -292,8 +286,7 @@ public class StorageChartTopPanel extends SimpleContainer {
@Override @Override
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
measureButton.setText(StorageChartMeasure.OperationCount measureButton.setText(StorageChartMeasure.OperationCount.getLabel());
.getLabel());
measure = StorageChartMeasure.OperationCount; measure = StorageChartMeasure.OperationCount;
unitButton.setVisible(false); unitButton.setVisible(false);
updateChart(); updateChart();
@ -309,17 +302,13 @@ public class StorageChartTopPanel extends SimpleContainer {
private Menu createUnitMenu() { private Menu createUnitMenu() {
Menu menuUnit = new Menu(); Menu menuUnit = new Menu();
kBItem = new MenuItem(ByteUnitMeasure.KILOBYTE, kBItem = new MenuItem(ByteUnitMeasure.KILOBYTE, AccountingManagerResources.INSTANCE.accountingUnitkB24());
AccountingManagerResources.INSTANCE.accountingUnitkB24());
kBItem.setHeight(30); kBItem.setHeight(30);
MBItem = new MenuItem(ByteUnitMeasure.MEGABYTE, MBItem = new MenuItem(ByteUnitMeasure.MEGABYTE, AccountingManagerResources.INSTANCE.accountingUnitMB24());
AccountingManagerResources.INSTANCE.accountingUnitMB24());
MBItem.setHeight(30); MBItem.setHeight(30);
GBItem = new MenuItem(ByteUnitMeasure.GIGABYTE, GBItem = new MenuItem(ByteUnitMeasure.GIGABYTE, AccountingManagerResources.INSTANCE.accountingUnitGB24());
AccountingManagerResources.INSTANCE.accountingUnitGB24());
GBItem.setHeight(30); GBItem.setHeight(30);
TBItem = new MenuItem(ByteUnitMeasure.TERABYTE, TBItem = new MenuItem(ByteUnitMeasure.TERABYTE, AccountingManagerResources.INSTANCE.accountingUnitTB24());
AccountingManagerResources.INSTANCE.accountingUnitTB24());
TBItem.setHeight(30); TBItem.setHeight(30);
kBItem.addSelectionHandler(new SelectionHandler<Item>() { kBItem.addSelectionHandler(new SelectionHandler<Item>() {
@ -328,8 +317,7 @@ public class StorageChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
unitMeasure = ByteUnitMeasure.getKiloByteDimForStorage(); unitMeasure = ByteUnitMeasure.getKiloByteDimForStorage();
unitMeasureLabel = ByteUnitMeasure.kB; unitMeasureLabel = ByteUnitMeasure.kB;
unitButton.setIcon(AccountingManagerResources.INSTANCE unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitkB24());
.accountingUnitkB24());
updateChart(); updateChart();
} }
}); });
@ -340,8 +328,7 @@ public class StorageChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
unitMeasure = ByteUnitMeasure.getMegaByteDimForStorage(); unitMeasure = ByteUnitMeasure.getMegaByteDimForStorage();
unitMeasureLabel = ByteUnitMeasure.MB; unitMeasureLabel = ByteUnitMeasure.MB;
unitButton.setIcon(AccountingManagerResources.INSTANCE unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitMB24());
.accountingUnitMB24());
updateChart(); updateChart();
} }
}); });
@ -352,8 +339,7 @@ public class StorageChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
unitMeasure = ByteUnitMeasure.getGigaByteDimForStorage(); unitMeasure = ByteUnitMeasure.getGigaByteDimForStorage();
unitMeasureLabel = ByteUnitMeasure.GB; unitMeasureLabel = ByteUnitMeasure.GB;
unitButton.setIcon(AccountingManagerResources.INSTANCE unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitGB24());
.accountingUnitGB24());
updateChart(); updateChart();
} }
}); });
@ -364,8 +350,7 @@ public class StorageChartTopPanel extends SimpleContainer {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
unitMeasure = ByteUnitMeasure.getTeraByteDimForStorage(); unitMeasure = ByteUnitMeasure.getTeraByteDimForStorage();
unitMeasureLabel = ByteUnitMeasure.TB; unitMeasureLabel = ByteUnitMeasure.TB;
unitButton.setIcon(AccountingManagerResources.INSTANCE unitButton.setIcon(AccountingManagerResources.INSTANCE.accountingUnitTB24());
.accountingUnitTB24());
updateChart(); updateChart();
} }
}); });
@ -379,20 +364,17 @@ public class StorageChartTopPanel extends SimpleContainer {
} }
private void onDownloadCSV() { private void onDownloadCSV() {
ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV, ExportRequestEvent event = new ExportRequestEvent(ExportType.CSV, accountingStateData.getAccountingType());
accountingStateData.getAccountingType());
eventBus.fireEvent(event); eventBus.fireEvent(event);
} }
private void onDownloadXML() { private void onDownloadXML() {
ExportRequestEvent event = new ExportRequestEvent(ExportType.XML, ExportRequestEvent event = new ExportRequestEvent(ExportType.XML, accountingStateData.getAccountingType());
accountingStateData.getAccountingType());
eventBus.fireEvent(event); eventBus.fireEvent(event);
} }
private void onDownloadJSON() { private void onDownloadJSON() {
ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON, ExportRequestEvent event = new ExportRequestEvent(ExportType.JSON, accountingStateData.getAccountingType());
accountingStateData.getAccountingType());
eventBus.fireEvent(event); eventBus.fireEvent(event);
} }
@ -449,15 +431,13 @@ public class StorageChartTopPanel extends SimpleContainer {
}-*/; }-*/;
private void createChart() { private void createChart() {
SeriesStorage seriesStorage = (SeriesStorage) accountingStateData SeriesStorage seriesStorage = (SeriesStorage) accountingStateData.getSeriesResponse();
.getSeriesResponse();
if (!(seriesStorage.getSeriesStorageDefinition() instanceof SeriesStorageTop)) { if (!(seriesStorage.getSeriesStorageDefinition() instanceof SeriesStorageTop)) {
Log.debug("Invalid SeriesStorageTop!"); Log.debug("Invalid SeriesStorageTop!");
return; return;
} }
SeriesStorageTop seriesStorageTop = (SeriesStorageTop) seriesStorage SeriesStorageTop seriesStorageTop = (SeriesStorageTop) seriesStorage.getSeriesStorageDefinition();
.getSeriesStorageDefinition();
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory(); HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
@ -468,32 +448,29 @@ public class StorageChartTopPanel extends SimpleContainer {
options.title().text("Accounting Storage Top"); options.title().text("Accounting Storage Top");
/* /*
* options.subtitle().text("Click and drag in the plot area to zoom in"); * options.subtitle().text("Click and drag in the plot area to zoom in"
* );
*/ */
ColorsPalette colorsPalette = new ColorsPalette();
ArrayString colors = options.colors(); ArrayString colors = options.colors();
colors = colorsPalette.getColorsPalette(colors);
options.colors(colors);
// colors.setValue(0, "#cc0038"); // colors.setValue(0, "#cc0038");
// colors.setValue(1, "#32cd32"); // colors.setValue(1, "#32cd32");
// yAxis // yAxis
options.setFieldAsJsonObject("yAxis", retrieveYAxis(colors)); options.setFieldAsJsonObject("yAxis", retrieveYAxis(colors));
options.plotOptions().setFieldAsJsonObject( options.plotOptions().setFieldAsJsonObject("column",
"column", "{ " + "\"stacking\": \"normal\"," + "\"dataLabels\": { " + " \"enabled\": \"true\","
"{ " + "\"stacking\": \"normal\"," + "\"dataLabels\": { "
+ " \"enabled\": \"true\","
+ " \"color\": \"white\", " + " \"style\": {" + " \"color\": \"white\", " + " \"style\": {"
+ " \"textShadow\": \"0 0 3px black\"" + " }" + " \"textShadow\": \"0 0 3px black\"" + " }" + " }" + " }");
+ " }" + " }");
ArrayList<SeriesColumn> seriesColumn = new ArrayList<>(); ArrayList<SeriesColumn> seriesColumn = new ArrayList<>();
if (seriesStorageTop.getShowOthers()) {
createSeriesColumnShowOthers(seriesStorageTop, highchartsFactory, createSeriesColumnSimple(seriesStorageTop, highchartsFactory, colors, seriesColumn);
colors, seriesColumn);
} else {
createSeriesColumnSimple(seriesStorageTop, highchartsFactory,
colors, seriesColumn);
}
for (SeriesColumn serie : seriesColumn) { for (SeriesColumn serie : seriesColumn) {
options.series().addToEnd(serie); options.series().addToEnd(serie);
@ -505,36 +482,28 @@ public class StorageChartTopPanel extends SimpleContainer {
return; return;
} }
private void createSeriesColumnShowOthers( private void createSeriesColumnShowOthers(SeriesStorageTop seriesStorageTop,
SeriesStorageTop seriesStorageTop, HighchartsOptionFactory highchartsFactory, ArrayString colors, ArrayList<SeriesColumn> seriesColumn) {
HighchartsOptionFactory highchartsFactory, ArrayString colors,
ArrayList<SeriesColumn> seriesColumn) {
Log.debug("Series ShowOthers"); Log.debug("Series ShowOthers");
if (accountingStateData.getSeriesRequest().getAccountingPeriod() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.DAILY) == 0 .compareTo(AccountingPeriodMode.DAILY) == 0
|| accountingStateData.getSeriesRequest().getAccountingPeriod() || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.HOURLY) == 0 .compareTo(AccountingPeriodMode.HOURLY) == 0
|| accountingStateData.getSeriesRequest().getAccountingPeriod() || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.MINUTELY) == 0) { .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
double minRange = ChartTimeMeasure double minRange = ChartTimeMeasure
.calculateMinRange(accountingStateData.getSeriesRequest() .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
.getAccountingPeriod());
double interval = ChartTimeMeasure double interval = ChartTimeMeasure
.calculateInterval(accountingStateData.getSeriesRequest() .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
.getAccountingPeriod());
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest() Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
.getAccountingPeriod().getStartDate());
dateStart.setTime(dateStart.getTime() dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
+ ChartTimeMeasure.timeZoneOffset()
* ChartTimeMeasure.MINUTE);
Log.debug("BuildChart DateStart: " Log.debug("BuildChart DateStart: "
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL) + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
.format(dateStart));
// xAxis // xAxis
options.xAxis().type("datetime"); options.xAxis().type("datetime");
@ -544,23 +513,20 @@ public class StorageChartTopPanel extends SimpleContainer {
int i = 0; int i = 0;
for (; i < seriesStorageTop.getSeriesStorageDataTopList().size() for (; i < seriesStorageTop.getSeriesStorageDataTopList().size()
&& i < seriesStorageTop.getTopNumber(); i++) { && i < seriesStorageTop.getTopNumber(); i++) {
SeriesColumn seriesColumnData = highchartsFactory SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
.createSeriesColumn();
seriesColumnData.name(seriesStorageTop seriesColumnData
.getSeriesStorageDataTopList().get(i).getFilterValue() .name(seriesStorageTop.getSeriesStorageDataTopList().get(i).getFilterValue().getValue());
.getValue());
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
ArrayNumber data = seriesColumnData.dataAsArrayNumber(); ArrayNumber data = seriesColumnData.dataAsArrayNumber();
for (SeriesStorageData seriesStorageData : seriesStorageTop for (SeriesStorageData seriesStorageData : seriesStorageTop.getSeriesStorageDataTopList().get(i)
.getSeriesStorageDataTopList().get(i).getSeries()) { .getSeries()) {
switch (measure) { switch (measure) {
case DataVolume: case DataVolume:
data.push(seriesStorageData.getDataVolume() data.push(seriesStorageData.getDataVolume() / unitMeasure);
/ unitMeasure);
break; break;
case OperationCount: case OperationCount:
data.push(seriesStorageData.getOperationCount()); data.push(seriesStorageData.getOperationCount());
@ -573,43 +539,34 @@ public class StorageChartTopPanel extends SimpleContainer {
} }
seriesColumnData.pointInterval(interval).pointStart( seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
dateStart.getTime());
seriesColumn.add(seriesColumnData); seriesColumn.add(seriesColumnData);
} }
if (i < seriesStorageTop.getSeriesStorageDataTopList().size()) { if (i < seriesStorageTop.getSeriesStorageDataTopList().size()) {
SeriesColumn seriesColumnData = highchartsFactory SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
.createSeriesColumn();
seriesColumnData.name("Others"); seriesColumnData.name("Others");
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
ArrayList<Long> othersData = new ArrayList<>(); ArrayList<Long> othersData = new ArrayList<>();
for (int j = i; j < seriesStorageTop for (int j = i; j < seriesStorageTop.getSeriesStorageDataTopList().size(); j++) {
.getSeriesStorageDataTopList().size(); j++) {
Long value; Long value;
for (int k = 0; k < seriesStorageTop for (int k = 0; k < seriesStorageTop.getSeriesStorageDataTopList().get(j).getSeries().size(); k++) {
.getSeriesStorageDataTopList().get(j).getSeries() SeriesStorageData seriesStorageData = seriesStorageTop.getSeriesStorageDataTopList().get(j)
.size(); k++) {
SeriesStorageData seriesStorageData = seriesStorageTop
.getSeriesStorageDataTopList().get(j)
.getSeries().get(k); .getSeries().get(k);
if (j == i) { if (j == i) {
switch (measure) { switch (measure) {
case DataVolume: case DataVolume:
othersData.add(seriesStorageData othersData.add(seriesStorageData.getDataVolume() / unitMeasure);
.getDataVolume() / unitMeasure);
break; break;
case OperationCount: case OperationCount:
othersData.add(seriesStorageData othersData.add(seriesStorageData.getOperationCount());
.getOperationCount());
break; break;
default: default:
othersData.add(seriesStorageData othersData.add(seriesStorageData.getDataVolume() / unitMeasure);
.getDataVolume() / unitMeasure);
break; break;
} }
@ -617,18 +574,15 @@ public class StorageChartTopPanel extends SimpleContainer {
switch (measure) { switch (measure) {
case DataVolume: case DataVolume:
value = seriesStorageData.getDataVolume() value = seriesStorageData.getDataVolume() / unitMeasure + othersData.get(k);
/ unitMeasure + othersData.get(k);
othersData.set(k, value); othersData.set(k, value);
break; break;
case OperationCount: case OperationCount:
value = seriesStorageData.getOperationCount() value = seriesStorageData.getOperationCount() + othersData.get(k);
+ othersData.get(k);
othersData.set(k, value); othersData.set(k, value);
break; break;
default: default:
value = seriesStorageData.getDataVolume() value = seriesStorageData.getDataVolume() / unitMeasure + othersData.get(k);
/ unitMeasure + othersData.get(k);
othersData.set(k, value); othersData.set(k, value);
break; break;
@ -644,8 +598,7 @@ public class StorageChartTopPanel extends SimpleContainer {
data.push(value); data.push(value);
} }
seriesColumnData.pointInterval(interval).pointStart( seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
dateStart.getTime());
seriesColumn.add(seriesColumnData); seriesColumn.add(seriesColumnData);
} }
@ -653,16 +606,15 @@ public class StorageChartTopPanel extends SimpleContainer {
// xAxis // xAxis
options.xAxis().type("datetime"); options.xAxis().type("datetime");
if (accountingStateData.getSeriesRequest().getAccountingPeriod() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.MONTHLY) == 0) { .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
//options.tooltip().xDateFormat("%b, %Y"); // options.tooltip().xDateFormat("%b, %Y");
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
} else { } else {
if (accountingStateData.getSeriesRequest() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getAccountingPeriod().getPeriod()
.compareTo(AccountingPeriodMode.YEARLY) == 0) { .compareTo(AccountingPeriodMode.YEARLY) == 0) {
//options.tooltip().xDateFormat("%Y"); // options.tooltip().xDateFormat("%Y");
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
} else { } else {
@ -674,23 +626,20 @@ public class StorageChartTopPanel extends SimpleContainer {
int i = 0; int i = 0;
for (; i < seriesStorageTop.getSeriesStorageDataTopList().size() for (; i < seriesStorageTop.getSeriesStorageDataTopList().size()
&& i < seriesStorageTop.getTopNumber(); i++) { && i < seriesStorageTop.getTopNumber(); i++) {
SeriesColumn seriesColumnData = highchartsFactory SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
.createSeriesColumn();
seriesColumnData.name(seriesStorageTop seriesColumnData
.getSeriesStorageDataTopList().get(i).getFilterValue() .name(seriesStorageTop.getSeriesStorageDataTopList().get(i).getFilterValue().getValue());
.getValue());
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
Array<Data> arrayData = seriesColumnData.dataAsArrayObject(); Array<Data> arrayData = seriesColumnData.dataAsArrayObject();
for (SeriesStorageData seriesStorageData : seriesStorageTop for (SeriesStorageData seriesStorageData : seriesStorageTop.getSeriesStorageDataTopList().get(i)
.getSeriesStorageDataTopList().get(i).getSeries()) { .getSeries()) {
long dateFrom1970 = seriesStorageData.getDate().getTime(); long dateFrom1970 = seriesStorageData.getDate().getTime();
Log.debug("SeriersStorageData: " Log.debug("SeriersStorageData: " + seriesStorageData.getDate());
+ seriesStorageData.getDate());
Log.debug("SeriersStorageData: " + dateFrom1970); Log.debug("SeriersStorageData: " + dateFrom1970);
Data data = highchartsFactory.createSeriesColumnData(); Data data = highchartsFactory.createSeriesColumnData();
@ -721,65 +670,51 @@ public class StorageChartTopPanel extends SimpleContainer {
} }
if (i < seriesStorageTop.getSeriesStorageDataTopList().size()) { if (i < seriesStorageTop.getSeriesStorageDataTopList().size()) {
SeriesColumn seriesColumnData = highchartsFactory SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
.createSeriesColumn();
seriesColumnData.name("Others"); seriesColumnData.name("Others");
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
ArrayList<ChartDateTimeData> othersData = new ArrayList<>(); ArrayList<ChartDateTimeData> othersData = new ArrayList<>();
for (int j = i; j < seriesStorageTop for (int j = i; j < seriesStorageTop.getSeriesStorageDataTopList().size(); j++) {
.getSeriesStorageDataTopList().size(); j++) {
ChartDateTimeData chartDateTimeData; ChartDateTimeData chartDateTimeData;
for (int k = 0; k < seriesStorageTop for (int k = 0; k < seriesStorageTop.getSeriesStorageDataTopList().get(j).getSeries().size(); k++) {
.getSeriesStorageDataTopList().get(j).getSeries() SeriesStorageData seriesStorageData = seriesStorageTop.getSeriesStorageDataTopList().get(j)
.size(); k++) {
SeriesStorageData seriesStorageData = seriesStorageTop
.getSeriesStorageDataTopList().get(j)
.getSeries().get(k); .getSeries().get(k);
if (j == i) { if (j == i) {
switch (measure) { switch (measure) {
case DataVolume: case DataVolume:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesStorageData.getDate(),
seriesStorageData.getDate(), seriesStorageData.getDataVolume() / unitMeasure);
seriesStorageData.getDataVolume()
/ unitMeasure);
othersData.add(chartDateTimeData); othersData.add(chartDateTimeData);
break; break;
case OperationCount: case OperationCount:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesStorageData.getDate(),
seriesStorageData.getDate(),
seriesStorageData.getOperationCount()); seriesStorageData.getOperationCount());
othersData.add(chartDateTimeData); othersData.add(chartDateTimeData);
break; break;
default: default:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesStorageData.getDate(),
seriesStorageData.getDate(), seriesStorageData.getDataVolume() / unitMeasure);
seriesStorageData.getDataVolume()
/ unitMeasure);
othersData.add(chartDateTimeData); othersData.add(chartDateTimeData);
break; break;
} }
} else { } else {
switch (measure) { switch (measure) {
case DataVolume: case DataVolume:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesStorageData.getDate(),
seriesStorageData.getDate(),
(seriesStorageData.getDataVolume() / unitMeasure) (seriesStorageData.getDataVolume() / unitMeasure)
+ othersData.get(k).getValue()); + othersData.get(k).getValue());
othersData.set(k, chartDateTimeData); othersData.set(k, chartDateTimeData);
break; break;
case OperationCount: case OperationCount:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesStorageData.getDate(),
seriesStorageData.getDate(), seriesStorageData.getOperationCount() + othersData.get(k).getValue());
seriesStorageData.getOperationCount()
+ othersData.get(k).getValue());
othersData.set(k, chartDateTimeData); othersData.set(k, chartDateTimeData);
break; break;
default: default:
chartDateTimeData = new ChartDateTimeData( chartDateTimeData = new ChartDateTimeData(seriesStorageData.getDate(),
seriesStorageData.getDate(),
(seriesStorageData.getDataVolume() / unitMeasure) (seriesStorageData.getDataVolume() / unitMeasure)
+ othersData.get(k).getValue()); + othersData.get(k).getValue());
othersData.set(k, chartDateTimeData); othersData.set(k, chartDateTimeData);
@ -796,8 +731,7 @@ public class StorageChartTopPanel extends SimpleContainer {
for (ChartDateTimeData chartDateTimeData : othersData) { for (ChartDateTimeData chartDateTimeData : othersData) {
long dateFrom1970 = chartDateTimeData.getDate().getTime(); long dateFrom1970 = chartDateTimeData.getDate().getTime();
Log.debug("SeriersOthersData: " Log.debug("SeriersOthersData: " + chartDateTimeData.getDate());
+ chartDateTimeData.getDate());
Log.debug("SeriersOthersData: " + dateFrom1970); Log.debug("SeriersOthersData: " + dateFrom1970);
Data data = highchartsFactory.createSeriesColumnData(); Data data = highchartsFactory.createSeriesColumnData();
@ -815,61 +749,50 @@ public class StorageChartTopPanel extends SimpleContainer {
} }
private void createSeriesColumnSimple(SeriesStorageTop seriesStorageTop, private void createSeriesColumnSimple(SeriesStorageTop seriesStorageTop, HighchartsOptionFactory highchartsFactory,
HighchartsOptionFactory highchartsFactory, ArrayString colors, ArrayString colors, ArrayList<SeriesColumn> seriesColumn) {
ArrayList<SeriesColumn> seriesColumn) {
Log.debug("Series Simple"); Log.debug("Series Simple");
if (accountingStateData.getSeriesRequest().getAccountingPeriod() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.DAILY) == 0 .compareTo(AccountingPeriodMode.DAILY) == 0
|| accountingStateData.getSeriesRequest().getAccountingPeriod() || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.HOURLY) == 0 .compareTo(AccountingPeriodMode.HOURLY) == 0
|| accountingStateData.getSeriesRequest().getAccountingPeriod() || accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.MINUTELY) == 0) { .compareTo(AccountingPeriodMode.MINUTELY) == 0) {
double minRange = ChartTimeMeasure double minRange = ChartTimeMeasure
.calculateMinRange(accountingStateData.getSeriesRequest() .calculateMinRange(accountingStateData.getSeriesRequest().getAccountingPeriod());
.getAccountingPeriod());
double interval = ChartTimeMeasure double interval = ChartTimeMeasure
.calculateInterval(accountingStateData.getSeriesRequest() .calculateInterval(accountingStateData.getSeriesRequest().getAccountingPeriod());
.getAccountingPeriod());
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest() Date dateStart = dtf.parse(accountingStateData.getSeriesRequest().getAccountingPeriod().getStartDate());
.getAccountingPeriod().getStartDate());
dateStart.setTime(dateStart.getTime() dateStart.setTime(dateStart.getTime() + ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
+ ChartTimeMeasure.timeZoneOffset()
* ChartTimeMeasure.MINUTE);
Log.debug("BuildChart DateStart: " Log.debug("BuildChart DateStart: "
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL) + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL).format(dateStart));
.format(dateStart));
// xAxis // xAxis
options.xAxis().type("datetime"); options.xAxis().type("datetime");
options.xAxis().minRange(minRange); options.xAxis().minRange(minRange);
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
for (int i = 0; i < seriesStorageTop.getSeriesStorageDataTopList() for (int i = 0; i < seriesStorageTop.getSeriesStorageDataTopList().size(); i++) {
.size(); i++) { SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
SeriesColumn seriesColumnData = highchartsFactory
.createSeriesColumn();
seriesColumnData.name(seriesStorageTop seriesColumnData
.getSeriesStorageDataTopList().get(i).getFilterValue() .name(seriesStorageTop.getSeriesStorageDataTopList().get(i).getFilterValue().getValue());
.getValue());
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
ArrayNumber data = seriesColumnData.dataAsArrayNumber(); ArrayNumber data = seriesColumnData.dataAsArrayNumber();
for (SeriesStorageData seriesStorageData : seriesStorageTop for (SeriesStorageData seriesStorageData : seriesStorageTop.getSeriesStorageDataTopList().get(i)
.getSeriesStorageDataTopList().get(i).getSeries()) { .getSeries()) {
switch (measure) { switch (measure) {
case DataVolume: case DataVolume:
data.push(seriesStorageData.getDataVolume() data.push(seriesStorageData.getDataVolume() / unitMeasure);
/ unitMeasure);
break; break;
case OperationCount: case OperationCount:
data.push(seriesStorageData.getOperationCount()); data.push(seriesStorageData.getOperationCount());
@ -882,8 +805,7 @@ public class StorageChartTopPanel extends SimpleContainer {
} }
seriesColumnData.pointInterval(interval).pointStart( seriesColumnData.pointInterval(interval).pointStart(dateStart.getTime());
dateStart.getTime());
seriesColumn.add(seriesColumnData); seriesColumn.add(seriesColumnData);
} }
@ -892,16 +814,15 @@ public class StorageChartTopPanel extends SimpleContainer {
// xAxis // xAxis
options.xAxis().type("datetime"); options.xAxis().type("datetime");
if (accountingStateData.getSeriesRequest().getAccountingPeriod() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getPeriod().compareTo(AccountingPeriodMode.MONTHLY) == 0) { .compareTo(AccountingPeriodMode.MONTHLY) == 0) {
//options.tooltip().xDateFormat("%b, %Y"); // options.tooltip().xDateFormat("%b, %Y");
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
} else { } else {
if (accountingStateData.getSeriesRequest() if (accountingStateData.getSeriesRequest().getAccountingPeriod().getPeriod()
.getAccountingPeriod().getPeriod()
.compareTo(AccountingPeriodMode.YEARLY) == 0) { .compareTo(AccountingPeriodMode.YEARLY) == 0) {
//options.tooltip().xDateFormat("%Y"); // options.tooltip().xDateFormat("%Y");
options.tooltip().xDateFormat("Selected Data"); options.tooltip().xDateFormat("Selected Data");
} else { } else {
@ -910,25 +831,21 @@ public class StorageChartTopPanel extends SimpleContainer {
} }
for (int i = 0; i < seriesStorageTop.getSeriesStorageDataTopList() for (int i = 0; i < seriesStorageTop.getSeriesStorageDataTopList().size(); i++) {
.size(); i++) { SeriesColumn seriesColumnData = highchartsFactory.createSeriesColumn();
SeriesColumn seriesColumnData = highchartsFactory
.createSeriesColumn();
seriesColumnData.name(seriesStorageTop seriesColumnData
.getSeriesStorageDataTopList().get(i).getFilterValue() .name(seriesStorageTop.getSeriesStorageDataTopList().get(i).getFilterValue().getValue());
.getValue());
seriesColumnData.color(colors.get(i)); seriesColumnData.color(colors.get(i));
seriesColumnData.type("column"); seriesColumnData.type("column");
Array<Data> arrayData = seriesColumnData.dataAsArrayObject(); Array<Data> arrayData = seriesColumnData.dataAsArrayObject();
for (SeriesStorageData seriesStorageData : seriesStorageTop for (SeriesStorageData seriesStorageData : seriesStorageTop.getSeriesStorageDataTopList().get(i)
.getSeriesStorageDataTopList().get(i).getSeries()) { .getSeries()) {
long dateFrom1970 = seriesStorageData.getDate().getTime(); long dateFrom1970 = seriesStorageData.getDate().getTime();
Log.debug("SeriersStorageData: " Log.debug("SeriersStorageData: " + seriesStorageData.getDate());
+ seriesStorageData.getDate());
Log.debug("SeriersStorageData: " + dateFrom1970); Log.debug("SeriersStorageData: " + dateFrom1970);
Data data = highchartsFactory.createSeriesColumnData(); Data data = highchartsFactory.createSeriesColumnData();
@ -964,44 +881,30 @@ public class StorageChartTopPanel extends SimpleContainer {
private String retrieveYAxis(ArrayString colors) { private String retrieveYAxis(ArrayString colors) {
switch (measure) { switch (measure) {
case DataVolume: case DataVolume:
return "[{" + " \"id\": \"" + StorageChartMeasure.DataVolume.name() return "[{" + " \"id\": \"" + StorageChartMeasure.DataVolume.name() + "\"," + " \"labels\": {"
+ "\"," + " \"labels\": {" + " \"format\": \"{value} " + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ unitMeasureLabel + "\"," + " \"style\": {" + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ " \"color\": \"" + colors.get(1) + "\"" + " }" + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ " \"style\": {" + " \"fontWeight\": \"bold\"," + StorageChartMeasure.DataVolume.getLabel() + "\"," + " \"style\": {"
+ " \"color\": \"gray\"" + " } " + " }," + " \"color\": \"#434348\"" + " }" + " }" + "}]";
+ " \"title\": { " + " \"text\": \""
+ StorageChartMeasure.DataVolume.getLabel() + "\","
+ " \"style\": {" + " \"color\": \""
+ colors.get(1) + "\"" + " }" + " }" + "}]";
case OperationCount: case OperationCount:
return "[{" + " \"id\": \"" return "[{" + " \"id\": \"" + StorageChartMeasure.OperationCount.name() + "\"," + " \"labels\": { "
+ StorageChartMeasure.OperationCount.name() + "\"," + " \"format\": \"{value}\"," + " \"style\": { " + " \"color\": \"#434348\"" + " }"
+ " \"labels\": { " + " \"format\": \"{value}\"," + " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"style\": {"
+ " \"style\": { " + " \"color\": \"" + " \"fontWeight\": \"bold\"," + " \"color\": \"gray\"" + " } " + " },"
+ colors.get(1) + "\"" + " }" + " }," + " \"title\": { " + " \"text\": \"" + StorageChartMeasure.OperationCount.getLabel() + "\","
+ " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"style\": {" + " \"color\": \"#434348\"" + " }" + " }" + "}]";
+ " \"style\": {" + " \"fontWeight\": \"bold\","
+ " \"color\": \"gray\"" + " } " + " },"
+ " \"title\": { " + " \"text\": \""
+ StorageChartMeasure.OperationCount.getLabel() + "\","
+ " \"style\": {" + " \"color\": \""
+ colors.get(1) + "\"" + " }" + " }" + "}]";
default: default:
return "[{" + " \"id\": \"" + StorageChartMeasure.DataVolume.name() return "[{" + " \"id\": \"" + StorageChartMeasure.DataVolume.name() + "\"," + " \"labels\": {"
+ "\"," + " \"labels\": {" + " \"format\": \"{value} " + " \"format\": \"{value} " + unitMeasureLabel + "\"," + " \"style\": {"
+ unitMeasureLabel + "\"," + " \"style\": {" + " \"color\": \"#434348\"" + " }" + " }," + " \"stackLabels\": {"
+ " \"color\": \"" + colors.get(1) + "\"" + " }" + " \"enabled\": \"true\"," + " \"style\": {" + " \"fontWeight\": \"bold\","
+ " }," + " \"stackLabels\": {" + " \"enabled\": \"true\"," + " \"color\": \"gray\"" + " } " + " }," + " \"title\": { " + " \"text\": \""
+ " \"style\": {" + " \"fontWeight\": \"bold\"," + StorageChartMeasure.DataVolume.getLabel() + "\"," + " \"style\": {"
+ " \"color\": \"gray\"" + " } " + " }," + " \"color\": \"#434348\"" + " }" + " }" + "}]";
+ " \"title\": { " + " \"text\": \""
+ StorageChartMeasure.DataVolume.getLabel() + "\","
+ " \"style\": {" + " \"color\": \""
+ colors.get(1) + "\"" + " }" + " }" + "}]";
} }

View File

@ -0,0 +1,35 @@
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils;
import com.github.highcharts4gwt.model.array.api.ArrayString;
/**
*
* @author Giancarlo Panichi
*
*/
public class ColorsPalette {
private String[] palette = { "#87CEEB", "#DAA520", "#3CB371", "#FF4500", "#8FBC8F", "#FF00FF", "#BDB76B", "#5F9EA0",
"#A0522D", "#6B8E23", "#FFA07A", "#696969", "#DDA0DD", "#C71585", "#1E90FF", "#D2B48C", "#90EE90",
"#B22222", "#00CED1", "#9400D3", "#FFDAB9", "#663399", "#FFE4C4", "#ADFF2F", "#FF0000", "#00FFFF",
"#483D8B", "#FFFF00", "#00008B", "#FFDEAD", "#7CFC00", "#FF6347", "#AFEEEE", "#6A5ACD", "#FFFACD",
"#0000CD", "#F5DEB3", "#00FF00", "#FF7F50", "#7FFFD4", "#7B68EE", "#FFEFD5", "#0000FF", "#DEB887",
"#32CD32", "#FFA500", "#40E0D0", "#9370DB", "#FFE4B5", "#4169E1", "#BC8F8F", "#98FB98", "#8B0000",
"#48D1CC", "#800080", "#EEE8AA", "#00BFFF", "#F4A460", "#00FA9A", "#800000", "#556B2F", "#8A2BE2",
"#F0E68C", "#6495ED", "#B8860B", "#2E8B57", "#FFD700", "#66CDAA", "#9932CC", "#FFC0CB", "#87CEFA",
"#CD853F", "#228B22", "#DC143C", "#20B2AA", "#BA55D3", "#FFB6C1", "#B0E0E6", "#D2691E", "#008000",
"#CD5C5C", "#008B8B", "#FF00FF", "#FF69B4", "#B0C4DE", "#808000", "#006400", "#F08080", "#008080",
"#EE82EE", "#FF1493", "#4682B4", "#8B4513", "#9ACD32", "#FA8072", "#778899", "#DA70D6", "#DB7093" };
public ColorsPalette() {
}
public ArrayString getColorsPalette(ArrayString colors) {
for (int i = 0; i < palette.length; i++) {
colors.setValue(i, palette[i]);
}
colors.setLength(palette.length);
return colors;
}
}

View File

@ -9,8 +9,7 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo * @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public interface AccountingFilterProperties extends public interface AccountingFilterProperties extends

View File

@ -9,12 +9,10 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo * @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public interface AccountingPeriodModePropertiesCombo extends public interface AccountingPeriodModePropertiesCombo extends PropertyAccess<AccountingPeriodMode> {
PropertyAccess<AccountingPeriodMode> {
@Path("id") @Path("id")
ModelKeyProvider<AccountingPeriodMode> id(); ModelKeyProvider<AccountingPeriodMode> id();

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.admin.accountingmanager.client.properties; package org.gcube.portlets.admin.accountingmanager.client.properties;
import org.gcube.portlets.admin.accountingmanager.shared.data.GenresData; import org.gcube.portlets.admin.accountingmanager.shared.data.ContextData;
import com.google.gwt.editor.client.Editor.Path; import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.core.client.ValueProvider; import com.sencha.gxt.core.client.ValueProvider;
@ -9,13 +9,14 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public interface GenresDataProperties extends PropertyAccess<GenresData> { public interface ContextDataProperties extends PropertyAccess<ContextData> {
@Path("genre")
ModelKeyProvider<GenresData> id();
ValueProvider<GenresData, String> label(); @Path("contextData")
ModelKeyProvider<ContextData> id();
ValueProvider<ContextData, String> label();
} }

View File

@ -1,24 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.client.properties;
import org.gcube.portlets.admin.accountingmanager.shared.data.GenresData;
import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface GenresDataPropertiesCombo extends
PropertyAccess<GenresData> {
@Path("genre")
ModelKeyProvider<GenresData> id();
LabelProvider<GenresData> label();
}

View File

@ -68,7 +68,7 @@ public class AccountingClientStateData implements Serializable {
*/ */
public AccountingClientStateData(AccountingType accountingType, SeriesRequest seriesRequest, public AccountingClientStateData(AccountingType accountingType, SeriesRequest seriesRequest,
SeriesResponse seriesResponse, ArrayList<FilterKey> availableFilterKeys, Context availableContext, SeriesResponse seriesResponse, ArrayList<FilterKey> availableFilterKeys, Context availableContext,
Spaces availableSpaces, Boolean rootScope) { String scopeFilterActive, Spaces availableSpaces, Boolean rootScope) {
super(); super();
this.accountingType = accountingType; this.accountingType = accountingType;
this.seriesRequest = seriesRequest; this.seriesRequest = seriesRequest;

View File

@ -3,11 +3,10 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandBasic; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandContext;
import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetFilterKeys; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetFilterKeys;
import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetFilterValues; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetFilterValues;
import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandSpaces;
import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetSpaces; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandGetSpaces;
import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandSpaces;
import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.command.AccountingCommandTop;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Job; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Job;
@ -18,15 +17,14 @@ import org.gcube.portlets.admin.accountingmanager.server.amservice.query.Account
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Task; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuery4Task;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBasic; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBuilder; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBuilder;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryContext;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryDirector; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryDirector;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuerySpaces; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuerySpaces;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryTop;
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.Spaces;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces;
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;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -102,11 +100,6 @@ public class AccountingCaller implements AccountingCallerInterface {
AccountingCommandTop accountingCommandTop = new AccountingCommandTop( AccountingCommandTop accountingCommandTop = new AccountingCommandTop(
accountingQueryTop, accountingType); accountingQueryTop, accountingType);
return accountingCommandTop.execute(); return accountingCommandTop.execute();
case Context:
AccountingQueryContext accountingQueryContext = (AccountingQueryContext) query;
AccountingCommandContext accountingCommandContext = new AccountingCommandContext(
accountingQueryContext, accountingType);
return accountingCommandContext.execute();
case Spaces: case Spaces:
AccountingQuerySpaces accountingQuerySpace = (AccountingQuerySpaces) query; AccountingQuerySpaces accountingQuerySpace = (AccountingQuerySpaces) query;
AccountingCommandSpaces accountingCommandSpace = new AccountingCommandSpaces( AccountingCommandSpaces accountingCommandSpace = new AccountingCommandSpaces(

View File

@ -12,12 +12,11 @@ import java.util.List;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; 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.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValuesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces;
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.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
@ -25,27 +24,21 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSer
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSpace; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSpace;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDefinition;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDefinition;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceSpaces;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceDataSpaces; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceDataSpaces;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceDefinition;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceSpaces;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDefinition;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop;
@ -60,8 +53,7 @@ import org.slf4j.LoggerFactory;
* *
*/ */
public class AccountingCallerTester implements AccountingCallerInterface { public class AccountingCallerTester implements AccountingCallerInterface {
private static Logger logger = LoggerFactory private static Logger logger = LoggerFactory.getLogger(AccountingCallerTester.class);
.getLogger(AccountingCallerTester.class);
protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMMM dd"); protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMMM dd");
@ -69,11 +61,9 @@ public class AccountingCallerTester implements AccountingCallerInterface {
super(); super();
} }
public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType) public ArrayList<FilterKey> getFilterKeys(AccountingType accountingType) throws ServiceException {
throws ServiceException {
try { try {
logger.debug("getFilterKeys(): [AccountingType=" + accountingType logger.debug("getFilterKeys(): [AccountingType=" + accountingType + "]");
+ "]");
if (accountingType == null) { if (accountingType == null) {
return new ArrayList<FilterKey>(); return new ArrayList<FilterKey>();
} }
@ -100,17 +90,13 @@ public class AccountingCallerTester implements AccountingCallerInterface {
} }
} }
public FilterValuesResponse getFilterValues( public FilterValuesResponse getFilterValues(FilterValuesRequest filterValuesRequest) throws ServiceException {
FilterValuesRequest filterValuesRequest) throws ServiceException {
try { try {
logger.debug("getFilterValue(): [FilterValueRequest=" logger.debug("getFilterValue(): [FilterValueRequest=" + filterValuesRequest + "]");
+ filterValuesRequest + "]");
FilterValuesResponse filterValuesResponse = null; FilterValuesResponse filterValuesResponse = null;
if (filterValuesRequest == null if (filterValuesRequest == null || filterValuesRequest.getAccountingType() == null
|| filterValuesRequest.getAccountingType() == null
|| filterValuesRequest.getFilterKey() == null) { || filterValuesRequest.getFilterKey() == null) {
filterValuesResponse = new FilterValuesResponse( filterValuesResponse = new FilterValuesResponse(new ArrayList<FilterValue>());
new ArrayList<FilterValue>());
return filterValuesResponse; return filterValuesResponse;
} }
@ -139,42 +125,36 @@ public class AccountingCallerTester implements AccountingCallerInterface {
filterValuesResponse = new FilterValuesResponse(filterValues); filterValuesResponse = new FilterValuesResponse(filterValues);
return filterValuesResponse; return filterValuesResponse;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error in getFilterValues(): " logger.error("Error in getFilterValues(): " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("No values available!"); throw new ServiceException("No values available!");
} }
} }
public SeriesResponse getSeries(AccountingType accountingType, public SeriesResponse getSeries(AccountingType accountingType, SeriesRequest seriesRequest)
SeriesRequest seriesRequest) throws ServiceException { throws ServiceException {
try { try {
logger.debug("getSeries(): [AccountingType=" + accountingType logger.debug("getSeries(): [AccountingType=" + accountingType + " , seriesRequest=" + seriesRequest + "]");
+ " , seriesRequest=" + seriesRequest + "]");
SeriesResponse seriesResponse = null; SeriesResponse seriesResponse = null;
Calendar startCalendar = GregorianCalendar Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
try { try {
startCalendar.setTime(sdf.parse(seriesRequest startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
.getAccountingPeriod().getStartDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("Start Date not valid!"); throw new ServiceException("Start Date not valid!");
} }
Calendar endCalendar = GregorianCalendar Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
// GregorianCalendar endCalendar = new GregorianCalendar(); // GregorianCalendar endCalendar = new GregorianCalendar();
// .getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); // .getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
// GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE); // GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
try { try {
endCalendar.setTime(sdf.parse(seriesRequest endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
.getAccountingPeriod().getEndDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("End Date not valid!"); throw new ServiceException("End Date not valid!");
@ -183,20 +163,16 @@ public class AccountingCallerTester implements AccountingCallerInterface {
switch (accountingType) { switch (accountingType) {
case JOB: case JOB:
SeriesJobDefinition serieJobDefinition = null; SeriesJobDefinition serieJobDefinition = null;
if (seriesRequest.getAccountingFilterDefinition() if (seriesRequest.getAccountingFilterDefinition().getChartType() != null) {
.getChartType() != null) {
ArrayList<SeriesJobData> seriesJobData = new ArrayList<>(); ArrayList<SeriesJobData> seriesJobData = new ArrayList<>();
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
SeriesJobData data = new SeriesJobData(new Date(), SeriesJobData data = new SeriesJobData(new Date(), new Double(10 * Math.random()).longValue(),
new Double(10 * Math.random()).longValue(), new Double(10 * Math.random()).longValue(), new Double(10 * Math.random()).longValue(),
new Double(10 * Math.random()).longValue(),
new Double(10 * Math.random()).longValue(),
new Double(100 * Math.random()).longValue()); new Double(100 * Math.random()).longValue());
seriesJobData.add(data); seriesJobData.add(data);
} }
switch (seriesRequest.getAccountingFilterDefinition() switch (seriesRequest.getAccountingFilterDefinition().getChartType()) {
.getChartType()) {
case Basic: case Basic:
serieJobDefinition = new SeriesJobBasic(seriesJobData); serieJobDefinition = new SeriesJobBasic(seriesJobData);
break; break;
@ -205,49 +181,13 @@ public class AccountingCallerTester implements AccountingCallerInterface {
.getAccountingFilterDefinition(); .getAccountingFilterDefinition();
ArrayList<SeriesJobDataTop> seriesJobDataTopList = new ArrayList<>(); ArrayList<SeriesJobDataTop> seriesJobDataTopList = new ArrayList<>();
if (accountingFilterTop.getShowOthers()) { for (int i = 0; i < accountingFilterTop.getTopNumber(); i++) {
for (int i = 0; i < 40; i++) {
SeriesJobDataTop seriesJobDataTop = new SeriesJobDataTop( SeriesJobDataTop seriesJobDataTop = new SeriesJobDataTop(new FilterValue("User" + i),
new FilterValue("User" + i), seriesJobData);
seriesJobData); seriesJobDataTopList.add(seriesJobDataTop);
seriesJobDataTopList.add(seriesJobDataTop);
}
} else {
for (int i = 0; i < accountingFilterTop
.getTopNumber(); i++) {
SeriesJobDataTop seriesJobDataTop = new SeriesJobDataTop(
new FilterValue("User" + i),
seriesJobData);
seriesJobDataTopList.add(seriesJobDataTop);
}
} }
serieJobDefinition = new SeriesJobTop(accountingFilterTop.getTopNumber(), seriesJobDataTopList);
serieJobDefinition = new SeriesJobTop(
accountingFilterTop.getShowOthers(),
accountingFilterTop.getTopNumber(),
seriesJobDataTopList);
break;
case Context:
// AccountingFilterContext accountingFilterContext =
// (AccountingFilterContext) seriesRequest
// .getAccountingFilterDefinition();
ArrayList<SeriesJobDataContext> seriesJobDataContextList = new ArrayList<>();
ArrayList<String> contexts = new ArrayList<>();
for (int i = 0; i < 20; i++) {
String scope = new String("VRE " + i);
contexts.add(scope);
SeriesJobDataContext seriesJobDataContext = new SeriesJobDataContext(
scope, seriesJobData);
seriesJobDataContextList.add(seriesJobDataContext);
}
Context context = new Context(contexts);
serieJobDefinition = new SeriesJobContext(context,
seriesJobDataContextList);
break; break;
default: default:
@ -263,49 +203,39 @@ public class AccountingCallerTester implements AccountingCallerInterface {
break; break;
case SERVICE: case SERVICE:
SeriesServiceDefinition serieServiceDefinition = null; SeriesServiceDefinition serieServiceDefinition = null;
if (seriesRequest.getAccountingFilterDefinition() if (seriesRequest.getAccountingFilterDefinition().getChartType() != null) {
.getChartType() != null) {
ArrayList<SeriesServiceData> seriesServiceData = new ArrayList<>(); ArrayList<SeriesServiceData> seriesServiceData = new ArrayList<>();
switch (seriesRequest.getAccountingPeriod().getPeriod()) { switch (seriesRequest.getAccountingPeriod().getPeriod()) {
case DAILY: case DAILY:
case HOURLY: case HOURLY:
case MINUTELY: case MINUTELY:
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
SeriesServiceData data = new SeriesServiceData( SeriesServiceData data = new SeriesServiceData(new Date(),
new Date(),
new Double(50 * Math.random()).longValue(), new Double(50 * Math.random()).longValue(),
new Double(10000 * Math.random()) new Double(10000 * Math.random()).longValue(),
.longValue(), new Double( new Double(10000 * Math.random()).longValue(),
10000 * Math.random()).longValue(), new Double(10000 * Math.random()).longValue());
new Double(10000 * Math.random())
.longValue());
seriesServiceData.add(data); seriesServiceData.add(data);
} }
break; break;
case MONTHLY: case MONTHLY:
while (startCalendar.compareTo(endCalendar) <= 0) { while (startCalendar.compareTo(endCalendar) <= 0) {
SeriesServiceData data = new SeriesServiceData( SeriesServiceData data = new SeriesServiceData(startCalendar.getTime(),
startCalendar.getTime(), new Double( new Double(50 * Math.random()).longValue(),
50 * Math.random()).longValue(), new Double(10000 * Math.random()).longValue(),
new Double(10000 * Math.random()) new Double(10000 * Math.random()).longValue(),
.longValue(), new Double( new Double(10000 * Math.random()).longValue());
10000 * Math.random()).longValue(),
new Double(10000 * Math.random())
.longValue());
seriesServiceData.add(data); seriesServiceData.add(data);
startCalendar.add(Calendar.MONTH, 1); startCalendar.add(Calendar.MONTH, 1);
} }
break; break;
case YEARLY: case YEARLY:
while (startCalendar.compareTo(endCalendar) <= 0) { while (startCalendar.compareTo(endCalendar) <= 0) {
SeriesServiceData data = new SeriesServiceData( SeriesServiceData data = new SeriesServiceData(startCalendar.getTime(),
startCalendar.getTime(), new Double( new Double(50 * Math.random()).longValue(),
50 * Math.random()).longValue(), new Double(10000 * Math.random()).longValue(),
new Double(10000 * Math.random()) new Double(10000 * Math.random()).longValue(),
.longValue(), new Double( new Double(10000 * Math.random()).longValue());
10000 * Math.random()).longValue(),
new Double(10000 * Math.random())
.longValue());
seriesServiceData.add(data); seriesServiceData.add(data);
startCalendar.add(Calendar.YEAR, 1); startCalendar.add(Calendar.YEAR, 1);
} }
@ -315,117 +245,25 @@ public class AccountingCallerTester implements AccountingCallerInterface {
} }
switch (seriesRequest.getAccountingFilterDefinition() switch (seriesRequest.getAccountingFilterDefinition().getChartType()) {
.getChartType()) {
case Basic: case Basic:
serieServiceDefinition = new SeriesServiceBasic( serieServiceDefinition = new SeriesServiceBasic(seriesServiceData);
seriesServiceData);
break; break;
case Top: case Top:
AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest
.getAccountingFilterDefinition(); .getAccountingFilterDefinition();
ArrayList<SeriesServiceDataTop> seriesServiceDataTopList = new ArrayList<>(); ArrayList<SeriesServiceDataTop> seriesServiceDataTopList = new ArrayList<>();
if (accountingFilterTop.getShowOthers()) { for (int i = 0; i < accountingFilterTop.getTopNumber(); i++) {
try { SeriesServiceDataTop seriesServiceDataTop1 = new SeriesServiceDataTop(
startCalendar.setTime(sdf.parse(seriesRequest new FilterValue("User" + i), seriesServiceData);
.getAccountingPeriod().getStartDate())); seriesServiceDataTopList.add(seriesServiceDataTop1);
} catch (ParseException e) {
e.printStackTrace();
throw new ServiceException(
"Start Date not valid!");
}
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 {
for (int i = 0; i < accountingFilterTop
.getTopNumber(); i++) {
SeriesServiceDataTop seriesServiceDataTop1 = new SeriesServiceDataTop(
new FilterValue("User" + i),
seriesServiceData);
seriesServiceDataTopList
.add(seriesServiceDataTop1);
}
} }
serieServiceDefinition = new SeriesServiceTop( serieServiceDefinition = new SeriesServiceTop(accountingFilterTop.getTopNumber(),
accountingFilterTop.getShowOthers(),
accountingFilterTop.getTopNumber(),
seriesServiceDataTopList); seriesServiceDataTopList);
break; break;
case Context:
// AccountingFilterContext accountingFilterContext =
// (AccountingFilterContext) seriesRequest
// .getAccountingFilterDefinition();
ArrayList<SeriesServiceDataContext> seriesServiceDataContextList = new ArrayList<>();
ArrayList<String> contexts = new ArrayList<>();
for (int i = 0; i < 20; i++) {
String scope = new String("VRE " + i);
contexts.add(scope);
SeriesServiceDataContext seriesServiceDataContext = new SeriesServiceDataContext(
scope, seriesServiceData);
seriesServiceDataContextList
.add(seriesServiceDataContext);
}
Context context = new Context(contexts);
serieServiceDefinition = new SeriesServiceContext(
context, seriesServiceDataContextList);
default: default:
break; break;
@ -438,34 +276,30 @@ public class AccountingCallerTester implements AccountingCallerInterface {
break; break;
case SPACE: case SPACE:
SeriesSpaceDefinition serieSpaceDefinition = null; SeriesSpaceDefinition serieSpaceDefinition = null;
if (seriesRequest.getAccountingFilterDefinition() if (seriesRequest.getAccountingFilterDefinition().getChartType() != null) {
.getChartType() != null) {
ArrayList<SeriesSpaceData> seriesSpaceData = new ArrayList<>(); ArrayList<SeriesSpaceData> seriesSpaceData = new ArrayList<>();
switch (seriesRequest.getAccountingPeriod().getPeriod()) { switch (seriesRequest.getAccountingPeriod().getPeriod()) {
case DAILY: case DAILY:
case HOURLY: case HOURLY:
case MINUTELY: case MINUTELY:
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
SeriesSpaceData data = new SeriesSpaceData( SeriesSpaceData data = new SeriesSpaceData(new Date(),
new Date(), new Double( new Double(10000 * Math.random()).longValue());
10000 * Math.random()).longValue());
seriesSpaceData.add(data); seriesSpaceData.add(data);
} }
break; break;
case MONTHLY: case MONTHLY:
while (startCalendar.compareTo(endCalendar) <= 0) { while (startCalendar.compareTo(endCalendar) <= 0) {
SeriesSpaceData data = new SeriesSpaceData( SeriesSpaceData data = new SeriesSpaceData(startCalendar.getTime(),
startCalendar.getTime(), new Double( new Double(10000 * Math.random()).longValue());
10000 * Math.random()).longValue());
seriesSpaceData.add(data); seriesSpaceData.add(data);
startCalendar.add(Calendar.MONTH, 1); startCalendar.add(Calendar.MONTH, 1);
} }
break; break;
case YEARLY: case YEARLY:
while (startCalendar.compareTo(endCalendar) <= 0) { while (startCalendar.compareTo(endCalendar) <= 0) {
SeriesSpaceData data = new SeriesSpaceData( SeriesSpaceData data = new SeriesSpaceData(startCalendar.getTime(),
startCalendar.getTime(), new Double( new Double(10000 * Math.random()).longValue());
10000 * Math.random()).longValue());
seriesSpaceData.add(data); seriesSpaceData.add(data);
startCalendar.add(Calendar.YEAR, 1); startCalendar.add(Calendar.YEAR, 1);
} }
@ -475,12 +309,9 @@ public class AccountingCallerTester implements AccountingCallerInterface {
} }
switch (seriesRequest.getAccountingFilterDefinition() switch (seriesRequest.getAccountingFilterDefinition().getChartType()) {
.getChartType()) {
case Basic: case Basic:
case Top: case Top:
case Context:
break;
case Spaces: case Spaces:
// AccountingFilterContext accountingFilterContext = // AccountingFilterContext accountingFilterContext =
// (AccountingFilterContext) seriesRequest // (AccountingFilterContext) seriesRequest
@ -491,15 +322,13 @@ public class AccountingCallerTester implements AccountingCallerInterface {
for (int i = 1; i < 3; i++) { for (int i = 1; i < 3; i++) {
String space = new String("Space" + i); String space = new String("Space" + i);
spacesList.add(space); spacesList.add(space);
SeriesSpaceDataSpaces seriesSpaceDataSpaces = new SeriesSpaceDataSpaces( SeriesSpaceDataSpaces seriesSpaceDataSpaces = new SeriesSpaceDataSpaces(space,
space, seriesSpaceData); seriesSpaceData);
seriesSpaceDataSpacesList seriesSpaceDataSpacesList.add(seriesSpaceDataSpaces);
.add(seriesSpaceDataSpaces);
} }
Spaces spaces=new Spaces(spacesList); Spaces spaces = new Spaces(spacesList);
serieSpaceDefinition = new SeriesSpaceSpaces( serieSpaceDefinition = new SeriesSpaceSpaces(spaces, seriesSpaceDataSpacesList);
spaces, seriesSpaceDataSpacesList);
default: default:
break; break;
@ -513,17 +342,14 @@ public class AccountingCallerTester implements AccountingCallerInterface {
case STORAGE: case STORAGE:
SeriesStorageDefinition serieStorageDefinition = null; SeriesStorageDefinition serieStorageDefinition = null;
if (seriesRequest.getAccountingFilterDefinition() if (seriesRequest.getAccountingFilterDefinition().getChartType() != null) {
.getChartType() != null) {
ArrayList<SeriesStorageData> seriesStorageData = new ArrayList<>(); ArrayList<SeriesStorageData> seriesStorageData = new ArrayList<>();
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
// Valori variabili // Valori variabili
SeriesStorageData data = new SeriesStorageData( SeriesStorageData data = new SeriesStorageData(new Date(),
new Date(), new Double(1024 * 1024 * Math.random()).longValue(),
new Double(1024 * 1024 * Math.random()) new Double(100 * Math.random()).longValue());
.longValue(), new Double(
100 * Math.random()).longValue());
// Valori Fissi // Valori Fissi
/* /*
@ -535,68 +361,29 @@ public class AccountingCallerTester implements AccountingCallerInterface {
seriesStorageData.add(data); seriesStorageData.add(data);
} }
switch (seriesRequest.getAccountingFilterDefinition() switch (seriesRequest.getAccountingFilterDefinition().getChartType()) {
.getChartType()) {
case Basic: case Basic:
for (SeriesStorageData serieStorageData : seriesStorageData) { for (SeriesStorageData serieStorageData : seriesStorageData) {
serieStorageData.setDataVolume(serieStorageData serieStorageData.setDataVolume(serieStorageData.getDataVolume() * 1000);
.getDataVolume() * 1000); serieStorageData.setOperationCount(serieStorageData.getOperationCount() * 1000);
serieStorageData.setOperationCount(serieStorageData
.getOperationCount() * 1000);
} }
serieStorageDefinition = new SeriesStorageBasic( serieStorageDefinition = new SeriesStorageBasic(seriesStorageData);
seriesStorageData);
break; break;
case Top: case Top:
AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest
.getAccountingFilterDefinition(); .getAccountingFilterDefinition();
ArrayList<SeriesStorageDataTop> seriesStorageDataTopList = new ArrayList<>(); ArrayList<SeriesStorageDataTop> seriesStorageDataTopList = new ArrayList<>();
if (accountingFilterTop.getShowOthers()) {
for (int i = 0; i < 1000; i++) {
SeriesStorageDataTop seriesStorageDataTop = new SeriesStorageDataTop(
new FilterValue("User" + i),
seriesStorageData);
seriesStorageDataTopList
.add(seriesStorageDataTop);
}
} else {
for (int i = 0; i < accountingFilterTop for (int i = 0; i < accountingFilterTop.getTopNumber(); i++) {
.getTopNumber(); i++) { SeriesStorageDataTop seriesStorageDataTop = new SeriesStorageDataTop(
SeriesStorageDataTop seriesStorageDataTop = new SeriesStorageDataTop( new FilterValue("User" + i), seriesStorageData);
new FilterValue("User" + i), seriesStorageDataTopList.add(seriesStorageDataTop);
seriesStorageData);
seriesStorageDataTopList
.add(seriesStorageDataTop);
}
} }
serieStorageDefinition = new SeriesStorageTop(
accountingFilterTop.getShowOthers(), serieStorageDefinition = new SeriesStorageTop(accountingFilterTop.getTopNumber(),
accountingFilterTop.getTopNumber(),
seriesStorageDataTopList); seriesStorageDataTopList);
break; break;
case Context:
// AccountingFilterContext accountingFilterContext =
// (AccountingFilterContext) seriesRequest
// .getAccountingFilterDefinition();
ArrayList<SeriesStorageDataContext> seriesStorageDataContextList = new ArrayList<>();
ArrayList<String> contexts = new ArrayList<>();
for (int i = 0; i < 20; i++) {
String scope = new String("VRE " + i);
contexts.add(scope);
SeriesStorageDataContext seriesStorageDataContext = new SeriesStorageDataContext(
scope, seriesStorageData);
seriesStorageDataContextList
.add(seriesStorageDataContext);
}
Context context = new Context(contexts);
serieStorageDefinition = new SeriesStorageContext(
context, seriesStorageDataContextList);
break;
default: default:
break; break;

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.SortedMap; import java.util.SortedMap;
@ -43,27 +44,31 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
public SeriesResponse execute() throws ServiceException { public SeriesResponse execute() throws ServiceException {
try { try {
if (accountingQueryBasic.getScope() != null && !accountingQueryBasic.getScope().isEmpty()) { //if (accountingQueryBasic.getScope() != null) {
AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryBasic.getScope()); // AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryBasic.getScope());
} //}
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance(); AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
SortedMap<Calendar, Info> sm = null; SortedMap<Calendar, Info> sm = null;
if (accountingQueryBasic.isNoContext()) { logger.debug("Execute Basic()");
logger.debug("Execute NoContextTimeSeries()"); apq.setRequestedRecords(accountingQueryBasic.getType());
sm = apq.getNoContextTimeSeries(accountingQueryBasic.getType(), HashSet<String> ctx=null;
accountingQueryBasic.getTemporalConstraint(), accountingQueryBasic.getFilters(), true); if(accountingQueryBasic.getContext()!=null&&accountingQueryBasic.getContext().getContexts()!=null
} else { &&!accountingQueryBasic.getContext().getContexts().isEmpty()){
logger.debug("Execute TimeSeries()"); ctx=new HashSet<String>(accountingQueryBasic.getContext().getContexts());
sm = apq.getTimeSeries(accountingQueryBasic.getType(), accountingQueryBasic.getTemporalConstraint(),
accountingQueryBasic.getFilters(), true);
} }
apq.setContexts(ctx);
apq.setTemporalConstraint(accountingQueryBasic.getTemporalConstraint());
apq.setFilters(accountingQueryBasic.getFilters());
sm=apq.getTimeSeries(true);
if (accountingQueryBasic.getScope() != null && !accountingQueryBasic.getScope().isEmpty()) { //sm = apq.getTimeSeries(accountingQueryBasic.getType(), accountingQueryBasic.getTemporalConstraint(),
AccountingPersistenceQueryFactory.getForcedQueryScope().remove(); // accountingQueryBasic.getFilters(), true);
}
//if (accountingQueryBasic.getScope() != null) {
// AccountingPersistenceQueryFactory.getForcedQueryScope().remove();
//}
if (sm == null || sm.values() == null) { if (sm == null || sm.values() == null) {
throw new ServiceException("Error retrieving info: sorted map is null!"); throw new ServiceException("Error retrieving info: sorted map is null!");

View File

@ -1,126 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryContext;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4JobContext;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4PortletContext;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4ServiceContext;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4StorageContext;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4TaskContext;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseBuilder;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseDirector;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class AccountingCommandContext implements AccountingCommand<SeriesResponse> {
private static final Logger logger = LoggerFactory
.getLogger(AccountingCommandContext.class);
private AccountingQueryContext accountingQueryContext;
private AccountingType accountingType;
public AccountingCommandContext(AccountingQueryContext accountingQueryContext,
AccountingType accountingType) {
this.accountingQueryContext = accountingQueryContext;
this.accountingType = accountingType;
}
@Override
public SeriesResponse execute() throws ServiceException {
try {
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory
.getInstance();
logger.debug("Query Context: "
+ accountingQueryContext.getContext());
SortedMap<Filter, SortedMap<Calendar, Info>> contextSM;
Context context=accountingQueryContext.getContext();
if(context==null){
throw new ServiceException(
"Error retrieving context param: null!");
}
contextSM= apq.getContextTimeSeries(accountingQueryContext.getType(),
accountingQueryContext.getTemporalConstraint(),
accountingQueryContext.getFilters(),
context.getContexts(),
true);
if (contextSM == null) {
throw new ServiceException(
"Error retrieving info for context: sorted map is null!");
}
logger.debug("ContextSM: " + contextSM);
SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder(
accountingType, context, contextSM);
SeriesResponseDirector seriesResponseDirector = new SeriesResponseDirector();
seriesResponseDirector
.setSeriesResponseBuilder(seriesResponseBuilder);
seriesResponseDirector.constructSeriesResponse();
SeriesResponse seriesResponse = seriesResponseDirector
.getSeriesResponse();
if (seriesResponse == null) {
throw new ServiceException("Error creating series response!");
}
logger.debug("SeriesResponse Created: " + seriesResponse);
return seriesResponse;
} catch (Throwable e) {
logger.error("Error in AccountingCommandTop(): "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException("No data available!");
}
}
private SeriesResponseBuilder getSeriesResponseBuilder(
AccountingType accountingType, Context context,
SortedMap<Filter, SortedMap<Calendar, Info>> contextSM)
throws ServiceException {
if (accountingType == null) {
throw new ServiceException("Error accounting type is null");
}
switch (accountingType) {
case JOB:
return new SeriesResponse4JobContext(context,contextSM);
case PORTLET:
return new SeriesResponse4PortletContext(context, contextSM);
case SERVICE:
return new SeriesResponse4ServiceContext(context, contextSM);
case STORAGE:
return new SeriesResponse4StorageContext(context, contextSM);
case TASK:
return new SeriesResponse4TaskContext(context, contextSM);
default:
throw new ServiceException("Error request type is unknow!");
}
}
}

View File

@ -27,19 +27,16 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class AccountingCommandGetFilterValues implements public class AccountingCommandGetFilterValues implements AccountingCommand<FilterValuesResponse> {
AccountingCommand<FilterValuesResponse> { private static final Logger logger = LoggerFactory.getLogger(AccountingCommandGetFilterValues.class);
private static final Logger logger = LoggerFactory
.getLogger(AccountingCommandGetFilterValues.class);
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMMM dd"); private SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMMMM dd");
private FilterValuesRequest filterValuesRequest; private FilterValuesRequest filterValuesRequest;
public AccountingCommandGetFilterValues( public AccountingCommandGetFilterValues(FilterValuesRequest filterValuesRequest) {
FilterValuesRequest filterValuesRequest) {
this.filterValuesRequest = filterValuesRequest; this.filterValuesRequest = filterValuesRequest;
} }
@ -47,14 +44,11 @@ public class AccountingCommandGetFilterValues implements
@Override @Override
public FilterValuesResponse execute() throws ServiceException { public FilterValuesResponse execute() throws ServiceException {
try { try {
logger.debug("getFilterValue(): [FilterValueRequest=" logger.debug("getFilterValue(): [FilterValueRequest=" + filterValuesRequest + "]");
+ filterValuesRequest + "]");
FilterValuesResponse filterValuesResponse = null; FilterValuesResponse filterValuesResponse = null;
if (filterValuesRequest == null if (filterValuesRequest == null || filterValuesRequest.getAccountingType() == null
|| filterValuesRequest.getAccountingType() == null
|| filterValuesRequest.getFilterKey() == null) { || filterValuesRequest.getFilterKey() == null) {
filterValuesResponse = new FilterValuesResponse( filterValuesResponse = new FilterValuesResponse(new ArrayList<FilterValue>());
new ArrayList<FilterValue>());
return filterValuesResponse; return filterValuesResponse;
} }
@ -62,24 +56,19 @@ public class AccountingCommandGetFilterValues implements
Set<NumberedFilter> values; Set<NumberedFilter> values;
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
.getInstance();
Calendar startCalendar = GregorianCalendar Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
try { try {
startCalendar.setTime(sdf.parse(filterValuesRequest startCalendar.setTime(sdf.parse(filterValuesRequest.getAccountingPeriod().getStartDate()));
.getAccountingPeriod().getStartDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("Start Date not valid!"); throw new ServiceException("Start Date not valid!");
} }
Calendar endCalendar = GregorianCalendar Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
try { try {
endCalendar.setTime(sdf.parse(filterValuesRequest endCalendar.setTime(sdf.parse(filterValuesRequest.getAccountingPeriod().getEndDate()));
.getAccountingPeriod().getEndDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("End Date not valid!"); throw new ServiceException("End Date not valid!");
@ -90,19 +79,18 @@ public class AccountingCommandGetFilterValues implements
endCalendar.set(GregorianCalendar.SECOND, 59); endCalendar.set(GregorianCalendar.SECOND, 59);
endCalendar.set(GregorianCalendar.MILLISECOND, 999); endCalendar.set(GregorianCalendar.MILLISECOND, 999);
TemporalConstraint tc = new TemporalConstraint( TemporalConstraint tc = new TemporalConstraint(startCalendar.getTimeInMillis(),
startCalendar.getTimeInMillis(),
endCalendar.getTimeInMillis(), endCalendar.getTimeInMillis(),
PeriodModeMap.getMode(filterValuesRequest PeriodModeMap.getMode(filterValuesRequest.getAccountingPeriod().getPeriod()));
.getAccountingPeriod().getPeriod()));
List<Filter> filters = new ArrayList<>(); List<Filter> filters = new ArrayList<>();
switch (filterValuesRequest.getAccountingType()) { switch (filterValuesRequest.getAccountingType()) {
case JOB: case JOB:
values = apq.getFilterValues(AggregatedJobUsageRecord.class, apq.setRequestedRecords(AggregatedJobUsageRecord.class);
tc, filters, filterValuesRequest.getFilterKey() apq.setTemporalConstraint(tc);
.getKey()); apq.setFilters(filters);
values = apq.getFilterValues(filterValuesRequest.getFilterKey().getKey());
break; break;
case PORTLET: case PORTLET:
// values = rrq.getPossibleValuesForKey( // values = rrq.getPossibleValuesForKey(
@ -111,14 +99,16 @@ public class AccountingCommandGetFilterValues implements
filterValuesResponse = new FilterValuesResponse(filterValues); filterValuesResponse = new FilterValuesResponse(filterValues);
return filterValuesResponse; return filterValuesResponse;
case SERVICE: case SERVICE:
values = apq.getFilterValues( apq.setRequestedRecords(AggregatedServiceUsageRecord.class);
AggregatedServiceUsageRecord.class, tc, filters, apq.setTemporalConstraint(tc);
filterValuesRequest.getFilterKey().getKey()); apq.setFilters(filters);
values = apq.getFilterValues(filterValuesRequest.getFilterKey().getKey());
break; break;
case STORAGE: case STORAGE:
values = apq.getFilterValues( apq.setRequestedRecords(AggregatedStorageUsageRecord.class);
AggregatedStorageUsageRecord.class, tc, filters, apq.setTemporalConstraint(tc);
filterValuesRequest.getFilterKey().getKey()); apq.setFilters(filters);
values = apq.getFilterValues(filterValuesRequest.getFilterKey().getKey());
break; break;
case TASK: case TASK:
// values = rrq.getPossibleValuesForKey( // values = rrq.getPossibleValuesForKey(
@ -127,9 +117,10 @@ public class AccountingCommandGetFilterValues implements
filterValuesResponse = new FilterValuesResponse(filterValues); filterValuesResponse = new FilterValuesResponse(filterValues);
return filterValuesResponse; return filterValuesResponse;
case SPACE: case SPACE:
values = apq.getFilterValues( apq.setRequestedRecords(AggregatedStorageStatusRecord.class);
AggregatedStorageStatusRecord.class, tc, filters, apq.setTemporalConstraint(tc);
filterValuesRequest.getFilterKey().getKey()); apq.setFilters(filters);
values = apq.getFilterValues(filterValuesRequest.getFilterKey().getKey());
break; break;
default: default:
filterValuesResponse = new FilterValuesResponse(filterValues); filterValuesResponse = new FilterValuesResponse(filterValues);
@ -145,8 +136,7 @@ public class AccountingCommandGetFilterValues implements
filterValuesResponse = new FilterValuesResponse(filterValues); filterValuesResponse = new FilterValuesResponse(filterValues);
return filterValuesResponse; return filterValuesResponse;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error in AccountingCommandGetFilterValues(): " logger.error("Error in AccountingCommandGetFilterValues(): " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("No values available!"); throw new ServiceException("No values available!");

View File

@ -3,8 +3,10 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.SortedSet; import java.util.SortedSet;
import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -26,10 +28,14 @@ public class AccountingCommandGetSpaces implements AccountingCommand<Spaces> {
public Spaces execute() throws ServiceException { public Spaces execute() throws ServiceException {
try { try {
logger.debug("getSpaces()"); logger.debug("getSpaces()");
SortedSet<String> keys = null; SortedSet<NumberedFilter> keys = null;
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance(); AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
keys = apq.getSpaceProvidersIds(); //TODO the library must implement this interface
keys = apq.getFilterValues(AggregatedStorageStatusRecord.DATA_TYPE);
//keys = apq.getSpaceProvidersIds();
logger.debug("AccountingPersistenceQuery.getSpaces: " + keys); logger.debug("AccountingPersistenceQuery.getSpaces: " + keys);
ArrayList<String> spaceList = new ArrayList<>(); ArrayList<String> spaceList = new ArrayList<>();
@ -37,9 +43,9 @@ public class AccountingCommandGetSpaces implements AccountingCommand<Spaces> {
if (keys == null || keys.isEmpty()) { if (keys == null || keys.isEmpty()) {
logger.error("Spaces have not keys: {}", keys); logger.error("Spaces have not keys: {}", keys);
} else { } else {
for (String key : keys) { for (NumberedFilter key : keys) {
if (key != null && !key.isEmpty()) { if (key != null ) {
spaceList.add(key); spaceList.add(key.getValue());
} }
} }
} }

View File

@ -1,9 +1,11 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.command; package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashSet;
import java.util.SortedMap; import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter; import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuerySpaces; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQuerySpaces;
@ -46,7 +48,7 @@ public class AccountingCommandSpaces implements
logger.debug("Query Spaces: " + accountingQuerySpaces.getSpaces()); logger.debug("Query Spaces: " + accountingQuerySpaces.getSpaces());
SortedMap<Filter, SortedMap<Calendar, Long>> spaceSM; SortedMap<Filter, SortedMap<Calendar, Info>> spaceSM;
Spaces spaces = accountingQuerySpaces.getSpaces(); Spaces spaces = accountingQuerySpaces.getSpaces();
@ -55,9 +57,15 @@ public class AccountingCommandSpaces implements
"Error retrieving Spaces param: null!"); "Error retrieving Spaces param: null!");
} }
spaceSM = apq.getSpaceTimeSeries(accountingQuerySpaces.getType(), apq.setRequestedRecords(accountingQuerySpaces.getType());
accountingQuerySpaces.getTemporalConstraint(), apq.setTemporalConstraint(accountingQuerySpaces.getTemporalConstraint());
accountingQuerySpaces.getFilters(), spaces.getSpacesList()); apq.setFilters(accountingQuerySpaces.getFilters());
spaceSM = apq.getSpaceTimeSeries(new HashSet<String>(spaces.getSpacesList()));
//spaceSM = apq.getSpaceTimeSeries(accountingQuerySpaces.getType(),
// accountingQuerySpaces.getTemporalConstraint(),
// accountingQuerySpaces.getFilters(), spaces.getSpacesList());
if (spaceSM == null) { if (spaceSM == null) {
throw new ServiceException( throw new ServiceException(
@ -93,7 +101,7 @@ public class AccountingCommandSpaces implements
private SeriesResponseBuilder getSeriesResponseBuilder( private SeriesResponseBuilder getSeriesResponseBuilder(
AccountingType accountingType, Spaces spaces, AccountingType accountingType, Spaces spaces,
SortedMap<Filter, SortedMap<Calendar, Long>> spaceSM) SortedMap<Filter, SortedMap<Calendar, Info>> spaceSM)
throws ServiceException { throws ServiceException {
if (accountingType == null) { if (accountingType == null) {
throw new ServiceException("Error accounting type is null"); throw new ServiceException("Error accounting type is null");

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.command; package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashSet;
import java.util.SortedMap; import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
@ -42,9 +43,10 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
public SeriesResponse execute() throws ServiceException { public SeriesResponse execute() throws ServiceException {
try { try {
if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) { // if (accountingQueryTop.getScope() != null &&
AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryTop.getScope()); // !accountingQueryTop.getScope().isEmpty()) {
} // AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryTop.getScope());
// }
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance(); AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
@ -52,18 +54,25 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM; SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
if (accountingQueryTop.getShowOthers()) { logger.debug("Execute Top()");
topSM = apq.getTopValues(accountingQueryTop.getType(), accountingQueryTop.getTemporalConstraint(), apq.setRequestedRecords(accountingQueryTop.getType());
accountingQueryTop.getFilters(), accountingQueryTop.getFilterKey().getKey(), null, true, 0);
} else {
topSM = apq.getTopValues(accountingQueryTop.getType(), accountingQueryTop.getTemporalConstraint(),
accountingQueryTop.getFilters(), accountingQueryTop.getFilterKey().getKey(), null, true,
accountingQueryTop.getTopNumber());
}
if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) { HashSet<String> ctx = null;
AccountingPersistenceQueryFactory.getForcedQueryScope().remove(); if (accountingQueryTop.getContext() != null && accountingQueryTop.getContext().getContexts() != null
&& !accountingQueryTop.getContext().getContexts().isEmpty()) {
ctx = new HashSet<String>(accountingQueryTop.getContext().getContexts());
} }
apq.setContexts(ctx);
apq.setTemporalConstraint(accountingQueryTop.getTemporalConstraint());
apq.setFilters(accountingQueryTop.getFilters());
topSM = apq.getTopValues(accountingQueryTop.getFilterKey().getKey(), null, true,
accountingQueryTop.getTopNumber());
// if (accountingQueryTop.getScope() != null &&
// !accountingQueryTop.getScope().isEmpty()) {
// AccountingPersistenceQueryFactory.getForcedQueryScope().remove();
// }
if (topSM == null) { if (topSM == null) {
throw new ServiceException("Error retrieving info for top: sorted map is null!"); throw new ServiceException("Error retrieving info for top: sorted map is null!");
@ -100,20 +109,15 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
switch (accountingType) { switch (accountingType) {
case JOB: case JOB:
return new SeriesResponse4JobTop(accountingQueryTop.getShowOthers(), accountingQueryTop.getTopNumber(), return new SeriesResponse4JobTop(accountingQueryTop.getTopNumber(), topSM);
topSM);
case PORTLET: case PORTLET:
return new SeriesResponse4PortletTop(accountingQueryTop.getShowOthers(), accountingQueryTop.getTopNumber(), return new SeriesResponse4PortletTop(accountingQueryTop.getTopNumber(), topSM);
topSM);
case SERVICE: case SERVICE:
return new SeriesResponse4ServiceTop(accountingQueryTop.getShowOthers(), accountingQueryTop.getTopNumber(), return new SeriesResponse4ServiceTop(accountingQueryTop.getTopNumber(), topSM);
topSM);
case STORAGE: case STORAGE:
return new SeriesResponse4StorageTop(accountingQueryTop.getShowOthers(), accountingQueryTop.getTopNumber(), return new SeriesResponse4StorageTop(accountingQueryTop.getTopNumber(), topSM);
topSM);
case TASK: case TASK:
return new SeriesResponse4TaskTop(accountingQueryTop.getShowOthers(), accountingQueryTop.getTopNumber(), return new SeriesResponse4TaskTop(accountingQueryTop.getTopNumber(), topSM);
topSM);
default: default:
throw new ServiceException("Error request type is unknow!"); throw new ServiceException("Error request type is unknow!");

View File

@ -11,7 +11,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
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.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -77,8 +76,8 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
filters.add(filter); filters.add(filter);
} }
} }
invocation = new AccountingQueryBasic(AggregatedJobUsageRecord.class, accountingFilterBasic.getScope(), invocation = new AccountingQueryBasic(AggregatedJobUsageRecord.class,
accountingFilterBasic.isNoContext(), temporalConstraint, filters); accountingFilterBasic.getContext(), temporalConstraint, filters);
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -93,28 +92,12 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
filters.add(filter); filters.add(filter);
} }
} }
invocation = new AccountingQueryTop(AggregatedJobUsageRecord.class, accountingFilterTop.getScope(), invocation = new AccountingQueryTop(AggregatedJobUsageRecord.class, accountingFilterTop.getContext(),
accountingFilterTop.getFilterKey(), accountingFilterTop.getShowOthers(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getTopNumber(), temporalConstraint, filters); accountingFilterTop.getTopNumber(), temporalConstraint, filters);
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) {
AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest
.getAccountingFilterDefinition();
accountingFilters = accountingFilterContext.getFilters();
filters = new ArrayList<Filter>();
if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters.getFilterKey().getKey(),
accountigFilters.getFilterValue());
filters.add(filter);
}
}
invocation = new AccountingQueryContext(AggregatedJobUsageRecord.class,
accountingFilterContext.getContext(), temporalConstraint, filters);
} else {
logger.error("Invalid Request: " + seriesRequest); logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException("Invalid Request!"); throw new ServiceException("Invalid Request!");
}
} }
} }

View File

@ -11,7 +11,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
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.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -77,8 +76,7 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
} }
} }
invocation = new AccountingQueryBasic(AggregatedPortletUsageRecord.class, invocation = new AccountingQueryBasic(AggregatedPortletUsageRecord.class,
accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint, accountingFilterBasic.getContext(), temporalConstraint, filters);
filters);
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -94,28 +92,11 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
} }
} }
invocation = new AccountingQueryTop(AggregatedPortletUsageRecord.class, invocation = new AccountingQueryTop(AggregatedPortletUsageRecord.class,
accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(), accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint, accountingFilterTop.getTopNumber(), temporalConstraint, filters);
filters);
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { logger.error("Invalid Request: " + seriesRequest);
AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest throw new ServiceException("Invalid Request!");
.getAccountingFilterDefinition();
accountingFilters = accountingFilterContext.getFilters();
filters = new ArrayList<Filter>();
if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters.getFilterKey().getKey(),
accountigFilters.getFilterValue());
filters.add(filter);
}
}
invocation = new AccountingQueryContext(AggregatedPortletUsageRecord.class,
accountingFilterContext.getContext(), temporalConstraint, filters);
} else {
logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException("Invalid Request!");
}
} }
} }

View File

@ -11,7 +11,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
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.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -78,8 +77,7 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
} }
} }
invocation = new AccountingQueryBasic(AggregatedServiceUsageRecord.class, invocation = new AccountingQueryBasic(AggregatedServiceUsageRecord.class,
accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint, accountingFilterBasic.getContext(), temporalConstraint, filters);
filters);
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -95,28 +93,11 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
} }
} }
invocation = new AccountingQueryTop(AggregatedServiceUsageRecord.class, invocation = new AccountingQueryTop(AggregatedServiceUsageRecord.class,
accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(), accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint, accountingFilterTop.getTopNumber(), temporalConstraint, filters);
filters);
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { logger.error("Invalid Request: " + seriesRequest);
AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest throw new ServiceException("Invalid Request!");
.getAccountingFilterDefinition();
accountingFilters = accountingFilterContext.getFilters();
filters = new ArrayList<Filter>();
if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters.getFilterKey().getKey(),
accountigFilters.getFilterValue());
filters.add(filter);
}
}
invocation = new AccountingQueryContext(AggregatedServiceUsageRecord.class,
accountingFilterContext.getContext(), temporalConstraint, filters);
} else {
logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException("Invalid Request!");
}
} }

View File

@ -11,7 +11,6 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
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.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -78,8 +77,7 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
} }
} }
invocation = new AccountingQueryBasic(AggregatedStorageUsageRecord.class, invocation = new AccountingQueryBasic(AggregatedStorageUsageRecord.class,
accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint, accountingFilterBasic.getContext(), temporalConstraint, filters);
filters);
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -95,28 +93,11 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
} }
} }
invocation = new AccountingQueryTop(AggregatedStorageUsageRecord.class, invocation = new AccountingQueryTop(AggregatedStorageUsageRecord.class,
accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(), accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint, accountingFilterTop.getTopNumber(), temporalConstraint, filters);
filters);
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { logger.error("Invalid Request: " + seriesRequest);
AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest throw new ServiceException("Invalid Request!");
.getAccountingFilterDefinition();
accountingFilters = accountingFilterContext.getFilters();
filters = new ArrayList<Filter>();
if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters.getFilterKey().getKey(),
accountigFilters.getFilterValue());
filters.add(filter);
}
}
invocation = new AccountingQueryContext(AggregatedStorageUsageRecord.class,
accountingFilterContext.getContext(), temporalConstraint, filters);
} else {
logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException("Invalid Request!");
}
} }
} }

View File

@ -7,11 +7,9 @@ import java.util.GregorianCalendar;
import org.gcube.accounting.analytics.Filter; import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
//import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord;
import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap; import org.gcube.portlets.admin.accountingmanager.server.amservice.PeriodModeMap;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilter;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
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.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -21,13 +19,12 @@ import org.slf4j.LoggerFactory;
/** /**
* Accounting Query 4 Task * Accounting Query 4 Task
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class AccountingQuery4Task extends AccountingQueryBuilder { public class AccountingQuery4Task extends AccountingQueryBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory.getLogger(AccountingQuery4Task.class);
.getLogger(AccountingQuery4Task.class);
private SeriesRequest seriesRequest; private SeriesRequest seriesRequest;
public AccountingQuery4Task(SeriesRequest seriesRequest) { public AccountingQuery4Task(SeriesRequest seriesRequest) {
@ -36,21 +33,17 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
@Override @Override
public void buildOpEx() throws ServiceException { public void buildOpEx() throws ServiceException {
Calendar startCalendar = GregorianCalendar Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
try { try {
startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod() startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
.getStartDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("Start Date not valid!"); throw new ServiceException("Start Date not valid!");
} }
Calendar endCalendar = GregorianCalendar Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
try { try {
endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod() endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
.getEndDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
throw new ServiceException("End Date not valid!"); throw new ServiceException("End Date not valid!");
@ -62,17 +55,14 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
endCalendar.set(GregorianCalendar.MILLISECOND, 999); endCalendar.set(GregorianCalendar.MILLISECOND, 999);
@SuppressWarnings("unused") @SuppressWarnings("unused")
TemporalConstraint temporalConstraint = new TemporalConstraint( TemporalConstraint temporalConstraint = new TemporalConstraint(startCalendar.getTimeInMillis(),
startCalendar.getTimeInMillis(), endCalendar.getTimeInMillis(), endCalendar.getTimeInMillis(), PeriodModeMap.getMode(seriesRequest.getAccountingPeriod().getPeriod()));
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
.getPeriod()));
ArrayList<Filter> filters = null; ArrayList<Filter> filters = null;
ArrayList<AccountingFilter> accountingFilters = null; ArrayList<AccountingFilter> accountingFilters = null;
AccountingQuery invocation = null; AccountingQuery invocation = null;
if (seriesRequest != null if (seriesRequest != null && seriesRequest.getAccountingFilterDefinition() != null) {
&& seriesRequest.getAccountingFilterDefinition() != null) {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterBasic) { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterBasic) {
AccountingFilterBasic accountingFilterBasic = (AccountingFilterBasic) seriesRequest AccountingFilterBasic accountingFilterBasic = (AccountingFilterBasic) seriesRequest
.getAccountingFilterDefinition(); .getAccountingFilterDefinition();
@ -80,16 +70,16 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
filters = new ArrayList<Filter>(); filters = new ArrayList<Filter>();
if (accountingFilters != null) { if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) { for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters Filter filter = new Filter(accountigFilters.getFilterKey().getKey(),
.getFilterKey().getKey(),
accountigFilters.getFilterValue()); accountigFilters.getFilterValue());
filters.add(filter); filters.add(filter);
} }
} }
/*invocation = new AccountingQueryBasic( /*
AggregatedTaskUsageRecord.class, temporalConstraint, * invocation = new AccountingQueryBasic(
filters, accountingFilterBasic.isNoContext()); * AggregatedTaskUsageRecord.class, temporalConstraint, filters,
*/ * accountingFilterBasic.isNoContext());
*/
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) { if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest
@ -98,42 +88,22 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
filters = new ArrayList<Filter>(); filters = new ArrayList<Filter>();
if (accountingFilters != null) { if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) { for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters Filter filter = new Filter(accountigFilters.getFilterKey().getKey(),
.getFilterKey().getKey(),
accountigFilters.getFilterValue()); accountigFilters.getFilterValue());
filters.add(filter); filters.add(filter);
} }
} }
/*invocation = new AccountingQueryTop( /*
AggregatedTaskUsageRecord.class, * invocation = new AccountingQueryTop(
accountingFilterTop.getFilterKey(), * AggregatedTaskUsageRecord.class,
accountingFilterTop.getShowOthers(), * accountingFilterTop.getFilterKey(),
accountingFilterTop.getTopNumber(), * accountingFilterTop.getShowOthers(),
temporalConstraint, filters);*/ * accountingFilterTop.getTopNumber(), temporalConstraint,
* filters);
*/
} else { } else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterContext) { logger.error("Invalid Request: " + seriesRequest);
AccountingFilterContext accountingFilterContext = (AccountingFilterContext) seriesRequest throw new ServiceException("Invalid Request!");
.getAccountingFilterDefinition();
accountingFilters = accountingFilterContext.getFilters();
filters = new ArrayList<Filter>();
if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters
.getFilterKey().getKey(),
accountigFilters.getFilterValue());
filters.add(filter);
}
}
/*invocation = new AccountingQueryContext(
AggregatedTaskUsageRecord.class,
accountingFilterContext.getContext(),
temporalConstraint,
filters);*/
} else {
logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException(
"Invalid Request!");
}
} }
} }

View File

@ -6,6 +6,7 @@ import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.AggregatedUsageRecord; import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
/** /**
* *
@ -15,20 +16,18 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
*/ */
public class AccountingQueryBasic extends AccountingQuery { public class AccountingQueryBasic extends AccountingQuery {
private Class<? extends AggregatedUsageRecord<?, ?>> type; private Class<? extends AggregatedUsageRecord<?, ?>> type;
private String scope; private Context context;
private boolean noContext;
private TemporalConstraint temporalConstraint; private TemporalConstraint temporalConstraint;
private ArrayList<Filter> filters; private ArrayList<Filter> filters;
public AccountingQueryBasic(Class<? extends AggregatedUsageRecord<?, ?>> type, String scope, boolean noContext, public AccountingQueryBasic(Class<? extends AggregatedUsageRecord<?, ?>> type, Context context,
TemporalConstraint temporalConstraint, ArrayList<Filter> filters) { TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
super(); super();
chartType = ChartType.Basic; chartType = ChartType.Basic;
this.type = type; this.type = type;
this.temporalConstraint = temporalConstraint; this.temporalConstraint = temporalConstraint;
this.scope = scope; this.context = context;
this.filters = filters; this.filters = filters;
this.noContext = noContext;
} }
public Class<? extends AggregatedUsageRecord<?, ?>> getType() { public Class<? extends AggregatedUsageRecord<?, ?>> getType() {
@ -47,12 +46,13 @@ public class AccountingQueryBasic extends AccountingQuery {
this.temporalConstraint = temporalConstraint; this.temporalConstraint = temporalConstraint;
} }
public String getScope() {
return scope; public Context getContext() {
return context;
} }
public void setScope(String scope) { public void setContext(Context context) {
this.scope = scope; this.context = context;
} }
public ArrayList<Filter> getFilters() { public ArrayList<Filter> getFilters() {
@ -63,18 +63,10 @@ public class AccountingQueryBasic extends AccountingQuery {
this.filters = filters; this.filters = filters;
} }
public boolean isNoContext() {
return noContext;
}
public void setNoContext(boolean noContext) {
this.noContext = noContext;
}
@Override @Override
public String toString() { public String toString() {
return "AccountingQueryBasic [type=" + type + ", temporalConstraint=" + temporalConstraint + ", scope=" + scope return "AccountingQueryBasic [type=" + type + ", context=" + context + ", temporalConstraint="
+ ", filters=" + filters + ", noContext=" + noContext + "]"; + temporalConstraint + ", filters=" + filters + "]";
} }
} }

View File

@ -1,71 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.query;
import java.util.ArrayList;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class AccountingQueryContext extends AccountingQuery {
private Class<? extends AggregatedUsageRecord<?, ?>> type;
private Context context;
private TemporalConstraint temporalConstraint;
private ArrayList<Filter> filters;
public AccountingQueryContext(Class<? extends AggregatedUsageRecord<?, ?>> type, Context context,
TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
super();
chartType = ChartType.Context;
this.type = type;
this.temporalConstraint = temporalConstraint;
this.filters = filters;
this.context = context;
}
public Class<? extends AggregatedUsageRecord<?, ?>> getType() {
return type;
}
public void setType(Class<? extends AggregatedUsageRecord<?, ?>> type) {
this.type = type;
}
public TemporalConstraint getTemporalConstraint() {
return temporalConstraint;
}
public void setTemporalConstraint(TemporalConstraint temporalConstraint) {
this.temporalConstraint = temporalConstraint;
}
public ArrayList<Filter> getFilters() {
return filters;
}
public void setFilters(ArrayList<Filter> filters) {
this.filters = filters;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
@Override
public String toString() {
return "AccountingQueryContext [type=" + type + ", context=" + context + ", temporalConstraint="
+ temporalConstraint + ", filters=" + filters + "]";
}
}

View File

@ -6,6 +6,7 @@ import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.TemporalConstraint; import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.datamodel.AggregatedUsageRecord; import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
/** /**
@ -16,23 +17,21 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
*/ */
public class AccountingQueryTop extends AccountingQuery { public class AccountingQueryTop extends AccountingQuery {
private Class<? extends AggregatedUsageRecord<?, ?>> type; private Class<? extends AggregatedUsageRecord<?, ?>> type;
private String scope; private Context context;
private FilterKey filterKey; private FilterKey filterKey;
private Integer topNumber; private Integer topNumber;
private Boolean showOthers;
private TemporalConstraint temporalConstraint; private TemporalConstraint temporalConstraint;
private ArrayList<Filter> filters; private ArrayList<Filter> filters;
public AccountingQueryTop(Class<? extends AggregatedUsageRecord<?, ?>> type, String scope, FilterKey filterKey, public AccountingQueryTop(Class<? extends AggregatedUsageRecord<?, ?>> type, Context context, FilterKey filterKey,
Boolean showOthers, Integer topNumber, TemporalConstraint temporalConstraint, ArrayList<Filter> filters) { Integer topNumber, TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
super(); super();
chartType = ChartType.Top; chartType = ChartType.Top;
this.type = type; this.type = type;
this.scope = scope; this.context = context;
this.temporalConstraint = temporalConstraint; this.temporalConstraint = temporalConstraint;
this.filters = filters; this.filters = filters;
this.filterKey = filterKey; this.filterKey = filterKey;
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
} }
@ -44,12 +43,12 @@ public class AccountingQueryTop extends AccountingQuery {
this.type = type; this.type = type;
} }
public String getScope() { public Context getContext() {
return scope; return context;
} }
public void setScope(String scope) { public void setContext(Context context) {
this.scope = scope; this.context = context;
} }
public TemporalConstraint getTemporalConstraint() { public TemporalConstraint getTemporalConstraint() {
@ -76,14 +75,6 @@ public class AccountingQueryTop extends AccountingQuery {
this.filterKey = filterKey; this.filterKey = filterKey;
} }
public Boolean getShowOthers() {
return showOthers;
}
public void setShowOthers(Boolean showOthers) {
this.showOthers = showOthers;
}
public Integer getTopNumber() { public Integer getTopNumber() {
return topNumber; return topNumber;
} }
@ -94,9 +85,9 @@ public class AccountingQueryTop extends AccountingQuery {
@Override @Override
public String toString() { public String toString() {
return "AccountingQueryTop [type=" + type + ", scope=" + scope + ", filterKey=" + filterKey + ", topNumber=" return "AccountingQueryTop [type=" + type + ", context=" + context + ", filterKey=" + filterKey + ", topNumber="
+ topNumber + ", showOthers=" + showOthers + ", temporalConstraint=" + temporalConstraint + ", filters=" + topNumber + ", temporalConstraint=" + temporalConstraint + ", filters=" + filters + ", chartType="
+ filters + "]"; + chartType + "]";
} }
} }

View File

@ -5,11 +5,11 @@ import java.util.List;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -39,14 +39,15 @@ public class SeriesResponse4JobBasic extends SeriesResponseBuilder {
ArrayList<SeriesJobData> series = new ArrayList<SeriesJobData>(); ArrayList<SeriesJobData> series = new ArrayList<SeriesJobData>();
for (Info info : infos) { for (Info info : infos) {
JSONObject jso = info.getValue(); JsonNode jso = info.getValue();
Long duration = jso.getLong(AggregatedJobUsageRecord.DURATION);
Long duration = jso.get(AggregatedJobUsageRecord.DURATION).asLong();
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedJobUsageRecord.OPERATION_COUNT); .get(AggregatedJobUsageRecord.OPERATION_COUNT).asLong();
Long maxInvocationTime = jso Long maxInvocationTime = jso
.getLong(AggregatedJobUsageRecord.MAX_INVOCATION_TIME); .get(AggregatedJobUsageRecord.MAX_INVOCATION_TIME).asLong();
Long minInvocationTime = jso Long minInvocationTime = jso
.getLong(AggregatedJobUsageRecord.MIN_INVOCATION_TIME); .get(AggregatedJobUsageRecord.MIN_INVOCATION_TIME).asLong();
series.add(new SeriesJobData(info.getCalendar().getTime(), series.add(new SeriesJobData(info.getCalendar().getTime(),
operationCount, duration, maxInvocationTime, operationCount, duration, maxInvocationTime,

View File

@ -1,91 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Context Series Response 4 Job
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesResponse4JobContext extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4JobContext.class);
private Context context;
private SortedMap<Filter, SortedMap<Calendar, Info>> contextSM;
public SeriesResponse4JobContext(Context context,
SortedMap<Filter, SortedMap<Calendar, Info>> contextSM) {
this.context=context;
this.contextSM = contextSM;
}
@Override
public void buildSeriesResponse() throws ServiceException {
try {
if (contextSM == null || contextSM.isEmpty()) {
logger.error("Error creating series for job accounting: No data available!");
throw new ServiceException("No data available!");
}
ArrayList<SeriesJobDataContext> seriesJobDataContextList = new ArrayList<>();
for (Filter contextValue : contextSM.keySet()) {
ArrayList<SeriesJobData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = contextSM.get(contextValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
Long duration = jso
.getLong(AggregatedServiceUsageRecord.DURATION);
Long operationCount = jso
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
Long maxInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
Long minInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesJobData(info.getCalendar().getTime(),
operationCount, duration, maxInvocationTime,
minInvocationTime));
}
SeriesJobDataContext seriesJobDataContext = new SeriesJobDataContext(
contextValue.getValue(), series);
seriesJobDataContextList.add(seriesJobDataContext);
}
SeriesJobContext seriesJobContext = new SeriesJobContext(context,
seriesJobDataContextList);
SeriesJob seriesService = new SeriesJob(seriesJobContext);
seriesResponseSpec.setSr(seriesService);
} catch (Throwable e) {
logger.error("Error creating series for job accounting context chart: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(
"Error creating series for job accounting context chart: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -7,13 +7,13 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -27,13 +27,11 @@ import org.slf4j.LoggerFactory;
public class SeriesResponse4JobTop extends SeriesResponseBuilder { public class SeriesResponse4JobTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4JobTop.class); .getLogger(SeriesResponse4JobTop.class);
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4JobTop(Boolean showOthers, Integer topNumber, public SeriesResponse4JobTop(Integer topNumber,
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) { SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.topSM = topSM; this.topSM = topSM;
} }
@ -55,15 +53,15 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
ArrayList<SeriesJobData> series = new ArrayList<>(); ArrayList<SeriesJobData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue); SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) { for (Info info : infos.values()) {
JSONObject jso = info.getValue(); JsonNode jso = info.getValue();
Long duration = jso Long duration = jso
.getLong(AggregatedServiceUsageRecord.DURATION); .get(AggregatedServiceUsageRecord.DURATION).asLong();
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); .get(AggregatedServiceUsageRecord.OPERATION_COUNT).asLong();
Long maxInvocationTime = jso Long maxInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); .get(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME).asLong();
Long minInvocationTime = jso Long minInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); .get(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME).asLong();
series.add(new SeriesJobData(info.getCalendar() series.add(new SeriesJobData(info.getCalendar()
.getTime(), operationCount, duration, .getTime(), operationCount, duration,
@ -76,7 +74,7 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
} }
SeriesJobTop seriesJobTop = new SeriesJobTop(showOthers,topNumber, SeriesJobTop seriesJobTop = new SeriesJobTop(topNumber,
seriesJobDataTopList); seriesJobDataTopList);
SeriesJob seriesService = new SeriesJob(seriesJobTop); SeriesJob seriesService = new SeriesJob(seriesJobTop);

View File

@ -1,89 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesPortlet;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Context Series Response 4 Portlet
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesResponse4PortletContext extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4PortletContext.class);
private Context context;
private SortedMap<Filter, SortedMap<Calendar, Info>> contextSM;
public SeriesResponse4PortletContext(Context context,
SortedMap<Filter, SortedMap<Calendar, Info>> contextSM) {
this.context = context;
this.contextSM = contextSM;
}
@Override
public void buildSeriesResponse() throws ServiceException {
try {
if (contextSM == null || contextSM.isEmpty()) {
logger.error("Error creating series for portlet accounting: No data available!");
throw new ServiceException("No data available!");
}
ArrayList<SeriesPortletDataContext> seriesPortletDataContextList = new ArrayList<>();
for (Filter contextValue : contextSM.keySet()) {
ArrayList<SeriesPortletData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = contextSM.get(contextValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
// Long duration =
// jso.getLong(AggregatedPortletUsageRecord.DURATION);
Long operationCount = jso
.getLong(AggregatedPortletUsageRecord.OPERATION_COUNT);
// Long maxInvocationTime =
// jso.getLong(AggregatedPortletUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime =
// jso.getLong(AggregatedPortletUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesPortletData(info.getCalendar()
.getTime(), operationCount));
}
SeriesPortletDataContext seriesPortletDataContext = new SeriesPortletDataContext(
contextValue.getValue(), series);
seriesPortletDataContextList.add(seriesPortletDataContext);
}
SeriesPortletContext seriesPortletContext = new SeriesPortletContext(
context, seriesPortletDataContextList);
SeriesPortlet seriesPortlet = new SeriesPortlet(
seriesPortletContext);
seriesResponseSpec.setSr(seriesPortlet);
} catch (Throwable e) {
logger.error("Error creating series for portlet accounting context chart: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(
"Error creating series for portlet accounting context chart: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -7,13 +7,13 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesPortlet; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesPortlet;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet.SeriesPortletTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -27,13 +27,11 @@ import org.slf4j.LoggerFactory;
public class SeriesResponse4PortletTop extends SeriesResponseBuilder { public class SeriesResponse4PortletTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4PortletTop.class); .getLogger(SeriesResponse4PortletTop.class);
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4PortletTop(Boolean showOthers, Integer topNumber, public SeriesResponse4PortletTop(Integer topNumber,
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) { SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.topSM = topSM; this.topSM = topSM;
} }
@ -53,11 +51,11 @@ public class SeriesResponse4PortletTop extends SeriesResponseBuilder {
ArrayList<SeriesPortletData> series = new ArrayList<>(); ArrayList<SeriesPortletData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue); SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) { for (Info info : infos.values()) {
JSONObject jso = info.getValue(); JsonNode jso = info.getValue();
// Long duration = // Long duration =
// jso.getLong(AggregatedPortletUsageRecord.DURATION); // jso.getLong(AggregatedPortletUsageRecord.DURATION);
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedPortletUsageRecord.OPERATION_COUNT); .get(AggregatedPortletUsageRecord.OPERATION_COUNT).asLong();
// Long maxInvocationTime = // Long maxInvocationTime =
// jso.getLong(AggregatedPortletUsageRecord.MAX_INVOCATION_TIME); // jso.getLong(AggregatedPortletUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime = // Long minInvocationTime =
@ -72,8 +70,7 @@ public class SeriesResponse4PortletTop extends SeriesResponseBuilder {
} }
SeriesPortletTop seriesPortletTop = new SeriesPortletTop( SeriesPortletTop seriesPortletTop = new SeriesPortletTop(topNumber, seriesPortletDataTopList);
showOthers, topNumber, seriesPortletDataTopList);
SeriesPortlet seriesPortlet = new SeriesPortlet(seriesPortletTop); SeriesPortlet seriesPortlet = new SeriesPortlet(seriesPortletTop);
seriesResponseSpec.setSr(seriesPortlet); seriesResponseSpec.setSr(seriesPortlet);

View File

@ -5,11 +5,11 @@ import java.util.List;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; 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.SeriesServiceBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -39,15 +39,15 @@ public class SeriesResponse4ServiceBasic extends SeriesResponseBuilder {
ArrayList<SeriesServiceData> series = new ArrayList<SeriesServiceData>(); ArrayList<SeriesServiceData> series = new ArrayList<SeriesServiceData>();
for (Info info : infos) { for (Info info : infos) {
JSONObject jso = info.getValue(); JsonNode jso = info.getValue();
Long duration = jso Long duration = jso
.getLong(AggregatedServiceUsageRecord.DURATION); .get(AggregatedServiceUsageRecord.DURATION).asLong();
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); .get(AggregatedServiceUsageRecord.OPERATION_COUNT).asLong();
Long maxInvocationTime = jso Long maxInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); .get(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME).asLong();
Long minInvocationTime = jso Long minInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); .get(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME).asLong();
series.add(new SeriesServiceData(info.getCalendar().getTime(), series.add(new SeriesServiceData(info.getCalendar().getTime(),
operationCount, duration, maxInvocationTime, operationCount, duration, maxInvocationTime,

View File

@ -1,92 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Context Series Response 4 Service
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesResponse4ServiceContext extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4ServiceContext.class);
private Context context;
private SortedMap<Filter, SortedMap<Calendar, Info>> contextSM;
public SeriesResponse4ServiceContext(Context context,
SortedMap<Filter, SortedMap<Calendar, Info>> contextSM) {
this.context = context;
this.contextSM = contextSM;
}
@Override
public void buildSeriesResponse() throws ServiceException {
try {
if (contextSM == null || contextSM.isEmpty()) {
logger.error("Error creating series for service accounting: No data available!");
throw new ServiceException("No data available!");
}
ArrayList<SeriesServiceDataContext> seriesServiceDataContextList = new ArrayList<>();
for (Filter contextValue : contextSM.keySet()) {
ArrayList<SeriesServiceData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = contextSM.get(contextValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
Long duration = jso
.getLong(AggregatedServiceUsageRecord.DURATION);
Long operationCount = jso
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
Long maxInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
Long minInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesServiceData(info.getCalendar()
.getTime(), operationCount, duration,
maxInvocationTime, minInvocationTime));
}
SeriesServiceDataContext seriesServiceDataContext = new SeriesServiceDataContext(
contextValue.getValue(), series);
seriesServiceDataContextList.add(seriesServiceDataContext);
}
SeriesServiceContext seriesServiceContext = new SeriesServiceContext(context,
seriesServiceDataContextList);
SeriesService seriesService = new SeriesService(
seriesServiceContext);
seriesResponseSpec.setSr(seriesService);
} catch (Throwable e) {
logger.error("Error creating series for service accounting context chart: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(
"Error creating series for service accounting context chart: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -7,33 +7,29 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Top Series Response 4 Service * Top Series Response 4 Service
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class SeriesResponse4ServiceTop extends SeriesResponseBuilder { public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory.getLogger(SeriesResponse4ServiceTop.class);
.getLogger(SeriesResponse4ServiceTop.class);
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4ServiceTop(Boolean showOthers, Integer topNumber, public SeriesResponse4ServiceTop(Integer topNumber, SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.topSM = topSM; this.topSM = topSM;
} }
@ -53,18 +49,13 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
ArrayList<SeriesServiceData> series = new ArrayList<>(); ArrayList<SeriesServiceData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue); SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) { for (Info info : infos.values()) {
JSONObject jso = info.getValue(); JsonNode jso = info.getValue();
Long duration = jso Long duration = jso.get(AggregatedServiceUsageRecord.DURATION).asLong();
.getLong(AggregatedServiceUsageRecord.DURATION); Long operationCount = jso.get(AggregatedServiceUsageRecord.OPERATION_COUNT).asLong();
Long operationCount = jso Long maxInvocationTime = jso.get(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME).asLong();
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); Long minInvocationTime = jso.get(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME).asLong();
Long maxInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
Long minInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesServiceData(info.getCalendar() series.add(new SeriesServiceData(info.getCalendar().getTime(), operationCount, duration,
.getTime(), operationCount, duration,
maxInvocationTime, minInvocationTime)); maxInvocationTime, minInvocationTime));
} }
@ -74,19 +65,16 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
} }
SeriesServiceTop seriesServiceTop = new SeriesServiceTop( SeriesServiceTop seriesServiceTop = new SeriesServiceTop(topNumber, seriesServiceDataTopList);
showOthers, topNumber, seriesServiceDataTopList);
SeriesService seriesService = new SeriesService(seriesServiceTop); SeriesService seriesService = new SeriesService(seriesServiceTop);
seriesResponseSpec.setSr(seriesService); seriesResponseSpec.setSr(seriesService);
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error creating series for service accounting top chart: " logger.error("Error creating series for service accounting top chart: " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new ServiceException( throw new ServiceException(
"Error creating series for service accounting top chart: " "Error creating series for service accounting top chart: " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
} }
} }

View File

@ -5,11 +5,14 @@ import java.util.Calendar;
import java.util.SortedMap; import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter; import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces; import org.gcube.portlets.admin.accountingmanager.shared.data.Spaces;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSpace; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesSpace;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceSpaces;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceDataSpaces; import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceDataSpaces;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceSpaces;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -25,10 +28,10 @@ public class SeriesResponse4SpaceSpaces extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4SpaceSpaces.class); .getLogger(SeriesResponse4SpaceSpaces.class);
private Spaces spaces; private Spaces spaces;
private SortedMap<Filter, SortedMap<Calendar, Long>> spaceSM; private SortedMap<Filter, SortedMap<Calendar, Info>> spaceSM;
public SeriesResponse4SpaceSpaces(Spaces spaces, public SeriesResponse4SpaceSpaces(Spaces spaces,
SortedMap<Filter, SortedMap<Calendar, Long>> spaceSM) { SortedMap<Filter, SortedMap<Calendar, Info>> spaceSM) {
this.spaces = spaces; this.spaces = spaces;
this.spaceSM = spaceSM; this.spaceSM = spaceSM;
} }
@ -46,11 +49,13 @@ public class SeriesResponse4SpaceSpaces extends SeriesResponseBuilder {
for (Filter spaceValue : spaceSM.keySet()) { for (Filter spaceValue : spaceSM.keySet()) {
ArrayList<SeriesSpaceData> series = new ArrayList<>(); ArrayList<SeriesSpaceData> series = new ArrayList<>();
SortedMap<Calendar, Long> infos = spaceSM.get(spaceValue); SortedMap<Calendar, Info> infos = spaceSM.get(spaceValue);
for (Calendar calendar : infos.keySet()) { for (Calendar calendar : infos.keySet()) {
Long value = infos.get(calendar); Info info = infos.get(calendar);
if(value==null){ Long value=0L;
value=0L; if(info!=null){
JsonNode jso=info.getValue();
value=jso.get(AggregatedStorageStatusRecord.DATA_VOLUME).asLong();
} }
series.add(new SeriesSpaceData(calendar.getTime(), value)); series.add(new SeriesSpaceData(calendar.getTime(), value));

View File

@ -5,11 +5,11 @@ import java.util.List;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -39,10 +39,10 @@ public class SeriesResponse4StorageBasic extends SeriesResponseBuilder {
ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>(); ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>();
for (Info info : infos) { for (Info info : infos) {
JSONObject jso = info.getValue(); JsonNode jso = info.getValue();
Long dataVolume = jso.getLong(AggregatedStorageUsageRecord.DATA_VOLUME); Long dataVolume = jso.get(AggregatedStorageUsageRecord.DATA_VOLUME).asLong();
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedStorageUsageRecord.OPERATION_COUNT); .get(AggregatedStorageUsageRecord.OPERATION_COUNT).asLong();
series.add(new SeriesStorageData(info.getCalendar().getTime(), dataVolume, operationCount)); series.add(new SeriesStorageData(info.getCalendar().getTime(), dataVolume, operationCount));
} }

View File

@ -1,85 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Context Series Response 4 Storage
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesResponse4StorageContext extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4StorageContext.class);
private Context context;
private SortedMap<Filter, SortedMap<Calendar, Info>> contextSM;
public SeriesResponse4StorageContext(Context context,
SortedMap<Filter, SortedMap<Calendar, Info>> contextSM) {
this.context = context;
this.contextSM = contextSM;
}
@Override
public void buildSeriesResponse() throws ServiceException {
try {
if (contextSM == null || contextSM.isEmpty()) {
logger.error("Error creating series for storage accounting: No data available!");
throw new ServiceException("No data available!");
}
ArrayList<SeriesStorageDataContext> seriesStorageDataContextList = new ArrayList<>();
for (Filter contextValue : contextSM.keySet()) {
ArrayList<SeriesStorageData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = contextSM.get(contextValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
Long dataVolume = jso
.getLong(AggregatedStorageUsageRecord.DATA_VOLUME);
Long operationCount = jso
.getLong(AggregatedStorageUsageRecord.OPERATION_COUNT);
series.add(new SeriesStorageData(info.getCalendar()
.getTime(), dataVolume, operationCount));
}
SeriesStorageDataContext seriesStorageDataContext = new SeriesStorageDataContext(
contextValue.getValue(), series);
seriesStorageDataContextList.add(seriesStorageDataContext);
}
SeriesStorageContext seriesStorageContext = new SeriesStorageContext(
context, seriesStorageDataContextList);
SeriesStorage seriesStorage = new SeriesStorage(
seriesStorageContext);
seriesResponseSpec.setSr(seriesStorage);
} catch (Throwable e) {
logger.error("Error creating series for storage accounting context chart: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(
"Error creating series for storage accounting context chart: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -7,33 +7,29 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Top Series Response 4 Storage * Top Series Response 4 Storage
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class SeriesResponse4StorageTop extends SeriesResponseBuilder { public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory.getLogger(SeriesResponse4StorageTop.class);
.getLogger(SeriesResponse4StorageTop.class);
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4StorageTop(Boolean showOthers, Integer topNumber, public SeriesResponse4StorageTop(Integer topNumber, SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.topSM = topSM; this.topSM = topSM;
@ -54,13 +50,10 @@ public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
ArrayList<SeriesStorageData> series = new ArrayList<>(); ArrayList<SeriesStorageData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue); SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) { for (Info info : infos.values()) {
JSONObject jso = info.getValue(); JsonNode jso = info.getValue();
Long dataVolume = jso Long dataVolume = jso.get(AggregatedStorageUsageRecord.DATA_VOLUME).asLong();
.getLong(AggregatedStorageUsageRecord.DATA_VOLUME); Long operationCount = jso.get(AggregatedStorageUsageRecord.OPERATION_COUNT).asLong();
Long operationCount = jso series.add(new SeriesStorageData(info.getCalendar().getTime(), dataVolume, operationCount));
.getLong(AggregatedStorageUsageRecord.OPERATION_COUNT);
series.add(new SeriesStorageData(info.getCalendar()
.getTime(), dataVolume, operationCount));
} }
SeriesStorageDataTop seriesStorageDataTop = new SeriesStorageDataTop( SeriesStorageDataTop seriesStorageDataTop = new SeriesStorageDataTop(
@ -69,18 +62,15 @@ public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
} }
SeriesStorageTop seriesStorageTop = new SeriesStorageTop( SeriesStorageTop seriesStorageTop = new SeriesStorageTop(topNumber, seriesStorageDataTopList);
showOthers, topNumber, seriesStorageDataTopList);
SeriesStorage seriesStorage = new SeriesStorage(seriesStorageTop); SeriesStorage seriesStorage = new SeriesStorage(seriesStorageTop);
seriesResponseSpec.setSr(seriesStorage); seriesResponseSpec.setSr(seriesStorage);
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error creating series for storage accounting top chart: " logger.error("Error creating series for storage accounting top chart: " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new ServiceException( throw new ServiceException(
"Error creating series for storage accounting basic chart: " "Error creating series for storage accounting basic chart: " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
} }
} }
} }

View File

@ -1,89 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info;
//import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesTask;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Context Series Response 4 Task
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesResponse4TaskContext extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4TaskContext.class);
private Context context;
private SortedMap<Filter, SortedMap<Calendar, Info>> contextSM;
public SeriesResponse4TaskContext(Context context,
SortedMap<Filter, SortedMap<Calendar, Info>> contextSM) {
this.context = context;
this.contextSM = contextSM;
}
@Override
public void buildSeriesResponse() throws ServiceException {
try {
if (contextSM == null || contextSM.isEmpty()) {
logger.error("Error creating series for task accounting: No data available!");
throw new ServiceException("No data available!");
}
ArrayList<SeriesTaskDataContext> seriesTaskDataContextList = new ArrayList<>();
for (Filter contextValue : contextSM.keySet()) {
ArrayList<SeriesTaskData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = contextSM.get(contextValue);
for (Info info : infos.values()) {
@SuppressWarnings("unused")
JSONObject jso = info.getValue();
// Long duration =
// jso.getLong(AggregatedTaskUsageRecord.DURATION);
//Long operationCount = jso
// .getLong(AggregatedTaskUsageRecord.OPERATION_COUNT);
// Long maxInvocationTime =
// jso.getLong(AggregatedTaskUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime =
// jso.getLong(AggregatedTaskUsageRecord.MIN_INVOCATION_TIME);
//series.add(new SeriesTaskData(info.getCalendar().getTime(),
// operationCount));
}
SeriesTaskDataContext seriesTaskDataContext = new SeriesTaskDataContext(
contextValue.getValue(), series);
seriesTaskDataContextList.add(seriesTaskDataContext);
}
SeriesTaskContext seriesTaskContext = new SeriesTaskContext(
context, seriesTaskDataContextList);
SeriesTask seriesTask = new SeriesTask(seriesTaskContext);
seriesResponseSpec.setSr(seriesTask);
} catch (Throwable e) {
logger.error("Error creating series for portlet accounting context chart: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(
"Error creating series for portlet accounting context chart: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -6,6 +6,7 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter; import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
//import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord; //import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesTask; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesTask;
@ -13,27 +14,22 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.Seri
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Top Series Response 4 Task * Top Series Response 4 Task
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class SeriesResponse4TaskTop extends SeriesResponseBuilder { public class SeriesResponse4TaskTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory.getLogger(SeriesResponse4TaskTop.class);
.getLogger(SeriesResponse4TaskTop.class);
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4TaskTop(Boolean showOthers, Integer topNumber, public SeriesResponse4TaskTop(Integer topNumber, SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.topSM = topSM; this.topSM = topSM;
} }
@ -54,38 +50,36 @@ public class SeriesResponse4TaskTop extends SeriesResponseBuilder {
SortedMap<Calendar, Info> infos = topSM.get(topValue); SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) { for (Info info : infos.values()) {
@SuppressWarnings("unused") @SuppressWarnings("unused")
JSONObject jso = info.getValue(); JsonNode jso = info.getValue();
// Long duration = // Long duration =
// jso.getLong(AggregatedTaskUsageRecord.DURATION); // jso.getLong(AggregatedTaskUsageRecord.DURATION);
//Long operationCount = jso // Long operationCount = jso
// .getLong(AggregatedTaskUsageRecord.OPERATION_COUNT); // .getLong(AggregatedTaskUsageRecord.OPERATION_COUNT);
// Long maxInvocationTime = // Long maxInvocationTime =
// jso.getLong(AggregatedTaskUsageRecord.MAX_INVOCATION_TIME); // jso.getLong(AggregatedTaskUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime = // Long minInvocationTime =
// jso.getLong(AggregatedTaskUsageRecord.MIN_INVOCATION_TIME); // jso.getLong(AggregatedTaskUsageRecord.MIN_INVOCATION_TIME);
//series.add(new SeriesTaskData(info.getCalendar().getTime(), // series.add(new
// operationCount)); // SeriesTaskData(info.getCalendar().getTime(),
// operationCount));
} }
SeriesTaskDataTop seriesTaskDataTop = new SeriesTaskDataTop( SeriesTaskDataTop seriesTaskDataTop = new SeriesTaskDataTop(new FilterValue(topValue.getValue()),
new FilterValue(topValue.getValue()), series); series);
seriesTaskDataTopList.add(seriesTaskDataTop); seriesTaskDataTopList.add(seriesTaskDataTop);
} }
SeriesTaskTop seriesTaskTop = new SeriesTaskTop(showOthers, SeriesTaskTop seriesTaskTop = new SeriesTaskTop(topNumber, seriesTaskDataTopList);
topNumber, seriesTaskDataTopList);
SeriesTask seriesTask = new SeriesTask(seriesTaskTop); SeriesTask seriesTask = new SeriesTask(seriesTaskTop);
seriesResponseSpec.setSr(seriesTask); seriesResponseSpec.setSr(seriesTask);
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error creating series for portlet accounting top chart: " logger.error("Error creating series for portlet accounting top chart: " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new ServiceException( throw new ServiceException(
"Error creating series for portlet accounting top chart: " "Error creating series for portlet accounting top chart: " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
} }
} }
} }

View File

@ -10,9 +10,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesReques
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDefinition;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop;
@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory;
/** /**
* Accounting Model 4 Job * Accounting Model 4 Job
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class AccountingModel4Job extends AccountingModelBuilder { public class AccountingModel4Job extends AccountingModelBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Job.class);
.getLogger(AccountingModel4Job.class);
private AccountingStateData accountingStateData; private AccountingStateData accountingStateData;
public AccountingModel4Job(AccountingStateData accountingStateData) { public AccountingModel4Job(AccountingStateData accountingStateData) {
@ -42,35 +39,30 @@ public class AccountingModel4Job extends AccountingModelBuilder {
if (seriesRequest == null) { if (seriesRequest == null) {
logger.error("Error series request is null"); logger.error("Error series request is null");
throw new ServiceException( throw new ServiceException("Error series request is null");
"Error series request is null");
} }
String startDate=""; String startDate = "";
try { try {
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
.getStartDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
String endDate=""; String endDate = "";
try { try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
.getEndDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
String periodType = seriesRequest.getAccountingPeriod().getPeriod() String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel();
.getLabel();
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse(); SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
if (seriesResponse == null) { if (seriesResponse == null) {
logger.error("Error series response is null"); logger.error("Error series response is null");
throw new ServiceException( throw new ServiceException("Error series response is null");
"Error series response is null");
} }
String fileName = "Untitled"; String fileName = "Untitled";
@ -78,17 +70,13 @@ public class AccountingModel4Job extends AccountingModelBuilder {
ArrayList<AccountingDataRow> rows = new ArrayList<>(); ArrayList<AccountingDataRow> rows = new ArrayList<>();
if (seriesResponse instanceof SeriesJob) { if (seriesResponse instanceof SeriesJob) {
SeriesJob seriesService = (SeriesJob) seriesResponse; SeriesJob seriesService = (SeriesJob) seriesResponse;
SeriesJobDefinition definition = seriesService SeriesJobDefinition definition = seriesService.getSeriesJobDefinition();
.getSeriesJobDefinition();
if (definition instanceof SeriesJobBasic) { if (definition instanceof SeriesJobBasic) {
SeriesJobBasic seriesJobBasic = (SeriesJobBasic) definition; SeriesJobBasic seriesJobBasic = (SeriesJobBasic) definition;
fileName = "Job_" + periodType + "_" + startDate + "_" fileName = "Job_" + periodType + "_" + startDate + "_" + endDate;
+ endDate; header = new ArrayList<>(Arrays.asList(
header = new ArrayList<>(Arrays.asList(new String[] { "Date", new String[] { "Date", "Operation Count", "Duration", "Max Invocation", "Min Invocation" }));
"Operation Count", "Duration", "Max Invocation", ArrayList<SeriesJobData> listData = seriesJobBasic.getSeries();
"Min Invocation" }));
ArrayList<SeriesJobData> listData = seriesJobBasic
.getSeries();
for (SeriesJobData seriesData : listData) { for (SeriesJobData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(sdfCSVDate.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
@ -102,76 +90,35 @@ public class AccountingModel4Job extends AccountingModelBuilder {
} else { } else {
if (definition instanceof SeriesJobTop) { if (definition instanceof SeriesJobTop) {
SeriesJobTop seriesJobTop = (SeriesJobTop) definition; SeriesJobTop seriesJobTop = (SeriesJobTop) definition;
fileName = "JobTop_" + periodType + "_" + startDate fileName = "JobTop_" + periodType + "_" + startDate + "_" + endDate;
+ "_" + endDate; header = new ArrayList<>(Arrays.asList(new String[] { "Value", "Date", "Operation Count",
header = new ArrayList<>(Arrays.asList(new String[] { "Duration", "Max Invocation", "Min Invocation" }));
"Value", "Date", "Operation Count", "Duration", ArrayList<SeriesJobDataTop> listDataTop = seriesJobTop.getSeriesJobDataTopList();
"Max Invocation", "Min Invocation" }));
ArrayList<SeriesJobDataTop> listDataTop = seriesJobTop
.getSeriesJobDataTopList();
for (SeriesJobDataTop seriesDataTop : listDataTop) { for (SeriesJobDataTop seriesDataTop : listDataTop) {
FilterValue filterValue = seriesDataTop FilterValue filterValue = seriesDataTop.getFilterValue();
.getFilterValue(); ArrayList<SeriesJobData> listData = seriesDataTop.getSeries();
ArrayList<SeriesJobData> listData = seriesDataTop
.getSeries();
for (SeriesJobData seriesData : listData) { for (SeriesJobData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue()); data.add(filterValue.getValue());
data.add(sdfCSVDate.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData data.add(String.valueOf(seriesData.getOperationCount()));
.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration())); data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData data.add(String.valueOf(seriesData.getMaxInvocationTime()));
.getMaxInvocationTime())); data.add(String.valueOf(seriesData.getMinInvocationTime()));
data.add(String.valueOf(seriesData
.getMinInvocationTime()));
AccountingDataRow csvDataRow = new AccountingDataRow(data); AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow); rows.add(csvDataRow);
} }
} }
} else { } else {
if (definition instanceof SeriesJobContext) {
SeriesJobContext seriesJobContext = (SeriesJobContext) definition; logger.error("Unsupported Serie Definition for Job: " + definition);
fileName = "JobContext_" + periodType + "_" + startDate throw new ServiceException("Unsupported Serie Definition for Job: " + definition);
+ "_" + endDate;
header = new ArrayList<>(Arrays.asList(new String[] {
"Value", "Date", "Operation Count", "Duration",
"Max Invocation", "Min Invocation" }));
ArrayList<SeriesJobDataContext> listDataContext = seriesJobContext
.getSeriesJobDataContextList();
for (SeriesJobDataContext seriesDataContext : listDataContext) {
ArrayList<SeriesJobData> listData = seriesDataContext
.getSeries();
for (SeriesJobData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(seriesDataContext.getContext());
data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData
.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData
.getMaxInvocationTime()));
data.add(String.valueOf(seriesData
.getMinInvocationTime()));
AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow);
}
}
} else {
logger.error("Unsupported Serie Definition for Job: "
+ definition);
throw new ServiceException(
"Unsupported Serie Definition for Job: "
+ definition);
}
} }
} }
} else { } else {
logger.error("Job not support this serie response: " logger.error("Job not support this serie response: " + seriesResponse);
+ seriesResponse); throw new ServiceException("Job not support this serie response: " + seriesResponse);
throw new ServiceException(
"Job not support this serie response: "
+ seriesResponse);
} }
AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows); AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows);

View File

@ -10,9 +10,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesReques
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; 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.SeriesServiceBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDefinition;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop;
@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory;
/** /**
* Accounting Model 4 Service * Accounting Model 4 Service
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class AccountingModel4Service extends AccountingModelBuilder { public class AccountingModel4Service extends AccountingModelBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Service.class);
.getLogger(AccountingModel4Service.class);
private AccountingStateData accountingStateData; private AccountingStateData accountingStateData;
public AccountingModel4Service(AccountingStateData accountingStateData) { public AccountingModel4Service(AccountingStateData accountingStateData) {
@ -42,35 +39,30 @@ public class AccountingModel4Service extends AccountingModelBuilder {
if (seriesRequest == null) { if (seriesRequest == null) {
logger.error("Error series request is null"); logger.error("Error series request is null");
throw new ServiceException( throw new ServiceException("Error series request is null");
"Error series request is null");
} }
String startDate=""; String startDate = "";
try { try {
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
.getStartDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
String endDate=""; String endDate = "";
try { try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
.getEndDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
String periodType = seriesRequest.getAccountingPeriod().getPeriod() String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel();
.getLabel();
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse(); SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
if (seriesResponse == null) { if (seriesResponse == null) {
logger.error("Error series response is null"); logger.error("Error series response is null");
throw new ServiceException( throw new ServiceException("Error series response is null");
"Error series response is null");
} }
String fileName = "Untitled"; String fileName = "Untitled";
@ -78,17 +70,13 @@ public class AccountingModel4Service extends AccountingModelBuilder {
ArrayList<AccountingDataRow> rows = new ArrayList<>(); ArrayList<AccountingDataRow> rows = new ArrayList<>();
if (seriesResponse instanceof SeriesService) { if (seriesResponse instanceof SeriesService) {
SeriesService seriesService = (SeriesService) seriesResponse; SeriesService seriesService = (SeriesService) seriesResponse;
SeriesServiceDefinition definition = seriesService SeriesServiceDefinition definition = seriesService.getSerieServiceDefinition();
.getSerieServiceDefinition();
if (definition instanceof SeriesServiceBasic) { if (definition instanceof SeriesServiceBasic) {
SeriesServiceBasic seriesServiceBasic = (SeriesServiceBasic) definition; SeriesServiceBasic seriesServiceBasic = (SeriesServiceBasic) definition;
fileName = "Service_" + periodType + "_" + startDate + "_" fileName = "Service_" + periodType + "_" + startDate + "_" + endDate;
+ endDate; header = new ArrayList<>(Arrays.asList(
header = new ArrayList<>(Arrays.asList(new String[] { "Date", new String[] { "Date", "Operation Count", "Duration", "Max Invocation", "Min Invocation" }));
"Operation Count", "Duration", "Max Invocation", ArrayList<SeriesServiceData> listData = seriesServiceBasic.getSeries();
"Min Invocation" }));
ArrayList<SeriesServiceData> listData = seriesServiceBasic
.getSeries();
for (SeriesServiceData seriesData : listData) { for (SeriesServiceData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(sdfCSVDate.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
@ -102,76 +90,33 @@ public class AccountingModel4Service extends AccountingModelBuilder {
} else { } else {
if (definition instanceof SeriesServiceTop) { if (definition instanceof SeriesServiceTop) {
SeriesServiceTop seriesServiceTop = (SeriesServiceTop) definition; SeriesServiceTop seriesServiceTop = (SeriesServiceTop) definition;
fileName = "ServiceTop_" + periodType + "_" + startDate fileName = "ServiceTop_" + periodType + "_" + startDate + "_" + endDate;
+ "_" + endDate; header = new ArrayList<>(Arrays.asList(new String[] { "Value", "Date", "Operation Count",
header = new ArrayList<>(Arrays.asList(new String[] { "Duration", "Max Invocation", "Min Invocation" }));
"Value", "Date", "Operation Count", "Duration", ArrayList<SeriesServiceDataTop> listDataTop = seriesServiceTop.getSeriesServiceDataTopList();
"Max Invocation", "Min Invocation" }));
ArrayList<SeriesServiceDataTop> listDataTop = seriesServiceTop
.getSeriesServiceDataTopList();
for (SeriesServiceDataTop seriesDataTop : listDataTop) { for (SeriesServiceDataTop seriesDataTop : listDataTop) {
FilterValue filterValue = seriesDataTop FilterValue filterValue = seriesDataTop.getFilterValue();
.getFilterValue(); ArrayList<SeriesServiceData> listData = seriesDataTop.getSeries();
ArrayList<SeriesServiceData> listData = seriesDataTop
.getSeries();
for (SeriesServiceData seriesData : listData) { for (SeriesServiceData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue()); data.add(filterValue.getValue());
data.add(sdfCSVDate.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData data.add(String.valueOf(seriesData.getOperationCount()));
.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration())); data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData data.add(String.valueOf(seriesData.getMaxInvocationTime()));
.getMaxInvocationTime())); data.add(String.valueOf(seriesData.getMinInvocationTime()));
data.add(String.valueOf(seriesData
.getMinInvocationTime()));
AccountingDataRow csvDataRow = new AccountingDataRow(data); AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow); rows.add(csvDataRow);
} }
} }
} else { } else {
if (definition instanceof SeriesServiceContext) { logger.error("Unsupported Serie Definition for Service: " + definition);
SeriesServiceContext seriesServiceContext = (SeriesServiceContext) definition; throw new ServiceException("Unsupported Serie Definition for Service: " + definition);
fileName = "ServiceContext_" + periodType + "_" + startDate
+ "_" + endDate;
header = new ArrayList<>(Arrays.asList(new String[] {
"Value", "Date", "Operation Count", "Duration",
"Max Invocation", "Min Invocation" }));
ArrayList<SeriesServiceDataContext> listDataContext = seriesServiceContext
.getSeriesServiceDataContextList();
for (SeriesServiceDataContext seriesDataContext : listDataContext) {
ArrayList<SeriesServiceData> listData = seriesDataContext
.getSeries();
for (SeriesServiceData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(seriesDataContext.getContext());
data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData
.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData
.getMaxInvocationTime()));
data.add(String.valueOf(seriesData
.getMinInvocationTime()));
AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow);
}
}
} else {
logger.error("Unsupported Serie Definition for Service: "
+ definition);
throw new ServiceException(
"Unsupported Serie Definition for Service: "
+ definition);
}
} }
} }
} else { } else {
logger.error("Service not support this serie response: " logger.error("Service not support this serie response: " + seriesResponse);
+ seriesResponse); throw new ServiceException("Service not support this serie response: " + seriesResponse);
throw new ServiceException(
"Service not support this serie response: "
+ seriesResponse);
} }
AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows); AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows);

View File

@ -10,9 +10,7 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesReques
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataContext;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDefinition; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageDefinition;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop; import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageTop;
@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory;
/** /**
* Accounting Model 4 Storage * Accounting Model 4 Storage
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class AccountingModel4Storage extends AccountingModelBuilder { public class AccountingModel4Storage extends AccountingModelBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Storage.class);
.getLogger(AccountingModel4Storage.class);
private AccountingStateData accountingStateData; private AccountingStateData accountingStateData;
public AccountingModel4Storage(AccountingStateData accountingStateData) { public AccountingModel4Storage(AccountingStateData accountingStateData) {
@ -42,36 +39,31 @@ public class AccountingModel4Storage extends AccountingModelBuilder {
if (seriesRequest == null) { if (seriesRequest == null) {
logger.error("Error series request is null"); logger.error("Error series request is null");
throw new ServiceException( throw new ServiceException("Error series request is null");
"Error series request is null");
} }
String startDate=""; String startDate = "";
try { try {
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
.getStartDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
String endDate=""; String endDate = "";
try { try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod() endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
.getEndDate()));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
String periodType = seriesRequest.getAccountingPeriod().getPeriod() String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel();
.getLabel();
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse(); SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
if (seriesResponse == null) { if (seriesResponse == null) {
logger.error("Error series response is null"); logger.error("Error series response is null");
throw new ServiceException( throw new ServiceException("Error series response is null");
"Error series response is null");
} }
String fileName = "Untitled"; String fileName = "Untitled";
@ -79,16 +71,12 @@ public class AccountingModel4Storage extends AccountingModelBuilder {
ArrayList<AccountingDataRow> rows = new ArrayList<>(); ArrayList<AccountingDataRow> rows = new ArrayList<>();
if (seriesResponse instanceof SeriesStorage) { if (seriesResponse instanceof SeriesStorage) {
SeriesStorage seriesStorage = (SeriesStorage) seriesResponse; SeriesStorage seriesStorage = (SeriesStorage) seriesResponse;
SeriesStorageDefinition definition = seriesStorage SeriesStorageDefinition definition = seriesStorage.getSeriesStorageDefinition();
.getSeriesStorageDefinition();
if (definition instanceof SeriesStorageBasic) { if (definition instanceof SeriesStorageBasic) {
SeriesStorageBasic seriesStorageBasic = (SeriesStorageBasic) definition; SeriesStorageBasic seriesStorageBasic = (SeriesStorageBasic) definition;
fileName = "Storage_" + periodType + "_" + startDate + "_" fileName = "Storage_" + periodType + "_" + startDate + "_" + endDate;
+ endDate; header = new ArrayList<>(Arrays.asList(new String[] { "Date", "Operation Count", "Data Volume" }));
header = new ArrayList<>(Arrays.asList(new String[] { "Date", ArrayList<SeriesStorageData> listData = seriesStorageBasic.getSeries();
"Operation Count", "Data Volume" }));
ArrayList<SeriesStorageData> listData = seriesStorageBasic
.getSeries();
for (SeriesStorageData seriesData : listData) { for (SeriesStorageData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(sdfCSVDate.format(seriesData.getDate())); data.add(sdfCSVDate.format(seriesData.getDate()));
@ -100,18 +88,13 @@ public class AccountingModel4Storage extends AccountingModelBuilder {
} else { } else {
if (definition instanceof SeriesStorageTop) { if (definition instanceof SeriesStorageTop) {
SeriesStorageTop seriesStorageTop = (SeriesStorageTop) definition; SeriesStorageTop seriesStorageTop = (SeriesStorageTop) definition;
fileName = "StorageTop_" + periodType + "_" + startDate fileName = "StorageTop_" + periodType + "_" + startDate + "_" + endDate;
+ "_" + endDate;
header = new ArrayList<>( header = new ArrayList<>(
Arrays.asList(new String[] { "Value", "Date", Arrays.asList(new String[] { "Value", "Date", "Operation Count", "Data Volume" }));
"Operation Count", "Data Volume" })); ArrayList<SeriesStorageDataTop> listDataTop = seriesStorageTop.getSeriesStorageDataTopList();
ArrayList<SeriesStorageDataTop> listDataTop = seriesStorageTop
.getSeriesStorageDataTopList();
for (SeriesStorageDataTop seriesDataTop : listDataTop) { for (SeriesStorageDataTop seriesDataTop : listDataTop) {
FilterValue filterValue = seriesDataTop FilterValue filterValue = seriesDataTop.getFilterValue();
.getFilterValue(); ArrayList<SeriesStorageData> listData = seriesDataTop.getSeries();
ArrayList<SeriesStorageData> listData = seriesDataTop
.getSeries();
for (SeriesStorageData seriesData : listData) { for (SeriesStorageData seriesData : listData) {
ArrayList<String> data = new ArrayList<>(); ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue()); data.add(filterValue.getValue());
@ -123,46 +106,16 @@ public class AccountingModel4Storage extends AccountingModelBuilder {
} }
} }
} else { } else {
if (definition instanceof SeriesStorageContext) { logger.error("Unsupported Serie Definition for Storage: " + definition);
SeriesStorageContext seriesStorageContext = (SeriesStorageContext) definition; throw new ServiceException("Unsupported Serie Definition for Storage: " + definition);
fileName = "StorageContext_" + periodType + "_" + startDate
+ "_" + endDate;
header = new ArrayList<>(
Arrays.asList(new String[] { "Value", "Date",
"Operation Count", "Data Volume" }));
ArrayList<SeriesStorageDataContext> listDataContext = seriesStorageContext
.getSeriesStorageDataContextList();
for (SeriesStorageDataContext seriesDataContext : listDataContext) {
ArrayList<SeriesStorageData> listData = seriesDataContext
.getSeries();
for (SeriesStorageData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(seriesDataContext.getContext());
data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData.getOperationCount()));
data.add(String.valueOf(seriesData.getDataVolume()));
AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow);
}
}
} else {
logger.error("Unsupported Serie Definition for Storage: "
+ definition);
throw new ServiceException(
"Unsupported Serie Definition for Storage: "
+ definition);
}
} }
} }
} else { } else {
logger.error("Storage not support this serie response: " logger.error("Storage not support this serie response: " + seriesResponse);
+ seriesResponse); throw new ServiceException("Storage not support this serie response: " + seriesResponse);
throw new ServiceException(
"Storage not support this serie response: "
+ seriesResponse);
} }
AccountingDataModel invocation = new AccountingDataModel(fileName,header, rows); AccountingDataModel invocation = new AccountingDataModel(fileName, header, rows);
accountingModelSpec.setOp(invocation); accountingModelSpec.setOp(invocation);
} }

View File

@ -48,5 +48,10 @@ public class Constants {
public static final int CLIENT_MONITOR_TIME_OUT_PERIODMILLIS = 1800000; public static final int CLIENT_MONITOR_TIME_OUT_PERIODMILLIS = 1800000;
public static final int DAEMON_SLEEP_MILLIS = 1000; public static final int DAEMON_SLEEP_MILLIS = 1000;
//Top Number
public static final int TOP_NUMBER_DEFAULT = 10;
public static final int TOP_NUMBER_MAX = 100;
public static final int TOP_NUMBER_MIN = 1;
} }

View File

@ -5,55 +5,64 @@ import java.util.ArrayList;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class AccountingFilterBasic extends AccountingFilterDefinition implements public class AccountingFilterBasic extends AccountingFilterDefinition implements Serializable {
Serializable {
private static final long serialVersionUID = -6805006183397381154L; private static final long serialVersionUID = -6805006183397381154L;
private ArrayList<AccountingFilter> filters; private ArrayList<AccountingFilter> filters;
private String scope; private Context context;
private Boolean noContext; private String scopeFilterActive;
public AccountingFilterBasic() { public AccountingFilterBasic() {
super(); super();
this.chartType = ChartType.Basic; this.chartType = ChartType.Basic;
noContext = false;
filters = null; filters = null;
scope=null; context = null;
scopeFilterActive = null;
} }
public AccountingFilterBasic(String scope, boolean noContenxt) { public AccountingFilterBasic(Context context) {
super(); super();
chartType = ChartType.Basic; chartType = ChartType.Basic;
this.filters = null; this.filters = null;
this.scope=scope; this.context = context;
this.noContext = noContenxt; this.scopeFilterActive = null;
} }
public AccountingFilterBasic(Context context,String scopeFilterActive) {
public AccountingFilterBasic(String scope, ArrayList<AccountingFilter> filters, super();
boolean noContenxt) { chartType = ChartType.Basic;
this.filters = null;
this.context = context;
this.scopeFilterActive = scopeFilterActive;
}
public AccountingFilterBasic(Context context, ArrayList<AccountingFilter> filters) {
super(); super();
chartType = ChartType.Basic; chartType = ChartType.Basic;
this.scope=scope;
this.filters = filters; this.filters = filters;
this.noContext = noContenxt; this.context = context;
this.scopeFilterActive = null;
} }
public AccountingFilterBasic(Context context, String scopeFilterActive, ArrayList<AccountingFilter> filters) {
public String getScope() { super();
return scope; chartType = ChartType.Basic;
this.filters = filters;
this.context = context;
this.scopeFilterActive = scopeFilterActive;
} }
public void setScope(String scope) { public String getScopeFilterActive() {
this.scope = scope; return scopeFilterActive;
} }
public Boolean getNoContext() { public void setScopeFilterActive(String scopeFilterActive) {
return noContext; this.scopeFilterActive = scopeFilterActive;
} }
public ArrayList<AccountingFilter> getFilters() { public ArrayList<AccountingFilter> getFilters() {
@ -64,20 +73,19 @@ public class AccountingFilterBasic extends AccountingFilterDefinition implements
this.filters = filters; this.filters = filters;
} }
public boolean isNoContext() { public Context getContext() {
return noContext; return context;
} }
public void setNoContext(Boolean noContext) { public void setContext(Context context) {
this.noContext = noContext; this.context = context;
} }
@Override @Override
public String toString() { public String toString() {
return "AccountingFilterBasic [filters=" + filters + ", scope=" + scope + ", noContext=" + noContext return "AccountingFilterBasic [filters=" + filters + ", context=" + context + ", scopeFilterActive="
+ ", chartType=" + chartType + "]"; + scopeFilterActive + ", chartType=" + chartType + "]";
} }
} }

View File

@ -1,58 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class AccountingFilterContext extends AccountingFilterDefinition
implements Serializable {
private static final long serialVersionUID = -6805006183397381154L;
private Context context;
private ArrayList<AccountingFilter> filters;
public AccountingFilterContext() {
super();
this.chartType = ChartType.Context;
context = null;
filters = null;
}
public AccountingFilterContext(Context context,
ArrayList<AccountingFilter> filters) {
super();
chartType = ChartType.Context;
this.context = context;
this.filters = filters;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
public ArrayList<AccountingFilter> getFilters() {
return filters;
}
public void setFilters(ArrayList<AccountingFilter> filters) {
this.filters = filters;
}
@Override
public String toString() {
return "AccountingFilterContext [context=" + context + ", filters="
+ filters + "]";
}
}

View File

@ -3,64 +3,84 @@ package org.gcube.portlets.admin.accountingmanager.shared.data;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class AccountingFilterTop extends AccountingFilterDefinition implements public class AccountingFilterTop extends AccountingFilterDefinition implements Serializable {
Serializable {
private static final long serialVersionUID = -6805006183397381154L; private static final long serialVersionUID = -6805006183397381154L;
private String scope; private Context context;
private String scopeFilterActive;
private FilterKey filterKey; private FilterKey filterKey;
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private ArrayList<AccountingFilter> filters; private ArrayList<AccountingFilter> filters;
public AccountingFilterTop() { public AccountingFilterTop() {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
scope=null; context = null;
showOthers = false; scopeFilterActive = null;
topNumber = 5; topNumber = Constants.TOP_NUMBER_DEFAULT;
filterKey = null; filterKey = null;
filters = null; filters = null;
} }
public AccountingFilterTop(String scope, Boolean showOthers,Integer topNumber) { public AccountingFilterTop(Context context, Integer topNumber) {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.scope=scope; this.context = context;
this.showOthers = showOthers; this.scopeFilterActive = null;
this.topNumber = topNumber; this.topNumber = topNumber;
filterKey = null; filterKey = null;
filters = null; filters = null;
} }
public AccountingFilterTop(Context context, String scopeFilterActive, Integer topNumber) {
super();
this.chartType = ChartType.Top;
this.context = context;
this.scopeFilterActive = scopeFilterActive;
this.topNumber = topNumber;
filterKey = null;
filters = null;
public AccountingFilterTop(String scope, FilterKey filterKey, }
ArrayList<AccountingFilter> filters, Boolean showOthers,
public AccountingFilterTop(Context context, FilterKey filterKey, ArrayList<AccountingFilter> filters,
Integer topNumber) { Integer topNumber) {
super(); super();
chartType = ChartType.Top; chartType = ChartType.Top;
this.scope=scope; this.context = context;
this.scopeFilterActive = null;
this.filterKey = filterKey; this.filterKey = filterKey;
this.filters = filters; this.filters = filters;
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
} }
public String getScope() { public AccountingFilterTop(Context context, String scopeFilterActive, FilterKey filterKey,
return scope; ArrayList<AccountingFilter> filters, Integer topNumber) {
super();
chartType = ChartType.Top;
this.context = context;
this.scopeFilterActive = scopeFilterActive;
this.filterKey = filterKey;
this.filters = filters;
this.topNumber = topNumber;
} }
public void setScope(String scope) { public Context getContext() {
this.scope = scope; return context;
}
public void setContext(Context context) {
this.context = context;
} }
public FilterKey getFilterKey() { public FilterKey getFilterKey() {
@ -71,14 +91,6 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements
this.filterKey = filterKey; this.filterKey = filterKey;
} }
public Boolean getShowOthers() {
return showOthers;
}
public void setShowOthers(Boolean showOthers) {
this.showOthers = showOthers;
}
public Integer getTopNumber() { public Integer getTopNumber() {
return topNumber; return topNumber;
} }
@ -95,12 +107,18 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements
this.filters = filters; this.filters = filters;
} }
@Override public String getScopeFilterActive() {
public String toString() { return scopeFilterActive;
return "AccountingFilterTop [scope=" + scope + ", filterKey=" + filterKey + ", showOthers=" + showOthers
+ ", topNumber=" + topNumber + ", filters=" + filters + ", chartType=" + chartType + "]";
} }
public void setScopeFilterActive(String scopeFilterActive) {
this.scopeFilterActive = scopeFilterActive;
}
@Override
public String toString() {
return "AccountingFilterTop [context=" + context + ", scopeFilterActive=" + scopeFilterActive + ", filterKey="
+ filterKey + ", topNumber=" + topNumber + ", filters=" + filters + ", chartType=" + chartType + "]";
}
} }

View File

@ -14,7 +14,7 @@ import java.util.List;
public enum ChartType { public enum ChartType {
Basic("Basic"), Top("Top"), Context("Context"), Spaces("Spaces"); Basic("Basic"), Top("Top"), Spaces("Spaces");
/** /**
* *

View File

@ -1,39 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class Genres implements Serializable {
private static final long serialVersionUID = -1704075020370137961L;
private ArrayList<String> genresList;
public Genres() {
super();
}
public Genres(ArrayList<String> genresList) {
super();
this.genresList = genresList;
}
public ArrayList<String> getGenresList() {
return genresList;
}
public void setGenresList(ArrayList<String> genresList) {
this.genresList = genresList;
}
@Override
public String toString() {
return "Genres [genresList=" + genresList + "]";
}
}

View File

@ -1,46 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class GenresData implements Serializable {
private static final long serialVersionUID = 719740085818609829L;
private String genre;
public GenresData() {
super();
}
public GenresData(String genre) {
super();
this.genre = genre;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public String getLabel() {
return genre;
}
public void setLabel(String genre) {
this.genre = genre;
}
@Override
public String toString() {
return "GenresData [genre=" + genre + "]";
}
}

View File

@ -21,8 +21,7 @@ public class SeriesRequest implements Serializable {
super(); super();
} }
public SeriesRequest(AccountingPeriod accountingPeriod, public SeriesRequest(AccountingPeriod accountingPeriod, AccountingFilterDefinition accountingFilterDefinition) {
AccountingFilterDefinition accountingFilterDefinition) {
super(); super();
this.accountingPeriod = accountingPeriod; this.accountingPeriod = accountingPeriod;
this.accountingFilterDefinition = accountingFilterDefinition; this.accountingFilterDefinition = accountingFilterDefinition;
@ -40,18 +39,14 @@ public class SeriesRequest implements Serializable {
return accountingFilterDefinition; return accountingFilterDefinition;
} }
public void setAccountingFilterDefinition( public void setAccountingFilterDefinition(AccountingFilterDefinition accountingFilterDefinition) {
AccountingFilterDefinition accountingFilterDefinition) {
this.accountingFilterDefinition = accountingFilterDefinition; this.accountingFilterDefinition = accountingFilterDefinition;
} }
@Override @Override
public String toString() { public String toString() {
return "SeriesRequest [accountingPeriod=" + accountingPeriod return "SeriesRequest [accountingPeriod=" + accountingPeriod + ", accountingFilterDefinition="
+ ", accountingFilterDefinition=" + accountingFilterDefinition + accountingFilterDefinition + "]";
+ "]";
} }
} }

View File

@ -1,57 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.job;
import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesJobContext extends SeriesJobDefinition {
private static final long serialVersionUID = -2350334263342186590L;
private Context context;
private ArrayList<SeriesJobDataContext> seriesJobDataContextList;
public SeriesJobContext() {
super();
this.chartType = ChartType.Context;
}
public SeriesJobContext(Context context,
ArrayList<SeriesJobDataContext> seriesJobDataContextList) {
super();
this.chartType = ChartType.Context;
this.context = context;
this.seriesJobDataContextList = seriesJobDataContextList;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
public ArrayList<SeriesJobDataContext> getSeriesJobDataContextList() {
return seriesJobDataContextList;
}
public void setSeriesJobDataContextList(
ArrayList<SeriesJobDataContext> seriesJobDataContextList) {
this.seriesJobDataContextList = seriesJobDataContextList;
}
@Override
public String toString() {
return "SeriesJobContext [context=" + context
+ ", seriesJobDataContextList=" + seriesJobDataContextList
+ "]";
}
}

View File

@ -1,50 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.job;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesJobDataContext implements Serializable {
private static final long serialVersionUID = 6043106605633429465L;
private String context;
private ArrayList<SeriesJobData> series;
public SeriesJobDataContext() {
super();
}
public SeriesJobDataContext(String context, ArrayList<SeriesJobData> series) {
super();
this.context = context;
this.series = series;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public ArrayList<SeriesJobData> getSeries() {
return series;
}
public void setSeries(ArrayList<SeriesJobData> series) {
this.series = series;
}
@Override
public String toString() {
return "SeriesJobDataContext [context=" + context + ", series="
+ series + "]";
}
}

View File

@ -2,11 +2,12 @@ package org.gcube.portlets.admin.accountingmanager.shared.data.response.job;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
@ -14,33 +15,21 @@ public class SeriesJobTop extends SeriesJobDefinition {
private static final long serialVersionUID = -2350334263342186590L; private static final long serialVersionUID = -2350334263342186590L;
private ArrayList<SeriesJobDataTop> seriesJobDataTopList; private ArrayList<SeriesJobDataTop> seriesJobDataTopList;
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
public SeriesJobTop() { public SeriesJobTop() {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = false; this.topNumber = Constants.TOP_NUMBER_DEFAULT;
this.topNumber = 5;
} }
public SeriesJobTop(Boolean showOthers, Integer topNumber, public SeriesJobTop(Integer topNumber, ArrayList<SeriesJobDataTop> seriesJobDataTopList) {
ArrayList<SeriesJobDataTop> seriesJobDataTopList) {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.seriesJobDataTopList = seriesJobDataTopList; this.seriesJobDataTopList = seriesJobDataTopList;
} }
public Boolean getShowOthers() {
return showOthers;
}
public void setShowOthers(Boolean showOthers) {
this.showOthers = showOthers;
}
public Integer getTopNumber() { public Integer getTopNumber() {
return topNumber; return topNumber;
} }
@ -53,16 +42,14 @@ public class SeriesJobTop extends SeriesJobDefinition {
return seriesJobDataTopList; return seriesJobDataTopList;
} }
public void setSeriesJobDataTopList( public void setSeriesJobDataTopList(ArrayList<SeriesJobDataTop> seriesJobDataTopList) {
ArrayList<SeriesJobDataTop> seriesJobDataTopList) {
this.seriesJobDataTopList = seriesJobDataTopList; this.seriesJobDataTopList = seriesJobDataTopList;
} }
@Override @Override
public String toString() { public String toString() {
return "SeriesJobTop [seriesJobDataTopList=" + seriesJobDataTopList return "SeriesJobTop [seriesJobDataTopList=" + seriesJobDataTopList + ", topNumber=" + topNumber
+ ", showOthers=" + showOthers + ", topNumber=" + topNumber + ", chartType=" + chartType + "]";
+ "]";
} }
} }

View File

@ -1,57 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet;
import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesPortletContext extends SeriesPortletDefinition {
private static final long serialVersionUID = -2350334263342186590L;
private Context context;
private ArrayList<SeriesPortletDataContext> seriesPortletDataContextList;
public SeriesPortletContext() {
super();
this.chartType = ChartType.Context;
}
public SeriesPortletContext(Context context,
ArrayList<SeriesPortletDataContext> seriesPortletDataContextList) {
super();
this.chartType = ChartType.Context;
this.context = context;
this.seriesPortletDataContextList = seriesPortletDataContextList;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
public ArrayList<SeriesPortletDataContext> getSeriesPortletDataContextList() {
return seriesPortletDataContextList;
}
public void setSeriesPortletDataContextList(
ArrayList<SeriesPortletDataContext> seriesPortletDataContextList) {
this.seriesPortletDataContextList = seriesPortletDataContextList;
}
@Override
public String toString() {
return "SeriesPortletContext [context=" + context
+ ", seriesPortletDataContextList="
+ seriesPortletDataContextList + "]";
}
}

View File

@ -1,51 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesPortletDataContext implements Serializable {
private static final long serialVersionUID = 6043106605633429465L;
private String context;
private ArrayList<SeriesPortletData> series;
public SeriesPortletDataContext() {
super();
}
public SeriesPortletDataContext(String context,
ArrayList<SeriesPortletData> series) {
super();
this.context = context;
this.series = series;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public ArrayList<SeriesPortletData> getSeries() {
return series;
}
public void setSeries(ArrayList<SeriesPortletData> series) {
this.series = series;
}
@Override
public String toString() {
return "SeriesPortletDataContext [context=" + context + ", series="
+ series + "]";
}
}

View File

@ -2,45 +2,34 @@ package org.gcube.portlets.admin.accountingmanager.shared.data.response.portlet;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class SeriesPortletTop extends SeriesPortletDefinition { public class SeriesPortletTop extends SeriesPortletDefinition {
private static final long serialVersionUID = -2350334263342186590L; private static final long serialVersionUID = -2350334263342186590L;
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private ArrayList<SeriesPortletDataTop> seriesPortletDataTopList; private ArrayList<SeriesPortletDataTop> seriesPortletDataTopList;
public SeriesPortletTop() { public SeriesPortletTop() {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = false; this.topNumber = Constants.TOP_NUMBER_DEFAULT;
this.topNumber = 5;
} }
public SeriesPortletTop(Boolean showOthers, Integer topNumber, public SeriesPortletTop(Integer topNumber, ArrayList<SeriesPortletDataTop> seriesPortletDataTopList) {
ArrayList<SeriesPortletDataTop> seriesPortletDataTopList) {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.seriesPortletDataTopList = seriesPortletDataTopList; this.seriesPortletDataTopList = seriesPortletDataTopList;
} }
public Boolean getShowOthers() {
return showOthers;
}
public void setShowOthers(Boolean showOthers) {
this.showOthers = showOthers;
}
public Integer getTopNumber() { public Integer getTopNumber() {
return topNumber; return topNumber;
} }
@ -53,16 +42,14 @@ public class SeriesPortletTop extends SeriesPortletDefinition {
return seriesPortletDataTopList; return seriesPortletDataTopList;
} }
public void setSeriesPortletDataTopList( public void setSeriesPortletDataTopList(ArrayList<SeriesPortletDataTop> seriesPortletDataTopList) {
ArrayList<SeriesPortletDataTop> seriesPortletDataTopList) {
this.seriesPortletDataTopList = seriesPortletDataTopList; this.seriesPortletDataTopList = seriesPortletDataTopList;
} }
@Override @Override
public String toString() { public String toString() {
return "SeriesPortletTop [showOthers=" + showOthers + ", topNumber=" return "SeriesPortletTop [topNumber=" + topNumber + ", seriesPortletDataTopList=" + seriesPortletDataTopList
+ topNumber + ", seriesPortletDataTopList=" + "]";
+ seriesPortletDataTopList + "]";
} }
} }

View File

@ -1,58 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.service;
import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesServiceContext extends SeriesServiceDefinition {
private static final long serialVersionUID = -2350334263342186590L;
private Context context;
private ArrayList<SeriesServiceDataContext> seriesServiceDataContextList;
public SeriesServiceContext() {
super();
this.chartType = ChartType.Context;
}
public SeriesServiceContext(Context context,
ArrayList<SeriesServiceDataContext> seriesServiceDataContextList) {
super();
this.chartType = ChartType.Context;
this.context = context;
this.seriesServiceDataContextList = seriesServiceDataContextList;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
public ArrayList<SeriesServiceDataContext> getSeriesServiceDataContextList() {
return seriesServiceDataContextList;
}
public void setSeriesServiceDataContextList(
ArrayList<SeriesServiceDataContext> seriesServiceDataContextList) {
this.seriesServiceDataContextList = seriesServiceDataContextList;
}
@Override
public String toString() {
return "SeriesServiceContext [context=" + context
+ ", seriesServiceDataContextList="
+ seriesServiceDataContextList + "]";
}
}

View File

@ -1,51 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.service;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesServiceDataContext implements Serializable {
private static final long serialVersionUID = 6043106605633429465L;
private String context;
private ArrayList<SeriesServiceData> series;
public SeriesServiceDataContext() {
super();
}
public SeriesServiceDataContext(String context,
ArrayList<SeriesServiceData> series) {
super();
this.context = context;
this.series = series;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public ArrayList<SeriesServiceData> getSeries() {
return series;
}
public void setSeries(ArrayList<SeriesServiceData> series) {
this.series = series;
}
@Override
public String toString() {
return "SeriesServiceDataContext [context=" + context + ", series="
+ series + "]";
}
}

View File

@ -2,46 +2,35 @@ package org.gcube.portlets.admin.accountingmanager.shared.data.response.service;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class SeriesServiceTop extends SeriesServiceDefinition { public class SeriesServiceTop extends SeriesServiceDefinition {
private static final long serialVersionUID = -2350334263342186590L; private static final long serialVersionUID = -2350334263342186590L;
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private ArrayList<SeriesServiceDataTop> seriesServiceDataTopList; private ArrayList<SeriesServiceDataTop> seriesServiceDataTopList;
public SeriesServiceTop() { public SeriesServiceTop() {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = false; this.topNumber = Constants.TOP_NUMBER_DEFAULT;
this.topNumber = 5;
} }
public SeriesServiceTop(Boolean showOthers, Integer topNumber, public SeriesServiceTop(Integer topNumber, ArrayList<SeriesServiceDataTop> seriesServiceDataTopList) {
ArrayList<SeriesServiceDataTop> seriesServiceDataTopList) {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.seriesServiceDataTopList = seriesServiceDataTopList; this.seriesServiceDataTopList = seriesServiceDataTopList;
} }
public Boolean getShowOthers() {
return showOthers;
}
public void setShowOthers(Boolean showOthers) {
this.showOthers = showOthers;
}
public Integer getTopNumber() { public Integer getTopNumber() {
return topNumber; return topNumber;
} }
@ -54,16 +43,14 @@ public class SeriesServiceTop extends SeriesServiceDefinition {
return seriesServiceDataTopList; return seriesServiceDataTopList;
} }
public void setSeriesServiceDataTopList( public void setSeriesServiceDataTopList(ArrayList<SeriesServiceDataTop> seriesServiceDataTopList) {
ArrayList<SeriesServiceDataTop> seriesServiceDataTopList) {
this.seriesServiceDataTopList = seriesServiceDataTopList; this.seriesServiceDataTopList = seriesServiceDataTopList;
} }
@Override @Override
public String toString() { public String toString() {
return "SeriesServiceTop [showOthers=" + showOthers + ", topNumber=" return "SeriesServiceTop [topNumber=" + topNumber + ", seriesServiceDataTopList=" + seriesServiceDataTopList
+ topNumber + ", seriesServiceDataTopList=" + ", chartType=" + chartType + "]";
+ seriesServiceDataTopList + "]";
} }
} }

View File

@ -1,59 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.storage;
import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesStorageContext extends SeriesStorageDefinition {
private static final long serialVersionUID = -5477545972037227361L;
private Context context;
private ArrayList<SeriesStorageDataContext> seriesStorageDataContextList;
public SeriesStorageContext() {
super();
this.chartType = ChartType.Context;
}
public SeriesStorageContext(Context context,
ArrayList<SeriesStorageDataContext> seriesStorageDataContextList) {
super();
this.chartType = ChartType.Context;
this.context=context;
this.seriesStorageDataContextList = seriesStorageDataContextList;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
public ArrayList<SeriesStorageDataContext> getSeriesStorageDataContextList() {
return seriesStorageDataContextList;
}
public void setSeriesStorageDataContextList(
ArrayList<SeriesStorageDataContext> seriesStorageDataContextList) {
this.seriesStorageDataContextList = seriesStorageDataContextList;
}
@Override
public String toString() {
return "SeriesStorageContext [context=" + context
+ ", seriesStorageDataContextList="
+ seriesStorageDataContextList + "]";
}
}

View File

@ -1,51 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.storage;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesStorageDataContext implements Serializable {
private static final long serialVersionUID = -627227653308818605L;
private String context;
private ArrayList<SeriesStorageData> series;
public SeriesStorageDataContext() {
super();
}
public SeriesStorageDataContext(String context,
ArrayList<SeriesStorageData> series) {
super();
this.context = context;
this.series = series;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public ArrayList<SeriesStorageData> getSeries() {
return series;
}
public void setSeries(ArrayList<SeriesStorageData> series) {
this.series = series;
}
@Override
public String toString() {
return "SeriesStorageDataContext [context=" + context + ", series="
+ series + "]";
}
}

View File

@ -2,46 +2,35 @@ package org.gcube.portlets.admin.accountingmanager.shared.data.response.storage;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class SeriesStorageTop extends SeriesStorageDefinition { public class SeriesStorageTop extends SeriesStorageDefinition {
private static final long serialVersionUID = -5477545972037227361L; private static final long serialVersionUID = -5477545972037227361L;
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private ArrayList<SeriesStorageDataTop> seriesStorageDataTopList; private ArrayList<SeriesStorageDataTop> seriesStorageDataTopList;
public SeriesStorageTop() { public SeriesStorageTop() {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = false; this.topNumber = Constants.TOP_NUMBER_DEFAULT;
this.topNumber = 5;
} }
public SeriesStorageTop(Boolean showOthers, Integer topNumber, public SeriesStorageTop(Integer topNumber, ArrayList<SeriesStorageDataTop> seriesStorageDataTopList) {
ArrayList<SeriesStorageDataTop> seriesStorageDataTopList) {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.seriesStorageDataTopList = seriesStorageDataTopList; this.seriesStorageDataTopList = seriesStorageDataTopList;
} }
public Boolean getShowOthers() {
return showOthers;
}
public void setShowOthers(Boolean showOthers) {
this.showOthers = showOthers;
}
public Integer getTopNumber() { public Integer getTopNumber() {
return topNumber; return topNumber;
} }
@ -54,16 +43,14 @@ public class SeriesStorageTop extends SeriesStorageDefinition {
return seriesStorageDataTopList; return seriesStorageDataTopList;
} }
public void setSeriesStorageDataTopList( public void setSeriesStorageDataTopList(ArrayList<SeriesStorageDataTop> seriesStorageDataTopList) {
ArrayList<SeriesStorageDataTop> seriesStorageDataTopList) {
this.seriesStorageDataTopList = seriesStorageDataTopList; this.seriesStorageDataTopList = seriesStorageDataTopList;
} }
@Override @Override
public String toString() { public String toString() {
return "SeriesStorageTop [showOthers=" + showOthers + ", topNumber=" return "SeriesStorageTop [topNumber=" + topNumber + ", seriesStorageDataTopList=" + seriesStorageDataTopList
+ topNumber + ", seriesStorageDataTopList=" + ", chartType=" + chartType + "]";
+ seriesStorageDataTopList + "]";
} }
} }

View File

@ -1,58 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.task;
import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
import org.gcube.portlets.admin.accountingmanager.shared.data.Context;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesTaskContext extends SeriesTaskDefinition {
private static final long serialVersionUID = 6805210072384752359L;
private Context context;
private ArrayList<SeriesTaskDataContext> seriesTaskDataContextList;
public SeriesTaskContext() {
super();
this.chartType = ChartType.Context;
}
public SeriesTaskContext(Context context,
ArrayList<SeriesTaskDataContext> seriesTaskDataTopList) {
super();
this.chartType = ChartType.Context;
this.context = context;
this.seriesTaskDataContextList = seriesTaskDataTopList;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
public ArrayList<SeriesTaskDataContext> getSeriesTaskDataContextList() {
return seriesTaskDataContextList;
}
public void setSeriesTaskDataContextList(
ArrayList<SeriesTaskDataContext> seriesTaskDataContextList) {
this.seriesTaskDataContextList = seriesTaskDataContextList;
}
@Override
public String toString() {
return "SeriesTaskContext [context=" + context
+ ", seriesTaskDataContextList=" + seriesTaskDataContextList
+ "]";
}
}

View File

@ -1,51 +0,0 @@
package org.gcube.portlets.admin.accountingmanager.shared.data.response.task;
import java.io.Serializable;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SeriesTaskDataContext implements Serializable {
private static final long serialVersionUID = 6799983693606904130L;
private String context;
private ArrayList<SeriesTaskData> series;
public SeriesTaskDataContext() {
super();
}
public SeriesTaskDataContext(String context,
ArrayList<SeriesTaskData> series) {
super();
this.context = context;
this.series = series;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
public ArrayList<SeriesTaskData> getSeries() {
return series;
}
public void setSeries(ArrayList<SeriesTaskData> series) {
this.series = series;
}
@Override
public String toString() {
return "SeriesTaskDataContext [context=" + context + ", series="
+ series + "]";
}
}

View File

@ -2,46 +2,35 @@ package org.gcube.portlets.admin.accountingmanager.shared.data.response.task;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType; import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
public class SeriesTaskTop extends SeriesTaskDefinition { public class SeriesTaskTop extends SeriesTaskDefinition {
private static final long serialVersionUID = 6805210072384752359L; private static final long serialVersionUID = 6805210072384752359L;
private Boolean showOthers;
private Integer topNumber; private Integer topNumber;
private ArrayList<SeriesTaskDataTop> seriesTaskDataTopList; private ArrayList<SeriesTaskDataTop> seriesTaskDataTopList;
public SeriesTaskTop() { public SeriesTaskTop() {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = false; this.topNumber = Constants.TOP_NUMBER_DEFAULT;
this.topNumber = 5;
} }
public SeriesTaskTop(Boolean showOthers, Integer topNumber, public SeriesTaskTop(Integer topNumber, ArrayList<SeriesTaskDataTop> seriesTaskDataTopList) {
ArrayList<SeriesTaskDataTop> seriesTaskDataTopList) {
super(); super();
this.chartType = ChartType.Top; this.chartType = ChartType.Top;
this.showOthers = showOthers;
this.topNumber = topNumber; this.topNumber = topNumber;
this.seriesTaskDataTopList = seriesTaskDataTopList; this.seriesTaskDataTopList = seriesTaskDataTopList;
} }
public Boolean getShowOthers() {
return showOthers;
}
public void setShowOthers(Boolean showOthers) {
this.showOthers = showOthers;
}
public Integer getTopNumber() { public Integer getTopNumber() {
return topNumber; return topNumber;
} }
@ -54,16 +43,14 @@ public class SeriesTaskTop extends SeriesTaskDefinition {
return seriesTaskDataTopList; return seriesTaskDataTopList;
} }
public void setSeriesTaskDataTopList( public void setSeriesTaskDataTopList(ArrayList<SeriesTaskDataTop> seriesTaskDataTopList) {
ArrayList<SeriesTaskDataTop> seriesTaskDataTopList) {
this.seriesTaskDataTopList = seriesTaskDataTopList; this.seriesTaskDataTopList = seriesTaskDataTopList;
} }
@Override @Override
public String toString() { public String toString() {
return "SeriesTaskTop [showOthers=" + showOthers + ", topNumber=" return "SeriesTaskTop [topNumber=" + topNumber + ", seriesTaskDataTopList=" + seriesTaskDataTopList
+ topNumber + ", seriesTaskDataTopList=" + ", chartType=" + chartType + "]";
+ seriesTaskDataTopList + "]";
} }
} }

View File

@ -0,0 +1,35 @@
/**
*
*/
package org.gcube.portlets.admin.accountingmanager.shared.exception;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class NoScopeSelectedException extends Exception {
private static final long serialVersionUID = -8737011216478988776L;
/**
*
*/
public NoScopeSelectedException() {
super();
}
/**
* @param message
* message
*/
public NoScopeSelectedException(String message) {
super(message);
}
public NoScopeSelectedException(String message, Throwable t) {
super(message, t);
}
}