2015-06-09 14:03:59 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package org.gcube.accounting.datamodel.implementations.aggregated;
|
|
|
|
|
2015-06-09 15:53:21 +02:00
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Map;
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
2015-06-24 15:24:57 +02:00
|
|
|
import org.gcube.accounting.datamodel.decorators.AggregatedField;
|
|
|
|
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
|
|
|
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
|
2015-06-09 15:53:21 +02:00
|
|
|
import org.gcube.accounting.exception.InvalidValueException;
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
/**
|
2015-06-23 17:47:38 +02:00
|
|
|
* This Class is for library internal use only
|
2015-06-09 14:03:59 +02:00
|
|
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
|
|
|
*/
|
2015-06-23 17:47:38 +02:00
|
|
|
public class StorageUsageRecord extends org.gcube.accounting.datamodel.implementations.StorageUsageRecord implements AggregatedUsageRecord<StorageUsageRecord, org.gcube.accounting.datamodel.implementations.StorageUsageRecord> {
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generated Serial Version UID
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1082525518686785682L;
|
|
|
|
|
2015-06-24 15:24:57 +02:00
|
|
|
/**
|
|
|
|
* Indicate The Number of Aggregated Operation
|
|
|
|
*/
|
|
|
|
@RequiredField @ValidInteger @AggregatedField
|
|
|
|
public static final String OPERATION_COUNT = "operationCount";
|
|
|
|
|
2015-06-10 16:13:28 +02:00
|
|
|
public StorageUsageRecord(){
|
2015-06-09 14:03:59 +02:00
|
|
|
super();
|
2015-06-09 15:53:21 +02:00
|
|
|
this.resourceProperties.put(AGGREGATED, true);
|
|
|
|
}
|
|
|
|
|
2015-06-10 16:13:28 +02:00
|
|
|
public StorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
2015-06-09 15:53:21 +02:00
|
|
|
super(properties);
|
|
|
|
this.resourceProperties.put(AGGREGATED, true);
|
2015-06-09 14:03:59 +02:00
|
|
|
}
|
2015-06-23 17:47:38 +02:00
|
|
|
|
2015-06-24 15:24:57 +02:00
|
|
|
protected StorageUsageRecord(org.gcube.accounting.datamodel.implementations.StorageUsageRecord usageRecord) throws InvalidValueException{
|
|
|
|
super(usageRecord.getResourceProperties());
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getOperationCount() {
|
|
|
|
return (Integer) this.resourceProperties.get(OPERATION_COUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
|
|
|
setResourceProperty(OPERATION_COUNT, operationCount);
|
|
|
|
}
|
|
|
|
|
2015-06-09 14:03:59 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2015-06-23 17:47:38 +02:00
|
|
|
public StorageUsageRecord getAggregatedUsageRecord(
|
2015-06-24 15:24:57 +02:00
|
|
|
org.gcube.accounting.datamodel.implementations.StorageUsageRecord usageRecord)
|
2015-06-23 17:47:38 +02:00
|
|
|
throws InvalidValueException {
|
2015-06-24 15:24:57 +02:00
|
|
|
if(usageRecord instanceof StorageUsageRecord){
|
|
|
|
return (StorageUsageRecord) usageRecord;
|
|
|
|
}
|
|
|
|
return new StorageUsageRecord(usageRecord);
|
2015-06-09 14:03:59 +02:00
|
|
|
}
|
2015-06-23 17:47:38 +02:00
|
|
|
|
2015-06-09 14:03:59 +02:00
|
|
|
}
|