From 073e303b4c7c40d10c52ba21be73025d8d72383e Mon Sep 17 00:00:00 2001 From: Alessandro Pieve Date: Fri, 3 Feb 2017 11:18:14 +0000 Subject: [PATCH] Add new method for NoContext Menu Change Usage Value with List filter git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@142145 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../analytics/UsageServiceValue.java | 28 +++++++------- .../AccountingPersistenceBackendQuery.java | 31 ++++++++++++++- .../AccountingPersistenceQuery.java | 38 +++++++++++++++++++ 3 files changed, 83 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/gcube/accounting/analytics/UsageServiceValue.java b/src/main/java/org/gcube/accounting/analytics/UsageServiceValue.java index 18a01b4..0be6838 100644 --- a/src/main/java/org/gcube/accounting/analytics/UsageServiceValue.java +++ b/src/main/java/org/gcube/accounting/analytics/UsageServiceValue.java @@ -9,7 +9,11 @@ public class UsageServiceValue extends UsageValue { protected Class> clz; protected TemporalConstraint temporalConstraint; - protected List filtersValue; + + //USED for a list service for each identifier (package service ) + //protected List filtersValue; + + protected List filters; protected String identifier; protected Double d; protected String orderingProperty; @@ -57,22 +61,21 @@ public class UsageServiceValue extends UsageValue { public UsageServiceValue(){} - public UsageServiceValue(String context,String identifier,Class> clz,TemporalConstraint temporalConstraint,List filtersValue){ + public UsageServiceValue(String context,String identifier,Class> clz,TemporalConstraint temporalConstraint,List filters){ super(); this.context=context; - this.filtersValue=filtersValue; + this.filters=filters; this.clz=clz; this.temporalConstraint=temporalConstraint; this.identifier=identifier; } - public List getFiltersValue() { - return filtersValue; + public List getFilters() { + return filters; } - - public void setFiltersValue(List filtersValue) { - this.filtersValue = filtersValue; + public void setFilters(List filters) { + this.filters = filters; } @Override @@ -87,12 +90,11 @@ public class UsageServiceValue extends UsageValue { @Override public String toString() { return "UsageServiceValue [clz=" + clz + ", temporalConstraint=" - + temporalConstraint + ", filtersValue=" + filtersValue - + ", identifier=" + identifier + ", d=" + d - + ", orderingProperty=" + orderingProperty + ", context=" - + context + "]"; + + temporalConstraint + ", filters=" + filters + ", identifier=" + + identifier + ", d=" + d + ", orderingProperty=" + + orderingProperty + "]"; } - + } diff --git a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQuery.java b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQuery.java index bcf7d94..832e7d0 100644 --- a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQuery.java +++ b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQuery.java @@ -61,6 +61,35 @@ public interface AccountingPersistenceBackendQuery { + /** + * Query the persistence obtaining a Map where the date is the key and the + * #Info is the value. The result is relative to an Usage Record Type, + * respect a TemporalConstraint and can be applied one or more filters. + * Used for no context call + * + * @param clz + * the Record Class of interest + * @param temporalConstraint + * the TemporalConstraint (interval and aggregation) + * @param filters + * list of filter to obtain the time series. If null or empty + * list get all data for the interested Record Class with the + * applying temporal constraint. All Filter must have not null + * and not empty key and value. The filters are must be related + * to different keys and are in AND. If the list contains more + * than one filter with the same key an Exception is thrown. + * @return the Map containing for each date in the required interval the + * requested data + * @throws DuplicatedKeyFilterException + * @throws KeyException + * @throws ValueException + * @throws Exception + */ + public SortedMap getNoContextTimeSeries( + Class> clz, + TemporalConstraint temporalConstraint, List filters) + throws DuplicatedKeyFilterException, KeyException, ValueException, + Exception; /** * Return a SortedMap containing the TimeSeries for top values for a certain @@ -270,5 +299,5 @@ public interface AccountingPersistenceBackendQuery { throws Exception; - + } diff --git a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java index 361068c..3600e12 100644 --- a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java +++ b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java @@ -149,6 +149,42 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ return ret; } + + + + public SortedMap getNoContextTimeSeries( + Class> clz, + TemporalConstraint temporalConstraint, List filters) + throws DuplicatedKeyFilterException, KeyException, ValueException, + Exception { + + return this.getNoContextTimeSeries(clz, temporalConstraint, filters, false); + } + + public SortedMap getNoContextTimeSeries( + Class> clz, + TemporalConstraint temporalConstraint, List filters, + boolean pad) throws DuplicatedKeyFilterException, KeyException, + ValueException, Exception { + SortedMap ret = + AccountingPersistenceBackendQueryFactory.getInstance() + .getNoContextTimeSeries(clz, temporalConstraint, + filters); + + if(ret==null){ + ret = new TreeMap<>(); + } + + + if(pad){ + ret = padMap(ret, temporalConstraint); + } + + return ret; + } + + + public SortedMap> getTopValues( Class> clz, @@ -348,6 +384,8 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ } return got; } + +