This commit is contained in:
Alessandro Pieve 2016-11-11 09:03:09 +00:00
parent 13d9e34a9c
commit 4f90c54f62
3 changed files with 106 additions and 30 deletions

View File

@ -2,21 +2,52 @@ package org.gcube.accounting.analytics;
import java.util.List; import java.util.List;
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
/**
* Object for calculate quota
*
*
* @author pieve
*
*/
public class TotalFilters { public class TotalFilters {
protected Class<? extends AggregatedUsageRecord<?, ?>> clz;
protected TemporalConstraint temporalConstraint;
protected List<Filters> totalFilters; protected List<Filters> totalFilters;
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;
}
protected String identifier;
protected Double d;
protected String 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() { public List<Filters> getTotalFilters() {
return totalFilters; return totalFilters;
} }
@ -25,6 +56,14 @@ public class TotalFilters {
this.totalFilters = totalFilters; this.totalFilters = totalFilters;
} }
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public Double getD() { public Double getD() {
return d; return d;
} }
@ -40,9 +79,16 @@ public class TotalFilters {
public void setOrderingProperty(String orderingProperty) { public void setOrderingProperty(String orderingProperty) {
this.orderingProperty = orderingProperty; this.orderingProperty = orderingProperty;
} }
@Override @Override
public String toString() { public String toString() {
return "TotalFilters [totalFilters=" + totalFilters + ", d=" + d return "TotalFilters [clz=" + clz + ", temporalConstraint="
+ temporalConstraint + ", totalFilters=" + totalFilters
+ ", identifier=" + identifier + ", d=" + d
+ ", orderingProperty=" + orderingProperty + "]"; + ", orderingProperty=" + orderingProperty + "]";
} }
} }

View File

@ -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] * 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] * out:[{ "consumerId" : "alessandro.pieve" }, { "serviceClass" : "DataAccess" }, { "serviceName" : "CkanConnector" }], d=88.0, orderingProperty=operationCount]
* @param clz * @param clz
@ -181,22 +185,58 @@ public interface AccountingPersistenceBackendQuery {
* @return * @return
* @throws Exception * @throws Exception
*/ */
/*
public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz, public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, TemporalConstraint temporalConstraint,
List<Filters> filterPackageQuota) throws Exception; 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 * @param listUsage
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<TotalFilters> getUsageValueQuotaTotal( public List<TotalFilters> getUsageValueQuotaTotal(
Class<? extends AggregatedRecord<?, ?>> clz, List<TotalFilters> listUsage)
TemporalConstraint temporalConstraint, List<TotalFilters> listUsage)
throws Exception; throws Exception;

View File

@ -286,23 +286,13 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
.getUsageValue(clz, temporalConstraint, applicant); .getUsageValue(clz, temporalConstraint, applicant);
} }
/*New task for quota*/
@Override
public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz,
TemporalConstraint temporalConstraint, List<Filters> listUsage)
throws Exception {
return AccountingPersistenceBackendQueryFactory.getInstance()
.getUsageValueQuota(clz, temporalConstraint, listUsage);
}
@Override @Override
public List<TotalFilters> getUsageValueQuotaTotal(Class<? extends AggregatedRecord<?, ?>> clz, public List<TotalFilters> getUsageValueQuotaTotal( List<TotalFilters> listUsage)
TemporalConstraint temporalConstraint, List<TotalFilters> listUsage)
throws Exception { throws Exception {
return AccountingPersistenceBackendQueryFactory.getInstance() return AccountingPersistenceBackendQueryFactory.getInstance()
.getUsageValueQuotaTotal(clz, temporalConstraint, listUsage); .getUsageValueQuotaTotal(listUsage);
} }