2015-05-28 13:19:25 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-07-01 12:50:00 +02:00
|
|
|
package org.gcube.accounting.datamodel.basetypes;
|
2015-05-28 13:19:25 +02:00
|
|
|
|
2015-06-09 15:53:21 +02:00
|
|
|
import java.io.Serializable;
|
2015-06-25 15:58:26 +02:00
|
|
|
import java.net.URI;
|
2015-06-09 15:53:21 +02:00
|
|
|
import java.util.Map;
|
|
|
|
|
2015-06-10 17:36:50 +02:00
|
|
|
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
2015-10-09 14:52:42 +02:00
|
|
|
import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign;
|
2015-06-26 15:50:39 +02:00
|
|
|
import org.gcube.accounting.datamodel.validations.annotations.ValidDataType;
|
2015-06-10 16:40:24 +02:00
|
|
|
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationType;
|
2015-06-25 15:58:26 +02:00
|
|
|
import org.gcube.accounting.datamodel.validations.annotations.ValidURI;
|
2015-12-18 17:09:05 +01:00
|
|
|
import org.gcube.documentstore.exception.InvalidValueException;
|
2015-12-21 11:50:09 +01:00
|
|
|
import org.gcube.documentstore.records.implementation.RequiredField;
|
|
|
|
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
|
|
|
|
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
|
|
|
|
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
|
|
|
*
|
|
|
|
*/
|
2015-07-29 14:41:28 +02:00
|
|
|
public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generated Serial Version UID
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1381025822586583326L;
|
|
|
|
|
2015-06-10 16:40:24 +02:00
|
|
|
public enum OperationType {
|
2015-06-26 15:50:39 +02:00
|
|
|
CREATE, READ, UPDATE, DELETE
|
2015-06-10 16:40:24 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public enum DataType {
|
|
|
|
STORAGE, TREE, GEO, DATABASE, OTHER
|
|
|
|
}
|
2015-06-26 12:21:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* KEY for : The Owner of the stored Resource
|
2015-06-25 17:41:56 +02:00
|
|
|
*/
|
2015-06-25 15:58:26 +02:00
|
|
|
@RequiredField @NotEmpty
|
2015-06-15 11:28:19 +02:00
|
|
|
public static final String RESOURCE_OWNER = "resourceOwner";
|
2015-06-26 12:21:28 +02:00
|
|
|
/**
|
|
|
|
* KEY for : The Scope where the Resource was stored
|
|
|
|
*/
|
2015-06-25 15:58:26 +02:00
|
|
|
@RequiredField @NotEmpty
|
|
|
|
public static final String RESOURCE_SCOPE = "resourceScope";
|
|
|
|
|
2015-06-26 12:21:28 +02:00
|
|
|
/**
|
|
|
|
* KEY for : The URI of the Stored Resource
|
|
|
|
*/
|
2015-06-26 15:50:39 +02:00
|
|
|
@RequiredField @ValidURI
|
2015-06-26 12:21:28 +02:00
|
|
|
public static final String RESOURCE_URI = "resourceURI";
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
@RequiredField @ValidURI
|
|
|
|
public static final String PROVIDER_URI = "providerURI";
|
|
|
|
|
2015-06-26 12:21:28 +02:00
|
|
|
/**
|
|
|
|
* KEY for : The operation performed over the stored resource.
|
|
|
|
* The value is a controlled dictionary by
|
|
|
|
* {@link #StorageUsageRecord.OperationType}
|
|
|
|
*/
|
2015-10-09 14:52:42 +02:00
|
|
|
@RequiredField @ValidOperationType @FixDataVolumeSign
|
2015-05-28 13:19:25 +02:00
|
|
|
public static final String OPERATION_TYPE = "operationType";
|
2015-06-26 12:21:28 +02:00
|
|
|
/**
|
|
|
|
* KEY for : type of data accessed.
|
2015-06-26 15:50:39 +02:00
|
|
|
* The value is a controlled dictionary by
|
|
|
|
* {@link #StorageUsageRecord.DataType}
|
2015-06-26 12:21:28 +02:00
|
|
|
*/
|
2015-06-26 15:50:39 +02:00
|
|
|
@RequiredField @ValidDataType
|
2015-06-04 18:52:29 +02:00
|
|
|
public static final String DATA_TYPE = "dataType";
|
2015-06-25 17:41:56 +02:00
|
|
|
|
|
|
|
/**
|
2015-12-01 14:37:23 +01:00
|
|
|
* KEY for : Quantity of data in terms of KB
|
2015-06-25 17:41:56 +02:00
|
|
|
*/
|
2015-10-09 14:52:42 +02:00
|
|
|
@RequiredField @ValidLong @FixDataVolumeSign
|
2015-06-04 18:52:29 +02:00
|
|
|
public static final String DATA_VOLUME = "dataVolume";
|
2015-06-24 15:24:57 +02:00
|
|
|
|
2015-06-26 17:09:55 +02:00
|
|
|
/**
|
2015-06-26 12:21:28 +02:00
|
|
|
* KEY for : Qualifies the data in terms of data (e.g. MIME type for the
|
|
|
|
* Storage, domain for a database)
|
2015-06-26 17:09:55 +02:00
|
|
|
*/
|
2015-06-26 12:21:28 +02:00
|
|
|
@NotEmptyIfNotNull
|
2015-06-25 15:58:26 +02:00
|
|
|
public static final String QUALIFIER = "qualifier";
|
2015-06-26 12:21:28 +02:00
|
|
|
|
2016-09-08 17:21:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* KEY for : callerQualifier
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
@NotEmptyIfNotNull
|
|
|
|
public static final String CALLERQUALIFIER = "callerQualifier";
|
|
|
|
*/
|
2015-07-29 14:41:28 +02:00
|
|
|
public AbstractStorageUsageRecord() {
|
2015-05-28 13:19:25 +02:00
|
|
|
super();
|
|
|
|
}
|
2015-05-29 16:08:21 +02:00
|
|
|
|
2016-01-28 18:29:11 +01:00
|
|
|
public AbstractStorageUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
2015-06-09 15:53:21 +02:00
|
|
|
super(properties);
|
|
|
|
}
|
2015-07-29 14:41:28 +02:00
|
|
|
|
|
|
|
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
2015-12-21 11:50:09 +01:00
|
|
|
protected String giveMeRecordType() {
|
2015-07-29 14:41:28 +02:00
|
|
|
return AbstractStorageUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
|
|
|
}
|
2015-06-09 15:53:21 +02:00
|
|
|
|
2015-06-15 11:28:19 +02:00
|
|
|
/**
|
2015-06-25 15:58:26 +02:00
|
|
|
* Return the identity id of the storage resource owner
|
|
|
|
* @return the identity id of the accounting owner
|
2015-06-15 11:28:19 +02:00
|
|
|
*/
|
|
|
|
public String getResourceOwner() {
|
|
|
|
return (String) this.resourceProperties.get(RESOURCE_OWNER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:58:26 +02:00
|
|
|
* Set the identity id of the storage resource owner
|
2015-06-26 15:50:39 +02:00
|
|
|
* @param owner the identity id of the storage resource owner
|
2015-06-15 11:28:19 +02:00
|
|
|
* @throws InvalidValueException
|
|
|
|
*/
|
2015-06-26 15:50:39 +02:00
|
|
|
public void setResourceOwner(String owner) throws InvalidValueException {
|
2015-06-15 11:28:19 +02:00
|
|
|
setResourceProperty(RESOURCE_OWNER, owner);
|
|
|
|
}
|
2015-06-25 15:58:26 +02:00
|
|
|
/**
|
|
|
|
* Return the scope of the storage resource
|
|
|
|
* @return The scope id of the storage resource
|
|
|
|
*/
|
|
|
|
public String getResourceScope() {
|
2015-07-27 12:45:23 +02:00
|
|
|
return (String) this.resourceProperties.get(RESOURCE_SCOPE);
|
2015-06-25 15:58:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the scope of the storage resource
|
|
|
|
* @param scope the scope of the storage resource
|
|
|
|
* @throws InvalidValueException
|
|
|
|
*/
|
2015-06-26 15:50:39 +02:00
|
|
|
public void setResourceScope(String scope) throws InvalidValueException {
|
2015-06-25 15:58:26 +02:00
|
|
|
setResourceProperty(RESOURCE_SCOPE, scope);
|
|
|
|
}
|
2015-06-15 11:28:19 +02:00
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public URI getProviderURI() {
|
|
|
|
return (URI) this.resourceProperties.get(PROVIDER_URI);
|
2015-06-25 16:21:56 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public void setProviderURI(URI providerURI) throws InvalidValueException {
|
|
|
|
setResourceProperty(PROVIDER_URI, providerURI);
|
2015-06-25 16:21:56 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 12:21:28 +02:00
|
|
|
public URI getResourceURI() {
|
|
|
|
return (URI) this.resourceProperties.get(RESOURCE_URI);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 12:21:28 +02:00
|
|
|
public void setResourceURI(URI resourceURI) throws InvalidValueException {
|
|
|
|
setResourceProperty(RESOURCE_URI, resourceURI);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
public OperationType getOperationType() {
|
|
|
|
return (OperationType) this.resourceProperties.get(OPERATION_TYPE);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
public void setOperationType(OperationType operationType) throws InvalidValueException {
|
2015-06-09 14:54:14 +02:00
|
|
|
setResourceProperty(OPERATION_TYPE, operationType);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public DataType getDataType() {
|
|
|
|
return (DataType) this.resourceProperties.get(DATA_TYPE);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public void setDataType(DataType dataType) throws InvalidValueException {
|
2015-06-25 16:21:56 +02:00
|
|
|
setResourceProperty(DATA_TYPE, dataType);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
2015-06-04 18:52:29 +02:00
|
|
|
|
2015-06-25 16:21:56 +02:00
|
|
|
public long getDataVolume() {
|
|
|
|
return (Long) this.resourceProperties.get(DATA_VOLUME);
|
2015-06-04 18:52:29 +02:00
|
|
|
}
|
|
|
|
|
2015-06-25 16:21:56 +02:00
|
|
|
public void setDataVolume(long dataVolume) throws InvalidValueException {
|
|
|
|
setResourceProperty(DATA_VOLUME, dataVolume);
|
2015-06-04 18:52:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getQualifier() {
|
2015-06-09 14:54:14 +02:00
|
|
|
return (String) this.resourceProperties.get(QUALIFIER);
|
2015-06-04 18:52:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setQualifier(String qualifier) throws InvalidValueException {
|
2015-06-09 14:54:14 +02:00
|
|
|
setResourceProperty(QUALIFIER, qualifier);
|
2015-06-04 18:52:29 +02:00
|
|
|
}
|
2015-06-05 09:47:48 +02:00
|
|
|
|
2016-09-08 17:21:05 +02:00
|
|
|
/*Add a new field*/
|
|
|
|
/*
|
|
|
|
public String getCallerQualifier() {
|
|
|
|
return (String) this.resourceProperties.get(CALLERQUALIFIER);
|
|
|
|
}
|
|
|
|
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
|
|
|
setResourceProperty(CALLERQUALIFIER, callerQualifier);
|
|
|
|
}
|
|
|
|
*/
|
2015-05-28 13:19:25 +02:00
|
|
|
}
|