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:
parent
1f2d359c68
commit
8e3895183f
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</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>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -45,5 +45,5 @@
|
|||
</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-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>
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
<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/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">
|
||||
<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="java-output-path" value="/accounting-manager/target/accounting-manager-1.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<property name="context-root" value="accounting-manager"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
|
|
@ -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>
|
|
@ -3,6 +3,5 @@
|
|||
<fixed facet="wst.jsdt.web"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
<installed facet="jst.web" version="2.3"/>
|
||||
<installed facet="jst.jaxrs" version="2.0"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
</faceted-project>
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.admin</groupId>
|
||||
<artifactId>accounting-manager</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
||||
|
@ -225,7 +225,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<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>
|
||||
|
||||
<!-- Document Store Lib -->
|
||||
|
@ -240,7 +240,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<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>
|
||||
|
||||
<!-- LOGGING -->
|
||||
|
|
|
@ -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.server.amservice.AccountingCaller;
|
||||
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.FilterKey;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
||||
|
@ -89,7 +88,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
AccountingCallerInterface accountingCaller = new AccountingCallerTester();
|
||||
AccountingCallerInterface accountingCaller = new AccountingCaller();
|
||||
SeriesResponse seriesResponse = accountingCaller.getSeries(
|
||||
accountingType, seriesRequest);
|
||||
|
||||
|
@ -117,7 +116,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
|
||||
AccountingCallerInterface accountingCaller = new AccountingCallerTester();
|
||||
AccountingCallerInterface accountingCaller = new AccountingCaller();
|
||||
ArrayList<FilterKey> filterKeys = accountingCaller.getFilterKeys(accountingType);
|
||||
|
||||
return filterKeys;
|
||||
|
@ -145,7 +144,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
|
||||
AccountingCallerInterface accountingCaller = new AccountingCallerTester();
|
||||
AccountingCallerInterface accountingCaller = new AccountingCaller();
|
||||
ArrayList<FilterValue> filterValues = accountingCaller.getFilterValues(filterValuesRequest);
|
||||
|
||||
return filterValues;
|
||||
|
|
|
@ -8,7 +8,6 @@ import javax.servlet.http.HttpSession;
|
|||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -30,9 +29,9 @@ public class SessionUtil {
|
|||
ASLSession session;
|
||||
if (username == null) {
|
||||
logger.warn("no user found in session, use test user");
|
||||
/*throw new AccountingManagerSessionExpiredException("Session Expired!");*/
|
||||
|
||||
throw new AccountingManagerSessionExpiredException("Session Expired!");
|
||||
|
||||
/*
|
||||
// Remove comment for Test
|
||||
username = Constants.DEFAULT_USER;
|
||||
String scope = Constants.DEFAULT_SCOPE;
|
||||
|
@ -41,7 +40,7 @@ public class SessionUtil {
|
|||
session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
session.setScope(scope);
|
||||
|
||||
*/
|
||||
} else {
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
|
|
|
@ -82,7 +82,7 @@ public class AccountingCaller implements AccountingCallerInterface {
|
|||
return accountingCommandBasic.execute();
|
||||
case Top:
|
||||
AccountingQueryTop accountingQueryTop = (AccountingQueryTop) query;
|
||||
AccountingCommandTop accountingCommandTop=new AccountingCommandTop(accountingQueryTop,accountingType, seriesRequest);
|
||||
AccountingCommandTop accountingCommandTop=new AccountingCommandTop(accountingQueryTop,accountingType);
|
||||
return accountingCommandTop.execute();
|
||||
default:
|
||||
throw new AccountingManagerServiceException(
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
|
||||
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.response.SeriesResponse4JobBasic;
|
||||
import org.gcube.portlets.admin.accountingmanager.server.amservice.response.SeriesResponse4PortletBasic;
|
||||
|
@ -39,14 +43,19 @@ public class AccountingCommandBasic implements AccountingCommand<SeriesResponse>
|
|||
@Override
|
||||
public SeriesResponse execute() throws AccountingManagerServiceException {
|
||||
try {
|
||||
ResourceRecordQuery rrq = new ResourceRecordQuery();
|
||||
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
|
||||
|
||||
List<Info> infos = rrq.getInfo(accountingQueryBasic.getType(),
|
||||
accountingQueryBasic.getTemporalConstraint(), accountingQueryBasic.getFilters(), true);
|
||||
if (infos == null) {
|
||||
SortedMap<Calendar, Info> sm = apq.getTimeSeries(
|
||||
accountingQueryBasic.getType(),
|
||||
accountingQueryBasic.getTemporalConstraint(),
|
||||
accountingQueryBasic.getFilters(), true);
|
||||
|
||||
if (sm == null || sm.values()==null) {
|
||||
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("Infos: " + infos);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
|
||||
|
||||
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.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||
|
@ -38,22 +38,21 @@ public class AccountingCommandGetFilterKeys implements AccountingCommand<ArrayLi
|
|||
return new ArrayList<FilterKey>();
|
||||
}
|
||||
ArrayList<FilterKey> filterKeys = new ArrayList<FilterKey>();
|
||||
List<String> keys;
|
||||
SortedSet<String> keys;
|
||||
|
||||
ResourceRecordQuery rrq = new ResourceRecordQuery();
|
||||
|
||||
switch (accountingType) {
|
||||
case JOB:
|
||||
keys = rrq.getKeys(AggregatedJobUsageRecord.class);
|
||||
keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedJobUsageRecord.class);
|
||||
break;
|
||||
case PORTLET:
|
||||
// keys=rrq.getKeys(AggregatedPortletUsageRecord.class);
|
||||
return filterKeys;
|
||||
case SERVICE:
|
||||
keys = rrq.getKeys(AggregatedServiceUsageRecord.class);
|
||||
keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedServiceUsageRecord.class);
|
||||
break;
|
||||
case STORAGE:
|
||||
keys = rrq.getKeys(AggregatedStorageUsageRecord.class);
|
||||
keys =AccountingPersistenceQuery.getQuerableKeys(AggregatedStorageUsageRecord.class);
|
||||
break;
|
||||
case TASK:
|
||||
// keys=rrq.getKeys(AggregatedTaskUsageRecord.class);
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
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.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||
|
@ -15,23 +22,26 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class AccountingCommandGetFilterValues implements AccountingCommand<ArrayList<FilterValue>> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AccountingCommandGetFilterValues.class);
|
||||
public class AccountingCommandGetFilterValues implements
|
||||
AccountingCommand<ArrayList<FilterValue>> {
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(AccountingCommandGetFilterValues.class);
|
||||
|
||||
private FilterValuesRequest filterValuesRequest;
|
||||
|
||||
public AccountingCommandGetFilterValues(FilterValuesRequest filterValuesRequest){
|
||||
public AccountingCommandGetFilterValues(
|
||||
FilterValuesRequest filterValuesRequest) {
|
||||
this.filterValuesRequest = filterValuesRequest;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<FilterValue> execute() throws AccountingManagerServiceException {
|
||||
public ArrayList<FilterValue> execute()
|
||||
throws AccountingManagerServiceException {
|
||||
try {
|
||||
logger.debug("getFilterValue(): [FilterValueRequest="
|
||||
+ filterValuesRequest + "]");
|
||||
|
@ -42,30 +52,45 @@ public class AccountingCommandGetFilterValues implements AccountingCommand<Array
|
|||
}
|
||||
|
||||
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()) {
|
||||
case JOB:
|
||||
values = rrq.getPossibleValuesForKey(
|
||||
AggregatedJobUsageRecord.class, filterValuesRequest
|
||||
.getFilterKey().getKey());
|
||||
return filteValues;
|
||||
values = apq.getNextPossibleValues(
|
||||
AggregatedJobUsageRecord.class, tc, filters);
|
||||
break;
|
||||
case PORTLET:
|
||||
// values = rrq.getPossibleValuesForKey(
|
||||
// AggregatedPortletUsageRecord.class, filterValuesRequest
|
||||
// .getFilterKey().getKey());
|
||||
return filteValues;
|
||||
case SERVICE:
|
||||
values = rrq.getPossibleValuesForKey(
|
||||
AggregatedServiceUsageRecord.class, filterValuesRequest
|
||||
.getFilterKey().getKey());
|
||||
values = apq.getNextPossibleValues(
|
||||
AggregatedServiceUsageRecord.class, tc, filters);
|
||||
break;
|
||||
case STORAGE:
|
||||
values = rrq.getPossibleValuesForKey(
|
||||
AggregatedStorageUsageRecord.class, filterValuesRequest
|
||||
.getFilterKey().getKey());
|
||||
values = apq.getNextPossibleValues(
|
||||
AggregatedStorageUsageRecord.class, tc, filters);
|
||||
break;
|
||||
case TASK:
|
||||
// values = rrq.getPossibleValuesForKey(
|
||||
|
@ -75,9 +100,12 @@ public class AccountingCommandGetFilterValues implements AccountingCommand<Array
|
|||
default:
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
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.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.response.SeriesResponse4JobBasic;
|
||||
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.SeriesResponse4ServiceBasic;
|
||||
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.SeriesResponse4TaskBasic;
|
||||
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.SeriesResponseDirector;
|
||||
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.exception.AccountingManagerServiceException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -25,42 +25,51 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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 AccountingType accountingType;
|
||||
private SeriesRequest seriesRequest;
|
||||
|
||||
public AccountingCommandTop(AccountingQueryTop accountingQueryTop, AccountingType accountingType, SeriesRequest seriesRequest){
|
||||
|
||||
public AccountingCommandTop(AccountingQueryTop accountingQueryTop,
|
||||
AccountingType accountingType) {
|
||||
this.accountingQueryTop = accountingQueryTop;
|
||||
this.accountingType = accountingType;
|
||||
this.seriesRequest=seriesRequest;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SeriesResponse execute() throws AccountingManagerServiceException {
|
||||
try {
|
||||
ResourceRecordQuery rrq = new ResourceRecordQuery();
|
||||
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory
|
||||
.getInstance();
|
||||
|
||||
/*
|
||||
List<Info> infos = rrq.getInfo(accountingQueryBasic.getType(),
|
||||
accountingQueryBasic.getTemporalConstraint(), accountingQueryBasic.getFilters(), true);
|
||||
if (infos == null) {
|
||||
ArrayList<Filter> filters = new ArrayList<>(
|
||||
accountingQueryTop.getFilters());
|
||||
Filter filterKey = new Filter(accountingQueryTop.getFilterKey()
|
||||
.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(
|
||||
"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
|
||||
|
@ -75,10 +84,10 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
}
|
||||
logger.debug("SeriesResponse Created: " + seriesResponse);
|
||||
return seriesResponse;
|
||||
*/
|
||||
return null;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in AccountingCommandTop(): " + e.getLocalizedMessage());
|
||||
logger.error("Error in AccountingCommandTop(): "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
|
||||
|
@ -86,7 +95,7 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
}
|
||||
|
||||
private SeriesResponseBuilder getSeriesResponseBuilder(
|
||||
AccountingType accountingType, List<Info> infos)
|
||||
AccountingType accountingType, SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM)
|
||||
throws AccountingManagerServiceException {
|
||||
if (accountingType == null) {
|
||||
throw new AccountingManagerServiceException(
|
||||
|
@ -95,15 +104,15 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
|
||||
switch (accountingType) {
|
||||
case JOB:
|
||||
return new SeriesResponse4JobTop(infos);
|
||||
return new SeriesResponse4JobTop(topSM);
|
||||
case PORTLET:
|
||||
return new SeriesResponse4PortletTop(infos);
|
||||
return new SeriesResponse4PortletTop(topSM);
|
||||
case SERVICE:
|
||||
return new SeriesResponse4ServiceTop(infos);
|
||||
return new SeriesResponse4ServiceTop(topSM);
|
||||
case STORAGE:
|
||||
return new SeriesResponse4StorageTop(infos);
|
||||
return new SeriesResponse4StorageTop(topSM);
|
||||
case TASK:
|
||||
return new SeriesResponse4TaskTop(infos);
|
||||
return new SeriesResponse4TaskTop(topSM);
|
||||
default:
|
||||
throw new AccountingManagerServiceException(
|
||||
"Error request type is unknow!");
|
||||
|
@ -111,5 +120,4 @@ public class AccountingCommandTop implements AccountingCommand<SeriesResponse> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class AccountingQueryBasic extends AccountingQuery {
|
||||
private Class<? extends AggregatedUsageRecord> type;
|
||||
private Class<? extends AggregatedUsageRecord<?,?>> type;
|
||||
private TemporalConstraint temporalConstraint;
|
||||
private ArrayList<Filter> filters;
|
||||
|
||||
|
||||
public AccountingQueryBasic(Class<? extends AggregatedUsageRecord> type,
|
||||
public AccountingQueryBasic(Class<? extends AggregatedUsageRecord<?,?>> type,
|
||||
TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
|
||||
super();
|
||||
chartType=ChartType.Basic;
|
||||
|
@ -31,11 +30,11 @@ public class AccountingQueryBasic extends AccountingQuery {
|
|||
this.filters = filters;
|
||||
}
|
||||
|
||||
public Class<? extends AggregatedUsageRecord> getType() {
|
||||
public Class<? extends AggregatedUsageRecord<?,?>> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Class<? extends AggregatedUsageRecord> type) {
|
||||
public void setType(Class<? extends AggregatedUsageRecord<?,?>> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class AccountingQueryTop extends AccountingQuery {
|
||||
private Class<? extends AggregatedUsageRecord> type;
|
||||
private Class<? extends AggregatedUsageRecord<?,?>> type;
|
||||
private FilterKey filterKey;
|
||||
private Integer topNumber;
|
||||
private TemporalConstraint temporalConstraint;
|
||||
private ArrayList<Filter> filters;
|
||||
|
||||
public AccountingQueryTop(Class<? extends AggregatedUsageRecord> type,
|
||||
public AccountingQueryTop(Class<? extends AggregatedUsageRecord<?,?>> type,
|
||||
FilterKey filterKey, Integer topNumber,
|
||||
TemporalConstraint temporalConstraint, ArrayList<Filter> filters) {
|
||||
super();
|
||||
|
@ -34,11 +33,11 @@ public class AccountingQueryTop extends AccountingQuery {
|
|||
this.topNumber = topNumber;
|
||||
}
|
||||
|
||||
public Class<? extends AggregatedUsageRecord> getType() {
|
||||
public Class<? extends AggregatedUsageRecord<?,?>> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Class<? extends AggregatedUsageRecord> type) {
|
||||
public void setType(Class<? extends AggregatedUsageRecord<?,?>> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
|
||||
|
||||
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.NumberedFilter;
|
||||
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.job.SeriesJobBasic;
|
||||
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.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Series Response 4 Job Basic
|
||||
* Top Series Response 4 Job
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <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 {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(SeriesResponse4JobTop.class);
|
||||
private List<Info> infos;
|
||||
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
|
||||
|
||||
public SeriesResponse4JobTop(List<Info> infos) {
|
||||
this.infos=infos;
|
||||
public SeriesResponse4JobTop(
|
||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
|
||||
this.topSM = topSM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
try {
|
||||
if(infos.size()<=0){
|
||||
if (topSM == null || topSM.isEmpty()) {
|
||||
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>();
|
||||
for (Info info : infos) {
|
||||
ArrayList<SeriesJobDataTop> seriesJobDataTopList = new ArrayList<>();
|
||||
|
||||
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();
|
||||
//Long duration = jso.getLong(AggregatedJobUsageRecord.DURATION);
|
||||
// Long duration =
|
||||
// jso.getLong(AggregatedJobUsageRecord.DURATION);
|
||||
Long operationCount = jso
|
||||
.getLong(AggregatedJobUsageRecord.OPERATION_COUNT);
|
||||
//Long maxInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
|
||||
//Long minInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
|
||||
// Long maxInvocationTime =
|
||||
// jso.getLong(AggregatedJobUsageRecord.MAX_INVOCATION_TIME);
|
||||
// Long minInvocationTime =
|
||||
// jso.getLong(AggregatedJobUsageRecord.MIN_INVOCATION_TIME);
|
||||
|
||||
series.add(new SeriesJobData(info.getCalendar().getTime(),
|
||||
operationCount, operationCount, operationCount,
|
||||
operationCount));
|
||||
}
|
||||
SeriesJobDataTop seriesJobDataTop = new SeriesJobDataTop(
|
||||
new FilterValue(topValue.getValue()), series);
|
||||
seriesJobDataTopList.add(seriesJobDataTop);
|
||||
|
||||
}
|
||||
|
||||
SeriesJobBasic seriesJobBasic=new SeriesJobBasic(series);
|
||||
|
||||
SeriesJob seriesJob = new SeriesJob(seriesJobBasic);
|
||||
SeriesJobTop seriesJobTop = new SeriesJobTop(seriesJobDataTopList);
|
||||
SeriesJob seriesJob = new SeriesJob(seriesJobTop);
|
||||
|
||||
seriesResponseSpec.setSr(seriesJob);
|
||||
|
||||
} 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();
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
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.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.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Series Response 4 Portlet Basic
|
||||
* Top Series Response 4 Portlet
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <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
|
||||
.getLogger(SeriesResponse4PortletTop.class);
|
||||
|
||||
private List<Info> infos;
|
||||
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
|
||||
|
||||
public SeriesResponse4PortletTop(List<Info> infos) {
|
||||
this.infos=infos;
|
||||
public SeriesResponse4PortletTop(SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
|
||||
this.topSM=topSM;
|
||||
}
|
||||
|
||||
@Override
|
||||
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!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new AccountingManagerServiceException(
|
||||
"No data available!");
|
||||
}
|
||||
|
||||
//SeriesPortletBasic seriesPortletBasic=new SeriesPortletBasic(series);
|
||||
//SeriesPortlet seriesPortlet = new SeriesPortlet(seriesPortletBasic);
|
||||
ArrayList<SeriesPortletDataTop> seriesPortletDataTopList = new ArrayList<>();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
|
||||
|
||||
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.NumberedFilter;
|
||||
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.service.SeriesServiceBasic;
|
||||
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.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Series Response 4 Service Basic
|
||||
* Top Series Response 4 Service
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <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 {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(SeriesResponse4ServiceTop.class);
|
||||
private List<Info> infos;
|
||||
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
|
||||
|
||||
public SeriesResponse4ServiceTop(List<Info> infos) {
|
||||
this.infos=infos;
|
||||
public SeriesResponse4ServiceTop(
|
||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
|
||||
this.topSM = topSM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
try {
|
||||
if(infos.size()<=0){
|
||||
if (topSM == null || topSM.isEmpty()) {
|
||||
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>();
|
||||
for (Info info : infos) {
|
||||
ArrayList<SeriesServiceDataTop> seriesServiceDataTopList = new ArrayList<>();
|
||||
|
||||
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();
|
||||
Long duration = jso.getLong(AggregatedServiceUsageRecord.DURATION);
|
||||
Long duration = jso
|
||||
.getLong(AggregatedServiceUsageRecord.DURATION);
|
||||
Long operationCount = jso
|
||||
.getLong(AggregatedServiceUsageRecord.OPERATION_COUNT);
|
||||
Long maxInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
|
||||
Long minInvocationTime = jso.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
|
||||
Long maxInvocationTime = jso
|
||||
.getLong(AggregatedServiceUsageRecord.MAX_INVOCATION_TIME);
|
||||
Long minInvocationTime = jso
|
||||
.getLong(AggregatedServiceUsageRecord.MIN_INVOCATION_TIME);
|
||||
|
||||
series.add(new SeriesServiceData(info.getCalendar().getTime(), operationCount, duration, maxInvocationTime, minInvocationTime));
|
||||
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);
|
||||
|
||||
SeriesService seriesService = new SeriesService(seriesServiceBasic);
|
||||
SeriesServiceTop seriesServiceTop = new SeriesServiceTop(
|
||||
seriesServiceDataTopList);
|
||||
SeriesService seriesService = new SeriesService(seriesServiceTop);
|
||||
|
||||
seriesResponseSpec.setSr(seriesService);
|
||||
|
||||
} 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();
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package org.gcube.portlets.admin.accountingmanager.server.amservice.response;
|
||||
|
||||
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.NumberedFilter;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.FilterValue;
|
||||
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesStorage;
|
||||
|
@ -16,7 +18,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Series Response 4 Storage Top
|
||||
* Top Series Response 4 Storage
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <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 {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(SeriesResponse4StorageTop.class);
|
||||
private List<Info> infos;
|
||||
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
|
||||
|
||||
public SeriesResponse4StorageTop(List<Info> infos) {
|
||||
this.infos = infos;
|
||||
public SeriesResponse4StorageTop(SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
|
||||
this.topSM=topSM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildSeriesResponse() throws AccountingManagerServiceException {
|
||||
try {
|
||||
if(infos.size()<=0){
|
||||
if(topSM==null||topSM.isEmpty()){
|
||||
logger.error("Error creating series for storage accounting: No data available!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
}
|
||||
|
||||
ArrayList<SeriesStorageData> series=new ArrayList<SeriesStorageData>();
|
||||
for (Info info : infos) {
|
||||
ArrayList<SeriesStorageDataTop> seriesStorageDataTopList=new ArrayList<>();
|
||||
|
||||
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();
|
||||
Long dataVolume = jso.getLong(AggregatedStorageUsageRecord.DATA_VOLUME);
|
||||
Long operationCount = jso
|
||||
|
@ -48,10 +55,12 @@ public class SeriesResponse4StorageTop extends SeriesResponseBuilder {
|
|||
series.add(new SeriesStorageData(info.getCalendar().getTime(), dataVolume, operationCount));
|
||||
|
||||
}
|
||||
|
||||
ArrayList<SeriesStorageDataTop> seriesStorageDataTopList=new ArrayList<>();
|
||||
SeriesStorageDataTop seriesStorageDataTop=new SeriesStorageDataTop(new FilterValue("giancarlo.panichi"), series);
|
||||
SeriesStorageDataTop seriesStorageDataTop=new SeriesStorageDataTop(
|
||||
new FilterValue(topValue.getValue()), series);
|
||||
seriesStorageDataTopList.add(seriesStorageDataTop);
|
||||
|
||||
}
|
||||
|
||||
SeriesStorageTop seriesStorageTop=new SeriesStorageTop(seriesStorageDataTopList);
|
||||
SeriesStorage seriesStorage = new SeriesStorage(seriesStorageTop);
|
||||
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
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.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.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Series Response 4 Task Basic
|
||||
* Top Series Response 4 Task
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <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 {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(SeriesResponse4TaskTop.class);
|
||||
private List<Info> infos;
|
||||
private SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM;
|
||||
|
||||
public SeriesResponse4TaskTop(List<Info> infos) {
|
||||
this.infos=infos;
|
||||
public SeriesResponse4TaskTop(SortedMap<NumberedFilter, SortedMap<Calendar, Info>> topSM) {
|
||||
this.topSM=topSM;
|
||||
}
|
||||
|
||||
@Override
|
||||
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!");
|
||||
throw new AccountingManagerServiceException("No data available!");
|
||||
throw new AccountingManagerServiceException(
|
||||
"No data available!");
|
||||
}
|
||||
|
||||
//SeriesTaskBasic seriesTaskBasic=new SeriesTaskBasic(series);
|
||||
//SeriesTask seriesTask = new SeriesTask(seriesTaskBasic);
|
||||
ArrayList<SeriesTaskDataTop> seriesTaskDataTopList = new ArrayList<>();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue