Fixed model
This commit is contained in:
parent
5637b3c0af
commit
9011b0262d
|
@ -116,10 +116,15 @@ public class AggregatedStorageStatusRecord extends AbstractStorageStatusRecord i
|
|||
throws NotAggregatableRecordsExceptions {
|
||||
try {
|
||||
AggregationUtility<AggregatedStorageStatusRecord> aggregationUtility = new AggregationUtility<AggregatedStorageStatusRecord>(this);
|
||||
Calendar thisStartTime = this.getStartTime();
|
||||
aggregationUtility.aggregate(record);
|
||||
this.setDataVolume(record.getDataVolume());
|
||||
this.setDataCount(record.getDataCount());
|
||||
|
||||
|
||||
// Getting the last value
|
||||
if(record.getStartTime().after(thisStartTime)) {
|
||||
this.setDataVolume(record.getDataVolume());
|
||||
this.setDataCount(record.getDataCount());
|
||||
}
|
||||
|
||||
}catch(NotAggregatableRecordsExceptions e){
|
||||
throw e;
|
||||
} catch(Exception ex){
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.documentstore.records.implementation.FieldDecorator;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@FieldDecorator(action=MoveToProviderURIAction.class)
|
||||
public @interface MoveToProviderURI {
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.accounting.datamodel.backwardcompatibility;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
|
||||
import org.gcube.accounting.datamodel.validations.validators.ValidURIValidator;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.implementation.FieldAction;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class MoveToProviderURIAction implements FieldAction {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
ValidURIValidator validURIValidator = new ValidURIValidator();
|
||||
value = validURIValidator.validate(key, value, record);
|
||||
record.setResourceProperty(AbstractStorageStatusRecord.PROVIDER_URI, (URI) value);
|
||||
return null; //Returning null the initial key is removed from Record
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import java.net.URI;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToProviderURI;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidDataType;
|
||||
|
@ -45,7 +46,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
/**
|
||||
* KEY for : data Count number of objects
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
@RequiredField @ValidLong @NotEmpty
|
||||
public static final String DATA_COUNT = "dataCount";
|
||||
|
||||
/**
|
||||
|
@ -69,9 +70,13 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
/**
|
||||
* KEY for : providerId the identifier of the provider which is the target of a read/write operation
|
||||
*/
|
||||
@RequiredField @ValidURI
|
||||
@ValidURI @MoveToProviderURI
|
||||
public static final String PROVIDER_ID = "providerId";
|
||||
|
||||
@RequiredField @ValidURI
|
||||
public static final String PROVIDER_URI = "providerURI";
|
||||
|
||||
|
||||
|
||||
public AbstractStorageStatusRecord() {
|
||||
super();
|
||||
|
@ -149,12 +154,23 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Deprecated
|
||||
public URI getProviderId() {
|
||||
return (URI) this.resourceProperties.get(PROVIDER_ID);
|
||||
return (URI) this.resourceProperties.get(PROVIDER_URI);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setProviderId(URI provideId) throws InvalidValueException {
|
||||
setResourceProperty(PROVIDER_ID, provideId);
|
||||
// setResourceProperty(PROVIDER_ID, provideId);
|
||||
setResourceProperty(PROVIDER_URI, provideId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public URI getProviderURI() {
|
||||
return (URI) this.resourceProperties.get(PROVIDER_URI);
|
||||
}
|
||||
|
||||
public void setProviderURI(URI provideURI) throws InvalidValueException {
|
||||
setResourceProperty(PROVIDER_URI, provideURI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
}
|
||||
|
||||
public enum DataType {
|
||||
STORAGE, TREE, GEO, DATABASE, LOCAL, OTHER
|
||||
STORAGE, TREE, GEO, DATABASE, LOCAL, OTHER, JUPYTER, KUBERNETES
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue