Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package org.gcube.accounting.datamodel.aggregation;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
|
|
|
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
|
|
|
|
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecord;
|
2020-07-10 18:30:52 +02:00
|
|
|
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
import org.gcube.documentstore.exception.InvalidValueException;
|
|
|
|
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
|
|
|
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
|
|
|
import org.gcube.documentstore.records.implementation.AggregatedField;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This Class is for library internal use only
|
|
|
|
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
|
|
|
|
*/
|
2017-05-11 16:38:38 +02:00
|
|
|
@JsonTypeName(value="StorageStatusRecord")
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord implements AggregatedUsageRecord<AggregatedStorageStatusRecord, StorageStatusRecord> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generated Serial Version UID
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 4683337274367137236L;
|
|
|
|
|
|
|
|
@AggregatedField
|
|
|
|
public static final String DATA_VOLUME = AbstractStorageStatusRecord.DATA_VOLUME;
|
|
|
|
|
|
|
|
@AggregatedField
|
|
|
|
public static final String DATA_COUNT = AbstractStorageStatusRecord.DATA_COUNT;
|
|
|
|
|
|
|
|
|
|
|
|
public AggregatedStorageStatusRecord() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
public AggregatedStorageStatusRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
|
|
|
super(properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AggregatedStorageStatusRecord(StorageStatusRecord record) throws InvalidValueException{
|
|
|
|
super(record.getResourceProperties());
|
|
|
|
this.setOperationCount(1);
|
|
|
|
Calendar creationTime = record.getCreationTime();
|
|
|
|
this.setCreationTime(Calendar.getInstance());
|
|
|
|
this.setStartTime(creationTime);
|
|
|
|
this.setEndTime(creationTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getOperationCount() {
|
|
|
|
return super.getOperationCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
|
|
|
super.setOperationCount(operationCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Calendar getStartTime() {
|
|
|
|
return super.getStartTimeAsCalendar();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void setStartTime(Calendar startTime) throws InvalidValueException {
|
|
|
|
super.setStartTime(startTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Calendar getEndTime() {
|
|
|
|
return super.getEndTimeAsCalendar();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
|
|
|
super.setEndTime(endTime);
|
|
|
|
}
|
|
|
|
|
2017-05-11 16:38:38 +02:00
|
|
|
@Override
|
2017-09-14 14:21:23 +02:00
|
|
|
public void setAggregated(Boolean aggregate) throws InvalidValueException {
|
|
|
|
super.setAggregated(aggregate);
|
2017-05-11 16:38:38 +02:00
|
|
|
}
|
2017-09-14 14:21:23 +02:00
|
|
|
|
2017-05-11 16:38:38 +02:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2017-09-14 14:21:23 +02:00
|
|
|
public Boolean isAggregated() {
|
|
|
|
return super.isAggregated();
|
2017-05-11 16:38:38 +02:00
|
|
|
}
|
|
|
|
|
Add a new UsageRecord for Storage Volume
e.g.
{
"scope": "/gcube",
"operationCount": 2,
"dataCount": 2802,
"dataServiceName": "dataServiceName",
"endTime": 1480606453491,
"consumerId": "alessandro.pieve",
"startTime": 1480606453487,
"id": "6e6808bf-3567-4ebf-93d3-0d55c97202a1",
"dataVolume": 5104,
"dataType": "STORAGE",
"operationResult": "SUCCESS",
"dataServiceId": "dataServiceId",
"aggregated": true,
"providerId": "testprotocol://providerURI",
"creationTime": 1480606453494,
"recordType": "StorageStatusRecord",
"dataServiceClass": "dataServiceClass"
}
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@141599 82a268e6-3cf1-43bd-a215-b396298e98cf
2017-01-17 11:59:14 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public AggregatedStorageStatusRecord aggregate(
|
|
|
|
AggregatedStorageStatusRecord record)
|
|
|
|
throws NotAggregatableRecordsExceptions {
|
|
|
|
try {
|
|
|
|
AggregationUtility<AggregatedStorageStatusRecord> aggregationUtility = new AggregationUtility<AggregatedStorageStatusRecord>(this);
|
|
|
|
aggregationUtility.aggregate(record);
|
|
|
|
this.setDataVolume(record.getDataVolume());
|
|
|
|
this.setDataCount(record.getDataCount());
|
|
|
|
|
|
|
|
}catch(NotAggregatableRecordsExceptions e){
|
|
|
|
throw e;
|
|
|
|
} catch(Exception ex){
|
|
|
|
throw new NotAggregatableRecordsExceptions(ex);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public AggregatedStorageStatusRecord aggregate(StorageStatusRecord record)
|
|
|
|
throws NotAggregatableRecordsExceptions {
|
|
|
|
try {
|
|
|
|
return aggregate(new AggregatedStorageStatusRecord(record));
|
|
|
|
} catch(NotAggregatableRecordsExceptions e){
|
|
|
|
throw e;
|
|
|
|
} catch(Exception ex){
|
|
|
|
throw new NotAggregatableRecordsExceptions(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isAggregable(AggregatedStorageStatusRecord record)
|
|
|
|
throws NotAggregatableRecordsExceptions {
|
|
|
|
AggregationUtility<AggregatedStorageStatusRecord> aggregationUtility = new AggregationUtility<AggregatedStorageStatusRecord>(this);
|
|
|
|
return aggregationUtility.isAggregable(record);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isAggregable(StorageStatusRecord record)
|
|
|
|
throws NotAggregatableRecordsExceptions {
|
|
|
|
try {
|
|
|
|
return isAggregable(new AggregatedStorageStatusRecord(record));
|
|
|
|
} catch(NotAggregatableRecordsExceptions e){
|
|
|
|
throw e;
|
|
|
|
} catch(Exception ex){
|
|
|
|
throw new NotAggregatableRecordsExceptions(ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Class<StorageStatusRecord> getAggregable() {
|
|
|
|
return StorageStatusRecord.class;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|