2251: Accounting Manager - Stacked column chart for tops

Task-Url: https://support.d4science.org/issues/2251

Added new client library

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@126050 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-03-22 14:58:40 +00:00
parent 1f2d359c68
commit 8e3895183f
19 changed files with 399 additions and 229 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/accounting-manager-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/accounting-manager-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -45,5 +45,5 @@
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="output" path="target/accounting-manager-1.1.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -4,10 +4,7 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="accounting-manager-theme-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/accounting-manager-theme/accounting-manager-theme"> <property name="java-output-path" value="/accounting-manager/target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes"/>
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/accounting-manager/target/accounting-manager-0.0.1-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="accounting-manager"/> <property name="context-root" value="accounting-manager"/>
</wb-module> </wb-module>
</project-modules> </project-modules>

View File

@ -1,7 +0,0 @@
<root>
<facet id="jst.jaxrs">
<node name="libprov">
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
</node>
</facet>
</root>

View File

@ -3,6 +3,5 @@
<fixed facet="wst.jsdt.web"/> <fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.7"/> <installed facet="java" version="1.7"/>
<installed facet="jst.web" version="2.3"/> <installed facet="jst.web" version="2.3"/>
<installed facet="jst.jaxrs" version="2.0"/>
<installed facet="wst.jsdt.web" version="1.0"/> <installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project> </faceted-project>

View File

@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.admin</groupId> <groupId>org.gcube.portlets.admin</groupId>
<artifactId>accounting-manager</artifactId> <artifactId>accounting-manager</artifactId>
<version>1.1.0-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
@ -225,7 +225,7 @@
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics</artifactId> <artifactId>accounting-analytics</artifactId>
<version>[1.1.0-SNAPSHOT,2.0.0-SNAPSHOT)</version> <version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<!-- Document Store Lib --> <!-- Document Store Lib -->
@ -240,7 +240,7 @@
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics-persistence-couchdb</artifactId> <artifactId>accounting-analytics-persistence-couchdb</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version> <version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<!-- LOGGING --> <!-- LOGGING -->

View File

@ -9,7 +9,6 @@ import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerService; import org.gcube.portlets.admin.accountingmanager.client.rpc.AccountingManagerService;
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCaller; import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCaller;
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCallerInterface; import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCallerInterface;
import org.gcube.portlets.admin.accountingmanager.server.amservice.AccountingCallerTester;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
@ -89,7 +88,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
try { try {
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session); SessionUtil.getAslSession(session);
AccountingCallerInterface accountingCaller = new AccountingCallerTester(); AccountingCallerInterface accountingCaller = new AccountingCaller();
SeriesResponse seriesResponse = accountingCaller.getSeries( SeriesResponse seriesResponse = accountingCaller.getSeries(
accountingType, seriesRequest); accountingType, seriesRequest);
@ -117,7 +116,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session); SessionUtil.getAslSession(session);
AccountingCallerInterface accountingCaller = new AccountingCallerTester(); AccountingCallerInterface accountingCaller = new AccountingCaller();
ArrayList<FilterKey> filterKeys = accountingCaller.getFilterKeys(accountingType); ArrayList<FilterKey> filterKeys = accountingCaller.getFilterKeys(accountingType);
return filterKeys; return filterKeys;
@ -145,7 +144,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session); SessionUtil.getAslSession(session);
AccountingCallerInterface accountingCaller = new AccountingCallerTester(); AccountingCallerInterface accountingCaller = new AccountingCaller();
ArrayList<FilterValue> filterValues = accountingCaller.getFilterValues(filterValuesRequest); ArrayList<FilterValue> filterValues = accountingCaller.getFilterValues(filterValuesRequest);
return filterValues; return filterValues;

View File

@ -8,7 +8,6 @@ import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager; import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.admin.accountingmanager.shared.Constants;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerSessionExpiredException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -30,9 +29,9 @@ public class SessionUtil {
ASLSession session; ASLSession session;
if (username == null) { if (username == null) {
logger.warn("no user found in session, use test user"); logger.warn("no user found in session, use test user");
/*throw new AccountingManagerSessionExpiredException("Session Expired!");*/ throw new AccountingManagerSessionExpiredException("Session Expired!");
/*
// Remove comment for Test // Remove comment for Test
username = Constants.DEFAULT_USER; username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE; String scope = Constants.DEFAULT_SCOPE;
@ -41,7 +40,7 @@ public class SessionUtil {
session = SessionManager.getInstance().getASLSession( session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username); httpSession.getId(), username);
session.setScope(scope); session.setScope(scope);
*/
} else { } else {
session = SessionManager.getInstance().getASLSession( session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username); httpSession.getId(), username);

View File

@ -82,7 +82,7 @@ public class AccountingCaller implements AccountingCallerInterface {
return accountingCommandBasic.execute(); return accountingCommandBasic.execute();
case Top: case Top:
AccountingQueryTop accountingQueryTop = (AccountingQueryTop) query; AccountingQueryTop accountingQueryTop = (AccountingQueryTop) query;
AccountingCommandTop accountingCommandTop=new AccountingCommandTop(accountingQueryTop,accountingType, seriesRequest); AccountingCommandTop accountingCommandTop=new AccountingCommandTop(accountingQueryTop,accountingType);
return accountingCommandTop.execute(); return accountingCommandTop.execute();
default: default:
throw new AccountingManagerServiceException( throw new AccountingManagerServiceException(

View File

@ -1,9 +1,13 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.command; package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.ResourceRecordQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBasic; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4JobBasic; import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4JobBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4PortletBasic; import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4PortletBasic;
@ -39,14 +43,19 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
@Override @Override
public SeriesResponse execute() throws AccountingManagerServiceException { public SeriesResponse execute() throws AccountingManagerServiceException {
try { try {
ResourceRecordQuery rrq = new ResourceRecordQuery(); AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
List<Info> infos = rrq.getInfo(accountingQueryBasic.getType(), SortedMap<Calendar, Info> sm = apq.getTimeSeries(
accountingQueryBasic.getTemporalConstraint(), accountingQueryBasic.getFilters(), true); accountingQueryBasic.getType(),
if (infos == null) { accountingQueryBasic.getTemporalConstraint(),
accountingQueryBasic.getFilters(), true);
if (sm == null || sm.values()==null) {
throw new AccountingManagerServiceException( throw new AccountingManagerServiceException(
"Error retrieving list of info: list is null!"); "Error retrieving info: sorted map is null!");
} }
List<Info> infos = new ArrayList<>(sm.values());
logger.debug("Retrieved Infos"); logger.debug("Retrieved Infos");
logger.debug("Infos: " + infos); logger.debug("Infos: " + infos);

View File

@ -1,9 +1,9 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.command; package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.SortedSet;
import org.gcube.accounting.analytics.ResourceRecordQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
@ -38,22 +38,21 @@ public class AccountingCommandGetFilterKeys implements AccountingCommand<ArrayLi
return new ArrayList<FilterKey>(); return new ArrayList<FilterKey>();
} }
ArrayList<FilterKey> filterKeys = new ArrayList<FilterKey>(); ArrayList<FilterKey> filterKeys = new ArrayList<FilterKey>();
List<String> keys; SortedSet<String> keys;
ResourceRecordQuery rrq = new ResourceRecordQuery();
switch (accountingType) { switch (accountingType) {
case JOB: case JOB:
keys = rrq.getKeys(AggregatedJobUsageRecord.class); keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedJobUsageRecord.class);
break; break;
case PORTLET: case PORTLET:
// keys=rrq.getKeys(AggregatedPortletUsageRecord.class); // keys=rrq.getKeys(AggregatedPortletUsageRecord.class);
return filterKeys; return filterKeys;
case SERVICE: case SERVICE:
keys = rrq.getKeys(AggregatedServiceUsageRecord.class); keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedServiceUsageRecord.class);
break; break;
case STORAGE: case STORAGE:
keys = rrq.getKeys(AggregatedStorageUsageRecord.class); keys =AccountingPersistenceQuery.getQuerableKeys(AggregatedStorageUsageRecord.class);
break; break;
case TASK: case TASK:
// keys=rrq.getKeys(AggregatedTaskUsageRecord.class); // keys=rrq.getKeys(AggregatedTaskUsageRecord.class);

View File

@ -1,9 +1,16 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.command; package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.Set;
import org.gcube.accounting.analytics.ResourceRecordQuery; import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.analytics.TemporalConstraint;
import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
@ -15,23 +22,26 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi email: <a
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class AccountingCommandGetFilterValues implements AccountingCommand<ArrayList<FilterValue>> { public class AccountingCommandGetFilterValues implements
private static final Logger logger = LoggerFactory.getLogger(AccountingCommandGetFilterValues.class); AccountingCommand<ArrayList<FilterValue>> {
private static final Logger logger = LoggerFactory
.getLogger(AccountingCommandGetFilterValues.class);
private FilterValuesRequest filterValuesRequest; private FilterValuesRequest filterValuesRequest;
public AccountingCommandGetFilterValues(FilterValuesRequest filterValuesRequest){ public AccountingCommandGetFilterValues(
this.filterValuesRequest=filterValuesRequest; FilterValuesRequest filterValuesRequest) {
this.filterValuesRequest = filterValuesRequest;
} }
@Override @Override
public ArrayList<FilterValue> execute() throws AccountingManagerServiceException { public ArrayList<FilterValue> execute()
throws AccountingManagerServiceException {
try { try {
logger.debug("getFilterValue(): [FilterValueRequest=" logger.debug("getFilterValue(): [FilterValueRequest="
+ filterValuesRequest + "]"); + filterValuesRequest + "]");
@ -42,30 +52,45 @@ public class AccountingCommandGetFilterValues implements AccountingCommand<Array
} }
ArrayList<FilterValue> filteValues = new ArrayList<FilterValue>(); ArrayList<FilterValue> filteValues = new ArrayList<FilterValue>();
List<String> values;
ResourceRecordQuery rrq = new ResourceRecordQuery();
Set<NumberedFilter> values;
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory
.getInstance();
GregorianCalendar startDate = new GregorianCalendar();
GregorianCalendar endDate = new GregorianCalendar();
endDate.add(GregorianCalendar.YEAR, -3);
TemporalConstraint tc = new TemporalConstraint(
startDate.getTimeInMillis(), endDate.getTimeInMillis(),
AggregationMode.YEARLY);
List<Filter> filters = new ArrayList<>();
Filter filterForValue = new Filter(filterValuesRequest
.getFilterKey().getKey(), null);
filters.add(filterForValue);
switch (filterValuesRequest.getAccountingType()) { switch (filterValuesRequest.getAccountingType()) {
case JOB: case JOB:
values = rrq.getPossibleValuesForKey( values = apq.getNextPossibleValues(
AggregatedJobUsageRecord.class, filterValuesRequest AggregatedJobUsageRecord.class, tc, filters);
.getFilterKey().getKey()); break;
return filteValues;
case PORTLET: case PORTLET:
// values = rrq.getPossibleValuesForKey( // values = rrq.getPossibleValuesForKey(
// AggregatedPortletUsageRecord.class, filterValuesRequest // AggregatedPortletUsageRecord.class, filterValuesRequest
// .getFilterKey().getKey()); // .getFilterKey().getKey());
return filteValues; return filteValues;
case SERVICE: case SERVICE:
values = rrq.getPossibleValuesForKey( values = apq.getNextPossibleValues(
AggregatedServiceUsageRecord.class, filterValuesRequest AggregatedServiceUsageRecord.class, tc, filters);
.getFilterKey().getKey());
break; break;
case STORAGE: case STORAGE:
values = rrq.getPossibleValuesForKey( values = apq.getNextPossibleValues(
AggregatedStorageUsageRecord.class, filterValuesRequest AggregatedStorageUsageRecord.class, tc, filters);
.getFilterKey().getKey());
break; break;
case TASK: case TASK:
// values = rrq.getPossibleValuesForKey( // values = rrq.getPossibleValuesForKey(
@ -75,9 +100,12 @@ public class AccountingCommandGetFilterValues implements AccountingCommand<Array
default: default:
return filteValues; return filteValues;
} }
for (String value : values) {
if (value != null && !value.isEmpty()) {
filteValues.add(new FilterValue(value));
for (NumberedFilter value : values) {
if (value != null) {
filteValues.add(new FilterValue(value.getValue()));
} }
} }

View File

@ -1,23 +1,23 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.command; package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
import java.util.List; import java.util.ArrayList;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Filter;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.ResourceRecordQuery; import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.query.AccountingQueryTop;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4JobBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4JobTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4JobTop;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4PortletBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4PortletTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4PortletTop;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4ServiceBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4ServiceTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4ServiceTop;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4StorageBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4StorageTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4StorageTop;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4TaskBasic;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4TaskTop; import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4TaskTop;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseBuilder; import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseBuilder;
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponseDirector;
import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType; import org.gcube.portlets.admin.accountingmanager.shared.data.AccountingType;
import org.gcube.portlets.admin.accountingmanager.shared.data.query.SeriesRequest;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -25,42 +25,51 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi email: <a
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class AccountingCommandTop implements AccountingCommand<SeriesResponse> { public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
private static final Logger logger = LoggerFactory.getLogger(AccountingCommandTop.class); private static final Logger logger = LoggerFactory
.getLogger(AccountingCommandTop.class);
private AccountingQueryTop accountingQueryTop; private AccountingQueryTop accountingQueryTop;
private AccountingType accountingType; private AccountingType accountingType;
private SeriesRequest seriesRequest;
public AccountingCommandTop(AccountingQueryTop accountingQueryTop, AccountingType accountingType, SeriesRequest seriesRequest){
this.accountingQueryTop=accountingQueryTop; public AccountingCommandTop(AccountingQueryTop accountingQueryTop,
this.accountingType=accountingType; AccountingType accountingType) {
this.seriesRequest=seriesRequest; this.accountingQueryTop = accountingQueryTop;
this.accountingType = accountingType;
} }
@Override @Override
public SeriesResponse execute() throws AccountingManagerServiceException { public SeriesResponse execute() throws AccountingManagerServiceException {
try { try {
ResourceRecordQuery rrq = new ResourceRecordQuery(); AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory
.getInstance();
/* ArrayList<Filter> filters = new ArrayList<>(
List<Info> infos = rrq.getInfo(accountingQueryBasic.getType(), accountingQueryTop.getFilters());
accountingQueryBasic.getTemporalConstraint(), accountingQueryBasic.getFilters(), true); Filter filterKey = new Filter(accountingQueryTop.getFilterKey()
if (infos == null) { .getKey(), null);
filters.add(filterKey);
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM = apq
.getTopValues(accountingQueryTop.getType(),
accountingQueryTop.getTemporalConstraint(),
filters, null, true,
accountingQueryTop.getTopNumber());
if (topSM == null) {
throw new AccountingManagerServiceException( throw new AccountingManagerServiceException(
"Error retrieving list of info: list is null!"); "Error retrieving info for top: sorted map is null!");
} }
logger.debug("Retrieved Infos");
logger.debug("Infos: " + infos);
*/
/*SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder(
accountingType, infos); SeriesResponseBuilder seriesResponseBuilder = getSeriesResponseBuilder(
accountingType, topSM);
SeriesResponseDirector seriesResponseDirector = new SeriesResponseDirector(); SeriesResponseDirector seriesResponseDirector = new SeriesResponseDirector();
seriesResponseDirector seriesResponseDirector
@ -75,10 +84,10 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
} }
logger.debug("SeriesResponse Created: " + seriesResponse); logger.debug("SeriesResponse Created: " + seriesResponse);
return seriesResponse; return seriesResponse;
*/
return null;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error in AccountingCommandTop(): " + e.getLocalizedMessage()); logger.error("Error in AccountingCommandTop(): "
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new AccountingManagerServiceException("No data available!"); throw new AccountingManagerServiceException("No data available!");
@ -86,7 +95,7 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
} }
private SeriesResponseBuilder getSeriesResponseBuilder( private SeriesResponseBuilder getSeriesResponseBuilder(
AccountingType accountingType, List<Info> infos) AccountingType accountingType, SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM)
throws AccountingManagerServiceException { throws AccountingManagerServiceException {
if (accountingType == null) { if (accountingType == null) {
throw new AccountingManagerServiceException( throw new AccountingManagerServiceException(
@ -95,15 +104,15 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
switch (accountingType) { switch (accountingType) {
case JOB: case JOB:
return new SeriesResponse4JobTop(infos); return new SeriesResponse4JobTop(topSM);
case PORTLET: case PORTLET:
return new SeriesResponse4PortletTop(infos); return new SeriesResponse4PortletTop(topSM);
case SERVICE: case SERVICE:
return new SeriesResponse4ServiceTop(infos); return new SeriesResponse4ServiceTop(topSM);
case STORAGE: case STORAGE:
return new SeriesResponse4StorageTop(infos); return new SeriesResponse4StorageTop(topSM);
case TASK: case TASK:
return new SeriesResponse4TaskTop(infos); return new SeriesResponse4TaskTop(topSM);
default: default:
throw new AccountingManagerServiceException( throw new AccountingManagerServiceException(
"Error request type is unknow!"); "Error request type is unknow!");
@ -111,5 +120,4 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
} }
} }
} }

View File

@ -15,14 +15,13 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.ChartType;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
@SuppressWarnings("rawtypes")
public class AccountingQueryBasic extends AccountingQuery { public class AccountingQueryBasic extends AccountingQuery {
private Class<? extends AggregatedUsageRecord> type; private Class<? extends AggregatedUsageRecord<?,?>> type;
private TemporalConstraint temporalConstraint; private TemporalConstraint temporalConstraint;
private ArrayList<Filter> filters; private ArrayList<Filter> filters;
public AccountingQueryBasic(Class<? extends AggregatedUsageRecord> type, public AccountingQueryBasic(Class<? extends AggregatedUsageRecord<?,?>> type,
TemporalConstraint temporalConstraint, ArrayList<Filter> filters) { TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
super(); super();
chartType=ChartType.Basic; chartType=ChartType.Basic;
@ -31,11 +30,11 @@ public class AccountingQueryBasic extends AccountingQuery {
this.filters = filters; this.filters = filters;
} }
public Class<? extends AggregatedUsageRecord> getType() { public Class<? extends AggregatedUsageRecord<?,?>> getType() {
return type; return type;
} }
public void setType(Class<? extends AggregatedUsageRecord> type) { public void setType(Class<? extends AggregatedUsageRecord<?,?>> type) {
this.type = type; this.type = type;
} }

View File

@ -14,15 +14,14 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.FilterKey;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
@SuppressWarnings("rawtypes")
public class AccountingQueryTop extends AccountingQuery { public class AccountingQueryTop extends AccountingQuery {
private Class<? extends AggregatedUsageRecord> type; private Class<? extends AggregatedUsageRecord<?,?>> type;
private FilterKey filterKey; private FilterKey filterKey;
private Integer topNumber; private Integer topNumber;
private TemporalConstraint temporalConstraint; private TemporalConstraint temporalConstraint;
private ArrayList<Filter> filters; private ArrayList<Filter> filters;
public AccountingQueryTop(Class<? extends AggregatedUsageRecord> type, public AccountingQueryTop(Class<? extends AggregatedUsageRecord<?,?>> type,
FilterKey filterKey, Integer topNumber, FilterKey filterKey, Integer topNumber,
TemporalConstraint temporalConstraint, ArrayList<Filter> filters) { TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
super(); super();
@ -34,11 +33,11 @@ public class AccountingQueryTop extends AccountingQuery {
this.topNumber = topNumber; this.topNumber = topNumber;
} }
public Class<? extends AggregatedUsageRecord> getType() { public Class<? extends AggregatedUsageRecord<?,?>> getType() {
return type; return type;
} }
public void setType(Class<? extends AggregatedUsageRecord> type) { public void setType(Class<? extends AggregatedUsageRecord<?,?>> type) {
this.type = type; this.type = type;
} }

View File

@ -1,20 +1,24 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response; package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Series Response 4 Job Basic * Top Series Response 4 Job
* *
* @author "Giancarlo Panichi" email: <a * @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
@ -23,44 +27,61 @@ import org.slf4j.LoggerFactory;
public class SeriesResponse4JobTop extends SeriesResponseBuilder { public class SeriesResponse4JobTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4JobTop.class); .getLogger(SeriesResponse4JobTop.class);
private List<Info> infos; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4JobTop(List<Info> infos) { public SeriesResponse4JobTop(
this.infos=infos; SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.topSM = topSM;
} }
@Override @Override
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
try { try {
if(infos.size()<=0){ if (topSM == null || topSM.isEmpty()) {
logger.error("Error creating series for job accounting: No data available!"); logger.error("Error creating series for job accounting: No data available!");
throw new AccountingManagerServiceException("No data available!"); throw new AccountingManagerServiceException(
"No data available!");
} }
ArrayList<SeriesJobData> series=new ArrayList<SeriesJobData>(); ArrayList<SeriesJobDataTop> seriesJobDataTopList = new ArrayList<>();
for (Info info : infos) {
for (NumberedFilter topValue : topSM.keySet()) {
ArrayList<SeriesJobData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue(); JSONObject jso = info.getValue();
//Long duration = jso.getLong(AggregatedJobUsageRecord.DURATION); // Long duration =
// jso.getLong(AggregatedJobUsageRecord.DURATION);
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedJobUsageRecord.OPERATION_COUNT); .getLong(AggregatedJobUsageRecord.OPERATION_COUNT);
//Long maxInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); // Long maxInvocationTime =
//Long minInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); // jso.getLong(AggregatedJobUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime =
// jso.getLong(AggregatedJobUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesJobData(info.getCalendar().getTime(), series.add(new SeriesJobData(info.getCalendar().getTime(),
operationCount, operationCount, operationCount, operationCount, operationCount, operationCount,
operationCount)); operationCount));
}
SeriesJobDataTop seriesJobDataTop = new SeriesJobDataTop(
new FilterValue(topValue.getValue()), series);
seriesJobDataTopList.add(seriesJobDataTop);
} }
SeriesJobBasic seriesJobBasic=new SeriesJobBasic(series); SeriesJobTop seriesJobTop = new SeriesJobTop(seriesJobDataTopList);
SeriesJob seriesJob = new SeriesJob(seriesJobTop);
SeriesJob seriesJob = new SeriesJob(seriesJobBasic);
seriesResponseSpec.setSr(seriesJob); seriesResponseSpec.setSr(seriesJob);
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error creating series for job accounting basic chart: "+e.getLocalizedMessage()); logger.error("Error creating series for job accounting top chart: "
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new AccountingManagerServiceException("Error creating series for job accounting basic chart: "+e.getLocalizedMessage()); throw new AccountingManagerServiceException(
"Error creating series for job accounting top chart: "
+ e.getLocalizedMessage());
} }
} }

View File

@ -1,15 +1,24 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response; package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.List; import java.util.ArrayList;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedPortletUsageRecord;
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.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Series Response 4 Portlet Basic * Top Series Response 4 Portlet
* *
* @author "Giancarlo Panichi" email: <a * @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
@ -19,25 +28,59 @@ public class SeriesResponse4PortletTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4PortletTop.class); .getLogger(SeriesResponse4PortletTop.class);
private List<Info> infos; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4PortletTop(List<Info> infos) { public SeriesResponse4PortletTop(SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.infos=infos; this.topSM=topSM;
} }
@Override @Override
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
if(infos.size()<=0){ try {
if (topSM == null || topSM.isEmpty()) {
logger.error("Error creating series for portlet accounting: No data available!"); logger.error("Error creating series for portlet accounting: No data available!");
throw new AccountingManagerServiceException("No data available!"); throw new AccountingManagerServiceException(
"No data available!");
} }
//SeriesPortletBasic seriesPortletBasic=new SeriesPortletBasic(series); ArrayList<SeriesPortletDataTop> seriesPortletDataTopList = new ArrayList<>();
//SeriesPortlet seriesPortlet = new SeriesPortlet(seriesPortletBasic);
SeriesResponse seriesResponse = new SeriesResponse(); for (NumberedFilter topValue : topSM.keySet()) {
seriesResponseSpec.setSr(seriesResponse); ArrayList<SeriesPortletData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
// Long duration =
// jso.getLong(AggregatedPortletUsageRecord.DURATION);
Long operationCount = jso
.getLong(AggregatedPortletUsageRecord.OPERATION_COUNT);
// Long maxInvocationTime =
// jso.getLong(AggregatedPortletUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime =
// jso.getLong(AggregatedPortletUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesPortletData(info.getCalendar().getTime(),
operationCount));
}
SeriesPortletDataTop seriesPortletDataTop = new SeriesPortletDataTop(
new FilterValue(topValue.getValue()), series);
seriesPortletDataTopList.add(seriesPortletDataTop);
}
SeriesPortletTop seriesPortletTop = new SeriesPortletTop(seriesPortletDataTopList);
SeriesPortlet seriesPortlet = new SeriesPortlet(seriesPortletTop);
seriesResponseSpec.setSr(seriesPortlet);
} catch (Throwable e) {
logger.error("Error creating series for portlet accounting top chart: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new AccountingManagerServiceException(
"Error creating series for portlet accounting top chart: "
+ e.getLocalizedMessage());
}
} }
} }

View File

@ -1,20 +1,24 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response; package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesService;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceBasic;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData; import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceData;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceDataTop;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.service.SeriesServiceTop;
import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Series Response 4 Service Basic * Top Series Response 4 Service
* *
* @author "Giancarlo Panichi" email: <a * @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
@ -23,42 +27,63 @@ import org.slf4j.LoggerFactory;
public class SeriesResponse4ServiceTop extends SeriesResponseBuilder { public class SeriesResponse4ServiceTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4ServiceTop.class); .getLogger(SeriesResponse4ServiceTop.class);
private List<Info> infos; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4ServiceTop(List<Info> infos) { public SeriesResponse4ServiceTop(
this.infos=infos; SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.topSM = topSM;
} }
@Override @Override
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
try { try {
if(infos.size()<=0){ if (topSM == null || topSM.isEmpty()) {
logger.error("Error creating series for service accounting: No data available!"); logger.error("Error creating series for service accounting: No data available!");
throw new AccountingManagerServiceException("No data available!"); throw new AccountingManagerServiceException(
"No data available!");
} }
ArrayList<SeriesServiceData> series=new ArrayList<SeriesServiceData>(); ArrayList<SeriesServiceDataTop> seriesServiceDataTopList = new ArrayList<>();
for (Info info : infos) {
for (NumberedFilter topValue : topSM.keySet()) {
ArrayList<SeriesServiceData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue(); JSONObject jso = info.getValue();
Long duration = jso.getLong(AggregatedServiceUsageRecord.DURATION); Long duration = jso
.getLong(AggregatedServiceUsageRecord.DURATION);
Long operationCount = jso Long operationCount = jso
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT); .getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
Long maxInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME); Long maxInvocationTime = jso
Long minInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME); .getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
Long minInvocationTime = jso
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesServiceData(info.getCalendar().getTime(), operationCount, duration, maxInvocationTime, minInvocationTime)); series.add(new SeriesServiceData(info.getCalendar()
.getTime(), operationCount, duration,
maxInvocationTime, minInvocationTime));
}
SeriesServiceDataTop seriesServiceDataTop = new SeriesServiceDataTop(
new FilterValue(topValue.getValue()), series);
seriesServiceDataTopList.add(seriesServiceDataTop);
} }
SeriesServiceBasic seriesServiceBasic=new SeriesServiceBasic(series); SeriesServiceTop seriesServiceTop = new SeriesServiceTop(
seriesServiceDataTopList);
SeriesService seriesService = new SeriesService(seriesServiceBasic); SeriesService seriesService = new SeriesService(seriesServiceTop);
seriesResponseSpec.setSr(seriesService); seriesResponseSpec.setSr(seriesService);
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error creating series for service accounting chart basic: "+e.getLocalizedMessage()); logger.error("Error creating series for service accounting top chart: "
+ e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new AccountingManagerServiceException("Error creating series for service accounting chart basic: "+e.getLocalizedMessage()); throw new AccountingManagerServiceException(
"Error creating series for service accounting top chart: "
+ e.getLocalizedMessage());
} }
} }

