diff --git a/src/main/java/org/gcube/accounting/datamodel/AggregatedUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/AggregatedUsageRecord.java
index 3dbeddf..0cb8d80 100644
--- a/src/main/java/org/gcube/accounting/datamodel/AggregatedUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/AggregatedUsageRecord.java
@@ -3,17 +3,16 @@
*/
package org.gcube.accounting.datamodel;
-import org.gcube.accounting.datamodel.decorators.AggregatedField;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
-import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
-import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.documentstore.records.AggregatedRecord;
+import org.gcube.documentstore.records.implementation.AggregatedField;
+import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidInteger;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
-@SuppressWarnings("rawtypes")
-public interface AggregatedUsageRecord extends AggregatedRecord {
+public interface AggregatedUsageRecord, U extends UsageRecord> extends AggregatedRecord {
@AggregatedField @NotEmptyIfNotNull
public static final String AGGREGATED = AggregatedRecord.AGGREGATED;
diff --git a/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java
index f1358ca..b2eadda 100644
--- a/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java
@@ -4,31 +4,15 @@
package org.gcube.accounting.datamodel;
import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.UUID;
-import org.gcube.accounting.datamodel.decorators.AggregatedField;
-import org.gcube.accounting.datamodel.decorators.ComputedField;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
-import org.gcube.accounting.datamodel.decorators.RequiredField;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
-import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
+import org.gcube.accounting.datamodel.backwardcompatibility.MoveToRecordType;
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.documentstore.exception.InvalidValueException;
-import org.gcube.documentstore.records.AggregatedRecord;
-import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.AbstractRecord;
+import org.gcube.documentstore.records.implementation.RequiredField;
+import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +20,7 @@ import org.slf4j.LoggerFactory;
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
-public abstract class BasicUsageRecord implements UsageRecord {
+public abstract class BasicUsageRecord extends AbstractRecord implements UsageRecord {
/**
* Generated Serial Version UID
@@ -44,131 +28,25 @@ public abstract class BasicUsageRecord implements UsageRecord {
private static final long serialVersionUID = -2060728578456796388L;
private static Logger logger = LoggerFactory.getLogger(BasicUsageRecord.class);
-
- @RequiredField @NotEmpty
- private static final String ID = Record.ID;
- @RequiredField @NotEmpty
- private static final String CONSUMER_ID = UsageRecord.CONSUMER_ID;
-
- @RequiredField @ValidLong
- private static final String CREATION_TIME = Record.CREATION_TIME;
+ @Deprecated @MoveToRecordType
+ private static final String USAGE_RECORD_TYPE = "usageRecordType";
@RequiredField @NotEmpty
- private static final String RECORD_TYPE = Record.RECORD_TYPE;
-
- // TODO MOVE TO RECORD_TYPE
- @Deprecated @RequiredField @NotEmpty
- public static final String USAGE_RECORD_TYPE = "usageRecordType";
+ public static final String CONSUMER_ID = UsageRecord.CONSUMER_ID;
@RequiredField @NotEmpty
- private static final String SCOPE = UsageRecord.SCOPE;
+ public static final String SCOPE = UsageRecord.SCOPE;
@RequiredField @ValidOperationResult
- private static final String OPERATION_RESULT = UsageRecord.OPERATION_RESULT;
-
- /** resource-specific properties */
- protected Map> resourceProperties;
-
- protected Map> validation;
- protected Set requiredFields;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set getRequiredFields() {
- return requiredFields;
- }
-
- protected Set computedFields;
-
- private static final String START_TIME = AggregatedRecord.START_TIME;
- private static final String END_TIME = AggregatedRecord.END_TIME;
- private static final String OPERATION_COUNT = AggregatedUsageRecord.OPERATION_COUNT;
-
- protected Set aggregatedFields;
-
- protected static Set getAllFields(Class> type) {
- Set fields = new HashSet();
- for (Class> c = type; c != null; c = c.getSuperclass())
- fields.addAll(Arrays.asList(c.getDeclaredFields()));
- return fields;
- }
-
- protected void initializeValidation() {
- //logger.trace("Initializing Field Validators");
- Set fields = getAllFields(this.getClass());
-
- for(Field field : fields){
- boolean defaultAccessibility = field.isAccessible();
- field.setAccessible(true);
- String keyString;
- try {
- keyString = (String) field.get(null);
- } catch (Exception e) {
- continue;
- }
- List fieldValidators = new ArrayList();
- validation.put(keyString, fieldValidators);
- for (Annotation annotation : field.getAnnotations()){
- if (annotation.annotationType().isAnnotationPresent(FieldDecorator.class)){
- Class extends FieldAction> managedClass = ((FieldDecorator)annotation.annotationType().getAnnotation(FieldDecorator.class)).managed();
- FieldAction validator;
- try {
- validator = managedClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- logger.error("{} {}", keyString, annotation, e);
- continue;
- }
- fieldValidators.add(validator);
- }
- if(annotation.annotationType().isAssignableFrom(RequiredField.class)){
- requiredFields.add(keyString);
- }
- if(annotation.annotationType().isAssignableFrom(AggregatedField.class)){
- aggregatedFields.add(keyString);
- }
- if(annotation.annotationType().isAssignableFrom(ComputedField.class)){
- computedFields.add(keyString);
- }
- }
- field.setAccessible(defaultAccessibility);
- }
- /*
- logger.trace("Required Fields {}", requiredFields);
- logger.trace("Aggregated Fields {}", aggregatedFields);
- logger.trace("Computed Fields {}", computedFields);
- */
- }
-
- protected void cleanExtraFields(){
- Set neededFields = this.requiredFields;
- neededFields.addAll(this.aggregatedFields);
-
- Set keysToRemove = new HashSet();
- Set propertyKeys = this.resourceProperties.keySet();
- for(String propertyName : propertyKeys){
- if(!neededFields.contains(propertyName)){
- keysToRemove.add(propertyName);
- }
- }
-
- for(String keyToRemove : keysToRemove){
- this.resourceProperties.remove(keyToRemove);
- }
- }
+ public static final String OPERATION_RESULT = UsageRecord.OPERATION_RESULT;
/**
* Initialize variable
*/
- private void init() {
- this.validation = new HashMap>();
- this.requiredFields = new HashSet();
- this.aggregatedFields = new HashSet();
- this.computedFields = new HashSet();
- this.resourceProperties = new HashMap>();
- initializeValidation();
+ protected void init() {
+ super.init();
+ // Backward compatibility
try {
this.setScope(ScopeProvider.instance.get());
} catch(Exception e) {
@@ -177,59 +55,13 @@ public abstract class BasicUsageRecord implements UsageRecord {
}
public BasicUsageRecord(){
- init();
- this.resourceProperties.put(ID, UUID.randomUUID().toString());
- this.setRecordType();
- Calendar calendar = Calendar.getInstance();
- this.resourceProperties.put(CREATION_TIME, calendar.getTimeInMillis());
+ super();
}
public BasicUsageRecord(Map> properties) throws InvalidValueException {
- init();
- setResourceProperties(properties);
- if(this instanceof AggregatedUsageRecord){
- this.resourceProperties.put(AggregatedUsageRecord.AGGREGATED, true);
- cleanExtraFields();
- }
- }
- @Deprecated
- public String getUsageRecordType() {
- return getRecordType();
- }
-
- @Override
- public String getRecordType() {
- return (String) this.resourceProperties.get(RECORD_TYPE);
- }
-
- protected abstract String giveMeUsageRecordType();
-
- @Deprecated
- protected void setUsageRecordType(){
- setRecordType();
- }
-
- protected void setRecordType(){
- this.resourceProperties.put(RECORD_TYPE, this.giveMeUsageRecordType());
- this.resourceProperties.put(USAGE_RECORD_TYPE, this.giveMeUsageRecordType());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getId() {
- return (String) this.resourceProperties.get(ID);
+ super();
}
- /**
- * {@inheritDoc}
- */
- @Override
- public void setId(String id) throws InvalidValueException {
- setResourceProperty(ID, id);
- }
-
/**
* {@inheritDoc}
*/
@@ -246,28 +78,6 @@ public abstract class BasicUsageRecord implements UsageRecord {
setResourceProperty(CONSUMER_ID, consumerId);
}
- protected Calendar timestampStringToCalendar(long millis){
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeInMillis(millis);
- return calendar;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Calendar getCreationTime() {
- long millis = (Long) this.resourceProperties.get(CREATION_TIME);
- return timestampStringToCalendar(millis);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setCreationTime(Calendar creationTime) throws InvalidValueException {
- setResourceProperty(CREATION_TIME, creationTime.getTimeInMillis());
- }
/**
* {@inheritDoc}
@@ -285,167 +95,6 @@ public abstract class BasicUsageRecord implements UsageRecord {
setResourceProperty(SCOPE, scope);
}
- /**
- * {@inheritDoc}
- */
- @Override
- public Map> getResourceProperties() {
- return new HashMap>(this.resourceProperties);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setResourceProperties(Map> properties) throws InvalidValueException {
- Map> validated = validateProperties(properties);
- this.resourceProperties = new HashMap>(validated);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Comparable extends Serializable> getResourceProperty(String key) {
- return this.resourceProperties.get(key);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setResourceProperty(String key, Comparable extends Serializable> value) throws InvalidValueException {
- Comparable extends Serializable> checkedValue = validateField(key, value);
- if(checkedValue == null){
- this.resourceProperties.remove(key);
- }else{
- this.resourceProperties.put(key, checkedValue);
- }
- }
-
- // AGGREGATION
- /* --------------------------------------- */
- /**
- * Return the left end of the time interval covered by this {#UsageRecord}
- * @return Start Time
- */
- protected long getStartTimeInMillis() {
- return (Long) this.resourceProperties.get(START_TIME);
- }
-
- /**
- * Return the left end of the time interval covered by this {#UsageRecord}
- * @return Start Time
- */
- protected Calendar getStartTimeAsCalendar() {
- long millis = getStartTimeInMillis();
- return timestampStringToCalendar(millis);
- }
-
- /**
- * Set the left end of the time interval covered by this {#UsageRecord}
- * @param startTime Start Time
- * @throws InvalidValueException
- */
- protected void setStartTime(Calendar startTime) throws InvalidValueException {
- setResourceProperty(START_TIME, startTime.getTimeInMillis());
- }
-
- /**
- * Return the right end of the time interval covered by this {#UsageRecord}
- * @return End Time
- */
- protected long getEndTimeInMillis() {
- return (Long) this.resourceProperties.get(END_TIME);
- }
-
- /**
- * Return the right end of the time interval covered by this {#UsageRecord}
- * @return End Time
- */
- protected Calendar getEndTimeAsCalendar() {
- long millis = getEndTimeInMillis();
- return timestampStringToCalendar(millis);
- }
-
- /**
- * Set the right end of the time interval covered by this {#UsageRecord}
- * @param endTime End Time
- * @throws InvalidValueException
- */
- protected void setEndTime(Calendar endTime) throws InvalidValueException {
- setResourceProperty(END_TIME, endTime.getTimeInMillis());
- }
-
- protected int getOperationCount() {
- return (Integer) this.resourceProperties.get(OPERATION_COUNT);
- }
-
- protected void setOperationCount(int operationCount) throws InvalidValueException {
- setResourceProperty(OPERATION_COUNT, operationCount);
- }
-
- /* --------------------------------------- */
-
-
-
- protected Comparable extends Serializable> validateField(String key, Comparable extends Serializable> value) throws InvalidValueException {
- if(key == null){
- throw new InvalidValueException("The key of property to set cannot be null");
- }
- Comparable extends Serializable> checkedValue = value;
- List fieldValidators = validation.get(key);
- if(fieldValidators!=null){
- for(FieldAction fieldValidator : fieldValidators){
- if(aggregatedFields.contains(key)){
- // TODO
- }
- if(computedFields.contains(key)){
- logger.debug("{} is a computed field. To be calculated all the required fields to calcutalate it MUST be set. In any case the provided value will be ignored.", key);
- }
- try {
- checkedValue = fieldValidator.validate(key, checkedValue, this);
- } catch (InvalidValueException e) {
- logger.error(String.format("The provided value %s is NOT valid for field with key %s.", checkedValue.toString(), key));
- throw e;
- }
- }
- }
- return checkedValue;
- }
-
- protected Map> validateProperties(Map> properties) throws InvalidValueException{
- Map> validated = new HashMap>();
- for(String key : properties.keySet()){
- Comparable extends Serializable> value = properties.get(key);
- validated.put(key, validateField(key, value));
- }
- return validated;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void validate() throws InvalidValueException {
- validateProperties(this.resourceProperties);
- Set notPresentProperties = new HashSet();
- for(String key : this.requiredFields){
- if(!this.resourceProperties.containsKey(key)){
- notPresentProperties.add(key);
- }
- }
- if(!notPresentProperties.isEmpty()){
- String pluralManagement = notPresentProperties.size() == 1 ? "y" : "ies";
- throw new InvalidValueException(String.format("The Usage Record does not contain the following required propert%s %s", pluralManagement, notPresentProperties.toString()));
- }
- }
-
- @Override
- public String toString(){
- return resourceProperties.toString();
- }
-
/**
* {@inheritDoc}
*/
@@ -462,30 +111,5 @@ public abstract class BasicUsageRecord implements UsageRecord {
public void setOperationResult(OperationResult operationResult) throws InvalidValueException {
setResourceProperty(OPERATION_RESULT, operationResult);
}
-
-
- /**
- * Compare this UsageRecord instance with the one provided as argument
- * @param usageRecord the Usage Record to compare
- * @return 0 is and only if the UsageRecord provided as parameter
- * contains all and ONLY the parameters contained in this instance.
- * If the number of parameters differs, the methods return the difference
- * between the number of parameter in this instance and the ones in the
- * UsageRecord provided as parameter.
- * If the size is the same but the UsageRecord provided as parameter does
- * not contains all parameters in this instance, -1 is returned.
- */
- @Override
- public int compareTo(Record record) {
- Set>> thisSet = this.resourceProperties.entrySet();
- Set>> usageRecordSet = record.getResourceProperties().entrySet();
- if(thisSet.size() != usageRecordSet.size()){
- return thisSet.size() - usageRecordSet.size();
- }
- if(usageRecordSet.containsAll(thisSet)){
- return 0;
- }
- return 1;
- }
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java
deleted file mode 100644
index 58e853a..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/RawUsageRecord.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/**
- *
- */
-package org.gcube.accounting.datamodel;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.gcube.accounting.datamodel.backwardcompatibility.MoveToCreationTime;
-import org.gcube.accounting.datamodel.backwardcompatibility.MoveToScope;
-import org.gcube.accounting.datamodel.backwardcompatibility.MoveToUsageRecordType;
-import org.gcube.accounting.datamodel.deprecationmanagement.DeprecatedWarning;
-import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
-import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord;
-import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
-import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
-import org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
-import org.gcube.documentstore.exception.InvalidValueException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
- *
- */
-@Deprecated
-public class RawUsageRecord extends BasicUsageRecord implements UsageRecord {
-
- /**
- * Generated Serial Version UID
- */
- private static final long serialVersionUID = 1203390363640634895L;
-
- private static Logger logger = LoggerFactory.getLogger(RawUsageRecord.class);
-
- @DeprecatedWarning @MoveToScope @NotEmpty
- public static final String RESOURCE_SCOPE = "resourceScope";
-
- @DeprecatedWarning @NotEmptyIfNotNull
- public static final String CREATOR_ID = "creatorId";
-
- @DeprecatedWarning @NotEmptyIfNotNull
- protected static final String RESOURCE_OWNER = "resourceOwner";
-
- @DeprecatedWarning @MoveToCreationTime
- protected static final String CREATE_TIME = "createTime";
-
- public final static Map resourceTypeMapping;
-
- private final static String JOB = "job";
- private final static String TASK = "task";
- private final static String PORTLET = "portlet";
- private final static String SERVICE = "service";
- private final static String STORAGE_USAGE = "storage-usage";
-
- static {
- resourceTypeMapping = new HashMap();
- resourceTypeMapping.put(JOB, JobUsageRecord.class.getSimpleName());
- resourceTypeMapping.put(TASK, TaskUsageRecord.class.getSimpleName());
- resourceTypeMapping.put(PORTLET, PortletUsageRecord.class.getSimpleName());
- resourceTypeMapping.put(SERVICE, ServiceUsageRecord.class.getSimpleName());
- resourceTypeMapping.put(STORAGE_USAGE, StorageUsageRecord.class.getSimpleName());
-
- }
-
- @DeprecatedWarning @MoveToUsageRecordType
- protected static final String RESOURCE_TYPE = "resourceType";
-
- @DeprecatedWarning //@MoveToAggregatedUsageRecordId
- protected static final String AGGREGATED_ID = "aggregatedId";
-
- /**
- * Redeclared to allow @MoveToUsageRecordTypeAction to access it
- */
- public static final String USAGE_RECORD_TYPE = BasicUsageRecord.USAGE_RECORD_TYPE;
-
- /*
- @Target(ElementType.FIELD)
- @Retention(RetentionPolicy.RUNTIME)
- @FieldDecorator(managed=MoveToAggregatedUsageRecordIdAction.class)
- protected @interface MoveToAggregatedUsageRecordId { }
- protected class MoveToAggregatedUsageRecordIdAction implements FieldAction {
- @Override
- public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
- NotEmptyIfNotNullValidator neinnv = new NotEmptyIfNotNullValidator();
- value = neinnv.validate(key, value, usageRecord);
- usageRecord.setAggregatedUsageRecordId((String) value);
- return value;
- }
- }
- */
-
- @NotEmptyIfNotNull @DeprecatedWarning
- protected static final String FULLY_QUALIFIED_CONSUMER_ID = "fullyQualifiedConsumerId";
-
- @Deprecated
- public RawUsageRecord(){
- super();
- this.resourceProperties.remove(USAGE_RECORD_TYPE);
- }
-
- @Deprecated
- public RawUsageRecord(Map> properties) throws InvalidValueException {
- super(properties);
- }
-
- /**
- * Return the identity of the entity creating this {#UsageRecord}
- * @return Creator ID
- */
- @Deprecated
- public String getCreatorId() {
- return (String) this.resourceProperties.get(CREATOR_ID);
- }
-
- /**
- * Set the identity of the entity creating this {#UsageRecord}
- * @param creatorId Creator ID
- * @throws InvalidValueException
- */
- @Deprecated
- public void setCreatorId(String creatorId) throws InvalidValueException {
- setResourceProperty(CREATOR_ID, creatorId);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- @Deprecated
- public void setConsumerId(String consumerId) {
- try{
- super.setConsumerId(consumerId);
- } catch(Exception e){
- logger.error("Unable to Set {}", CONSUMER_ID);
- }
- }
-
- /**
- * Set the scope of the {#UsageRecord}
- * @param scope the scope of the {#UsageRecord}
- */
- @Deprecated
- public void setResourceScope(String scope) {
- try{
- setResourceProperty(RESOURCE_SCOPE, scope);
- }catch(Exception e){
- logger.error("Unable to Set {}", RESOURCE_SCOPE);
- }
- }
-
- /**
- * Use {#getUsageRecordType} instead
- * @param resourceType
- * @return Usage Record Type
- */
- @Deprecated
- public String getResourceType(){
- return (String) this.resourceProperties.get(RESOURCE_TYPE);
- }
-
- /**
- * This method is not valid due to Resource Type is derived by
- * the Usage Record Implementation class. The method is deprecated and
- * the implementations in known classes is a NoOperation.
- * @param resourceType
- */
- @Deprecated
- public void setResourceType(String resourceType){
- try {
- setResourceProperty(RESOURCE_TYPE, resourceType);
- }catch(InvalidValueException e){
- logger.error("Unable to Set {}", RESOURCE_TYPE);
- }
- }
-
-
- /**
- * Return the creation time for this {#UsageRecord}
- * @return the creation time for this {#UsageRecord}
- */
- @Deprecated
- public Date getCreateTime() {
- long millis = (Long) this.resourceProperties.get(AggregatedUsageRecord.CREATION_TIME);
- return timestampStringToCalendar(millis).getTime();
- }
-
- /**
- * Use {{@link #setCreationTime(Calendar)}} instead
- * @param createTime
- * @throws InvalidValueException
- */
- @Deprecated
- public void setCreateTime(Date createTime) {
- /*
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(createTime);
- setCreationTime(calendar);
- */
- //logger.warn("The method is deprecated. Please modify your code as soon as possible");
- }
-
-
-
- /**
- * Return the left end of the time interval covered by this usage record
- * @return Start Time
- */
- @Deprecated
- public Date getStartTime() {
- long millis = (Long) this.resourceProperties.get(AggregatedUsageRecord.START_TIME);
- return timestampStringToCalendar(millis).getTime();
- }
-
- /**
- * @param createTime
- * @throws InvalidValueException
- */
- @Deprecated
- public void setStartTime(Date startTime) throws InvalidValueException {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(startTime);
- setStartTime(calendar);
- }
-
-
- /**
- * Return the right end of the time interval covered by this usage record
- * @return End Time
- */
- @Deprecated
- public Date getEndTime() {
- long millis = (Long) this.resourceProperties.get(AggregatedUsageRecord.END_TIME);
- return timestampStringToCalendar(millis).getTime();
- }
-
- /**
- * @param endTime
- * @throws InvalidValueException
- */
- @Deprecated
- public void setEndTime(Date endTime) throws InvalidValueException {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(endTime);
- setEndTime(calendar);
- }
-
-
- /**
- * Return the identity id of the owner
- * @return The identity id of the owner
- */
- @Deprecated
- public String getResourceOwner() {
- return (String) this.resourceProperties.get(RESOURCE_OWNER);
- }
-
- /**
- * Set the identity id of the owner
- * @param ownerID The identity id of the owner
- * @throws InvalidValueException
- */
- @Deprecated
- public void setResourceOwner(String owner) {
- try {
- setResourceProperty(RESOURCE_OWNER, owner);
- } catch (InvalidValueException e) {
- logger.error("Unable to Set {}", RESOURCE_OWNER);
- }
- }
-
- /**
- * Return the id of the usage record aggregating this, null if this record
- * has not been aggregated by any record.
- * This method id deprecated. Use {@link #getAggregatedUsageRecordId()}
- * instead.
- * @return Aggregated Id The ID of the aggregation Record
- */
- @Deprecated
- public String getAggregatedId() {
- return (String) this.resourceProperties.get(AGGREGATED_ID);
- }
-
-
- /**
- * Set the id of the usage record aggregating this.
- * This method id deprecated. Use {@link #setAggregatedUsageRecordId()}
- * instead.
- * @param aggregatedId The ID of the aggregation Record
- * @throws InvalidValueException
- */
- @Deprecated
- public void setAggregatedId(String aggregatedId) throws InvalidValueException {
- setResourceProperty(AGGREGATED_ID, aggregatedId);
- }
-
- /**
- * Return all resource properties
- * Use {@link #getResourceSpecificProperties()}
- * @return a Map containing the properties
- */
- @Deprecated
- public Map getResourceSpecificProperties() {
- Map ret = new HashMap();
- for(String key : this.resourceProperties.keySet()){
- String value = this.resourceProperties.get(key).toString();
- ret.put(key, value);
- }
- return ret;
- }
-
- /**
- * Set all resource properties, replacing existing ones
- * Use {@link #setResourceSpecificProperties()}
- */
- @Deprecated
- public void setResourceSpecificProperties(Map properties) throws InvalidValueException {
- Map> map = new HashMap>(properties);
- setResourceProperties(map);
- }
-
- /**
- * Return the value of the given resource property.
- * @param key the key of the requested property
- * @return the value of the given resource property
- */
- @Deprecated
- public String getResourceSpecificProperty(String key) {
- return getResourceProperty(key).toString();
- }
-
- /**
- * Set the value of the given resource property.
- * If the key has the value of one of the predefined property, the value
- * is validated.
- * @param key the key of the requested property
- * @param value the value of the given resource property
- */
- @Deprecated
- public void setResourceSpecificProperty(String key, Comparable extends Serializable> value) {
- try {
- setResourceProperty(key, value);
- } catch (InvalidValueException e) {
- logger.error("Unable to Set {}", key);
- }
-
- }
-
- /**
- * The method is deprecated and the implementations in known classes
- * return Consumer ID
- * @return Consumer ID
- */
- @Deprecated
- public String getFullyQualifiedConsumerId() {
- return (String) this.resourceProperties.get(FULLY_QUALIFIED_CONSUMER_ID);
- }
-
- /**
- * The method is deprecated and the implementations in known classes is
- * a NoOperation.
- * @param fqcid Fully Qualified Consumer Id
- */
- @Deprecated
- public void setFullyQualifiedConsumerId(String fqcid) {
- try {
- setResourceProperty(FULLY_QUALIFIED_CONSUMER_ID, fqcid);
- } catch (InvalidValueException e) {
- logger.error("Unable to Set {}", FULLY_QUALIFIED_CONSUMER_ID);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String giveMeUsageRecordType() {
- // This implementation is just a placeholder
- return this.getClass().getSimpleName();
- }
-
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/aggregation/AggregatedServiceUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/aggregation/AggregatedServiceUsageRecord.java
index 61f2214..7c77295 100644
--- a/src/main/java/org/gcube/accounting/datamodel/aggregation/AggregatedServiceUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/aggregation/AggregatedServiceUsageRecord.java
@@ -9,12 +9,12 @@ import java.util.Map;
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
-import org.gcube.accounting.datamodel.decorators.AggregatedField;
-import org.gcube.accounting.datamodel.decorators.RequiredField;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
-import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
+import org.gcube.documentstore.records.implementation.AggregatedField;
+import org.gcube.documentstore.records.implementation.RequiredField;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
/**
* This Class is for library internal use only
diff --git a/src/main/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecord.java
index 2a25020..8212a7b 100644
--- a/src/main/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/aggregation/AggregatedStorageUsageRecord.java
@@ -9,12 +9,12 @@ import java.util.Map;
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
-import org.gcube.accounting.datamodel.decorators.AggregatedField;
-import org.gcube.accounting.datamodel.decorators.RequiredField;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
-import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
+import org.gcube.documentstore.records.implementation.AggregatedField;
+import org.gcube.documentstore.records.implementation.RequiredField;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
/**
* This Class is for library internal use only
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToConsumerId.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToConsumerId.java
index dd9f8e6..b3b31ef 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToConsumerId.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToConsumerId.java
@@ -8,9 +8,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=MoveToConsumerIdAction.class)
+@FieldDecorator(action=MoveToConsumerIdAction.class)
public @interface MoveToConsumerId { }
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToConsumerIdAction.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToConsumerIdAction.java
index 7c9649e..24d34db 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToConsumerIdAction.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToConsumerIdAction.java
@@ -6,16 +6,19 @@ package org.gcube.accounting.datamodel.backwardcompatibility;
import java.io.Serializable;
import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.accounting.datamodel.validations.validators.NotEmptyIfNotNullValidator;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
+import org.gcube.documentstore.records.implementation.validations.validators.NotEmptyIfNotNullValidator;
public class MoveToConsumerIdAction implements FieldAction {
+
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
NotEmptyIfNotNullValidator neinnv = new NotEmptyIfNotNullValidator();
- value = neinnv.validate(key, value, usageRecord);
- usageRecord.setConsumerId((String) value);
- return value;
+ value = neinnv.validate(key, value, record);
+ record.setResourceProperty(UsageRecord.CONSUMER_ID, (String) value);
+ return null;
}
+
}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToCreationTimeAction.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToCreationTimeAction.java
deleted file mode 100644
index 29835f2..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToCreationTimeAction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- *
- */
-package org.gcube.accounting.datamodel.backwardcompatibility;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Date;
-
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.documentstore.exception.InvalidValueException;
-
-public class MoveToCreationTimeAction implements FieldAction {
- @Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
- if(value instanceof Date){
- Calendar calendar = Calendar.getInstance();
- calendar.setTime((Date) value);
- value = calendar;
- }
- if(value instanceof Long){
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeInMillis((Long) value);
- value = calendar;
- }
-
- if(value instanceof Calendar){
- usageRecord.setCreationTime((Calendar) value);
- }else{
- throw new InvalidValueException();
- }
-
- return value;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToOperationResult.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToOperationResult.java
index 5931958..f9f5563 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToOperationResult.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToOperationResult.java
@@ -5,11 +5,11 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=MoveToOperationResultAction.class)
+@FieldDecorator(action=MoveToOperationResultAction.class)
public @interface MoveToOperationResult {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToOperationResultAction.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToOperationResultAction.java
index f410e24..f57ad79 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToOperationResultAction.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToOperationResultAction.java
@@ -7,9 +7,10 @@ import java.io.Serializable;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.accounting.datamodel.validations.validators.ValidOperationResultValidator;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -21,11 +22,11 @@ public class MoveToOperationResultAction implements FieldAction {
* {@inheritDoc}
*/
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
ValidOperationResultValidator vorv = new ValidOperationResultValidator();
- value = vorv.validate(key, value, usageRecord);
- usageRecord.setOperationResult((OperationResult) value);
- return value;
+ value = vorv.validate(key, value, record);
+ record.setResourceProperty(UsageRecord.OPERATION_RESULT, (OperationResult) value);
+ return null;
}
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToCreationTime.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToRecordType.java
similarity index 65%
rename from src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToCreationTime.java
rename to src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToRecordType.java
index f702b6d..47ab8c2 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToCreationTime.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToRecordType.java
@@ -8,9 +8,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=MoveToCreationTimeAction.class)
-public @interface MoveToCreationTime { }
\ No newline at end of file
+@FieldDecorator(action=MoveToRecordTypeAction.class)
+public @interface MoveToRecordType { }
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToRecordTypeAction.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToRecordTypeAction.java
new file mode 100644
index 0000000..a539c35
--- /dev/null
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToRecordTypeAction.java
@@ -0,0 +1,22 @@
+/**
+ *
+ */
+package org.gcube.accounting.datamodel.backwardcompatibility;
+
+import java.io.Serializable;
+
+import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
+
+public class MoveToRecordTypeAction implements FieldAction {
+
+ @Override
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
+ if(value instanceof String && value!= null && !((String) value).isEmpty()){
+ record.setResourceProperty(Record.RECORD_TYPE, value);
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToScope.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToScope.java
deleted file mode 100644
index a974476..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToScope.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- *
- */
-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.accounting.datamodel.decorators.FieldDecorator;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=MoveToScopeAction.class)
-public @interface MoveToScope { }
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToScopeAction.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToScopeAction.java
deleted file mode 100644
index 9618da1..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToScopeAction.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- *
- */
-package org.gcube.accounting.datamodel.backwardcompatibility;
-
-import java.io.Serializable;
-
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.documentstore.exception.InvalidValueException;
-
-public class MoveToScopeAction implements FieldAction {
- @Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
- if(value instanceof String){
- usageRecord.setScope((String) value);
- }else{
- throw new InvalidValueException();
- }
- return value;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskEndTime.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskEndTime.java
index c70eb63..2e5f096 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskEndTime.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskEndTime.java
@@ -12,11 +12,11 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=MoveToTaskEndTimeAction.class)
+@FieldDecorator(action=MoveToTaskEndTimeAction.class)
public @interface MoveToTaskEndTime {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskEndTimeAction.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskEndTimeAction.java
index 3862c20..3cdfbce 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskEndTimeAction.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskEndTimeAction.java
@@ -5,10 +5,10 @@ package org.gcube.accounting.datamodel.backwardcompatibility;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -21,10 +21,10 @@ public class MoveToTaskEndTimeAction implements FieldAction {
*/
@Override
public Comparable extends Serializable> validate(String key,
- Comparable extends Serializable> value, UsageRecord usageRecord)
+ Comparable extends Serializable> value, Record record)
throws InvalidValueException {
- usageRecord.setResourceProperty(AbstractTaskUsageRecord.TASK_END_TIME, value);
- return usageRecord.getResourceProperty(AbstractTaskUsageRecord.TASK_END_TIME);
+ record.setResourceProperty(AbstractTaskUsageRecord.TASK_END_TIME, value);
+ return null;
}
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskStartTime.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskStartTime.java
index 5096d58..86698e9 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskStartTime.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskStartTime.java
@@ -12,11 +12,11 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=MoveToTaskStartTimeAction.class)
+@FieldDecorator(action=MoveToTaskStartTimeAction.class)
public @interface MoveToTaskStartTime {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskStartTimeAction.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskStartTimeAction.java
index 4641f40..3dbd902 100644
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskStartTimeAction.java
+++ b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToTaskStartTimeAction.java
@@ -5,10 +5,10 @@ package org.gcube.accounting.datamodel.backwardcompatibility;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractTaskUsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -21,10 +21,10 @@ public class MoveToTaskStartTimeAction implements FieldAction {
*/
@Override
public Comparable extends Serializable> validate(String key,
- Comparable extends Serializable> value, UsageRecord usageRecord)
+ Comparable extends Serializable> value, Record record)
throws InvalidValueException {
- usageRecord.setResourceProperty(AbstractTaskUsageRecord.TASK_START_TIME, value);
- return usageRecord.getResourceProperty(AbstractTaskUsageRecord.TASK_START_TIME);
+ record.setResourceProperty(AbstractTaskUsageRecord.TASK_START_TIME, value);
+ return null;
}
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToUsageRecordType.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToUsageRecordType.java
deleted file mode 100644
index 15e1cea..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToUsageRecordType.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- *
- */
-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.accounting.datamodel.decorators.FieldDecorator;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=MoveToUsageRecordTypeAction.class)
-public @interface MoveToUsageRecordType { }
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToUsageRecordTypeAction.java b/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToUsageRecordTypeAction.java
deleted file mode 100644
index 108f000..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/backwardcompatibility/MoveToUsageRecordTypeAction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- */
-package org.gcube.accounting.datamodel.backwardcompatibility;
-
-import java.io.Serializable;
-
-import org.gcube.accounting.datamodel.RawUsageRecord;
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.documentstore.exception.InvalidValueException;
-
-@SuppressWarnings("deprecation")
-public class MoveToUsageRecordTypeAction implements FieldAction {
-
- @Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
- if(value instanceof String){
- String newValue = RawUsageRecord.resourceTypeMapping.get(value);
- if(newValue == null){
- throw new InvalidValueException();
- }
- usageRecord.setResourceProperty(RawUsageRecord.USAGE_RECORD_TYPE, newValue);
- }else{
- throw new InvalidValueException();
- }
- return value;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractJobUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractJobUsageRecord.java
index 3203141..afa7d6e 100644
--- a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractJobUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractJobUsageRecord.java
@@ -9,13 +9,13 @@ import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToOperationResult;
-import org.gcube.accounting.datamodel.decorators.ComputedField;
-import org.gcube.accounting.datamodel.decorators.RequiredField;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
-import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
-import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.AggregatedRecord;
+import org.gcube.documentstore.records.implementation.ComputedField;
+import org.gcube.documentstore.records.implementation.RequiredField;
+import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidInteger;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -60,7 +60,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
* {@inheritDoc}
*/
@Override
- protected String giveMeUsageRecordType() {
+ protected String giveMeRecordType() {
return AbstractJobUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractPortletUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractPortletUsageRecord.java
index 37b92e2..22e2443 100644
--- a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractPortletUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractPortletUsageRecord.java
@@ -8,11 +8,11 @@ import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToConsumerId;
-import org.gcube.accounting.datamodel.decorators.RequiredField;
import org.gcube.accounting.datamodel.deprecationmanagement.DeprecatedWarning;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
import org.gcube.documentstore.exception.InvalidValueException;
+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;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -48,7 +48,7 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
* {@inheritDoc}
*/
@Override
- protected String giveMeUsageRecordType() {
+ protected String giveMeRecordType() {
return AbstractPortletUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractServiceUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractServiceUsageRecord.java
index a8ea747..d946b83 100644
--- a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractServiceUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractServiceUsageRecord.java
@@ -7,10 +7,10 @@ import java.io.Serializable;
import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord;
-import org.gcube.accounting.datamodel.decorators.RequiredField;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
-import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.implementation.RequiredField;
+import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -73,7 +73,7 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
* {@inheritDoc}
*/
@Override
- protected String giveMeUsageRecordType() {
+ protected String giveMeRecordType() {
return AbstractServiceUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java
index 32cff79..8ac8ed1 100644
--- a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractStorageUsageRecord.java
@@ -8,15 +8,15 @@ import java.net.URI;
import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord;
-import org.gcube.accounting.datamodel.decorators.RequiredField;
import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
import org.gcube.accounting.datamodel.validations.annotations.ValidDataType;
-import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationType;
import org.gcube.accounting.datamodel.validations.annotations.ValidURI;
import org.gcube.documentstore.exception.InvalidValueException;
+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;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -99,7 +99,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
* {@inheritDoc}
*/
@Override
- protected String giveMeUsageRecordType() {
+ protected String giveMeRecordType() {
return AbstractStorageUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractTaskUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractTaskUsageRecord.java
index c544d2b..b13245d 100644
--- a/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractTaskUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/AbstractTaskUsageRecord.java
@@ -11,12 +11,12 @@ import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToOperationResult;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToTaskEndTime;
import org.gcube.accounting.datamodel.backwardcompatibility.MoveToTaskStartTime;
-import org.gcube.accounting.datamodel.decorators.RequiredField;
import org.gcube.accounting.datamodel.deprecationmanagement.DeprecatedWarning;
-import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
-import org.gcube.accounting.datamodel.validations.annotations.ValidInteger;
-import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.implementation.RequiredField;
+import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidInteger;
+import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -83,7 +83,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
* {@inheritDoc}
*/
@Override
- protected String giveMeUsageRecordType() {
+ protected String giveMeRecordType() {
return AbstractTaskUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/CalculateWallDuration.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/CalculateWallDuration.java
index c7267d7..211656e 100644
--- a/src/main/java/org/gcube/accounting/datamodel/basetypes/CalculateWallDuration.java
+++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/CalculateWallDuration.java
@@ -8,9 +8,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=CalculateWallDurationAction.class)
+@FieldDecorator(action=CalculateWallDurationAction.class)
public @interface CalculateWallDuration {}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/accounting/datamodel/basetypes/CalculateWallDurationAction.java b/src/main/java/org/gcube/accounting/datamodel/basetypes/CalculateWallDurationAction.java
index 0deae93..2761f4c 100644
--- a/src/main/java/org/gcube/accounting/datamodel/basetypes/CalculateWallDurationAction.java
+++ b/src/main/java/org/gcube/accounting/datamodel/basetypes/CalculateWallDurationAction.java
@@ -5,9 +5,9 @@ package org.gcube.accounting.datamodel.basetypes;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -16,9 +16,9 @@ public class CalculateWallDurationAction implements FieldAction {
private static final Logger logger = LoggerFactory.getLogger(CalculateWallDurationAction.class);
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
try {
- long wallDuration = ((AbstractJobUsageRecord) usageRecord).calculateWallDuration();
+ long wallDuration = ((AbstractJobUsageRecord) record).calculateWallDuration();
if(key.compareTo(AbstractJobUsageRecord.WALL_DURATION)==0){
logger.warn("{} is automatically computed using {} and {}. This invocation has the only effect of recalculating the value. Any provided value is ignored.",
AbstractJobUsageRecord.WALL_DURATION, AbstractJobUsageRecord.JOB_START_TIME, AbstractJobUsageRecord.JOB_END_TIME);
diff --git a/src/main/java/org/gcube/accounting/datamodel/decorators/AggregatedField.java b/src/main/java/org/gcube/accounting/datamodel/decorators/AggregatedField.java
deleted file mode 100644
index baa5944..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/decorators/AggregatedField.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.gcube.accounting.datamodel.decorators;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotations indicates that the field is related to an aggregation
- * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
- */
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AggregatedField {
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/decorators/ComputedField.java b/src/main/java/org/gcube/accounting/datamodel/decorators/ComputedField.java
deleted file mode 100644
index 0a512cd..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/decorators/ComputedField.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.gcube.accounting.datamodel.decorators;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotations indicates that the field is calculated using the
- * value of other field in the instance
- * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
- */
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ComputedField {
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/decorators/FieldAction.java b/src/main/java/org/gcube/accounting/datamodel/decorators/FieldAction.java
deleted file mode 100644
index f69cb54..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/decorators/FieldAction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- */
-package org.gcube.accounting.datamodel.decorators;
-
-import java.io.Serializable;
-
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.documentstore.exception.InvalidValueException;
-
-/**
- * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
- */
-public interface FieldAction {
-
- /**
- * Validate (and eventually convert) the value of the property identified by
- * the key.
- * @param key The key of the property
- * @param value The value to be validated (and eventually converted) of the
- * property
- * @param usageRecord the Usage Record the property is attached
- * @return the validated (and eventually converted) value of the property
- * @throws InvalidValueException if the validation or the eventual
- * conversion fails
- */
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException;
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/decorators/FieldDecorator.java b/src/main/java/org/gcube/accounting/datamodel/decorators/FieldDecorator.java
deleted file mode 100644
index a7a20aa..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/decorators/FieldDecorator.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- *
- */
-package org.gcube.accounting.datamodel.decorators;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
- *
- */
-@Target(ElementType.ANNOTATION_TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface FieldDecorator {
-
- Class extends FieldAction> managed();
-}
-
diff --git a/src/main/java/org/gcube/accounting/datamodel/decorators/RequiredField.java b/src/main/java/org/gcube/accounting/datamodel/decorators/RequiredField.java
deleted file mode 100644
index 7baa3bc..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/decorators/RequiredField.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.gcube.accounting.datamodel.decorators;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface RequiredField {
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/deprecationmanagement/DeprecatedWarning.java b/src/main/java/org/gcube/accounting/datamodel/deprecationmanagement/DeprecatedWarning.java
index 8d8878f..4238249 100644
--- a/src/main/java/org/gcube/accounting/datamodel/deprecationmanagement/DeprecatedWarning.java
+++ b/src/main/java/org/gcube/accounting/datamodel/deprecationmanagement/DeprecatedWarning.java
@@ -5,11 +5,11 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=DeprecatedWarningAction.class)
+@FieldDecorator(action=DeprecatedWarningAction.class)
public @interface DeprecatedWarning {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/deprecationmanagement/DeprecatedWarningAction.java b/src/main/java/org/gcube/accounting/datamodel/deprecationmanagement/DeprecatedWarningAction.java
index bfd9546..fcb84c1 100644
--- a/src/main/java/org/gcube/accounting/datamodel/deprecationmanagement/DeprecatedWarningAction.java
+++ b/src/main/java/org/gcube/accounting/datamodel/deprecationmanagement/DeprecatedWarningAction.java
@@ -5,9 +5,9 @@ package org.gcube.accounting.datamodel.deprecationmanagement;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,9 +23,9 @@ public class DeprecatedWarningAction implements FieldAction {
* {@inheritDoc}
*/
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
logger.trace("The field {} is deprecated for {}. Anyway the field will be included in the SingleUsageRecord. The field can be lost during aggregation.",
- key, usageRecord.getClass().getSimpleName());
+ key, record.getClass().getSimpleName());
return value;
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/FixDataVolumeSign.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/FixDataVolumeSign.java
index 923212d..e273a11 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/FixDataVolumeSign.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/FixDataVolumeSign.java
@@ -8,8 +8,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
import org.gcube.accounting.datamodel.validations.validators.FixDataVolumeSignAction;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -17,7 +17,7 @@ import org.gcube.accounting.datamodel.validations.validators.FixDataVolumeSignAc
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=FixDataVolumeSignAction.class)
+@FieldDecorator(action=FixDataVolumeSignAction.class)
public @interface FixDataVolumeSign {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotEmpty.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotEmpty.java
deleted file mode 100644
index f6f49e0..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotEmpty.java
+++ /dev/null
@@ -1,16 +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.decorators.FieldDecorator;
-import org.gcube.accounting.datamodel.validations.validators.NotEmptyValidator;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=NotEmptyValidator.class)
-public @interface NotEmpty {
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotEmptyIfNotNull.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotEmptyIfNotNull.java
deleted file mode 100644
index dbc0630..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotEmptyIfNotNull.java
+++ /dev/null
@@ -1,16 +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.decorators.FieldDecorator;
-import org.gcube.accounting.datamodel.validations.validators.NotEmptyIfNotNullValidator;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=NotEmptyIfNotNullValidator.class)
-public @interface NotEmptyIfNotNull {
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotNull.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotNull.java
deleted file mode 100644
index 86dda9c..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/NotNull.java
+++ /dev/null
@@ -1,16 +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.decorators.FieldDecorator;
-import org.gcube.accounting.datamodel.validations.validators.NotNullValidator;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=NotNullValidator.class)
-public @interface NotNull {
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidDataType.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidDataType.java
index 5725b33..60b6814 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidDataType.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidDataType.java
@@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
import org.gcube.accounting.datamodel.validations.validators.ValidDataTypeValidator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=ValidDataTypeValidator.class)
+@FieldDecorator(action=ValidDataTypeValidator.class)
public @interface ValidDataType {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidIP.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidIP.java
index e051944..81243d1 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidIP.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidIP.java
@@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
import org.gcube.accounting.datamodel.validations.validators.ValidIPValidator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=ValidIPValidator.class)
+@FieldDecorator(action=ValidIPValidator.class)
public @interface ValidIP {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidInteger.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidInteger.java
deleted file mode 100644
index 3433519..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidInteger.java
+++ /dev/null
@@ -1,16 +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.decorators.FieldDecorator;
-import org.gcube.accounting.datamodel.validations.validators.ValidIntegerValidator;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=ValidIntegerValidator.class)
-public @interface ValidInteger {
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidLong.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidLong.java
deleted file mode 100644
index 684a319..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidLong.java
+++ /dev/null
@@ -1,16 +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.decorators.FieldDecorator;
-import org.gcube.accounting.datamodel.validations.validators.ValidLongValidator;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=ValidLongValidator.class)
-public @interface ValidLong {
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidOperationResult.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidOperationResult.java
index 46f62c2..1ca4b5e 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidOperationResult.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidOperationResult.java
@@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
import org.gcube.accounting.datamodel.validations.validators.ValidOperationResultValidator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=ValidOperationResultValidator.class)
+@FieldDecorator(action=ValidOperationResultValidator.class)
public @interface ValidOperationResult {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidOperationType.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidOperationType.java
index 098c1b0..6a2f630 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidOperationType.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidOperationType.java
@@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
import org.gcube.accounting.datamodel.validations.validators.ValidOperationTypeValidator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=ValidOperationTypeValidator.class)
+@FieldDecorator(action=ValidOperationTypeValidator.class)
public @interface ValidOperationType {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidURI.java b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidURI.java
index 3d626bc..5246ad5 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidURI.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/annotations/ValidURI.java
@@ -5,12 +5,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.gcube.accounting.datamodel.decorators.FieldDecorator;
import org.gcube.accounting.datamodel.validations.validators.ValidURIValidator;
+import org.gcube.documentstore.records.implementation.FieldDecorator;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
-@FieldDecorator(managed=ValidURIValidator.class)
+@FieldDecorator(action=ValidURIValidator.class)
public @interface ValidURI {
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/FixDataVolumeSignAction.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/FixDataVolumeSignAction.java
index b475c82..37d7398 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/FixDataVolumeSignAction.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/validators/FixDataVolumeSignAction.java
@@ -5,11 +5,12 @@ package org.gcube.accounting.datamodel.validations.validators;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.OperationType;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
+import org.gcube.documentstore.records.implementation.validations.validators.ValidLongValidator;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
@@ -46,27 +47,27 @@ public class FixDataVolumeSignAction implements FieldAction {
* {@inheritDoc}
*/
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
try {
if(key.compareTo(AbstractStorageUsageRecord.DATA_VOLUME)==0){
- OperationType operationType = (OperationType) usageRecord.getResourceProperty(AbstractStorageUsageRecord.OPERATION_TYPE);
+ OperationType operationType = (OperationType) record.getResourceProperty(AbstractStorageUsageRecord.OPERATION_TYPE);
if(operationType!=null){
ValidLongValidator validLongValidator = new ValidLongValidator();
- value = validLongValidator.validate(key, value, usageRecord);
+ value = validLongValidator.validate(key, value, record);
Long dataVolume = new Long((Long) value);
value = checkIt(dataVolume, operationType);
}
}
if(key.compareTo(AbstractStorageUsageRecord.OPERATION_TYPE)==0){
- Long dataVolume = (Long) usageRecord.getResourceProperty(AbstractStorageUsageRecord.DATA_VOLUME);
+ Long dataVolume = (Long) record.getResourceProperty(AbstractStorageUsageRecord.DATA_VOLUME);
if(dataVolume!=null){
ValidOperationTypeValidator v = new ValidOperationTypeValidator();
- value = v.validate(key, value, usageRecord);
+ value = v.validate(key, value, record);
OperationType operationType = (OperationType) value;
Long newDataVolume = checkIt(dataVolume, operationType);
- usageRecord.setResourceProperty(AbstractStorageUsageRecord.DATA_VOLUME, newDataVolume);
+ record.setResourceProperty(AbstractStorageUsageRecord.DATA_VOLUME, newDataVolume);
}
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyIfNotNullValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyIfNotNullValidator.java
deleted file mode 100644
index d24501c..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyIfNotNullValidator.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.gcube.accounting.datamodel.validations.validators;
-
-import java.io.Serializable;
-import java.util.Map;
-
-public class NotEmptyIfNotNullValidator extends NotEmptyValidator {
-
- protected boolean isValid(Serializable toValidate) {
- if (toValidate == null) return true;
- if (toValidate.getClass().isArray() ){
- return ((Object[])toValidate).length>0;
- }else if ( toValidate instanceof Iterable>){
- return ((Iterable>) toValidate).iterator().hasNext();
- } else if (toValidate instanceof Map,?>){
- return ((Map,?>) toValidate).size()>0;
- } else if (toValidate instanceof String ){
- return !((String)toValidate).isEmpty();
- } else return true;
- }
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyValidator.java
deleted file mode 100644
index b341c56..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyValidator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.gcube.accounting.datamodel.validations.validators;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.documentstore.exception.InvalidValueException;
-
-public class NotEmptyValidator implements FieldAction{
-
- private static final String ERROR = "Is Empty";
-
- protected boolean isValid(Serializable toValidate) {
- if (toValidate == null) return false;
- if (toValidate.getClass().isArray() ){
- return ((Object[])toValidate).length>0;
- }else if ( toValidate instanceof Iterable>){
- return ((Iterable>) toValidate).iterator().hasNext();
- } else if (toValidate instanceof Map,?>){
- return ((Map,?>) toValidate).size()>0;
- } else if (toValidate instanceof String ){
- return !((String)toValidate).isEmpty();
- } else return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
- try{
- if(isValid((Serializable) value)){
- return value;
- }
- }catch(Exception e){
- throw new InvalidValueException(ERROR, e);
- }
- throw new InvalidValueException(ERROR);
- }
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotNullValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotNullValidator.java
deleted file mode 100644
index c6bd4a1..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/NotNullValidator.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.gcube.accounting.datamodel.validations.validators;
-
-import java.io.Serializable;
-
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.documentstore.exception.InvalidValueException;
-
-public class NotNullValidator implements FieldAction {
-
- private static final String ERROR = "Is Null";
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
- if(value!=null){
- return value;
- }
- throw new InvalidValueException(ERROR);
- }
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidDataTypeValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidDataTypeValidator.java
index e03654c..84a2cb6 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidDataTypeValidator.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidDataTypeValidator.java
@@ -2,10 +2,10 @@ package org.gcube.accounting.datamodel.validations.validators;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.DataType;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
public class ValidDataTypeValidator implements FieldAction {
@@ -16,7 +16,7 @@ public class ValidDataTypeValidator implements FieldAction {
*/
@SuppressWarnings("rawtypes")
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
if(value instanceof DataType){
return value;
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidIPValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidIPValidator.java
index 981a9a8..00a6d39 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidIPValidator.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidIPValidator.java
@@ -4,13 +4,13 @@ import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ValidIPValidator implements FieldAction{
+public class ValidIPValidator implements FieldAction {
private static Logger logger = LoggerFactory.getLogger(ValidIPValidator.class);
@@ -47,7 +47,7 @@ public class ValidIPValidator implements FieldAction{
* {@inheritDoc}
*/
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
try {
if(isIpAddress((String) value)){
return (String) value;
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidIntegerValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidIntegerValidator.java
deleted file mode 100644
index 7ee4080..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidIntegerValidator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.gcube.accounting.datamodel.validations.validators;
-
-import java.io.Serializable;
-
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.documentstore.exception.InvalidValueException;
-
-
-public class ValidIntegerValidator implements FieldAction {
-
- private static final String ERROR = String.format("Not Instance of %s", Integer.class.getSimpleName());
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
- if(value instanceof Integer){
- return value;
- }
- Integer integerObj = Integer.valueOf((String) value);
- if(integerObj!=null){
- return integerObj;
- }
-
- throw new InvalidValueException(ERROR);
- }
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidLongValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidLongValidator.java
deleted file mode 100644
index 8d1dd03..0000000
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidLongValidator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.gcube.accounting.datamodel.validations.validators;
-
-import java.io.Serializable;
-
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
-import org.gcube.documentstore.exception.InvalidValueException;
-
-
-public class ValidLongValidator implements FieldAction {
-
- private static final String ERROR = String.format("Not Instance of %s", Integer.class.getSimpleName());
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
- if(value instanceof Long){
- return value;
- }
- try {
- Long longObj = Long.valueOf((String) value);
- if(longObj!=null){
- return longObj;
- }
- }catch (Exception e) {
- throw new InvalidValueException(ERROR, e);
- }
- throw new InvalidValueException(ERROR);
- }
-
-}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidOperationResultValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidOperationResultValidator.java
index 5bb4199..c42de56 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidOperationResultValidator.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidOperationResultValidator.java
@@ -2,10 +2,10 @@ package org.gcube.accounting.datamodel.validations.validators;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
public class ValidOperationResultValidator implements FieldAction {
@@ -16,7 +16,7 @@ public class ValidOperationResultValidator implements FieldAction {
*/
@SuppressWarnings("rawtypes")
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
if(value instanceof OperationResult){
return value;
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidOperationTypeValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidOperationTypeValidator.java
index da9e3e1..2120085 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidOperationTypeValidator.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidOperationTypeValidator.java
@@ -2,11 +2,11 @@ package org.gcube.accounting.datamodel.validations.validators;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.UsageRecord.OperationResult;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.OperationType;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
public class ValidOperationTypeValidator implements FieldAction {
@@ -17,7 +17,7 @@ public class ValidOperationTypeValidator implements FieldAction {
*/
@SuppressWarnings("rawtypes")
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
if(value instanceof OperationType){
return value;
}
diff --git a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidURIValidator.java b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidURIValidator.java
index 8aacd55..a636056 100644
--- a/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidURIValidator.java
+++ b/src/main/java/org/gcube/accounting/datamodel/validations/validators/ValidURIValidator.java
@@ -3,9 +3,9 @@ package org.gcube.accounting.datamodel.validations.validators;
import java.io.Serializable;
import java.net.URI;
-import org.gcube.accounting.datamodel.UsageRecord;
-import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.Record;
+import org.gcube.documentstore.records.implementation.FieldAction;
public class ValidURIValidator implements FieldAction {
@@ -15,7 +15,7 @@ public class ValidURIValidator implements FieldAction {
* {@inheritDoc}
*/
@Override
- public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
+ public Comparable extends Serializable> validate(String key, Comparable extends Serializable> value, Record record) throws InvalidValueException {
try {
if(value instanceof URI){
return value;
diff --git a/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java
index 5b80cee..7a223a2 100644
--- a/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java
+++ b/src/test/java/org/gcube/accounting/datamodel/usagerecords/JobUsageRecordTest.java
@@ -6,11 +6,9 @@ package org.gcube.accounting.datamodel.usagerecords;
import java.util.HashSet;
import java.util.Set;
-import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
-import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.Record;
@@ -23,14 +21,12 @@ import org.junit.Test;
*/
public class JobUsageRecordTest {
- @SuppressWarnings("deprecation")
public static Set getExpectedRequiredFields(){
Set expectedRequiredFields = new HashSet();
expectedRequiredFields.add(Record.ID);
expectedRequiredFields.add(UsageRecord.CONSUMER_ID);
expectedRequiredFields.add(UsageRecord.CREATION_TIME);
expectedRequiredFields.add(UsageRecord.RECORD_TYPE);
- expectedRequiredFields.add(BasicUsageRecord.USAGE_RECORD_TYPE);
expectedRequiredFields.add(UsageRecord.SCOPE);
expectedRequiredFields.add(UsageRecord.OPERATION_RESULT);
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_ID);
diff --git a/src/test/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecordTest.java
index 540c253..a229d93 100644
--- a/src/test/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecordTest.java
+++ b/src/test/java/org/gcube/accounting/datamodel/usagerecords/ServiceUsageRecordTest.java
@@ -6,11 +6,9 @@ package org.gcube.accounting.datamodel.usagerecords;
import java.util.HashSet;
import java.util.Set;
-import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
-import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.Record;
@@ -23,14 +21,12 @@ import org.junit.Test;
*/
public class ServiceUsageRecordTest {
- @SuppressWarnings("deprecation")
public static Set getExpectedRequiredFields(){
Set expectedRequiredFields = new HashSet();
expectedRequiredFields.add(Record.ID);
expectedRequiredFields.add(UsageRecord.CONSUMER_ID);
expectedRequiredFields.add(UsageRecord.CREATION_TIME);
expectedRequiredFields.add(UsageRecord.RECORD_TYPE);
- expectedRequiredFields.add(BasicUsageRecord.USAGE_RECORD_TYPE);
expectedRequiredFields.add(UsageRecord.SCOPE);
expectedRequiredFields.add(UsageRecord.OPERATION_RESULT);
expectedRequiredFields.add(AbstractServiceUsageRecord.CALLER_HOST);
diff --git a/src/test/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecordTest.java b/src/test/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecordTest.java
index 186f1bc..f67b182 100644
--- a/src/test/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecordTest.java
+++ b/src/test/java/org/gcube/accounting/datamodel/usagerecords/StorageUsageRecordTest.java
@@ -6,11 +6,9 @@ package org.gcube.accounting.datamodel.usagerecords;
import java.util.HashSet;
import java.util.Set;
-import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.UsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
-import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.Record;
@@ -41,14 +39,12 @@ public class StorageUsageRecordTest {
logger.trace("Scope reset");
}
- @SuppressWarnings("deprecation")
public static Set getExpectedRequiredFields(){
Set expectedRequiredFields = new HashSet();
expectedRequiredFields.add(Record.ID);
expectedRequiredFields.add(UsageRecord.CONSUMER_ID);
expectedRequiredFields.add(UsageRecord.CREATION_TIME);
expectedRequiredFields.add(UsageRecord.RECORD_TYPE);
- expectedRequiredFields.add(BasicUsageRecord.USAGE_RECORD_TYPE);
expectedRequiredFields.add(UsageRecord.SCOPE);
expectedRequiredFields.add(UsageRecord.OPERATION_RESULT);
expectedRequiredFields.add(AbstractJobUsageRecord.JOB_ID);
diff --git a/src/test/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyIfNotNullValidatorTest.java b/src/test/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyIfNotNullValidatorTest.java
index d53695f..55c699d 100644
--- a/src/test/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyIfNotNullValidatorTest.java
+++ b/src/test/java/org/gcube/accounting/datamodel/validations/validators/NotEmptyIfNotNullValidatorTest.java
@@ -5,8 +5,8 @@ package org.gcube.accounting.datamodel.validations.validators;
import java.io.Serializable;
-import org.gcube.accounting.datamodel.validations.validators.NotEmptyIfNotNullValidator;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.implementation.validations.validators.NotEmptyIfNotNullValidator;
import org.junit.Assert;
import org.junit.Test;
diff --git a/src/test/java/org/gcube/accounting/datamodel/validations/validators/ValidTimeValidatorTest.java b/src/test/java/org/gcube/accounting/datamodel/validations/validators/ValidTimeValidatorTest.java
index bcc7339..b285934 100644
--- a/src/test/java/org/gcube/accounting/datamodel/validations/validators/ValidTimeValidatorTest.java
+++ b/src/test/java/org/gcube/accounting/datamodel/validations/validators/ValidTimeValidatorTest.java
@@ -3,8 +3,8 @@
*/
package org.gcube.accounting.datamodel.validations.validators;
-import org.gcube.accounting.datamodel.validations.validators.ValidLongValidator;
import org.gcube.documentstore.exception.InvalidValueException;
+import org.gcube.documentstore.records.implementation.validations.validators.ValidLongValidator;
import org.junit.Test;
/**