2015-05-28 13:19:25 +02:00
|
|
|
package org.gcube.accounting.datamodel;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Map;
|
2015-07-09 15:34:31 +02:00
|
|
|
import java.util.Set;
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
import org.gcube.accounting.exception.InvalidValueException;
|
|
|
|
|
2015-07-09 15:34:31 +02:00
|
|
|
public interface UsageRecord extends Comparable<UsageRecord> {
|
2015-05-28 13:19:25 +02:00
|
|
|
|
2015-06-04 18:52:29 +02:00
|
|
|
public enum OperationResult {
|
|
|
|
SUCCESS, FAILED
|
|
|
|
}
|
|
|
|
|
2015-07-09 15:34:31 +02:00
|
|
|
/**
|
|
|
|
* @return a Set containing the keys of required fields
|
|
|
|
*/
|
|
|
|
public Set<String> getRequiredFields();
|
|
|
|
|
2015-05-28 13:19:25 +02:00
|
|
|
/**
|
|
|
|
* Return the unique id for this {#UsageRecord}
|
|
|
|
* @return {#UsageRecord} Unique ID
|
|
|
|
*/
|
|
|
|
public String getId();
|
|
|
|
|
|
|
|
/**
|
2015-06-25 17:41:20 +02:00
|
|
|
* The ID is automatically Created by the implementation Class.
|
|
|
|
* Set the ID only if you really know what you are going to do.
|
2015-05-28 13:19:25 +02:00
|
|
|
* Set the unique id for this {#UsageRecord}
|
|
|
|
* @param id {#UsageRecord} Unique ID
|
|
|
|
* @throws InvalidValueException
|
|
|
|
*/
|
|
|
|
public void setId(String id) throws InvalidValueException;
|
|
|
|
|
|
|
|
/**
|
2015-06-25 17:41:20 +02:00
|
|
|
* Return the user (or the Consumer Identity, that in the S2S
|
|
|
|
* communication is another service)
|
2015-05-28 13:19:25 +02:00
|
|
|
* @return Consumer ID
|
|
|
|
*/
|
|
|
|
public String getConsumerId();
|
|
|
|
|
|
|
|
/**
|
2015-06-25 17:41:20 +02:00
|
|
|
* Set the user (or the Consumer Identity, that in the S2S
|
|
|
|
* communication is another service)
|
2015-05-28 13:19:25 +02:00
|
|
|
* @param consumerId Consumer ID
|
|
|
|
* @throws InvalidValueException
|
|
|
|
*/
|
|
|
|
public void setConsumerId(String consumerId) throws InvalidValueException;
|
|
|
|
|
|
|
|
/**
|
2015-06-25 17:41:20 +02:00
|
|
|
* Return the instant when this {#UsageRecord} was created.
|
2015-05-28 13:19:25 +02:00
|
|
|
* @return the creation time for this {#UsageRecord}
|
|
|
|
*/
|
|
|
|
public Calendar getCreationTime();
|
|
|
|
|
|
|
|
/**
|
2015-06-25 17:41:20 +02:00
|
|
|
* The CreationTime is automatically created by the implementation Class.
|
|
|
|
* Set the CreationTime only if you really know what you are going to do.
|
|
|
|
* Set the instant when this {#UsageRecord} was created.
|
2015-05-28 13:19:25 +02:00
|
|
|
* @param creationTime creation time
|
|
|
|
* @throws InvalidValueException
|
|
|
|
*/
|
|
|
|
public void setCreationTime(Calendar creationTime) throws InvalidValueException;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 17:41:20 +02:00
|
|
|
* Return the scope of this {#UsageRecord}
|
|
|
|
* @return The scope of this {#UsageRecord}
|
2015-05-28 13:19:25 +02:00
|
|
|
*/
|
2015-06-23 17:47:38 +02:00
|
|
|
public String getScope();
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the accounting scope of the {#UsageRecord}
|
|
|
|
* @param scope The accounting scope of the {#UsageRecord}
|
|
|
|
* @throws InvalidValueException
|
|
|
|
*/
|
2015-06-23 17:47:38 +02:00
|
|
|
public void setScope(String scope) throws InvalidValueException;
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
2015-06-15 11:28:19 +02:00
|
|
|
* Return all resource-specific properties. The returned Map is a copy of
|
|
|
|
* the internal representation. Any modification to the returned Map MUST
|
|
|
|
* not affect the object
|
2015-06-09 14:54:14 +02:00
|
|
|
* @return a Map containing the properties
|
|
|
|
*/
|
|
|
|
public Map<String, Serializable> getResourceProperties();
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
2015-06-09 14:54:14 +02:00
|
|
|
* Set all resource-specific properties, replacing existing ones
|
2015-05-28 13:19:25 +02:00
|
|
|
*/
|
2015-06-09 14:54:14 +02:00
|
|
|
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
|
|
|
|
*/
|
|
|
|
public Serializable getResourceProperty(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
|
|
|
|
*/
|
|
|
|
public void setResourceProperty(String key, Serializable value) throws InvalidValueException;
|
|
|
|
|
2015-06-04 18:52:29 +02:00
|
|
|
/**
|
2015-06-25 17:41:20 +02:00
|
|
|
* @return the Operation Result of the accounted operation.
|
2015-06-04 18:52:29 +02:00
|
|
|
*/
|
|
|
|
public OperationResult getOperationResult();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the Operation Result related to the accounted Usage Record
|
|
|
|
* @param operationResult the Operation Result to set
|
2015-06-05 09:47:48 +02:00
|
|
|
* @throws InvalidValueException
|
2015-06-04 18:52:29 +02:00
|
|
|
*/
|
2015-06-05 09:47:48 +02:00
|
|
|
public void setOperationResult(OperationResult operationResult) throws InvalidValueException;
|
2015-06-04 18:52:29 +02:00
|
|
|
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
2015-06-25 17:41:20 +02:00
|
|
|
* Validate the Resource Record.
|
|
|
|
* The validation check if all the Required Field are set and has valid
|
|
|
|
* value.
|
2015-05-28 13:19:25 +02:00
|
|
|
* @throws InvalidValueException
|
|
|
|
*/
|
|
|
|
public void validate() throws InvalidValueException;
|
|
|
|
|
|
|
|
}
|