View File

@ -1,9 +1,11 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response; package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.accounting.analytics.NumberedFilter;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue; import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage; import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
@ -16,7 +18,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Series Response 4 Storage Top * Top Series Response 4 Storage
* *
* @author "Giancarlo Panichi" email: <a * @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
@ -25,22 +27,27 @@ import org.slf4j.LoggerFactory;
public class SeriesResponse4StorageTop extends SeriesResponseBuilder { public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4StorageTop.class); .getLogger(SeriesResponse4StorageTop.class);
private List<Info> infos; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4StorageTop(List<Info> infos) { public SeriesResponse4StorageTop(SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.infos = infos; this.topSM=topSM;
} }
@Override @Override
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
try { try {
if(infos.size()<=0){ if(topSM==null||topSM.isEmpty()){
logger.error("Error creating series for storage accounting: No data available!"); logger.error("Error creating series for storage accounting: No data available!");
throw new AccountingManagerServiceException("No data available!"); throw new AccountingManagerServiceException("No data available!");
} }
ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>(); ArrayList<SeriesStorageDataTop> seriesStorageDataTopList=new ArrayList<>();
for (Info info : infos) {
for(NumberedFilter topValue:topSM.keySet()){
ArrayList<SeriesStorageData> series=new ArrayList<>();
SortedMap<Calendar, Info> infos=topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue(); JSONObject jso = info.getValue();
Long dataVolume = jso.getLong(AggregatedStorageUsageRecord.DATA_VOLUME); Long dataVolume = jso.getLong(AggregatedStorageUsageRecord.DATA_VOLUME);
Long operationCount = jso Long operationCount = jso
@ -48,10 +55,12 @@ public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
series.add(new SeriesStorageData(info.getCalendar().getTime(), dataVolume, operationCount)); series.add(new SeriesStorageData(info.getCalendar().getTime(), dataVolume, operationCount));
} }
SeriesStorageDataTop seriesStorageDataTop=new SeriesStorageDataTop(
ArrayList<SeriesStorageDataTop> seriesStorageDataTopList=new ArrayList<>(); new FilterValue(topValue.getValue()), series);
SeriesStorageDataTop seriesStorageDataTop=new SeriesStorageDataTop(new FilterValue("giancarlo.panichi"), series);
seriesStorageDataTopList.add(seriesStorageDataTop); seriesStorageDataTopList.add(seriesStorageDataTop);
}
SeriesStorageTop seriesStorageTop=new SeriesStorageTop(seriesStorageDataTopList); SeriesStorageTop seriesStorageTop=new SeriesStorageTop(seriesStorageDataTopList);
SeriesStorage seriesStorage = new SeriesStorage(seriesStorageTop); SeriesStorage seriesStorage = new SeriesStorage(seriesStorageTop);

View File

@ -1,15 +1,24 @@
package org.gcube.portlets.admin.accountingmanager.server.amservice.response; package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
import java.util.List; import java.util.ArrayList;
import java.util.Calendar;
import java.util.SortedMap;
import org.gcube.accounting.analytics.Info; import org.gcube.accounting.analytics.Info;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesResponse; import org.gcube.accounting.analytics.NumberedFilter;
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;
import org.gcube.portlets.admin.accountingmanager.shared.data.response.task.SeriesTaskData;
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.AccountingManagerServiceException; import org.gcube.portlets.admin.accountingmanager.shared.exception.AccountingManagerServiceException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Series Response 4 Task Basic * Top Series Response 4 Task
* *
* @author "Giancarlo Panichi" email: <a * @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
@ -18,25 +27,59 @@ import org.slf4j.LoggerFactory;
public class SeriesResponse4TaskTop extends SeriesResponseBuilder { public class SeriesResponse4TaskTop extends SeriesResponseBuilder {
protected static Logger logger = LoggerFactory protected static Logger logger = LoggerFactory
.getLogger(SeriesResponse4TaskTop.class); .getLogger(SeriesResponse4TaskTop.class);
private List<Info> infos; private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
public SeriesResponse4TaskTop(List<Info> infos) { public SeriesResponse4TaskTop(SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
this.infos=infos; this.topSM=topSM;
} }
@Override @Override
public void buildSeriesResponse() throws AccountingManagerServiceException { public void buildSeriesResponse() throws AccountingManagerServiceException {
if(infos.size()<=0){ try {
if (topSM == null || topSM.isEmpty()) {
logger.error("Error creating series for task accounting: No data available!"); logger.error("Error creating series for task accounting: No data available!");
throw new AccountingManagerServiceException("No data available!"); throw new AccountingManagerServiceException(
"No data available!");
} }
//SeriesTaskBasic seriesTaskBasic=new SeriesTaskBasic(series); ArrayList<SeriesTaskDataTop> seriesTaskDataTopList = new ArrayList<>();
//SeriesTask seriesTask = new SeriesTask(seriesTaskBasic);
SeriesResponse seriesResponse = new SeriesResponse(); for (NumberedFilter topValue : topSM.keySet()) {
seriesResponseSpec.setSr(seriesResponse); ArrayList<SeriesTaskData> series = new ArrayList<>();
SortedMap<Calendar, Info> infos = topSM.get(topValue);
for (Info info : infos.values()) {
JSONObject jso = info.getValue();
// Long duration =
// jso.getLong(AggregatedTaskUsageRecord.DURATION);
Long operationCount = jso
.getLong(AggregatedTaskUsageRecord.OPERATION_COUNT);
// Long maxInvocationTime =
// jso.getLong(AggregatedTaskUsageRecord.MAX_INVOCATION_TIME);
// Long minInvocationTime =
// jso.getLong(AggregatedTaskUsageRecord.MIN_INVOCATION_TIME);
series.add(new SeriesTaskData(info.getCalendar().getTime(),
operationCount));
}
SeriesTaskDataTop seriesTaskDataTop = new SeriesTaskDataTop(
new FilterValue(topValue.getValue()), series);
seriesTaskDataTopList.add(seriesTaskDataTop);
}
SeriesTaskTop seriesTaskTop = new SeriesTaskTop(seriesTaskDataTopList);
SeriesTask seriesTask = new SeriesTask(seriesTaskTop);
seriesResponseSpec.setSr(seriesTask);
} catch (Throwable e) {
logger.error("Error creating series for portlet accounting top chart: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new AccountingManagerServiceException(
"Error creating series for portlet accounting top chart: "
+ e.getLocalizedMessage());
}
} }
} }