Refs #21354: Improve accounting manager portlet by new persistence

Updated portlet behavior
This commit is contained in:
Giancarlo Panichi 2021-11-22 18:09:02 +01:00
parent b829c6bf2f
commit a36fef1aa9
44 changed files with 718 additions and 1361 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</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>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -45,5 +45,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</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>

View File

@ -1,5 +1,5 @@
<?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="/src/main/webapp" tag="defaultRootSource"/>
<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"
## [v1.15.0-SNAPSHOT] - 2021-11-30
### Features
- Improve query support of the new persistence [#21354]
## [v1.14.0] - 2021-06-28
### Fixes

View File

@ -1,4 +1,8 @@
<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"
date="2021-06-28">
<Change>Fixed display errors generated in Root scope [#21729]</Change>

22
pom.xml
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
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.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> {
@Path("genre")
ModelKeyProvider<GenresData> id();
public interface ContextDataProperties extends PropertyAccess<ContextData> {
ValueProvider<GenresData, String> label();
@Path("contextData")
ModelKeyProvider<ContextData> id();
ValueProvider<ContextData, String> label();
}

View File

@ -3,11 +3,10 @@ package org.gcube.portlets.admin.accountingmanager.server.amservice;
import java.util.ArrayList;
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.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.AccountingCommandSpaces;
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.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.AccountingQueryBasic;
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.AccountingQuerySpaces;
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.Spaces;
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.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.response.SeriesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -102,11 +100,6 @@ public class AccountingCaller implements AccountingCallerInterface {
AccountingCommandTop accountingCommandTop = new AccountingCommandTop(
accountingQueryTop, accountingType);
return accountingCommandTop.execute();
case Context:
AccountingQueryContext accountingQueryContext = (AccountingQueryContext) query;
AccountingCommandContext accountingCommandContext = new AccountingCommandContext(
accountingQueryContext, accountingType);
return accountingCommandContext.execute();
case Spaces:
AccountingQuerySpaces accountingQuerySpace = (AccountingQuerySpaces) query;
AccountingCommandSpaces accountingCommandSpace = new AccountingCommandSpaces(

View File

@ -12,12 +12,11 @@ import java.util.List;
import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingFilterTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.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.FilterValue;
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.Spaces;
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.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.SeriesStorage;
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.SeriesJobDataContext;
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.SeriesJobTop;
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.SeriesServiceDataContext;
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.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.SeriesSpaceDataSpaces;
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.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.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.SeriesStorageTop;
@ -229,26 +222,6 @@ public class AccountingCallerTester implements AccountingCallerInterface {
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;
default:
break;
@ -407,25 +380,6 @@ public class AccountingCallerTester implements AccountingCallerInterface {
accountingFilterTop.getTopNumber(),
seriesServiceDataTopList);
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:
break;
@ -479,8 +433,6 @@ public class AccountingCallerTester implements AccountingCallerInterface {
.getChartType()) {
case Basic:
case Top:
case Context:
break;
case Spaces:
// AccountingFilterContext accountingFilterContext =
// (AccountingFilterContext) seriesRequest
@ -576,27 +528,6 @@ public class AccountingCallerTester implements AccountingCallerInterface {
accountingFilterTop.getTopNumber(),
seriesStorageDataTopList);
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:
break;

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.Calendar;
import java.util.HashSet;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Info;
@ -42,28 +43,38 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
public SeriesResponse execute() throws ServiceException {
try {
if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) {
AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryTop.getScope());
}
//if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) {
// AccountingPersistenceQueryFactory.getForcedQueryScope().set(accountingQueryTop.getScope());
//}
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
logger.debug("Query TopValues: " + accountingQueryTop.getFilterKey().getKey());
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
logger.debug("Execute Top()");
apq.setRequestedRecords(accountingQueryTop.getType());
HashSet<String> ctx=null;
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());
if (accountingQueryTop.getShowOthers()) {
topSM = apq.getTopValues(accountingQueryTop.getType(), accountingQueryTop.getTemporalConstraint(),
accountingQueryTop.getFilters(), accountingQueryTop.getFilterKey().getKey(), null, true, 0);
topSM = apq.getTopValues(accountingQueryTop.getFilterKey().getKey(), null, true, 0);
} else {
topSM = apq.getTopValues(accountingQueryTop.getType(), accountingQueryTop.getTemporalConstraint(),
accountingQueryTop.getFilters(), accountingQueryTop.getFilterKey().getKey(), null, true,
topSM = apq.getTopValues(accountingQueryTop.getFilterKey().getKey(), null, true,
accountingQueryTop.getTopNumber());
}
if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) {
AccountingPersistenceQueryFactory.getForcedQueryScope().remove();
}
//if (accountingQueryTop.getScope() != null && !accountingQueryTop.getScope().isEmpty()) {
// AccountingPersistenceQueryFactory.getForcedQueryScope().remove();
//}
if (topSM == null) {
throw new ServiceException("Error retrieving info for top: sorted map is null!");

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.shared.data.AccountingFilter;
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.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -77,8 +76,8 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
filters.add(filter);
}
}
invocation = new AccountingQueryBasic(AggregatedJobUsageRecord.class, accountingFilterBasic.getScope(),
accountingFilterBasic.isNoContext(), temporalConstraint, filters);
invocation = new AccountingQueryBasic(AggregatedJobUsageRecord.class,
accountingFilterBasic.getContext(), temporalConstraint, filters);
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -93,28 +92,12 @@ public class AccountingQuery4Job extends AccountingQueryBuilder {
filters.add(filter);
}
}
invocation = new AccountingQueryTop(AggregatedJobUsageRecord.class, accountingFilterTop.getScope(),
invocation = new AccountingQueryTop(AggregatedJobUsageRecord.class, accountingFilterTop.getContext(),
accountingFilterTop.getFilterKey(), accountingFilterTop.getShowOthers(),
accountingFilterTop.getTopNumber(), temporalConstraint, filters);
} 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);
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.shared.data.AccountingFilter;
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.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -77,8 +76,7 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
}
}
invocation = new AccountingQueryBasic(AggregatedPortletUsageRecord.class,
accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint,
filters);
accountingFilterBasic.getContext(), temporalConstraint, filters);
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -94,28 +92,12 @@ public class AccountingQuery4Portlet extends AccountingQueryBuilder {
}
}
invocation = new AccountingQueryTop(AggregatedPortletUsageRecord.class,
accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint,
filters);
} 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(AggregatedPortletUsageRecord.class,
accountingFilterContext.getContext(), temporalConstraint, filters);
} else {
logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException("Invalid Request!");
}
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.shared.data.AccountingFilter;
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.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -78,8 +77,7 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
}
}
invocation = new AccountingQueryBasic(AggregatedServiceUsageRecord.class,
accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint,
filters);
accountingFilterBasic.getContext(), temporalConstraint, filters);
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -95,28 +93,12 @@ public class AccountingQuery4Service extends AccountingQueryBuilder {
}
}
invocation = new AccountingQueryTop(AggregatedServiceUsageRecord.class,
accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint,
filters);
} 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(AggregatedServiceUsageRecord.class,
accountingFilterContext.getContext(), temporalConstraint, filters);
} else {
logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException("Invalid Request!");
}
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.shared.data.AccountingFilter;
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.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -78,8 +77,7 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
}
}
invocation = new AccountingQueryBasic(AggregatedStorageUsageRecord.class,
accountingFilterBasic.getScope(), accountingFilterBasic.isNoContext(), temporalConstraint,
filters);
accountingFilterBasic.getContext(), temporalConstraint, filters);
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
@ -95,28 +93,12 @@ public class AccountingQuery4Storage extends AccountingQueryBuilder {
}
}
invocation = new AccountingQueryTop(AggregatedStorageUsageRecord.class,
accountingFilterTop.getScope(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getContext(), accountingFilterTop.getFilterKey(),
accountingFilterTop.getShowOthers(), accountingFilterTop.getTopNumber(), temporalConstraint,
filters);
} 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(AggregatedStorageUsageRecord.class,
accountingFilterContext.getContext(), temporalConstraint, filters);
} else {
logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException("Invalid Request!");
}
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.TemporalConstraint;
//import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord;
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.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.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
@ -21,13 +19,12 @@ import org.slf4j.LoggerFactory;
/**
* Accounting Query 4 Task
*
* @author Giancarlo Panichi
* @author Giancarlo Panichi
*
*
*/
public class AccountingQuery4Task extends AccountingQueryBuilder {
protected static Logger logger = LoggerFactory
.getLogger(AccountingQuery4Task.class);
protected static Logger logger = LoggerFactory.getLogger(AccountingQuery4Task.class);
private SeriesRequest seriesRequest;
public AccountingQuery4Task(SeriesRequest seriesRequest) {
@ -36,21 +33,17 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
@Override
public void buildOpEx() throws ServiceException {
Calendar startCalendar = GregorianCalendar
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
Calendar startCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
try {
startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod()
.getStartDate()));
startCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
} catch (ParseException e) {
e.printStackTrace();
throw new ServiceException("Start Date not valid!");
}
Calendar endCalendar = GregorianCalendar
.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
Calendar endCalendar = GregorianCalendar.getInstance(TemporalConstraint.DEFAULT_TIME_ZONE);
try {
endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()));
endCalendar.setTime(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
} catch (ParseException e) {
e.printStackTrace();
throw new ServiceException("End Date not valid!");
@ -62,17 +55,14 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
endCalendar.set(GregorianCalendar.MILLISECOND, 999);
@SuppressWarnings("unused")
TemporalConstraint temporalConstraint = new TemporalConstraint(
startCalendar.getTimeInMillis(), endCalendar.getTimeInMillis(),
PeriodModeMap.getMode(seriesRequest.getAccountingPeriod()
.getPeriod()));
TemporalConstraint temporalConstraint = new TemporalConstraint(startCalendar.getTimeInMillis(),
endCalendar.getTimeInMillis(), PeriodModeMap.getMode(seriesRequest.getAccountingPeriod().getPeriod()));
ArrayList<Filter> filters = null;
ArrayList<AccountingFilter> accountingFilters = null;
AccountingQuery invocation = null;
if (seriesRequest != null
&& seriesRequest.getAccountingFilterDefinition() != null) {
if (seriesRequest != null && seriesRequest.getAccountingFilterDefinition() != null) {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterBasic) {
AccountingFilterBasic accountingFilterBasic = (AccountingFilterBasic) seriesRequest
.getAccountingFilterDefinition();
@ -80,16 +70,16 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
filters = new ArrayList<Filter>();
if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters
.getFilterKey().getKey(),
Filter filter = new Filter(accountigFilters.getFilterKey().getKey(),
accountigFilters.getFilterValue());
filters.add(filter);
}
}
/*invocation = new AccountingQueryBasic(
AggregatedTaskUsageRecord.class, temporalConstraint,
filters, accountingFilterBasic.isNoContext());
*/
/*
* invocation = new AccountingQueryBasic(
* AggregatedTaskUsageRecord.class, temporalConstraint, filters,
* accountingFilterBasic.isNoContext());
*/
} else {
if (seriesRequest.getAccountingFilterDefinition() instanceof AccountingFilterTop) {
AccountingFilterTop accountingFilterTop = (AccountingFilterTop) seriesRequest
@ -98,42 +88,22 @@ public class AccountingQuery4Task extends AccountingQueryBuilder {
filters = new ArrayList<Filter>();
if (accountingFilters != null) {
for (AccountingFilter accountigFilters : accountingFilters) {
Filter filter = new Filter(accountigFilters
.getFilterKey().getKey(),
Filter filter = new Filter(accountigFilters.getFilterKey().getKey(),
accountigFilters.getFilterValue());
filters.add(filter);
}
}
/*invocation = new AccountingQueryTop(
AggregatedTaskUsageRecord.class,
accountingFilterTop.getFilterKey(),
accountingFilterTop.getShowOthers(),
accountingFilterTop.getTopNumber(),
temporalConstraint, filters);*/
/*
* invocation = new AccountingQueryTop(
* AggregatedTaskUsageRecord.class,
* accountingFilterTop.getFilterKey(),
* accountingFilterTop.getShowOthers(),
* accountingFilterTop.getTopNumber(), temporalConstraint,
* filters);
*/
} 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(
AggregatedTaskUsageRecord.class,
accountingFilterContext.getContext(),
temporalConstraint,
filters);*/
} else {
logger.error("Invalid Request: " + seriesRequest);
throw new ServiceException(
"Invalid Request!");
}
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.datamodel.AggregatedUsageRecord;
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 {
private Class<? extends AggregatedUsageRecord<?, ?>> type;
private String scope;
private boolean noContext;
private Context context;
private TemporalConstraint temporalConstraint;
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) {
super();
chartType = ChartType.Basic;
this.type = type;
this.temporalConstraint = temporalConstraint;
this.scope = scope;
this.context = context;
this.filters = filters;
this.noContext = noContext;
}
public Class<? extends AggregatedUsageRecord<?, ?>> getType() {
@ -47,12 +46,13 @@ public class AccountingQueryBasic extends AccountingQuery {
this.temporalConstraint = temporalConstraint;
}
public String getScope() {
return scope;
public Context getContext() {
return context;
}
public void setScope(String scope) {
this.scope = scope;
public void setContext(Context context) {
this.context = context;
}
public ArrayList<Filter> getFilters() {
@ -63,18 +63,10 @@ public class AccountingQueryBasic extends AccountingQuery {
this.filters = filters;
}
public boolean isNoContext() {
return noContext;
}
public void setNoContext(boolean noContext) {
this.noContext = noContext;
}
@Override
public String toString() {
return "AccountingQueryBasic [type=" + type + ", temporalConstraint=" + temporalConstraint + ", scope=" + scope
+ ", filters=" + filters + ", noContext=" + noContext + "]";
return "AccountingQueryBasic [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.datamodel.AggregatedUsageRecord;
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;
/**
@ -16,19 +17,19 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
*/
public class AccountingQueryTop extends AccountingQuery {
private Class<? extends AggregatedUsageRecord<?, ?>> type;
private String scope;
private Context context;
private FilterKey filterKey;
private Integer topNumber;
private Boolean showOthers;
private TemporalConstraint temporalConstraint;
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) {
super();
chartType = ChartType.Top;
this.type = type;
this.scope = scope;
this.context = context;
this.temporalConstraint = temporalConstraint;
this.filters = filters;
this.filterKey = filterKey;
@ -43,13 +44,13 @@ public class AccountingQueryTop extends AccountingQuery {
public void setType(Class<? extends AggregatedUsageRecord<?, ?>> type) {
this.type = type;
}
public String getScope() {
return scope;
public Context getContext() {
return context;
}
public void setScope(String scope) {
this.scope = scope;
public void setContext(Context context) {
this.context = context;
}
public TemporalConstraint getTemporalConstraint() {
@ -94,9 +95,10 @@ public class AccountingQueryTop extends AccountingQuery {
@Override
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="
+ filters + "]";
+ filters + ", chartType=" + chartType + "]";
}
}

View File

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

View File

@ -7,13 +7,13 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
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.response.SeriesJob;
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.SeriesJobTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -55,15 +55,15 @@ public class SeriesResponse4JobTop extends SeriesResponseBuilder {
ArrayList<SeriesJobData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
JsonNode jso = info.getValue();
Long duration = jso
.getLong(AggregatedServiceUsageRecord.DURATION);
.get(AggregatedServiceUsageRecord.DURATION).asLong();
Long operationCount = jso
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
.get(AggregatedServiceUsageRecord.OPERATION_COUNT).asLong();
Long maxInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
.get(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME).asLong();
Long minInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
.get(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME).asLong();
series.add(new SeriesJobData(info.getCalendar()
.getTime(), operationCount, duration,

View File

@ -7,13 +7,13 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
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.response.SeriesPortlet;
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.SeriesPortletTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -53,11 +53,11 @@ public class SeriesResponse4PortletTop extends SeriesResponseBuilder {
ArrayList<SeriesPortletData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
JsonNode jso = info.getValue();
// Long duration =
// jso.getLong(AggregatedPortletUsageRecord.DURATION);
Long operationCount = jso
.getLong(AggregatedPortletUsageRecord.OPERATION_COUNT);
.get(AggregatedPortletUsageRecord.OPERATION_COUNT).asLong();
// Long maxInvocationTime =
// jso.getLong(AggregatedPortletUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime =

View File

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

View File

@ -7,13 +7,13 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
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.response.SeriesService;
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.SeriesServiceTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -53,15 +53,15 @@ public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
ArrayList<SeriesServiceData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
JsonNode jso = info.getValue();
Long duration = jso
.getLong(AggregatedServiceUsageRecord.DURATION);
.get(AggregatedServiceUsageRecord.DURATION).asLong();
Long operationCount = jso
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
.get(AggregatedServiceUsageRecord.OPERATION_COUNT).asLong();
Long maxInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
.get(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME).asLong();
Long minInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
.get(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME).asLong();
series.add(new SeriesServiceData(info.getCalendar()
.getTime(), operationCount, duration,

View File

@ -5,6 +5,10 @@ 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.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.response.SeriesSpace;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.space.SeriesSpaceSpaces;
@ -25,10 +29,10 @@ public class SeriesResponse4SpaceSpaces extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4SpaceSpaces.class);
private Spaces spaces;
private SortedMap<Filter, SortedMap<Calendar, Long>> spaceSM;
private SortedMap<Filter, SortedMap<Calendar, Info>> spaceSM;
public SeriesResponse4SpaceSpaces(Spaces spaces,
SortedMap<Filter, SortedMap<Calendar, Long>> spaceSM) {
SortedMap<Filter, SortedMap<Calendar, Info>> spaceSM) {
this.spaces = spaces;
this.spaceSM = spaceSM;
}
@ -46,11 +50,13 @@ public class SeriesResponse4SpaceSpaces extends SeriesResponseBuilder {
for (Filter spaceValue : spaceSM.keySet()) {
ArrayList<SeriesSpaceData> series = new ArrayList<>();
SortedMap<Calendar, Long> infos = spaceSM.get(spaceValue);
SortedMap<Calendar, Info> infos = spaceSM.get(spaceValue);
for (Calendar calendar : infos.keySet()) {
Long value = infos.get(calendar);
if(value==null){
value=0L;
Info info = infos.get(calendar);
Long value=0L;
if(info!=null){
JsonNode jso=info.getValue();
value=jso.get(AggregatedStorageStatusRecord.DATA_VOLUME).asLong();
}
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.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.storage.SeriesStorageBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.storage.SeriesStorageData;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -39,10 +39,10 @@ public class SeriesResponse4StorageBasic extends SeriesResponseBuilder {
ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>();
for (Info info : infos) {
JSONObject jso = info.getValue();
Long dataVolume = jso.getLong(AggregatedStorageUsageRecord.DATA_VOLUME);
JsonNode jso = info.getValue();
Long dataVolume = jso.get(AggregatedStorageUsageRecord.DATA_VOLUME).asLong();
Long operationCount = jso
.getLong(AggregatedStorageUsageRecord.OPERATION_COUNT);
.get(AggregatedStorageUsageRecord.OPERATION_COUNT).asLong();
series.add(new SeriesStorageData(info.getCalendar().getTime(), dataVolume, operationCount));
}

View File

@ -7,13 +7,13 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
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.response.SeriesStorage;
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.SeriesStorageTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -54,11 +54,11 @@ public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
ArrayList<SeriesStorageData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
JsonNode jso = info.getValue();
Long dataVolume = jso
.getLong(AggregatedStorageUsageRecord.DATA_VOLUME);
.get(AggregatedStorageUsageRecord.DATA_VOLUME).asLong();
Long operationCount = jso
.getLong(AggregatedStorageUsageRecord.OPERATION_COUNT);
.get(AggregatedStorageUsageRecord.OPERATION_COUNT).asLong();
series.add(new SeriesStorageData(info.getCalendar()
.getTime(), dataVolume, operationCount));

View File

@ -6,6 +6,7 @@ import java.util.SortedMap;
import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
//import org.gcube.accounting.datamodel.aggregation.AggregatedTaskUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesTask;
@ -13,7 +14,6 @@ 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.SeriesTaskTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -54,7 +54,7 @@ public class SeriesResponse4TaskTop extends SeriesResponseBuilder {
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
@SuppressWarnings("unused")
JSONObject jso = info.getValue();
JsonNode jso = info.getValue();
// Long duration =
// jso.getLong(AggregatedTaskUsageRecord.DURATION);
//Long operationCount = jso

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.SeriesResponse;
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.SeriesJobDataContext;
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.SeriesJobTop;
@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory;
/**
* Accounting Model 4 Job
*
* @author Giancarlo Panichi
* @author Giancarlo Panichi
*
*
*/
public class AccountingModel4Job extends AccountingModelBuilder {
protected static Logger logger = LoggerFactory
.getLogger(AccountingModel4Job.class);
protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Job.class);
private AccountingStateData accountingStateData;
public AccountingModel4Job(AccountingStateData accountingStateData) {
@ -42,35 +39,30 @@ public class AccountingModel4Job extends AccountingModelBuilder {
if (seriesRequest == null) {
logger.error("Error series request is null");
throw new ServiceException(
"Error series request is null");
throw new ServiceException("Error series request is null");
}
String startDate="";
String startDate = "";
try {
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getStartDate()));
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String endDate="";
String endDate = "";
try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()));
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String periodType = seriesRequest.getAccountingPeriod().getPeriod()
.getLabel();
String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel();
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
if (seriesResponse == null) {
logger.error("Error series response is null");
throw new ServiceException(
"Error series response is null");
throw new ServiceException("Error series response is null");
}
String fileName = "Untitled";
@ -78,17 +70,13 @@ public class AccountingModel4Job extends AccountingModelBuilder {
ArrayList<AccountingDataRow> rows = new ArrayList<>();
if (seriesResponse instanceof SeriesJob) {
SeriesJob seriesService = (SeriesJob) seriesResponse;
SeriesJobDefinition definition = seriesService
.getSeriesJobDefinition();
SeriesJobDefinition definition = seriesService.getSeriesJobDefinition();
if (definition instanceof SeriesJobBasic) {
SeriesJobBasic seriesJobBasic = (SeriesJobBasic) definition;
fileName = "Job_" + periodType + "_" + startDate + "_"
+ endDate;
header = new ArrayList<>(Arrays.asList(new String[] { "Date",
"Operation Count", "Duration", "Max Invocation",
"Min Invocation" }));
ArrayList<SeriesJobData> listData = seriesJobBasic
.getSeries();
fileName = "Job_" + periodType + "_" + startDate + "_" + endDate;
header = new ArrayList<>(Arrays.asList(
new String[] { "Date", "Operation Count", "Duration", "Max Invocation", "Min Invocation" }));
ArrayList<SeriesJobData> listData = seriesJobBasic.getSeries();
for (SeriesJobData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(sdfCSVDate.format(seriesData.getDate()));
@ -102,76 +90,35 @@ public class AccountingModel4Job extends AccountingModelBuilder {
} else {
if (definition instanceof SeriesJobTop) {
SeriesJobTop seriesJobTop = (SeriesJobTop) definition;
fileName = "JobTop_" + periodType + "_" + startDate
+ "_" + endDate;
header = new ArrayList<>(Arrays.asList(new String[] {
"Value", "Date", "Operation Count", "Duration",
"Max Invocation", "Min Invocation" }));
ArrayList<SeriesJobDataTop> listDataTop = seriesJobTop
.getSeriesJobDataTopList();
fileName = "JobTop_" + periodType + "_" + startDate + "_" + endDate;
header = new ArrayList<>(Arrays.asList(new String[] { "Value", "Date", "Operation Count",
"Duration", "Max Invocation", "Min Invocation" }));
ArrayList<SeriesJobDataTop> listDataTop = seriesJobTop.getSeriesJobDataTopList();
for (SeriesJobDataTop seriesDataTop : listDataTop) {
FilterValue filterValue = seriesDataTop
.getFilterValue();
ArrayList<SeriesJobData> listData = seriesDataTop
.getSeries();
FilterValue filterValue = seriesDataTop.getFilterValue();
ArrayList<SeriesJobData> listData = seriesDataTop.getSeries();
for (SeriesJobData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue());
data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData
.getOperationCount()));
data.add(String.valueOf(seriesData.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData
.getMaxInvocationTime()));
data.add(String.valueOf(seriesData
.getMinInvocationTime()));
data.add(String.valueOf(seriesData.getMaxInvocationTime()));
data.add(String.valueOf(seriesData.getMinInvocationTime()));
AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow);
}
}
} else {
if (definition instanceof SeriesJobContext) {
SeriesJobContext seriesJobContext = (SeriesJobContext) definition;
fileName = "JobContext_" + periodType + "_" + startDate
+ "_" + 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);
}
logger.error("Unsupported Serie Definition for Job: " + definition);
throw new ServiceException("Unsupported Serie Definition for Job: " + definition);
}
}
} else {
logger.error("Job not support this serie response: "
+ seriesResponse);
throw new ServiceException(
"Job not support this serie response: "
+ seriesResponse);
logger.error("Job not support this serie response: " + seriesResponse);
throw new ServiceException("Job not support this serie response: " + seriesResponse);
}
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.SeriesService;
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.SeriesServiceDataContext;
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.SeriesServiceTop;
@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory;
/**
* Accounting Model 4 Service
*
* @author Giancarlo Panichi
* @author Giancarlo Panichi
*
*
*/
public class AccountingModel4Service extends AccountingModelBuilder {
protected static Logger logger = LoggerFactory
.getLogger(AccountingModel4Service.class);
protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Service.class);
private AccountingStateData accountingStateData;
public AccountingModel4Service(AccountingStateData accountingStateData) {
@ -42,35 +39,30 @@ public class AccountingModel4Service extends AccountingModelBuilder {
if (seriesRequest == null) {
logger.error("Error series request is null");
throw new ServiceException(
"Error series request is null");
throw new ServiceException("Error series request is null");
}
String startDate="";
String startDate = "";
try {
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getStartDate()));
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String endDate="";
String endDate = "";
try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()));
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String periodType = seriesRequest.getAccountingPeriod().getPeriod()
.getLabel();
String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel();
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
if (seriesResponse == null) {
logger.error("Error series response is null");
throw new ServiceException(
"Error series response is null");
throw new ServiceException("Error series response is null");
}
String fileName = "Untitled";
@ -78,17 +70,13 @@ public class AccountingModel4Service extends AccountingModelBuilder {
ArrayList<AccountingDataRow> rows = new ArrayList<>();
if (seriesResponse instanceof SeriesService) {
SeriesService seriesService = (SeriesService) seriesResponse;
SeriesServiceDefinition definition = seriesService
.getSerieServiceDefinition();
SeriesServiceDefinition definition = seriesService.getSerieServiceDefinition();
if (definition instanceof SeriesServiceBasic) {
SeriesServiceBasic seriesServiceBasic = (SeriesServiceBasic) definition;
fileName = "Service_" + periodType + "_" + startDate + "_"
+ endDate;
header = new ArrayList<>(Arrays.asList(new String[] { "Date",
"Operation Count", "Duration", "Max Invocation",
"Min Invocation" }));
ArrayList<SeriesServiceData> listData = seriesServiceBasic
.getSeries();
fileName = "Service_" + periodType + "_" + startDate + "_" + endDate;
header = new ArrayList<>(Arrays.asList(
new String[] { "Date", "Operation Count", "Duration", "Max Invocation", "Min Invocation" }));
ArrayList<SeriesServiceData> listData = seriesServiceBasic.getSeries();
for (SeriesServiceData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(sdfCSVDate.format(seriesData.getDate()));
@ -102,76 +90,33 @@ public class AccountingModel4Service extends AccountingModelBuilder {
} else {
if (definition instanceof SeriesServiceTop) {
SeriesServiceTop seriesServiceTop = (SeriesServiceTop) definition;
fileName = "ServiceTop_" + periodType + "_" + startDate
+ "_" + endDate;
header = new ArrayList<>(Arrays.asList(new String[] {
"Value", "Date", "Operation Count", "Duration",
"Max Invocation", "Min Invocation" }));
ArrayList<SeriesServiceDataTop> listDataTop = seriesServiceTop
.getSeriesServiceDataTopList();
fileName = "ServiceTop_" + periodType + "_" + startDate + "_" + endDate;
header = new ArrayList<>(Arrays.asList(new String[] { "Value", "Date", "Operation Count",
"Duration", "Max Invocation", "Min Invocation" }));
ArrayList<SeriesServiceDataTop> listDataTop = seriesServiceTop.getSeriesServiceDataTopList();
for (SeriesServiceDataTop seriesDataTop : listDataTop) {
FilterValue filterValue = seriesDataTop
.getFilterValue();
ArrayList<SeriesServiceData> listData = seriesDataTop
.getSeries();
FilterValue filterValue = seriesDataTop.getFilterValue();
ArrayList<SeriesServiceData> listData = seriesDataTop.getSeries();
for (SeriesServiceData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue());
data.add(sdfCSVDate.format(seriesData.getDate()));
data.add(String.valueOf(seriesData
.getOperationCount()));
data.add(String.valueOf(seriesData.getOperationCount()));
data.add(String.valueOf(seriesData.getDuration()));
data.add(String.valueOf(seriesData
.getMaxInvocationTime()));
data.add(String.valueOf(seriesData
.getMinInvocationTime()));
data.add(String.valueOf(seriesData.getMaxInvocationTime()));
data.add(String.valueOf(seriesData.getMinInvocationTime()));
AccountingDataRow csvDataRow = new AccountingDataRow(data);
rows.add(csvDataRow);
}
}
} else {
if (definition instanceof SeriesServiceContext) {
SeriesServiceContext seriesServiceContext = (SeriesServiceContext) 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);
}
logger.error("Unsupported Serie Definition for Service: " + definition);
throw new ServiceException("Unsupported Serie Definition for Service: " + definition);
}
}
} else {
logger.error("Service not support this serie response: "
+ seriesResponse);
throw new ServiceException(
"Service not support this serie response: "
+ seriesResponse);
logger.error("Service not support this serie response: " + seriesResponse);
throw new ServiceException("Service not support this serie response: " + seriesResponse);
}
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.SeriesStorage;
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.SeriesStorageDataContext;
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.SeriesStorageTop;
@ -23,13 +21,12 @@ import org.slf4j.LoggerFactory;
/**
* Accounting Model 4 Storage
*
* @author Giancarlo Panichi
* @author Giancarlo Panichi
*
*
*/
public class AccountingModel4Storage extends AccountingModelBuilder {
protected static Logger logger = LoggerFactory
.getLogger(AccountingModel4Storage.class);
protected static Logger logger = LoggerFactory.getLogger(AccountingModel4Storage.class);
private AccountingStateData accountingStateData;
public AccountingModel4Storage(AccountingStateData accountingStateData) {
@ -42,36 +39,31 @@ public class AccountingModel4Storage extends AccountingModelBuilder {
if (seriesRequest == null) {
logger.error("Error series request is null");
throw new ServiceException(
"Error series request is null");
throw new ServiceException("Error series request is null");
}
String startDate="";
String startDate = "";
try {
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getStartDate()));
startDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getStartDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String endDate="";
String endDate = "";
try {
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod()
.getEndDate()));
endDate = sdfFile.format(sdf.parse(seriesRequest.getAccountingPeriod().getEndDate()));
} catch (ParseException e) {
e.printStackTrace();
}
String periodType = seriesRequest.getAccountingPeriod().getPeriod()
.getLabel();
String periodType = seriesRequest.getAccountingPeriod().getPeriod().getLabel();
SeriesResponse seriesResponse = accountingStateData.getSeriesResponse();
if (seriesResponse == null) {
logger.error("Error series response is null");
throw new ServiceException(
"Error series response is null");
throw new ServiceException("Error series response is null");
}
String fileName = "Untitled";
@ -79,16 +71,12 @@ public class AccountingModel4Storage extends AccountingModelBuilder {
ArrayList<AccountingDataRow> rows = new ArrayList<>();
if (seriesResponse instanceof SeriesStorage) {
SeriesStorage seriesStorage = (SeriesStorage) seriesResponse;
SeriesStorageDefinition definition = seriesStorage
.getSeriesStorageDefinition();
SeriesStorageDefinition definition = seriesStorage.getSeriesStorageDefinition();
if (definition instanceof SeriesStorageBasic) {
SeriesStorageBasic seriesStorageBasic = (SeriesStorageBasic) definition;
fileName = "Storage_" + periodType + "_" + startDate + "_"
+ endDate;
header = new ArrayList<>(Arrays.asList(new String[] { "Date",
"Operation Count", "Data Volume" }));
ArrayList<SeriesStorageData> listData = seriesStorageBasic
.getSeries();
fileName = "Storage_" + periodType + "_" + startDate + "_" + endDate;
header = new ArrayList<>(Arrays.asList(new String[] { "Date", "Operation Count", "Data Volume" }));
ArrayList<SeriesStorageData> listData = seriesStorageBasic.getSeries();
for (SeriesStorageData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(sdfCSVDate.format(seriesData.getDate()));
@ -100,18 +88,13 @@ public class AccountingModel4Storage extends AccountingModelBuilder {
} else {
if (definition instanceof SeriesStorageTop) {
SeriesStorageTop seriesStorageTop = (SeriesStorageTop) definition;
fileName = "StorageTop_" + periodType + "_" + startDate
+ "_" + endDate;
fileName = "StorageTop_" + periodType + "_" + startDate + "_" + endDate;
header = new ArrayList<>(
Arrays.asList(new String[] { "Value", "Date",
"Operation Count", "Data Volume" }));
ArrayList<SeriesStorageDataTop> listDataTop = seriesStorageTop
.getSeriesStorageDataTopList();
Arrays.asList(new String[] { "Value", "Date", "Operation Count", "Data Volume" }));
ArrayList<SeriesStorageDataTop> listDataTop = seriesStorageTop.getSeriesStorageDataTopList();
for (SeriesStorageDataTop seriesDataTop : listDataTop) {
FilterValue filterValue = seriesDataTop
.getFilterValue();
ArrayList<SeriesStorageData> listData = seriesDataTop
.getSeries();
FilterValue filterValue = seriesDataTop.getFilterValue();
ArrayList<SeriesStorageData> listData = seriesDataTop.getSeries();
for (SeriesStorageData seriesData : listData) {
ArrayList<String> data = new ArrayList<>();
data.add(filterValue.getValue());
@ -123,46 +106,16 @@ public class AccountingModel4Storage extends AccountingModelBuilder {
}
}
} else {
if (definition instanceof SeriesStorageContext) {
SeriesStorageContext seriesStorageContext = (SeriesStorageContext) 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);
}
logger.error("Unsupported Serie Definition for Storage: " + definition);
throw new ServiceException("Unsupported Serie Definition for Storage: " + definition);
}
}
} else {
logger.error("Storage not support this serie response: "
+ seriesResponse);
throw new ServiceException(
"Storage not support this serie response: "
+ seriesResponse);
logger.error("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);
}

View File

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

View File

@ -5,15 +5,14 @@ import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi
* @author Giancarlo Panichi
*
*
*/
public class AccountingFilterTop extends AccountingFilterDefinition implements
Serializable {
public class AccountingFilterTop extends AccountingFilterDefinition implements Serializable {
private static final long serialVersionUID = -6805006183397381154L;
private String scope;
private Context context;
private FilterKey filterKey;
private Boolean showOthers;
private Integer topNumber;
@ -22,32 +21,30 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements
public AccountingFilterTop() {
super();
this.chartType = ChartType.Top;
scope=null;
context = null;
showOthers = false;
topNumber = 5;
filterKey = null;
filters = null;
}
public AccountingFilterTop(String scope, Boolean showOthers,Integer topNumber) {
public AccountingFilterTop(Context context, Boolean showOthers, Integer topNumber) {
super();
this.chartType = ChartType.Top;
this.scope=scope;
this.context = context;
this.showOthers = showOthers;
this.topNumber = topNumber;
filterKey = null;
filters = null;
}
public AccountingFilterTop(String scope, FilterKey filterKey,
ArrayList<AccountingFilter> filters, Boolean showOthers,
Integer topNumber) {
public AccountingFilterTop(Context context, FilterKey filterKey, ArrayList<AccountingFilter> filters,
Boolean showOthers, Integer topNumber) {
super();
chartType = ChartType.Top;
this.scope=scope;
this.context = context;
this.filterKey = filterKey;
this.filters = filters;
this.showOthers = showOthers;
@ -55,12 +52,12 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements
}
public String getScope() {
return scope;
public Context getContext() {
return context;
}
public void setScope(String scope) {
this.scope = scope;
public void setContext(Context context) {
this.context = context;
}
public FilterKey getFilterKey() {
@ -97,10 +94,10 @@ public class AccountingFilterTop extends AccountingFilterDefinition implements
@Override
public String toString() {
return "AccountingFilterTop [scope=" + scope + ", filterKey=" + filterKey + ", showOthers=" + showOthers
return "AccountingFilterTop [context=" + context + ", filterKey=" + filterKey + ", showOthers=" + showOthers
+ ", topNumber=" + topNumber + ", filters=" + filters + ", chartType=" + chartType + "]";
}
}

View File

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