add getContextTimeSeries

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@133948 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Alessandro Pieve 2016-11-08 09:00:15 +00:00
parent c0ca3f0b63
commit 13d9e34a9c
3 changed files with 64 additions and 10 deletions

View File

@ -9,7 +9,7 @@
<groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.3.0-SNAPSHOT</version>
<name>accounting-analytics</name>
<properties>

View File

@ -200,8 +200,17 @@ public interface AccountingPersistenceBackendQuery {
throws Exception;
/**
* Return a SortedMap containing the TimeSeries for each context.
* @param clz
* @param temporalConstraint
* @param filters
* @param contexts
* @return
*/
public SortedMap<Filter, SortedMap<Calendar, Info>> getContextTimeSeries(
Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, List<Filter> filters,List<String> contexts)
throws Exception;
}

View File

@ -271,7 +271,7 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, List<Filter> filters,
String key) throws Exception {
// TODO Auto-generated method stub
return AccountingPersistenceBackendQueryFactory.getInstance()
.getFilterValues(clz, temporalConstraint, filters,
key);
@ -281,17 +281,17 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
public JSONObject getUsageValue(Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, Filter applicant)
throws Exception {
// TODO Auto-generated method stub
return AccountingPersistenceBackendQueryFactory.getInstance()
.getUsageValue(clz, temporalConstraint, applicant);
}
/*New task for quota*/
@Override
public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, List<Filters> listUsage)
throws Exception {
// TODO Auto-generated method stub
return AccountingPersistenceBackendQueryFactory.getInstance()
.getUsageValueQuota(clz, temporalConstraint, listUsage);
}
@ -300,10 +300,55 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
public List<TotalFilters> getUsageValueQuotaTotal(Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, List<TotalFilters> listUsage)
throws Exception {
// TODO Auto-generated method stub
return AccountingPersistenceBackendQueryFactory.getInstance()
.getUsageValueQuotaTotal(clz, temporalConstraint, listUsage);
}
@Override
public SortedMap<Filter, SortedMap<Calendar, Info>> getContextTimeSeries(
Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, List<Filter> filters,List<String> contexts)
throws Exception {
return AccountingPersistenceBackendQueryFactory.getInstance()
.getContextTimeSeries(clz, temporalConstraint, filters, contexts);
}
public SortedMap<Filter, SortedMap<Calendar, Info>> getContextTimeSeries(
Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, List<Filter> filters,
List<String> contexts, boolean pad)
throws DuplicatedKeyFilterException,
Exception {
SortedMap<Filter, SortedMap<Calendar, Info>> got;
got = AccountingPersistenceBackendQueryFactory.getInstance()
.getContextTimeSeries(clz, temporalConstraint, filters, contexts);
int count = got.size();
Filter firstRemovalKey = null;
for(Filter nf : got.keySet()){
if(--count>=0){
if(pad){
padMap(got.get(nf), temporalConstraint);
}
}else{
if(firstRemovalKey==null){
firstRemovalKey = nf;
}else{
break;
}
}
}
if(firstRemovalKey!=null){
return got.subMap(got.firstKey(), firstRemovalKey);
}
return got;
}
}