2015-06-24 17:51:46 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-07-01 12:34:48 +02:00
|
|
|
package org.gcube.accounting.aggregation.strategy;
|
2015-06-24 17:51:46 +02:00
|
|
|
|
2015-07-29 14:41:28 +02:00
|
|
|
import org.gcube.accounting.aggregation.AggregatedStorageUsageRecord;
|
2015-06-24 17:51:46 +02:00
|
|
|
import org.gcube.accounting.datamodel.AggregationStrategy;
|
2015-07-29 14:41:28 +02:00
|
|
|
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
|
2015-06-24 17:51:46 +02:00
|
|
|
import org.gcube.accounting.exception.NotAggregatableRecordsExceptions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
|
|
|
*
|
|
|
|
*/
|
2015-07-29 14:41:28 +02:00
|
|
|
public class StorageUsageRecordAggregationStrategy extends AggregationStrategy<AggregatedStorageUsageRecord, StorageUsageRecord>{
|
2015-06-24 17:51:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param serviceUsageRecord
|
|
|
|
*/
|
2015-07-29 14:41:28 +02:00
|
|
|
public StorageUsageRecordAggregationStrategy(AggregatedStorageUsageRecord storageUsageRecord) {
|
2015-06-24 17:51:46 +02:00
|
|
|
super(storageUsageRecord);
|
2015-07-29 14:41:28 +02:00
|
|
|
this.aggregationField.add(AggregatedStorageUsageRecord.RESOURCE_OWNER);
|
|
|
|
this.aggregationField.add(AggregatedStorageUsageRecord.RESOURCE_SCOPE);
|
|
|
|
this.aggregationField.add(AggregatedStorageUsageRecord.RESOURCE_URI);
|
|
|
|
this.aggregationField.add(AggregatedStorageUsageRecord.PROVIDER_URI);
|
|
|
|
this.aggregationField.add(AggregatedStorageUsageRecord.OPERATION_TYPE);
|
|
|
|
this.aggregationField.add(AggregatedStorageUsageRecord.DATA_TYPE);
|
2015-06-24 17:51:46 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 14:41:28 +02:00
|
|
|
protected AggregatedStorageUsageRecord reallyAggregate(AggregatedStorageUsageRecord record)
|
2015-06-24 17:51:46 +02:00
|
|
|
throws NotAggregatableRecordsExceptions {
|
|
|
|
|
|
|
|
try {
|
|
|
|
t.setOperationCount(t.getOperationCount() + record.getOperationCount());
|
|
|
|
t.setDataVolume(t.getDataVolume() + record.getDataVolume());
|
|
|
|
}catch(Exception e){
|
2015-07-22 17:28:30 +02:00
|
|
|
throw new UnsupportedOperationException(e);
|
2015-06-24 17:51:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|