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 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 String identifier;
|
||||||
protected Double d;
|
protected Double d;
|
||||||
protected String orderingProperty;
|
protected String orderingProperty;
|
||||||
public TotalFilters(){}
|
|
||||||
|
|
||||||
public TotalFilters(List<Filters> totalFilters, Number n, String orderingProperty) {
|
|
||||||
super();
|
public TemporalConstraint getTemporalConstraint() {
|
||||||
this.totalFilters=totalFilters;
|
return temporalConstraint;
|
||||||
this.d = n.doubleValue();
|
|
||||||
this.orderingProperty = orderingProperty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* Example for crequire 2 different quota (lucio.lelii for service and alessandro.pieve for storage)
|
||||||
* @param temporalConstraint
|
* 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;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -286,23 +286,13 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
||||||
.getUsageValue(clz, temporalConstraint, applicant);
|
.getUsageValue(clz, temporalConstraint, applicant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*New task for quota*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<Filters> getUsageValueQuota(Class<? extends AggregatedRecord<?, ?>> clz,
|
public List<TotalFilters> getUsageValueQuotaTotal( List<TotalFilters> listUsage)
|
||||||
TemporalConstraint temporalConstraint, List<Filters> listUsage)
|
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
return AccountingPersistenceBackendQueryFactory.getInstance()
|
||||||
.getUsageValueQuota(clz, temporalConstraint, listUsage);
|
.getUsageValueQuotaTotal(listUsage);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<TotalFilters> getUsageValueQuotaTotal(Class<? extends AggregatedRecord<?, ?>> clz,
|
|
||||||
TemporalConstraint temporalConstraint, List<TotalFilters> listUsage)
|
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
|
||||||
.getUsageValueQuotaTotal(clz, temporalConstraint, listUsage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue