git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@134075 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
13d9e34a9c
commit
4f90c54f62
|
@ -2,20 +2,51 @@ package org.gcube.accounting.analytics;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
/**
|
||||
* Object for calculate quota
|
||||
*
|
||||
*
|
||||
* @author pieve
|
||||
*
|
||||
*/
|
||||
public class TotalFilters {
|
||||
protected Class<? extends AggregatedUsageRecord<?, ?>> clz;
|
||||
protected TemporalConstraint temporalConstraint;
|
||||
protected List<Filters> totalFilters;
|
||||
|
||||
|
||||
protected String identifier;
|
||||
protected Double d;
|
||||
protected String orderingProperty;
|
||||
public TotalFilters(){}
|
||||
|
||||
public TotalFilters(List<Filters> totalFilters, Number n, String orderingProperty) {
|
||||
super();
|
||||
this.totalFilters=totalFilters;
|
||||
this.d = n.doubleValue();
|
||||
this.orderingProperty = orderingProperty;
|
||||
|
||||
public TemporalConstraint getTemporalConstraint() {
|
||||
return temporalConstraint;
|
||||
}
|
||||
|
||||
public void setTemporalConstraint(TemporalConstraint temporalConstraint) {
|
||||
this.temporalConstraint = temporalConstraint;
|
||||
}
|
||||
|
||||
public Class<? extends AggregatedUsageRecord<?, ?>> getClz() {
|
||||
return clz;
|
||||
}
|
||||
|
||||
public void setClz(Class<? extends AggregatedUsageRecord<?, ?>> clz) {
|
||||
this.clz = clz;
|
||||
}
|
||||
|
||||
public TotalFilters(){}
|
||||
|
||||
public TotalFilters(String identifier,Class<? extends AggregatedUsageRecord<?, ?>> clz,TemporalConstraint temporalConstraint,List<Filters> totalFilters){
|
||||
super();
|
||||
this.totalFilters=totalFilters;
|
||||
this.clz=clz;
|
||||
this.temporalConstraint=temporalConstraint;
|
||||
this.identifier=identifier;
|
||||
|
||||
}
|
||||
|
||||
public List<Filters> getTotalFilters() {
|
||||
return totalFilters;
|
||||
|
@ -25,6 +56,14 @@ public class TotalFilters {
|
|||
this.totalFilters = totalFilters;
|
||||
}
|
||||
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
public Double getD() {
|
||||
return d;
|
||||
}
|
||||
|
@ -40,9 +79,16 @@ public class TotalFilters {
|
|||
public void setOrderingProperty(String orderingProperty) {
|
||||
this.orderingProperty = orderingProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TotalFilters [totalFilters=" + totalFilters + ", d=" + d
|
||||
return "TotalFilters [clz=" + clz + ", temporalConstraint="
|
||||
+ temporalConstraint + ", totalFilters=" + totalFilters
|
||||
+ ", identifier=" + identifier + ", d=" + d
|
||||
+ ", orderingProperty=" + orderingProperty + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -168,6 +168,10 @@ public interface AccountingPersistenceBackendQuery {
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* getUsageValueQuota
|
||||
* use for a specifiy consumer id and for single quota
|
||||
*
|
||||
* in:[{ "consumerId" : "alessandro.pieve" }, { "serviceClass" : "DataAccess" }, { "serviceName" : "CkanConnector" }], d=null, orderingProperty=null]
|
||||
* out:[{ "consumerId" : "alessandro.pieve" }, { "serviceClass" : "DataAccess" }, { "serviceName" : "CkanConnector" }], d=88.0, orderingProperty=operationCount]
|
||||
* @param clz
|
||||
|
@ -181,22 +185,58 @@ public interface AccountingPersistenceBackendQuery {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
/*
|
||||
public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz,
|
||||
TemporalConstraint temporalConstraint,
|
||||
List<Filters> filterPackageQuota) throws Exception;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* getUsageValueQuotaTotal
|
||||
*
|
||||
* @param clz
|
||||
* @param temporalConstraint
|
||||
* Example for crequire 2 different quota (lucio.lelii for service and alessandro.pieve for storage)
|
||||
* Input:
|
||||
* [
|
||||
* TotalFilters [
|
||||
* clz=class org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord,
|
||||
* temporalConstraint=StartTime : 2015-05-01 11:42:34:515 UTC (1430480554515 millis), EndTime : 2016-11-09 11:42:34:515 UTC (1478691754515 millis),
|
||||
* Aggregated DAILY,
|
||||
* totalFilters=[
|
||||
* Filters [filters=[
|
||||
* { "consumerId" : "lucio.lelii" },
|
||||
* { "serviceClass" : "DataAccess" },
|
||||
* { "serviceName" : "CkanConnector" }
|
||||
* ], d=null, orderingProperty=null],
|
||||
* Filters [filters=[
|
||||
* { "consumerId" : "lucio.lelii" },
|
||||
* { "serviceClass" : "VREManagement" }
|
||||
* ], d=null, orderingProperty=null]
|
||||
* ], d=null, orderingProperty=null]
|
||||
* ]
|
||||
* Output:
|
||||
* [
|
||||
* TotalFilters [
|
||||
* clz=class org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord,
|
||||
* temporalConstraint=StartTime : 2015-05-01 11:42:34:515 UTC (1430480554515 millis), EndTime : 2016-11-09 11:42:34:515 UTC (1478691754515 millis),
|
||||
* Aggregated DAILY,
|
||||
* totalFilters=[
|
||||
* Filters [filters=[
|
||||
* { "consumerId" : "lucio.lelii" },
|
||||
* { "serviceClass" : "DataAccess" },
|
||||
* { "serviceName" : "CkanConnector" }
|
||||
* ], d=1.0, orderingProperty=operationCount],
|
||||
* Filters [filters=[
|
||||
* { "consumerId" : "lucio.lelii" },
|
||||
* { "serviceClass" : "VREManagement" }
|
||||
* ], d=1.0, orderingProperty=operationCount]
|
||||
* ], d=2.0, orderingProperty=null]
|
||||
* ]
|
||||
* @param listUsage
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<TotalFilters> getUsageValueQuotaTotal(
|
||||
Class<? extends AggregatedRecord<?, ?>> clz,
|
||||
TemporalConstraint temporalConstraint, List<TotalFilters> listUsage)
|
||||
List<TotalFilters> listUsage)
|
||||
throws Exception;
|
||||
|
||||
|
||||
|
|
|
@ -286,23 +286,13 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
|||
.getUsageValue(clz, temporalConstraint, applicant);
|
||||
}
|
||||
|
||||
/*New task for quota*/
|
||||
|
||||
@Override
|
||||
public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz,
|
||||
TemporalConstraint temporalConstraint, List<Filters> listUsage)
|
||||
public List<TotalFilters> getUsageValueQuotaTotal( List<TotalFilters> listUsage)
|
||||
throws Exception {
|
||||
|
||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
||||
.getUsageValueQuota(clz, temporalConstraint, listUsage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TotalFilters> getUsageValueQuotaTotal(Class<? extends AggregatedRecord<?, ?>> clz,
|
||||
TemporalConstraint temporalConstraint, List<TotalFilters> listUsage)
|
||||
throws Exception {
|
||||
|
||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
||||
.getUsageValueQuotaTotal(clz, temporalConstraint, listUsage);
|
||||
.getUsageValueQuotaTotal(listUsage);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue