Fixing accounting lib

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@154346 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-09-21 07:52:10 +00:00
parent de611d3b58
commit 333e440a1a
5 changed files with 33 additions and 21 deletions

View File

@ -12,6 +12,8 @@ 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;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@ -77,6 +79,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
return AbstractJobUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
}
@JsonIgnore
public String getJobName() {
return (String) this.resourceProperties.get(JOB_NAME);
}
@ -85,6 +88,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
setResourceProperty(JOB_NAME, jobName);
}
@JsonIgnore
public String getHost() {
return (String) this.resourceProperties.get(HOST);
}
@ -93,6 +97,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
setResourceProperty(HOST, host);
}
@JsonIgnore
public String getServiceClass() {
return (String) this.resourceProperties.get(SERVICE_CLASS);
}
@ -101,6 +106,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
setResourceProperty(SERVICE_CLASS, serviceClass);
}
@JsonIgnore
public String getServiceName() {
return (String) this.resourceProperties.get(SERVICE_NAME);
}
@ -109,6 +115,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
setResourceProperty(SERVICE_NAME, serviceName);
}
@JsonIgnore
public Long getDuration() {
return (Long) this.resourceProperties.get(DURATION);
}
@ -117,6 +124,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
setResourceProperty(DURATION, duration);
}
@JsonIgnore
public String getCallerQualifier() {
return (String) this.resourceProperties.get(CALLER_QUALIFIER);
}

View File

@ -12,6 +12,8 @@ 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 com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@ -47,6 +49,7 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
return AbstractPortletUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
}
@JsonIgnore
public String getPortletId() {
return (String) this.resourceProperties.get(PORTLET_ID);
}
@ -55,6 +58,7 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
setResourceProperty(PORTLET_ID, portletId);
}
@JsonIgnore
public String getOperationId() {
return (String) this.resourceProperties.get(OPERATION_ID);
}
@ -63,6 +67,7 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
setResourceProperty(OPERATION_ID, operationId);
}
@JsonIgnore
public String getMessage() {
return (String) this.resourceProperties.get(MESSAGE);
}

View File

@ -67,22 +67,14 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
@RequiredField @NotEmpty
public static final String CALLER_QUALIFIER = "callerQualifier";
protected static final String UNKNOWN = "UNKNOWN";
public static final String UNKNOWN = "UNKNOWN";
public AbstractServiceUsageRecord(){
super();
try{
// Need to fix old ServiceUsageRecords which does not have such a field
setResourceProperty(CALLER_QUALIFIER, UNKNOWN);
}catch (Exception e) {
throw new RuntimeException("Unable to set " + CALLER_QUALIFIER + " to " + UNKNOWN);
}
}
public AbstractServiceUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
super(properties);
// Need to fix old ServiceUsageRecords which does not have such a field
setResourceProperty(CALLER_QUALIFIER, UNKNOWN);
}
private static final String ABSTRACT_TO_REPLACE = "Abstract";

View File

@ -16,6 +16,8 @@ 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;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
* @author Luca Frosini (ISTI - CNR)
@ -91,6 +93,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
return AbstractStorageStatusRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
}
@JsonIgnore
public long getDataVolume() {
return (Long) this.resourceProperties.get(DATA_VOLUME);
}
@ -99,6 +102,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
setResourceProperty(DATA_VOLUME, dataVolume);
}
@JsonIgnore
public DataType getDataType() {
return (DataType) this.resourceProperties.get(DATA_TYPE);
}
@ -107,6 +111,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
setResourceProperty(DATA_TYPE, dataType);
}
@JsonIgnore
public long getDataCount() {
return (Long) this.resourceProperties.get(DATA_COUNT);
}
@ -115,6 +120,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
setResourceProperty(DATA_COUNT, dataCount);
}
@JsonIgnore
public String getDataServiceClass() {
return (String) this.resourceProperties.get(DATA_SERVICECLASS);
}
@ -123,6 +129,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
setResourceProperty(DATA_SERVICECLASS, dataServiceClass);
}
@JsonIgnore
public String getDataServiceName() {
return (String) this.resourceProperties.get(DATA_SERVICENAME);
}
@ -131,6 +138,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
setResourceProperty(DATA_SERVICENAME, dataServiceName);
}
@JsonIgnore
public String getDataServiceId() {
return (String) this.resourceProperties.get(DATA_SERVICEID);
}
@ -139,6 +147,7 @@ public abstract class AbstractStorageStatusRecord extends BasicUsageRecord {
setResourceProperty(DATA_SERVICEID, dataServiceId);
}
@JsonIgnore
public URI getProviderId() {
return (URI) this.resourceProperties.get(PROVIDER_ID);
}

View File

@ -18,6 +18,8 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@ -84,8 +86,6 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
@NotEmptyIfNotNull
public static final String QUALIFIER = "qualifier";
/**
* KEY for : callerQualifier
*/
@ -112,6 +112,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
* Return the identity id of the storage resource owner
* @return the identity id of the accounting owner
*/
@JsonIgnore
public String getResourceOwner() {
return (String) this.resourceProperties.get(RESOURCE_OWNER);
}
@ -128,6 +129,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
* Return the scope of the storage resource
* @return The scope id of the storage resource
*/
@JsonIgnore
public String getResourceScope() {
return (String) this.resourceProperties.get(RESOURCE_SCOPE);
}
@ -141,6 +143,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
setResourceProperty(RESOURCE_SCOPE, scope);
}
@JsonIgnore
public URI getProviderURI() {
return (URI) this.resourceProperties.get(PROVIDER_URI);
}
@ -149,6 +152,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
setResourceProperty(PROVIDER_URI, providerURI);
}
@JsonIgnore
public URI getResourceURI() {
return (URI) this.resourceProperties.get(RESOURCE_URI);
}
@ -157,6 +161,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
setResourceProperty(RESOURCE_URI, resourceURI);
}
@JsonIgnore
public OperationType getOperationType() {
return (OperationType) this.resourceProperties.get(OPERATION_TYPE);
}
@ -165,6 +170,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
setResourceProperty(OPERATION_TYPE, operationType);
}
@JsonIgnore
public DataType getDataType() {
return (DataType) this.resourceProperties.get(DATA_TYPE);
}
@ -173,6 +179,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
setResourceProperty(DATA_TYPE, dataType);
}
@JsonIgnore
public long getDataVolume() {
return (Long) this.resourceProperties.get(DATA_VOLUME);
}
@ -181,6 +188,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
setResourceProperty(DATA_VOLUME, dataVolume);
}
@JsonIgnore
public String getQualifier() {
return (String) this.resourceProperties.get(QUALIFIER);
}
@ -189,14 +197,4 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
setResourceProperty(QUALIFIER, qualifier);
}
/*Add a new field*/
/*
public String getCallerQualifier() {
return (String) this.resourceProperties.get(CALLERQUALIFIER);
}
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
setResourceProperty(CALLERQUALIFIER, callerQualifier);
}
*/
}