Deprecating not needed fields
This commit is contained in:
parent
ffb9220fb2
commit
248c745e69
|
@ -8,8 +8,9 @@ import java.net.URI;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidDataTypeVolume;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidDataType;
|
||||
import org.gcube.accounting.datamodel.validations.annotations.ValidURI;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
|
@ -28,10 +29,6 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
*/
|
||||
private static final long serialVersionUID = -5754343539116896036L;
|
||||
|
||||
public enum DataType {
|
||||
STORAGE, TREE, GEO, DATABASE, LOCAL, OTHER
|
||||
}
|
||||
|
||||
/**
|
||||
* KEY for : Quantity of data in terms of KB
|
||||
*/
|
||||
|
@ -42,7 +39,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
* KEY for : type of data accessed.
|
||||
* The value is a controlled dictionary by StorageStatusRecord.DataType
|
||||
*/
|
||||
@RequiredField @ValidDataTypeVolume
|
||||
@RequiredField @ValidDataType
|
||||
public static final String DATA_TYPE = "dataType";
|
||||
|
||||
/**
|
||||
|
@ -54,19 +51,19 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
/**
|
||||
* KEY for : data service class identifier
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
@Deprecated
|
||||
public static final String DATA_SERVICECLASS = "dataServiceClass";
|
||||
|
||||
/**
|
||||
* KEY for : data service name identifier
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
@Deprecated
|
||||
public static final String DATA_SERVICENAME = "dataServiceName";
|
||||
|
||||
/**
|
||||
* KEY for : data service name id
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
@Deprecated
|
||||
public static final String DATA_SERVICEID = "dataServiceId";
|
||||
|
||||
/**
|
||||
|
@ -118,31 +115,40 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
|
|||
setResourceProperty(DATA_COUNT, dataCount);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public String getDataServiceClass() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICECLASS);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDataServiceClass(String dataServiceClass) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICECLASS, dataServiceClass);
|
||||
setResourceProperty(DATA_SERVICECLASS, AbstractStorageUsageRecord.NOT_NEEDED);
|
||||
// setResourceProperty(DATA_SERVICECLASS, dataServiceClass);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public String getDataServiceName() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICENAME);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDataServiceName(String dataServiceName) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICENAME, dataServiceName);
|
||||
setResourceProperty(DATA_SERVICENAME, AbstractStorageUsageRecord.NOT_NEEDED);
|
||||
// setResourceProperty(DATA_SERVICENAME, dataServiceName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public String getDataServiceId() {
|
||||
return (String) this.resourceProperties.get(DATA_SERVICEID);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDataServiceId(String dataServiceId) throws InvalidValueException {
|
||||
setResourceProperty(DATA_SERVICEID, dataServiceId);
|
||||
setResourceProperty(DATA_SERVICEID, AbstractStorageUsageRecord.NOT_NEEDED);
|
||||
// setResourceProperty(DATA_SERVICEID, dataServiceId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.gcube.documentstore.records.implementation.validations.annotations.Va
|
|||
*/
|
||||
public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
||||
|
||||
protected static final String NOT_NEEDED = "NOT_NEEDED";
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
*/
|
||||
|
@ -42,18 +44,20 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
*/
|
||||
@RequiredField @NotEmpty
|
||||
public static final String RESOURCE_OWNER = "resourceOwner";
|
||||
|
||||
/**
|
||||
* KEY for : The Scope where the Resource was stored
|
||||
*/
|
||||
@RequiredField @NotEmpty
|
||||
@Deprecated
|
||||
public static final String RESOURCE_SCOPE = "resourceScope";
|
||||
|
||||
/**
|
||||
* KEY for : The URI of the Stored Resource
|
||||
*/
|
||||
@RequiredField @ValidURI
|
||||
@Deprecated
|
||||
public static final String RESOURCE_URI = "resourceURI";
|
||||
|
||||
|
||||
@RequiredField @ValidURI
|
||||
public static final String PROVIDER_URI = "providerURI";
|
||||
|
||||
|
@ -126,6 +130,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* Return the scope of the storage resource
|
||||
* @return The scope id of the storage resource
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public String getResourceScope() {
|
||||
return (String) this.resourceProperties.get(RESOURCE_SCOPE);
|
||||
|
@ -136,8 +141,10 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
* @param scope the scope of the storage resource
|
||||
* @throws InvalidValueException
|
||||
*/
|
||||
@Deprecated
|
||||
public void setResourceScope(String scope) throws InvalidValueException {
|
||||
setResourceProperty(RESOURCE_SCOPE, scope);
|
||||
setResourceProperty(RESOURCE_SCOPE, NOT_NEEDED);
|
||||
// setResourceProperty(RESOURCE_SCOPE, scope);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
@ -149,13 +156,16 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
|
|||
setResourceProperty(PROVIDER_URI, providerURI);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public URI getResourceURI() {
|
||||
return (URI) this.resourceProperties.get(RESOURCE_URI);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setResourceURI(URI resourceURI) throws InvalidValueException {
|
||||
setResourceProperty(RESOURCE_URI, resourceURI);
|
||||
setResourceProperty(RESOURCE_SCOPE, NOT_NEEDED);
|
||||
// setResourceProperty(RESOURCE_URI, resourceURI);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package org.gcube.accounting.datamodel.validations.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.accounting.datamodel.validations.validators.ValidDataTypeValidatorVolume;
|
||||
import org.gcube.documentstore.records.implementation.FieldDecorator;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@FieldDecorator(action=ValidDataTypeValidatorVolume.class)
|
||||
public @interface ValidDataTypeVolume {
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package org.gcube.accounting.datamodel.validations.validators;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord.DataType;
|
||||
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 ValidDataTypeValidatorVolume implements FieldAction {
|
||||
|
||||
private static final String ERROR = String.format("Not Instance of %s", DataType.class.getSimpleName());
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Serializable validate(String key, Serializable value, Record record) throws InvalidValueException {
|
||||
if(value instanceof DataType){
|
||||
return value;
|
||||
}
|
||||
|
||||
try {
|
||||
if(value instanceof String){
|
||||
try{
|
||||
DataType dataType = DataType.valueOf((String) value);
|
||||
if(dataType !=null){
|
||||
return dataType;
|
||||
}
|
||||
} catch(Exception e){
|
||||
// Trying another way
|
||||
}
|
||||
|
||||
try{
|
||||
Integer integer = Integer.getInteger((String) value);
|
||||
if(integer!=null){
|
||||
value = integer;
|
||||
}
|
||||
} catch(Exception e){
|
||||
// Trying another way
|
||||
}
|
||||
}
|
||||
|
||||
if(value instanceof Integer){
|
||||
return DataType.values()[(Integer) value];
|
||||
}
|
||||
|
||||
if(value instanceof Enum){
|
||||
return DataType.values()[((Enum) value).ordinal()];
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
|
||||
throw new InvalidValueException(ERROR);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -37,9 +37,6 @@ public class StorageStatusRecordTest extends ContextTest {
|
|||
expectedRequiredFields.add(AbstractStorageStatusRecord.DATA_VOLUME);
|
||||
expectedRequiredFields.add(AbstractStorageStatusRecord.DATA_COUNT);
|
||||
expectedRequiredFields.add(AbstractStorageStatusRecord.DATA_TYPE);
|
||||
expectedRequiredFields.add(AbstractStorageStatusRecord.DATA_SERVICECLASS);
|
||||
expectedRequiredFields.add(AbstractStorageStatusRecord.DATA_SERVICENAME);
|
||||
expectedRequiredFields.add(AbstractStorageStatusRecord.DATA_SERVICEID);
|
||||
expectedRequiredFields.add(AbstractStorageStatusRecord.PROVIDER_ID);
|
||||
|
||||
return expectedRequiredFields;
|
||||
|
|
|
@ -35,8 +35,6 @@ public class StorageUsageRecordTest extends ContextTest {
|
|||
expectedRequiredFields.add(UsageRecord.SCOPE);
|
||||
expectedRequiredFields.add(UsageRecord.OPERATION_RESULT);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.RESOURCE_OWNER);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.RESOURCE_SCOPE);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.RESOURCE_URI);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.PROVIDER_URI);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.OPERATION_TYPE);
|
||||
expectedRequiredFields.add(AbstractStorageUsageRecord.DATA_TYPE);
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.net.URISyntaxException;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord;
|
||||
|
@ -95,7 +94,6 @@ public class TestUsageRecord {
|
|||
public final static String TEST_RESOUCE_OWNER = "resource.owner";
|
||||
public final static String TEST_RESOUCE_SCOPE = TEST_SCOPE;
|
||||
|
||||
public final static String TEST_RESOURCE_URI = "testprotocol://objectURI";
|
||||
public final static String TEST_PROVIDER_URI = "testprotocol://providerURI";
|
||||
|
||||
private final static long MIN_DATA_VOLUME = 1024;
|
||||
|
@ -112,9 +110,7 @@ public class TestUsageRecord {
|
|||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||
|
||||
usageRecord.setResourceOwner(TEST_RESOUCE_OWNER);
|
||||
usageRecord.setResourceScope(TEST_RESOUCE_SCOPE);
|
||||
|
||||
usageRecord.setResourceURI(new URI(TEST_RESOURCE_URI));
|
||||
usageRecord.setProviderURI(new URI(TEST_PROVIDER_URI));
|
||||
|
||||
usageRecord.setOperationType(AbstractStorageUsageRecord.OperationType.READ);
|
||||
|
@ -143,11 +139,8 @@ public class TestUsageRecord {
|
|||
usageRecord.setConsumerId(TEST_CONSUMER_ID);
|
||||
usageRecord.setOperationResult(TEST_OPERATION_RESULT);
|
||||
usageRecord.setDataVolume(generateRandomLong(MIN_DATA_VOLUME, MAX_DATA_VOLUME));
|
||||
usageRecord.setDataType(AbstractStorageStatusRecord.DataType.STORAGE);
|
||||
usageRecord.setDataType(AbstractStorageUsageRecord.DataType.STORAGE);
|
||||
usageRecord.setDataCount(generateRandomLong(MIN_DATA_VOLUME, MAX_DATA_VOLUME));
|
||||
usageRecord.setDataServiceClass("dataServiceClass");
|
||||
usageRecord.setDataServiceName("dataServiceName");
|
||||
usageRecord.setDataServiceId("dataServiceId");
|
||||
usageRecord.setProviderId(new URI(TEST_PROVIDER_URI));
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue