public abstract class BasicUsageRecord extends Object implements UsageRecord, Serializable
UsageRecord.OperationResult| Modifier and Type | Field and Description |
|---|---|
protected static String |
AGGREGATED
Internal USE ONLY.
|
protected Set<String> |
aggregatedFields |
protected Set<String> |
computedFields |
static String |
CONSUMER_ID
KEY for : The user (or the Consumer Identity, that in the S2S
communication is another service).
|
static String |
CREATION_TIME
KEY for : The instant when the UR was created.
|
protected static String |
END_TIME
KEY for : Used in aggregated record.
|
protected static String |
ID
KEY for : The unique identifier for the UsageRecord.
|
protected static String |
OPERATION_COUNT
KEY for : Indicate The Number of Aggregated Operation
|
static String |
OPERATION_RESULT
KEY for : The Operation Result of the accounted operation.
|
protected Set<String> |
requiredFields |
protected Map<String,Serializable> |
resourceProperties
resource-specific properties
|
static String |
SCOPE
KEY for : The accounting scope
|
protected static String |
START_TIME
KEY for : Used in aggregated record.
|
protected static String |
USAGE_RECORD_TYPE
Internal USE ONLY.
|
protected Map<String,List<FieldAction>> |
validation |
| Constructor and Description |
|---|
BasicUsageRecord() |
BasicUsageRecord(Map<String,Serializable> properties) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(UsageRecord usageRecord)
Compare this UsageRecord instance with the one provided as argument
|
protected static Set<Field> |
getAllFields(Class<?> type) |
protected static Class<? extends UsageRecord> |
getClass(String usageRecordName,
boolean aggregated) |
String |
getConsumerId()
Return the user (or the Consumer Identity, that in the S2S
communication is another service)
|
Calendar |
getCreationTime()
Return the instant when this {#UsageRecord} was created.
|
protected Calendar |
getEndTimeAsCalendar()
Return the right end of the time interval covered by this {#UsageRecord}
|
protected long |
getEndTimeInMillis()
Return the right end of the time interval covered by this {#UsageRecord}
|
String |
getId()
Return the unique id for this {#UsageRecord}
|
protected static Map<String,Serializable> |
getMapFromString(String serializedMap) |
protected int |
getOperationCount() |
UsageRecord.OperationResult |
getOperationResult() |
Set<String> |
getRequiredFields() |
Map<String,Serializable> |
getResourceProperties()
Return all resource-specific properties.
|
Serializable |
getResourceProperty(String key)
Return the value of the given resource property.
|
String |
getScope()
Return the scope of this {#UsageRecord}
|
protected Calendar |
getStartTimeAsCalendar()
Return the left end of the time interval covered by this {#UsageRecord}
|
protected long |
getStartTimeInMillis()
Return the left end of the time interval covered by this {#UsageRecord}
|
static UsageRecord |
getUsageRecord(Map<String,Serializable> usageRecordMap)
This method use the resourceType value contained in the Map to instance
the right UsageRecord class and return it.
|
static UsageRecord |
getUsageRecord(String serializedMap) |
String |
getUsageRecordType()
Return the Usage Record Type
|
protected abstract String |
giveMeUsageRecordType() |
protected void |
initializeValidation() |
void |
setConsumerId(String consumerId)
Set the user (or the Consumer Identity, that in the S2S
communication is another service)
|
void |
setCreationTime(Calendar creationTime)
The CreationTime is automatically created by the implementation Class.
|
protected void |
setEndTime(Calendar endTime)
Set the right end of the time interval covered by this {#UsageRecord}
|
void |
setId(String id)
The ID is automatically Created by the implementation Class.
|
protected void |
setOperationCount(int operationCount) |
void |
setOperationResult(UsageRecord.OperationResult operationResult)
Set the Operation Result related to the accounted Usage Record
|
void |
setResourceProperties(Map<String,Serializable> properties)
Set all resource-specific properties, replacing existing ones
|
void |
setResourceProperty(String key,
Serializable value)
Set the value of the given resource property.
|
void |
setScope(String scope)
Set the accounting scope of the {#UsageRecord}
|
protected void |
setStartTime(Calendar startTime)
Set the left end of the time interval covered by this {#UsageRecord}
|
protected void |
setUsageRecordType() |
protected Calendar |
timestampStringToCalendar(long millis) |
String |
toString() |
void |
validate()
Validate the Resource Record.
|
protected Serializable |
validateField(String key,
Serializable serializable) |
protected Map<String,Serializable> |
validateProperties(Map<String,Serializable> properties) |
protected static final String ID
public static final String CONSUMER_ID
public static final String CREATION_TIME
protected static final String USAGE_RECORD_TYPE
public static final String SCOPE
public static final String OPERATION_RESULT
#org.gcube.accounting.datamodel.UsageRecord.OperationResultprotected Map<String,Serializable> resourceProperties
protected Map<String,List<FieldAction>> validation
protected static final String START_TIME
protected static final String END_TIME
protected static final String AGGREGATED
protected static final String OPERATION_COUNT
public BasicUsageRecord()
public BasicUsageRecord(Map<String,Serializable> properties) throws InvalidValueException
InvalidValueExceptionpublic Set<String> getRequiredFields()
getRequiredFields in interface UsageRecordprotected void initializeValidation()
public String getUsageRecordType()
getUsageRecordType in interface UsageRecordprotected abstract String giveMeUsageRecordType()
protected void setUsageRecordType()
public String getId()
getId in interface UsageRecordpublic void setId(String id) throws InvalidValueException
setId in interface UsageRecordid - {#UsageRecord} Unique IDInvalidValueExceptionpublic String getConsumerId()
getConsumerId in interface UsageRecordpublic void setConsumerId(String consumerId) throws InvalidValueException
setConsumerId in interface UsageRecordconsumerId - Consumer IDInvalidValueExceptionprotected Calendar timestampStringToCalendar(long millis)
public Calendar getCreationTime()
getCreationTime in interface UsageRecordpublic void setCreationTime(Calendar creationTime) throws InvalidValueException
setCreationTime in interface UsageRecordcreationTime - creation timeInvalidValueExceptionpublic String getScope()
getScope in interface UsageRecordpublic void setScope(String scope) throws InvalidValueException
setScope in interface UsageRecordscope - The accounting scope of the {#UsageRecord}InvalidValueExceptionpublic Map<String,Serializable> getResourceProperties()
getResourceProperties in interface UsageRecordpublic void setResourceProperties(Map<String,Serializable> properties) throws InvalidValueException
setResourceProperties in interface UsageRecordInvalidValueExceptionpublic Serializable getResourceProperty(String key)
getResourceProperty in interface UsageRecordkey - the key of the requested propertypublic void setResourceProperty(String key, Serializable value) throws InvalidValueException
setResourceProperty in interface UsageRecordkey - the key of the requested propertyvalue - the value of the given resource propertyInvalidValueExceptionprotected long getStartTimeInMillis()
protected Calendar getStartTimeAsCalendar()
protected void setStartTime(Calendar startTime) throws InvalidValueException
startTime - Start TimeInvalidValueExceptionprotected long getEndTimeInMillis()
protected Calendar getEndTimeAsCalendar()
protected void setEndTime(Calendar endTime) throws InvalidValueException
endTime - End TimeInvalidValueExceptionprotected int getOperationCount()
protected void setOperationCount(int operationCount)
throws InvalidValueException
InvalidValueExceptionprotected Serializable validateField(String key, Serializable serializable) throws InvalidValueException
InvalidValueExceptionprotected Map<String,Serializable> validateProperties(Map<String,Serializable> properties) throws InvalidValueException
InvalidValueExceptionpublic void validate()
throws InvalidValueException
validate in interface UsageRecordInvalidValueExceptionpublic UsageRecord.OperationResult getOperationResult()
getOperationResult in interface UsageRecordpublic void setOperationResult(UsageRecord.OperationResult operationResult) throws InvalidValueException
setOperationResult in interface UsageRecordoperationResult - the Operation Result to setInvalidValueExceptionpublic int compareTo(UsageRecord usageRecord)
compareTo in interface Comparable<UsageRecord>usageRecord - the Usage Record to compareprotected static Class<? extends UsageRecord> getClass(String usageRecordName, boolean aggregated) throws ClassNotFoundException
ClassNotFoundExceptionpublic static UsageRecord getUsageRecord(Map<String,Serializable> usageRecordMap) throws Exception
usageRecordMap - Exception - if failsprotected static Map<String,Serializable> getMapFromString(String serializedMap)
public static UsageRecord getUsageRecord(String serializedMap) throws Exception
serializedMap - ExceptionCopyright © 2015. All Rights Reserved.