2015-06-09 14:03:59 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-12-18 17:09:05 +01:00
|
|
|
package org.gcube.accounting.datamodel.aggregation;
|
2015-06-09 14:03:59 +02:00
|
|
|
|
2015-06-09 15:53:21 +02:00
|
|
|
import java.io.Serializable;
|
2015-11-30 18:34:48 +01:00
|
|
|
import java.util.Calendar;
|
2015-06-09 15:53:21 +02:00
|
|
|
import java.util.Map;
|
2016-01-13 16:18:59 +01:00
|
|
|
import java.util.Set;
|
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.AbstractJobUsageRecord;
|
|
|
|
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
2015-12-18 17:09:05 +01:00
|
|
|
import org.gcube.documentstore.exception.InvalidValueException;
|
|
|
|
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
|
2016-01-13 16:18:59 +01:00
|
|
|
import org.gcube.documentstore.records.aggregation.AggregationUtility;
|
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 AggregatedJobUsageRecord extends AbstractJobUsageRecord implements AggregatedUsageRecord<AggregatedJobUsageRecord, JobUsageRecord> {
|
2015-06-09 14:03:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generated Serial Version UID
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = -3376423316219914682L;
|
|
|
|
|
2015-07-29 14:41:28 +02:00
|
|
|
public AggregatedJobUsageRecord(){
|
2015-06-09 14:03:59 +02:00
|
|
|
super();
|
|
|
|
}
|
2015-06-09 15:53:21 +02:00
|
|
|
|
2016-01-28 18:29:11 +01:00
|
|
|
public AggregatedJobUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException{
|
2015-06-09 15:53:21 +02:00
|
|
|
super(properties);
|
|
|
|
}
|
2015-12-18 17:09:05 +01:00
|
|
|
|
|
|
|
// TODO
|
|
|
|
public AggregatedJobUsageRecord(JobUsageRecord jobUsageRecord) throws InvalidValueException{
|
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
2016-01-13 16:18:59 +01:00
|
|
|
@Override
|
|
|
|
public Set<String> getAggregatedFields() {
|
|
|
|
return aggregatedFields;
|
|
|
|
}
|
|
|
|
|
2015-11-19 16:19:51 +01:00
|
|
|
@Override
|
|
|
|
public int getOperationCount() {
|
|
|
|
return super.getOperationCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setOperationCount(int operationCount) throws InvalidValueException {
|
|
|
|
super.setOperationCount(operationCount);
|
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
return super.getEndTimeAsCalendar();
|
2015-11-30 18:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void setEndTime(Calendar endTime) throws InvalidValueException {
|
|
|
|
super.setEndTime(endTime);
|
|
|
|
}
|
|
|
|
|
2015-12-18 17:09:05 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public AggregatedJobUsageRecord aggregate(AggregatedJobUsageRecord record)
|
|
|
|
throws NotAggregatableRecordsExceptions {
|
2016-01-13 16:18:59 +01:00
|
|
|
try {
|
|
|
|
/*
|
|
|
|
AggregationUtility<AggregatedJobUsageRecord> aggregationUtility = new AggregationUtility<AggregatedJobUsageRecord>(this);
|
|
|
|
aggregationUtility.aggregate(record);
|
|
|
|
*/
|
|
|
|
// TODO
|
|
|
|
}catch(Exception e){
|
|
|
|
throw new UnsupportedOperationException(e);
|
|
|
|
}
|
|
|
|
//return this;
|
|
|
|
|
2015-12-18 17:09:05 +01:00
|
|
|
throw new UnsupportedOperationException();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public AggregatedJobUsageRecord aggregate(JobUsageRecord record)
|
|
|
|
throws NotAggregatableRecordsExceptions {
|
2016-01-13 16:18:59 +01:00
|
|
|
try {
|
|
|
|
return aggregate(new AggregatedJobUsageRecord(record));
|
|
|
|
} catch (InvalidValueException e) {
|
|
|
|
throw new NotAggregatableRecordsExceptions(e.getCause());
|
|
|
|
}
|
2015-12-18 17:09:05 +01:00
|
|
|
}
|
2016-01-13 16:18:59 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isAggregable(AggregatedJobUsageRecord record) throws NotAggregatableRecordsExceptions {
|
|
|
|
AggregationUtility<AggregatedJobUsageRecord> aggregationUtility = new AggregationUtility<AggregatedJobUsageRecord>(this);
|
|
|
|
return aggregationUtility.isAggregable(record);
|
2015-12-18 17:09:05 +01:00
|
|
|
|
2016-01-13 16:18:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isAggregable(JobUsageRecord record) throws NotAggregatableRecordsExceptions {
|
|
|
|
try {
|
|
|
|
return isAggregable(new AggregatedJobUsageRecord(record));
|
|
|
|
} catch (InvalidValueException e) {
|
|
|
|
throw new NotAggregatableRecordsExceptions(e.getCause());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-18 17:09:05 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Class<JobUsageRecord> getAggregable() {
|
|
|
|
return JobUsageRecord.class;
|
|
|
|
}
|
|
|
|
|
2015-06-09 14:03:59 +02:00
|
|
|
}
|