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:
parent
c0ca3f0b63
commit
13d9e34a9c
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.accounting</groupId>
|
<groupId>org.gcube.accounting</groupId>
|
||||||
<artifactId>accounting-analytics</artifactId>
|
<artifactId>accounting-analytics</artifactId>
|
||||||
<version>2.2.0-SNAPSHOT</version>
|
<version>2.3.0-SNAPSHOT</version>
|
||||||
<name>accounting-analytics</name>
|
<name>accounting-analytics</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -200,8 +200,17 @@ public interface AccountingPersistenceBackendQuery {
|
||||||
throws Exception;
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
||||||
Class<? extends AggregatedRecord<?, ?>> clz,
|
Class<? extends AggregatedRecord<?, ?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters,
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
String key) throws Exception {
|
String key) throws Exception {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
return AccountingPersistenceBackendQueryFactory.getInstance()
|
||||||
.getFilterValues(clz, temporalConstraint, filters,
|
.getFilterValues(clz, temporalConstraint, filters,
|
||||||
key);
|
key);
|
||||||
|
@ -281,17 +281,17 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
||||||
public JSONObject getUsageValue(Class<? extends AggregatedRecord<?, ?>> clz,
|
public JSONObject getUsageValue(Class<? extends AggregatedRecord<?, ?>> clz,
|
||||||
TemporalConstraint temporalConstraint, Filter applicant)
|
TemporalConstraint temporalConstraint, Filter applicant)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
return AccountingPersistenceBackendQueryFactory.getInstance()
|
||||||
.getUsageValue(clz, temporalConstraint, applicant);
|
.getUsageValue(clz, temporalConstraint, applicant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*New task for quota*/
|
/*New task for quota*/
|
||||||
@Override
|
@Override
|
||||||
public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz,
|
public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filters> listUsage)
|
TemporalConstraint temporalConstraint, List<Filters> listUsage)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
return AccountingPersistenceBackendQueryFactory.getInstance()
|
||||||
.getUsageValueQuota(clz, temporalConstraint, listUsage);
|
.getUsageValueQuota(clz, temporalConstraint, listUsage);
|
||||||
}
|
}
|
||||||
|
@ -300,10 +300,55 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
||||||
public List<TotalFilters> getUsageValueQuotaTotal(Class<? extends AggregatedRecord<?, ?>> clz,
|
public List<TotalFilters> getUsageValueQuotaTotal(Class<? extends AggregatedRecord<?, ?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<TotalFilters> listUsage)
|
TemporalConstraint temporalConstraint, List<TotalFilters> listUsage)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
return AccountingPersistenceBackendQueryFactory.getInstance()
|
||||||
.getUsageValueQuotaTotal(clz, temporalConstraint, listUsage);
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue