refs #200: Create accouting-lib library

https://support.d4science.org/issues/200
Fixing data model

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115376 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-06-15 09:28:19 +00:00
parent 0bd2074020
commit cdb9707745
6 changed files with 248 additions and 397 deletions

View File

@ -12,26 +12,6 @@ import org.gcube.accounting.exception.InvalidValueException;
*/ */
public interface AggregatedUsageRecord<T> extends UsageRecord { public interface AggregatedUsageRecord<T> extends UsageRecord {
/**
* 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();
/**
* 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;
/** /**
* Return the id of the usage record aggregating this, null if this record * Return the id of the usage record aggregating this, null if this record
* has not been aggregated by any record. * has not been aggregated by any record.

View File

@ -5,16 +5,11 @@ package org.gcube.accounting.datamodel;
import java.io.Serializable; import java.io.Serializable;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -28,12 +23,10 @@ import org.gcube.accounting.datamodel.decorators.ComputedField;
import org.gcube.accounting.datamodel.decorators.FieldAction; import org.gcube.accounting.datamodel.decorators.FieldAction;
import org.gcube.accounting.datamodel.decorators.FieldDecorator; import org.gcube.accounting.datamodel.decorators.FieldDecorator;
import org.gcube.accounting.datamodel.decorators.RequiredField; import org.gcube.accounting.datamodel.decorators.RequiredField;
import org.gcube.accounting.datamodel.deprecationmanagement.annotations.DeprecatedWarning;
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty; import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull; import org.gcube.accounting.datamodel.validations.annotations.NotEmptyIfNotNull;
import org.gcube.accounting.datamodel.validations.annotations.ValidLong; import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult; import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult;
import org.gcube.accounting.datamodel.validations.validators.NotEmptyIfNotNullValidator;
import org.gcube.accounting.exception.InvalidValueException; import org.gcube.accounting.exception.InvalidValueException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -70,31 +63,12 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
@RequiredField @NotEmpty @RequiredField @NotEmpty
public static final String RESOURCE_SCOPE = "resourceScope"; public static final String RESOURCE_SCOPE = "resourceScope";
@DeprecatedWarning @NotEmpty
protected static final String RESOURCE_OWNER = "resourceOwner";
@AggregatedField @NotEmptyIfNotNull @AggregatedField @NotEmptyIfNotNull
protected static final String AGGREGATED = "aggregated"; protected static final String AGGREGATED = "aggregated";
@AggregatedField @NotEmptyIfNotNull @AggregatedField @NotEmptyIfNotNull
protected static final String AGGREGATED_USAGE_RECORD_ID = "aggregatedUsageRecordId"; protected static final String AGGREGATED_USAGE_RECORD_ID = "aggregatedUsageRecordId";
@NotEmptyIfNotNull @MoveToAggregatedUsageRecordId
protected static final String AGGREGATED_ID = "aggregatedId";
@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;
}
}
@RequiredField @ValidOperationResult @RequiredField @ValidOperationResult
public static final String OPERATION_RESULT = "operationResult"; public static final String OPERATION_RESULT = "operationResult";
@ -237,32 +211,11 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
setResourceProperty(CREATION_TIME, creationTime.getTimeInMillis()); setResourceProperty(CREATION_TIME, creationTime.getTimeInMillis());
} }
@Override
@Deprecated
public Date getCreateTime() {
long millis = (Long) this.resourceProperties.get(CREATION_TIME);
return timestampStringToCalendar(millis).getTime();
}
/** /**
* {@inheritDoc} * Return the left end of the time interval covered by this {#UsageRecord}
* @return Start Time
*/ */
@Override protected Calendar getStartTimeAsCalendar() {
@Deprecated
public void setCreateTime(Date createTime) throws InvalidValueException {
/*
Calendar calendar = Calendar.getInstance();
calendar.setTime(createTime);
setCreationTime(calendar);
*/
logger.warn("The method is deprecated. Please modify your code as soon as possible");
}
/**
* {@inheritDoc}
*/
@Override
public Calendar getStartTime() {
long millis = (Long) this.resourceProperties.get(START_TIME); long millis = (Long) this.resourceProperties.get(START_TIME);
return timestampStringToCalendar(millis); return timestampStringToCalendar(millis);
} }
@ -276,23 +229,12 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
setResourceProperty(START_TIME, startTime.getTimeInMillis()); setResourceProperty(START_TIME, startTime.getTimeInMillis());
} }
/* *
* {@inheritDoc}
* /
@Override
@Deprecated
public void setStartTime(Date startTime) throws InvalidValueException {
Calendar calendar = Calendar.getInstance();
calendar.setTime(startTime);
setStartTime(calendar);
}
*/
/** /**
* {@inheritDoc} * Return the right end of the time interval covered by this {#UsageRecord}
* @return End Time
*/ */
@Override protected Calendar getEndTimeAsCalendar() {
public Calendar getEndTime() {
long millis = (Long) this.resourceProperties.get(END_TIME); long millis = (Long) this.resourceProperties.get(END_TIME);
return timestampStringToCalendar(millis); return timestampStringToCalendar(millis);
} }
@ -306,39 +248,12 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
setResourceProperty(END_TIME, endTime.getTimeInMillis()); setResourceProperty(END_TIME, endTime.getTimeInMillis());
} }
/* * /*
* {@inheritDoc}
* /
@Override
@Deprecated
public void setEndTime(Date endTime) throws InvalidValueException {
Calendar calendar = Calendar.getInstance();
calendar.setTime(endTime);
setEndTime(calendar);
}
*/
protected String getUsageRecordType() { protected String getUsageRecordType() {
//return (String) this.resourceSpecificProperties.get(RESOURCE_TYPE); //return (String) this.resourceSpecificProperties.get(RESOURCE_TYPE);
return this.getClass().getSimpleName(); return this.getClass().getSimpleName();
} }
*/
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public String getResourceType(){
return (String) this.resourceProperties.get(USAGE_RECORD_TYPE);
}
/**
* {@inheritDoc}
*/
@Deprecated
public void setResourceType(String resourceType){
logger.warn("The method is deprecated. Please modify your code as soon as possible");
}
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -356,42 +271,6 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
setResourceProperty(RESOURCE_SCOPE, scope); setResourceProperty(RESOURCE_SCOPE, scope);
} }
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public String getResourceOwner() {
return (String) this.resourceProperties.get(RESOURCE_OWNER);
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public void setResourceOwner(String owner) throws InvalidValueException {
setResourceProperty(RESOURCE_OWNER, owner);
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public String getAggregatedId() {
return (String) this.resourceProperties.get(AGGREGATED_ID);
}
/**
* {@inheritDoc}
*/
@Override@
Deprecated
public void setAggregatedId(String aggregatedId) throws InvalidValueException {
setResourceProperty(AGGREGATED_ID, aggregatedId);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -408,31 +287,12 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
setResourceProperty(AGGREGATED_USAGE_RECORD_ID, aggregatedId); setResourceProperty(AGGREGATED_USAGE_RECORD_ID, aggregatedId);
} }
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public Map<String, Serializable> getResourceSpecificProperties() {
return getResourceProperties();
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public void setResourceSpecificProperties(Map<String, Serializable> properties) throws InvalidValueException {
setResourceProperties(properties);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public Map<String, Serializable> getResourceProperties() { public Map<String, Serializable> getResourceProperties() {
return this.resourceProperties; return new HashMap<String, Serializable>(this.resourceProperties);
} }
/** /**
@ -444,24 +304,6 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
this.resourceProperties = new HashMap<String, Serializable>(properties); this.resourceProperties = new HashMap<String, Serializable>(properties);
} }
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public Serializable getResourceSpecificProperty(String key) {
return getResourceProperty(key);
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public void setResourceSpecificProperty(String key, Serializable value) throws InvalidValueException {
setResourceProperty(key, value);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -534,24 +376,6 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
return resourceProperties.toString(); return resourceProperties.toString();
} }
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public String getFullyQualifiedConsumerId() {
return getConsumerId();
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public void setFullyQualifiedConsumerId(String fqcid) { }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -21,6 +21,8 @@ import org.gcube.accounting.datamodel.implementations.PortletUsageRecord;
import org.gcube.accounting.datamodel.implementations.ServiceUsageRecord; import org.gcube.accounting.datamodel.implementations.ServiceUsageRecord;
import org.gcube.accounting.datamodel.implementations.StorageUsageRecord; import org.gcube.accounting.datamodel.implementations.StorageUsageRecord;
import org.gcube.accounting.datamodel.implementations.TaskUsageRecord; import org.gcube.accounting.datamodel.implementations.TaskUsageRecord;
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
import org.gcube.accounting.datamodel.validations.validators.NotEmptyIfNotNullValidator;
import org.gcube.accounting.exception.InvalidValueException; import org.gcube.accounting.exception.InvalidValueException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -30,7 +32,7 @@ import org.slf4j.LoggerFactory;
* *
*/ */
@Deprecated @Deprecated
public class RawUsageRecord extends BasicUsageRecord{ public class RawUsageRecord extends BasicUsageRecord {
/** /**
* Generated Serial Version UID * Generated Serial Version UID
@ -39,7 +41,11 @@ public class RawUsageRecord extends BasicUsageRecord{
private static Logger logger = LoggerFactory.getLogger(RawUsageRecord.class); private static Logger logger = LoggerFactory.getLogger(RawUsageRecord.class);
@MoveToCreationTime
@DeprecatedWarning @NotEmpty
protected static final String RESOURCE_OWNER = "resourceOwner";
@DeprecatedWarning @MoveToCreationTime
protected static final String CREATE_TIME = "createTime"; protected static final String CREATE_TIME = "createTime";
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@ -70,13 +76,6 @@ public class RawUsageRecord extends BasicUsageRecord{
} }
} }
@DeprecatedWarning
protected static final String RESOURCE_TYPE = "resourceType";
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@FieldDecorator(managed=MoveToUsageRecordTypeAction.class)
protected @interface MoveToUsageRecordType { }
private final static Map<String, String> resourceTypeMapping; private final static Map<String, String> resourceTypeMapping;
private final static String JOB = "job"; private final static String JOB = "job";
@ -95,6 +94,12 @@ public class RawUsageRecord extends BasicUsageRecord{
} }
@DeprecatedWarning @MoveToUsageRecordType
protected static final String RESOURCE_TYPE = "resourceType";
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@FieldDecorator(managed=MoveToUsageRecordTypeAction.class)
protected @interface MoveToUsageRecordType { }
protected class MoveToUsageRecordTypeAction implements FieldAction { protected class MoveToUsageRecordTypeAction implements FieldAction {
@Override @Override
@ -112,6 +117,24 @@ public class RawUsageRecord extends BasicUsageRecord{
} }
} }
@DeprecatedWarning @MoveToAggregatedUsageRecordId
protected static final String AGGREGATED_ID = "aggregatedId";
@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;
}
}
public RawUsageRecord(){ public RawUsageRecord(){
super(); super();
this.resourceProperties.remove(USAGE_RECORD_TYPE); this.resourceProperties.remove(USAGE_RECORD_TYPE);
@ -122,16 +145,20 @@ public class RawUsageRecord extends BasicUsageRecord{
} }
/** /**
* {@inheritDoc} * Use {#getUsageRecordType} instead
* @param resourceType
* @return Usage Record Type
*/ */
@Override
@Deprecated @Deprecated
public String getResourceType(){ public String getResourceType(){
return (String) this.resourceProperties.get(RESOURCE_TYPE); return (String) this.resourceProperties.get(RESOURCE_TYPE);
} }
/** /**
* {@inheritDoc} * 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 @Deprecated
public void setResourceType(String resourceType){ public void setResourceType(String resourceType){
@ -143,6 +170,181 @@ public class RawUsageRecord extends BasicUsageRecord{
} }
/**
* Return the creation time for this {#UsageRecord}
* @return the creation time for this {#UsageRecord}
*/
@Deprecated
public Date getCreateTime() {
long millis = (Long) this.resourceProperties.get(CREATION_TIME);
return timestampStringToCalendar(millis).getTime();
}
/**
* Use {{@link #setCreationTime(Calendar)}} instead
* @param createTime
* @throws InvalidValueException
*/
@Deprecated
public void setCreateTime(Date createTime) throws InvalidValueException {
/*
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(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(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 accounting owner
* @return The identity id of the accounting owner
*/
@Deprecated
public String getResourceOwner() {
return (String) this.resourceProperties.get(RESOURCE_OWNER);
}
/**
* Set the identity id of the accounting owner
* @param ownerID The identity id of the accounting owner
* @throws InvalidValueException
*/
@Deprecated
public void setResourceOwner(String owner) throws InvalidValueException {
setResourceProperty(RESOURCE_OWNER, 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<String, Serializable> getResourceSpecificProperties() {
return getResourceProperties();
}
/**
* Set all resource properties, replacing existing ones
* Use {@link #setResourceSpecificProperties()}
*/
@Deprecated
public void setResourceSpecificProperties(Map<String, Serializable> properties) throws InvalidValueException {
setResourceProperties(properties);
}
/**
* 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 Serializable getResourceSpecificProperty(String key) {
return getResourceProperty(key);
}
/**
* 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, Serializable value) throws InvalidValueException {
setResourceProperty(key, value);
}
/**
* The method is deprecated and the implementations in known classes
* return Consumer ID
* @return Consumer ID
*/
@Deprecated
public String getFullyQualifiedConsumerId() {
return getConsumerId();
}
/**
* 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) {
// TODO
}
} }

View File

@ -2,7 +2,6 @@ package org.gcube.accounting.datamodel;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.gcube.accounting.exception.InvalidValueException; import org.gcube.accounting.exception.InvalidValueException;
@ -66,81 +65,6 @@ public interface UsageRecord extends Comparable<UsageRecord>{
*/ */
public void setCreationTime(Calendar creationTime) throws InvalidValueException; public void setCreationTime(Calendar creationTime) throws InvalidValueException;
/**
* Return the creation time for this {#UsageRecord}
* @return the creation time for this {#UsageRecord}
*/
@Deprecated
public Date getCreateTime();
/**
* Use {{@link #setCreationTime(Calendar)}} instead
* @param createTime
* @throws InvalidValueException
*/
@Deprecated
public void setCreateTime(Date createTime) throws InvalidValueException;
/**
* Return the left end of the time interval covered by this {#UsageRecord}
* @return Start Time
*/
public Calendar getStartTime();
/* *
* Set the left end of the time interval covered by this {#UsageRecord}
* @param startTime Start Time
* @throws InvalidValueException
* /
public void setStartTime(Calendar startTime) throws InvalidValueException;
/* *
* Use {{@link #setStartTime(Calendar)}} instead
* @param createTime
* @throws InvalidValueException
* /
@Deprecated
public void setStartTime(Date startTime) throws InvalidValueException;
*/
/**
* Return the right end of the time interval covered by this {#UsageRecord}
* @return End Time
*/
public Calendar getEndTime();
/* *
* Set the right end of the time interval covered by this {#UsageRecord}
* @param endTime End Time
* @throws InvalidValueException
* /
public void setEndTime(Calendar endTime) throws InvalidValueException;
/* *
* Use {{@link #setEndTime(Calendar)}} instead
* @param createTime
* @throws InvalidValueException
* /
@Deprecated
public void setEndTime(Date endTime) throws InvalidValueException;
*/
/**
* Use {#getUsageRecordType} instead
* @param resourceType
* @return Usage Record Type
*/
@Deprecated
public String getResourceType();
/**
* 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);
/** /**
* Return the accounting scope of the {#UsageRecord} * Return the accounting scope of the {#UsageRecord}
@ -155,41 +79,6 @@ public interface UsageRecord extends Comparable<UsageRecord>{
*/ */
public void setResourceScope(String scope) throws InvalidValueException; public void setResourceScope(String scope) throws InvalidValueException;
/**
* Return the identity id of the accounting owner
* @return The identity id of the accounting owner
*/
@Deprecated
public String getResourceOwner();
/**
* Set the identity id of the accounting owner
* @param ownerID The identity id of the accounting owner
* @throws InvalidValueException
*/
@Deprecated
public void setResourceOwner(String ownerID) throws InvalidValueException;
/**
* 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();
/**
* 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;
/** /**
* Return the id of the usage record aggregating this, null if this record * Return the id of the usage record aggregating this, null if this record
* has not been aggregated by any record. * has not been aggregated by any record.
@ -205,22 +94,9 @@ public interface UsageRecord extends Comparable<UsageRecord>{
public void setAggregatedUsageRecordId(String aggregatedId) throws InvalidValueException; public void setAggregatedUsageRecordId(String aggregatedId) throws InvalidValueException;
/** /**
* Return all resource properties * Return all resource-specific properties. The returned Map is a copy of
* Use {@link #getResourceSpecificProperties()} * the internal representation. Any modification to the returned Map MUST
* @return a Map containing the properties * not affect the object
*/
@Deprecated
public Map<String, Serializable> getResourceSpecificProperties();
/**
* Set all resource properties, replacing existing ones
* Use {@link #setResourceSpecificProperties()}
*/
@Deprecated
public void setResourceSpecificProperties(Map<String, Serializable> resourceSpecificProperties) throws InvalidValueException;
/**
* Return all resource-specific properties
* @return a Map containing the properties * @return a Map containing the properties
*/ */
public Map<String, Serializable> getResourceProperties(); public Map<String, Serializable> getResourceProperties();
@ -231,24 +107,6 @@ public interface UsageRecord extends Comparable<UsageRecord>{
public void setResourceProperties(Map<String, Serializable> resourceSpecificProperties) throws InvalidValueException; public void setResourceProperties(Map<String, Serializable> resourceSpecificProperties) throws InvalidValueException;
/**
* 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 Serializable getResourceSpecificProperty(String key);
/**
* 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, Serializable value) throws InvalidValueException;
/** /**
* Return the value of the given resource property. * Return the value of the given resource property.
* @param key the key of the requested property * @param key the key of the requested property
@ -265,23 +123,6 @@ public interface UsageRecord extends Comparable<UsageRecord>{
*/ */
public void setResourceProperty(String key, Serializable value) throws InvalidValueException; public void setResourceProperty(String key, Serializable value) throws InvalidValueException;
/**
* The method is deprecated and the implementations in known classes
* return Consumer ID
* @return Consumer ID
*/
@Deprecated
public String getFullyQualifiedConsumerId();
/**
* 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);
/** /**
* @return the Operation Result related to the accounted Usage Record * @return the Operation Result related to the accounted Usage Record
*/ */

View File

@ -36,6 +36,8 @@ public class StorageUsageRecord extends BasicUsageRecord implements SingleUsageR
GET, PUT, UPDATE, DELETE GET, PUT, UPDATE, DELETE
} }
@NotEmpty
public static final String RESOURCE_OWNER = "resourceOwner";
@NotEmptyIfNotNull @NotEmptyIfNotNull
public static final String PROVIDER_ID = "providerId"; public static final String PROVIDER_ID = "providerId";
@NotEmptyIfNotNull @NotEmptyIfNotNull
@ -61,6 +63,23 @@ public class StorageUsageRecord extends BasicUsageRecord implements SingleUsageR
super(properties); super(properties);
} }
/**
* Return the identity id of the accounting owner
* @return The identity id of the accounting owner
*/
public String getResourceOwner() {
return (String) this.resourceProperties.get(RESOURCE_OWNER);
}
/**
* Set the identity id of the accounting owner
* @param ownerID The identity id of the accounting owner
* @throws InvalidValueException
*/
public void setResourceOwner(String owner) throws InvalidValueException {
setResourceProperty(RESOURCE_OWNER, owner);
}
public String getObjectURI() { public String getObjectURI() {
return (String) this.resourceProperties.get(OBJECT_URI); return (String) this.resourceProperties.get(OBJECT_URI);
} }
@ -125,20 +144,4 @@ public class StorageUsageRecord extends BasicUsageRecord implements SingleUsageR
setResourceProperty(DATA_COUNT, dataCount); setResourceProperty(DATA_COUNT, dataCount);
} }
/**
* {@inheritDoc}
*/
@Override
public String getResourceOwner() {
return (String) this.resourceProperties.get(RESOURCE_OWNER);
}
/**
* {@inheritDoc}
*/
@Override
public void setResourceOwner(String owner) throws InvalidValueException {
setResourceProperty(RESOURCE_OWNER, owner);
}
} }

View File

@ -40,4 +40,5 @@ public class JobUsageRecord extends org.gcube.accounting.datamodel.implementatio
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} }