2015-06-09 14:03:59 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-07-01 11:02:45 +02:00
|
|
|
package org.gcube.accounting.aggregation;
|
2015-06-09 14:03:59 +02:00
|
|
|
|
2015-06-09 15:53:21 +02:00
|
|
|
import java.io.Serializable;
|
2015-06-26 15:50:39 +02:00
|
|
|
import java.util.Calendar;
|
2015-06-09 15:53:21 +02:00
|
|
|
import java.util.Map;
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
2015-07-29 14:41:28 +02:00
|
|
|
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
2015-06-24 15:24:57 +02:00
|
|
|
import org.gcube.accounting.datamodel.decorators.AggregatedField;
|
|
|
|
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
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.datamodel.validations.annotations.ValidLong;
|
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-07-29 14:41:28 +02:00
|
|
|
public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord implements AggregatedUsageRecord<AggregatedStorageUsageRecord, StorageUsageRecord> {
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generated Serial Version UID
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1082525518686785682L;
|
|
|
|
|
2015-06-24 17:51:46 +02:00
|
|
|
// Redefining DATA_VOLUME to Set @AggregatedField
|
|
|
|
@RequiredField @ValidLong @AggregatedField
|
2015-07-29 14:41:28 +02:00
|
|
|
public static final String DATA_VOLUME = org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DATA_VOLUME;
|
2015-06-26 15:50:39 +02:00
|
|
|
|
|
|
|
private void init(){
|
2015-06-26 12:40:24 +02:00
|
|
|
this.resourceProperties.put(AGGREGATED, true);
|
|
|
|
}
|
2015-06-26 15:50:39 +02:00
|
|
|
|
2015-07-29 14:41:28 +02:00
|
|
|
public AggregatedStorageUsageRecord() {
|
2015-06-09 14:03:59 +02:00
|
|
|
super();
|
2015-06-26 15:50:39 +02:00
|
|
|
init();
|
2015-06-09 15:53:21 +02:00
|
|
|
}
|
|
|
|
|
2015-11-30 17:49:18 +01:00
|
|
|
public AggregatedStorageUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
|
2015-06-09 15:53:21 +02:00
|
|
|
super(properties);
|
2015-06-26 15:50:39 +02:00
|
|
|
init();
|
2015-06-09 14:03:59 +02:00
|
|
|
}
|
2015-06-23 17:47:38 +02:00
|
|
|
|
2015-07-29 14:41:28 +02:00
|
|
|
public AggregatedStorageUsageRecord(org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord record) throws InvalidValueException{
|
2015-06-26 15:50:39 +02:00
|
|
|
super(record.getResourceProperties());
|
|
|
|
this.setOperationCount(1);
|
|
|
|
Calendar creationTime = record.getCreationTime();
|
|
|
|
this.setCreationTime(Calendar.getInstance());
|
|
|
|
this.setStartTime(creationTime);
|
|
|
|
this.setEndTime(creationTime);
|
|
|
|
init();
|
|
|
|
|
2015-06-24 15:24:57 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
@Override
|
2015-06-24 15:24:57 +02:00
|
|
|
public int getOperationCount() {
|
2015-06-26 15:50:39 +02:00
|
|
|
return super.getOperationCount();
|
2015-06-24 15:24:57 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
@Override
|
2015-06-24 15:24:57 +02:00
|
|
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
2015-06-26 15:50:39 +02:00
|
|
|
super.setOperationCount(operationCount);
|
2015-06-24 15:24:57 +02:00
|
|
|
}
|
|
|
|
|
2015-06-09 14:03:59 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2015-07-29 14:41:28 +02:00
|
|
|
public AggregatedStorageUsageRecord getAggregatedUsageRecord(StorageUsageRecord usageRecord)
|
2015-06-23 17:47:38 +02:00
|
|
|
throws InvalidValueException {
|
2015-07-29 14:41:28 +02:00
|
|
|
return new AggregatedStorageUsageRecord(usageRecord);
|
2015-06-09 14:03:59 +02:00
|
|
|
}
|
2015-06-23 17:47:38 +02:00
|
|
|
|
2015-11-30 18:34:48 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Calendar getStartTime() {
|
2015-12-02 11:08:14 +01:00
|
|
|
return super.getStartTimeAsCalendar();
|
2015-11-30 18:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
|
|
|
super.setStartTime(startTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2015-12-02 11:08:14 +01:00
|
|
|
public Calendar getEndTime() {
|
2015-12-02 11:05:27 +01:00
|
|
|
return super.getEndTimeAsCalendar();
|
2015-11-30 18:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
|
|
|
super.setEndTime(endTime);
|
|
|
|
}
|
|
|
|
|
2015-06-09 14:03:59 +02:00
|
|
|
}
|