76 lines
2.3 KiB
Java
76 lines
2.3 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.accounting.datamodel.aggregation;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Map;
|
|
|
|
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
|
import org.gcube.accounting.datamodel.decorators.AggregatedField;
|
|
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
|
import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
|
|
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
|
import org.gcube.accounting.exception.InvalidValueException;
|
|
|
|
/**
|
|
* This Class is for library internal use only
|
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
|
*/
|
|
public class StorageUsageRecord extends org.gcube.accounting.datamodel.implementations.StorageUsageRecord implements AggregatedUsageRecord<StorageUsageRecord, org.gcube.accounting.datamodel.implementations.StorageUsageRecord> {
|
|
|
|
/**
|
|
* Generated Serial Version UID
|
|
*/
|
|
private static final long serialVersionUID = 1082525518686785682L;
|
|
|
|
// Redefining DATA_VOLUME to Set @AggregatedField
|
|
@RequiredField @ValidLong @AggregatedField
|
|
public static final String DATA_VOLUME = "dataVolume";
|
|
/**
|
|
* KEY for : Indicate The Number of Aggregated Operation
|
|
*/
|
|
@RequiredField @ValidInteger @AggregatedField
|
|
public static final String OPERATION_COUNT = "operationCount";
|
|
|
|
@Override
|
|
protected void init(){
|
|
super.init();
|
|
this.resourceProperties.put(AGGREGATED, true);
|
|
}
|
|
|
|
public StorageUsageRecord(){
|
|
super();
|
|
}
|
|
|
|
public StorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
|
|
super(properties);
|
|
}
|
|
|
|
public StorageUsageRecord(org.gcube.accounting.datamodel.implementations.StorageUsageRecord usageRecord) throws InvalidValueException{
|
|
super(usageRecord.getResourceProperties());
|
|
}
|
|
|
|
public int getOperationCount() {
|
|
return (Integer) this.resourceProperties.get(OPERATION_COUNT);
|
|
}
|
|
|
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
|
setResourceProperty(OPERATION_COUNT, operationCount);
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
@Override
|
|
public StorageUsageRecord getAggregatedUsageRecord(
|
|
org.gcube.accounting.datamodel.implementations.StorageUsageRecord usageRecord)
|
|
throws InvalidValueException {
|
|
if(usageRecord instanceof StorageUsageRecord){
|
|
return (StorageUsageRecord) usageRecord;
|
|
}
|
|
return new StorageUsageRecord(usageRecord);
|
|
}
|
|
|
|
}
|