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
This commit is contained in:
Alessandro Pieve 2017-02-03 11:18:14 +00:00
parent 2e637013b6
commit 073e303b4c
3 changed files with 83 additions and 14 deletions

View File

@ -9,7 +9,11 @@ public class UsageServiceValue extends UsageValue {
protected Class<? extends AggregatedUsageRecord<?, ?>> clz;
protected TemporalConstraint temporalConstraint;
protected List<FiltersValue> filtersValue;
//USED for a list service for each identifier (package service )
//protected List<FiltersValue> filtersValue;
protected List<Filter> 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<? extends AggregatedUsageRecord<?, ?>> clz,TemporalConstraint temporalConstraint,List<FiltersValue> filtersValue){
public UsageServiceValue(String context,String identifier,Class<? extends AggregatedUsageRecord<?, ?>> clz,TemporalConstraint temporalConstraint,List<Filter> filters){
super();
this.context=context;
this.filtersValue=filtersValue;
this.filters=filters;
this.clz=clz;
this.temporalConstraint=temporalConstraint;
this.identifier=identifier;
}
public List<FiltersValue> getFiltersValue() {
return filtersValue;
public List<Filter> getFilters() {
return filters;
}
public void setFiltersValue(List<FiltersValue> filtersValue) {
this.filtersValue = filtersValue;
public void setFilters(List<Filter> 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 + "]";
}
}

View File

@ -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<Calendar, Info> getNoContextTimeSeries(
Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, List<Filter> 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;
}

View File

@ -149,6 +149,42 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
return ret;
}
public SortedMap<Calendar, Info> getNoContextTimeSeries(
Class<? extends AggregatedRecord<?,?>> clz,
TemporalConstraint temporalConstraint, List<Filter> filters)
throws DuplicatedKeyFilterException, KeyException, ValueException,
Exception {
return this.getNoContextTimeSeries(clz, temporalConstraint, filters, false);
}
public SortedMap<Calendar, Info> getNoContextTimeSeries(
Class<? extends AggregatedRecord<?,?>> clz,
TemporalConstraint temporalConstraint, List<Filter> filters,
boolean pad) throws DuplicatedKeyFilterException, KeyException,
ValueException, Exception {
SortedMap<Calendar, Info> ret =
AccountingPersistenceBackendQueryFactory.getInstance()
.getNoContextTimeSeries(clz, temporalConstraint,
filters);
if(ret==null){
ret = new TreeMap<>();
}
if(pad){
ret = padMap(ret, temporalConstraint);
}
return ret;
}
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
Class<? extends AggregatedRecord<?, ?>> clz,
@ -348,6 +384,8 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
}
return got;
}