git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics-persistence-couchbase@142540 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
51cad72fb1
commit
1b4b05e045
|
@ -23,9 +23,7 @@ import java.util.SortedSet;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
|
||||||
import org.gcube.accounting.analytics.Filter;
|
import org.gcube.accounting.analytics.Filter;
|
||||||
import org.gcube.accounting.analytics.FiltersValue;
|
|
||||||
import org.gcube.accounting.analytics.Info;
|
import org.gcube.accounting.analytics.Info;
|
||||||
import org.gcube.accounting.analytics.NumberedFilter;
|
import org.gcube.accounting.analytics.NumberedFilter;
|
||||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||||
|
@ -1458,7 +1456,7 @@ AccountingPersistenceBackendQuery {
|
||||||
String keyOrderingProperty = null;
|
String keyOrderingProperty = null;
|
||||||
for (UsageValue totalFilters:listUsage){
|
for (UsageValue totalFilters:listUsage){
|
||||||
|
|
||||||
logger.debug("----------------- init for totalFilters");
|
logger.debug("-----------------/ init for totalFilters");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1514,7 +1512,7 @@ AccountingPersistenceBackendQuery {
|
||||||
//int i = 0;
|
//int i = 0;
|
||||||
//int countFilters=0;
|
//int countFilters=0;
|
||||||
|
|
||||||
if (totalFilters.getClass().getSimpleName().equals(UsageServiceValue.class.getSimpleName())){
|
if (totalFilters instanceof UsageServiceValue){
|
||||||
UsageServiceValue totalFiltersService = (UsageServiceValue)totalFilters;
|
UsageServiceValue totalFiltersService = (UsageServiceValue)totalFilters;
|
||||||
//countFilters =totalFiltersService.getFiltersValue().size();
|
//countFilters =totalFiltersService.getFiltersValue().size();
|
||||||
}
|
}
|
||||||
|
@ -1532,7 +1530,9 @@ AccountingPersistenceBackendQuery {
|
||||||
startKeyTmp.add(totalFilters.getIdentifier());
|
startKeyTmp.add(totalFilters.getIdentifier());
|
||||||
endKeyTmp.add(totalFilters.getIdentifier());
|
endKeyTmp.add(totalFilters.getIdentifier());
|
||||||
//FiltersValue singleFilter=null;
|
//FiltersValue singleFilter=null;
|
||||||
if (totalFilters.getClass().getSimpleName().equals(UsageServiceValue.class.getSimpleName())){
|
if (totalFilters instanceof UsageServiceValue){
|
||||||
|
//logger.debug("******UsageServiceValue");
|
||||||
|
|
||||||
UsageServiceValue totalFiltersService = (UsageServiceValue)totalFilters;
|
UsageServiceValue totalFiltersService = (UsageServiceValue)totalFilters;
|
||||||
//singleFilter=totalFiltersService.getFiltersValue().get(i);
|
//singleFilter=totalFiltersService.getFiltersValue().get(i);
|
||||||
for (Filter filter:totalFiltersService.getFilters()){
|
for (Filter filter:totalFiltersService.getFilters()){
|
||||||
|
@ -1598,23 +1598,15 @@ AccountingPersistenceBackendQuery {
|
||||||
map.put(key, valuetmp + map.get(key));
|
map.put(key, valuetmp + map.get(key));
|
||||||
|
|
||||||
// TODO verify a better method
|
// TODO verify a better method
|
||||||
if (totalFilters.getClass().getSimpleName().equals(UsageStorageValue.class.getSimpleName())){
|
if (totalFilters instanceof UsageStorageValue){
|
||||||
logger.debug("storageUsageRecord -designDocId:{}",designDocId);
|
logger.debug("storageUsageRecord -designDocId:{}",designDocId);
|
||||||
if (key.equals("dataVolume")){
|
if (key.equals("dataVolume")){
|
||||||
if (totalFilters.getClass().getSimpleName().equals(UsageServiceValue.class.getSimpleName())){
|
|
||||||
totalFilters.setOrderingProperty(key);
|
|
||||||
totalFilters.setD(totalFilters.getD()+valuetmp.doubleValue());
|
|
||||||
}
|
|
||||||
keyOrderingProperty=key;
|
keyOrderingProperty=key;
|
||||||
totalQuota+=totalFilters.getD()+valuetmp.doubleValue();
|
totalQuota+=totalFilters.getD()+valuetmp.doubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
logger.debug("?UsageRecord -designDocId:{}",designDocId);
|
logger.debug("?UsageRecord -designDocId:{}",designDocId);
|
||||||
if (totalFilters.getClass().getSimpleName().equals(UsageServiceValue.class.getSimpleName())){
|
|
||||||
totalFilters.setOrderingProperty(key);
|
|
||||||
totalFilters.setD(totalFilters.getD()+valuetmp.doubleValue());
|
|
||||||
}
|
|
||||||
keyOrderingProperty=key;
|
keyOrderingProperty=key;
|
||||||
totalQuota+=totalFilters.getD()+valuetmp.doubleValue();
|
totalQuota+=totalFilters.getD()+valuetmp.doubleValue();
|
||||||
}
|
}
|
||||||
|
@ -1624,24 +1616,18 @@ AccountingPersistenceBackendQuery {
|
||||||
map.put(key, valuetmp);
|
map.put(key, valuetmp);
|
||||||
|
|
||||||
// TODO verify a better method
|
// TODO verify a better method
|
||||||
if (totalFilters.getClass().getSimpleName().equals(UsageStorageValue.class.getSimpleName())){
|
if (totalFilters instanceof UsageStorageValue){
|
||||||
logger.debug("storageUsageRecord -designDocId:{}",designDocId);
|
logger.debug("storageUsageRecord -designDocId:{}",designDocId);
|
||||||
if (key.equals("dataVolume")){
|
if (key.equals("dataVolume")){
|
||||||
keyOrderingProperty=key;
|
keyOrderingProperty=key;
|
||||||
if (totalFilters.getClass().getSimpleName().equals(UsageServiceValue.class.getSimpleName())){
|
|
||||||
totalFilters.setOrderingProperty(key);
|
|
||||||
totalFilters.setD(valuetmp.doubleValue());
|
|
||||||
}
|
|
||||||
totalQuota+=valuetmp.doubleValue();
|
totalQuota+=valuetmp.doubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
logger.debug("UsageRecord -designDocId:{}",designDocId);
|
logger.debug("?UsageRecord -designDocId:{}",designDocId);
|
||||||
keyOrderingProperty=key;
|
keyOrderingProperty=key;
|
||||||
if (totalFilters.getClass().getSimpleName().equals(UsageServiceValue.class.getSimpleName())){
|
|
||||||
totalFilters.setOrderingProperty(key);
|
|
||||||
totalFilters.setD(valuetmp.doubleValue());
|
|
||||||
}
|
|
||||||
totalQuota+=valuetmp.doubleValue();
|
totalQuota+=valuetmp.doubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1650,7 +1636,15 @@ AccountingPersistenceBackendQuery {
|
||||||
}
|
}
|
||||||
//i++;
|
//i++;
|
||||||
//} while (i <countFilters );
|
//} while (i <countFilters );
|
||||||
|
//convert usage from byte to Mb
|
||||||
|
if (totalFilters instanceof UsageStorageValue){
|
||||||
|
totalQuota=totalQuota/1024/1024;
|
||||||
|
totalQuota=Math.round(totalQuota * 100.0) / 100.0;
|
||||||
|
}
|
||||||
totalFilters.setOrderingProperty(keyOrderingProperty);
|
totalFilters.setOrderingProperty(keyOrderingProperty);
|
||||||
|
if (totalQuota.isNaN()){
|
||||||
|
totalQuota=0.0;
|
||||||
|
}
|
||||||
totalFilters.setD(totalQuota);
|
totalFilters.setD(totalQuota);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue