2015-05-28 13:19:25 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-07-01 12:50:00 +02:00
|
|
|
package org.gcube.accounting.datamodel.basetypes;
|
2015-05-28 13:19:25 +02:00
|
|
|
|
2015-06-09 15:53:21 +02:00
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2015-06-10 17:36:50 +02:00
|
|
|
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
2019-11-15 13:38:37 +01:00
|
|
|
import org.gcube.accounting.datamodel.validations.annotations.Harmonize;
|
2020-07-10 18:30:52 +02:00
|
|
|
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
2015-12-18 17:09:05 +01:00
|
|
|
import org.gcube.documentstore.exception.InvalidValueException;
|
2015-12-21 11:50:09 +01:00
|
|
|
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;
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
2016-10-12 14:15:28 +02:00
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
2015-05-28 13:19:25 +02:00
|
|
|
*/
|
2017-09-06 11:47:13 +02:00
|
|
|
public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generated Serial Version UID
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = -4214891294699473587L;
|
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
/**
|
2015-06-26 15:50:39 +02:00
|
|
|
* KEY for : hostname:port of the Hosting Node made the service call
|
2015-06-25 17:41:56 +02:00
|
|
|
*/
|
2017-05-11 16:38:38 +02:00
|
|
|
|
2015-06-08 17:30:08 +02:00
|
|
|
@RequiredField @NotEmpty
|
2015-07-13 11:26:50 +02:00
|
|
|
public static final String CALLER_HOST = "callerHost";
|
2015-06-26 12:21:28 +02:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
/**
|
2015-06-26 15:50:39 +02:00
|
|
|
* KEY for : hostname:port of the Hosting Node receiving the service call
|
2015-06-25 17:41:56 +02:00
|
|
|
*/
|
2015-06-08 17:30:08 +02:00
|
|
|
@RequiredField @NotEmpty
|
2015-06-26 15:50:39 +02:00
|
|
|
public static final String HOST = "host";
|
2015-06-26 12:21:28 +02:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
/**
|
2015-06-26 12:21:28 +02:00
|
|
|
* KEY for : Service Class
|
2015-06-25 17:41:56 +02:00
|
|
|
*/
|
2015-06-09 17:36:38 +02:00
|
|
|
@RequiredField @NotEmpty
|
2015-05-28 13:19:25 +02:00
|
|
|
public static final String SERVICE_CLASS = "serviceClass";
|
2015-06-26 12:21:28 +02:00
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
/**
|
2015-06-26 12:21:28 +02:00
|
|
|
* KEY for : Service Name
|
2015-06-25 17:41:56 +02:00
|
|
|
*/
|
2015-06-09 17:36:38 +02:00
|
|
|
@RequiredField @NotEmpty
|
2015-05-28 13:19:25 +02:00
|
|
|
public static final String SERVICE_NAME = "serviceName";
|
2015-06-26 12:21:28 +02:00
|
|
|
|
2015-07-13 11:26:50 +02:00
|
|
|
/**
|
2016-09-08 17:21:05 +02:00
|
|
|
* KEY for : Called Method
|
2015-07-13 11:26:50 +02:00
|
|
|
*/
|
2019-11-15 13:38:37 +01:00
|
|
|
@RequiredField @NotEmpty @Harmonize
|
2015-07-13 11:26:50 +02:00
|
|
|
public static final String CALLED_METHOD = "calledMethod";
|
|
|
|
|
2015-06-25 17:41:56 +02:00
|
|
|
/**
|
2016-09-08 17:21:05 +02:00
|
|
|
* KEY for : Duration
|
2015-06-25 17:41:56 +02:00
|
|
|
*/
|
2015-06-18 16:30:42 +02:00
|
|
|
@RequiredField @ValidLong
|
|
|
|
public static final String DURATION = "duration";
|
|
|
|
|
2016-09-08 17:21:05 +02:00
|
|
|
/**
|
|
|
|
* KEY for : callerQualifier
|
|
|
|
*/
|
|
|
|
@RequiredField @NotEmpty
|
2017-09-06 11:47:13 +02:00
|
|
|
public static final String CALLER_QUALIFIER = "callerQualifier";
|
2016-09-29 10:37:39 +02:00
|
|
|
|
2017-09-21 09:52:10 +02:00
|
|
|
public static final String UNKNOWN = "UNKNOWN";
|
2016-09-08 17:21:05 +02:00
|
|
|
|
2015-07-29 14:41:28 +02:00
|
|
|
public AbstractServiceUsageRecord(){
|
2015-05-28 13:19:25 +02:00
|
|
|
super();
|
|
|
|
}
|
2015-05-29 16:08:21 +02:00
|
|
|
|
2016-01-28 18:29:11 +01:00
|
|
|
public AbstractServiceUsageRecord(Map<String, ? extends Serializable> properties) throws InvalidValueException {
|
2015-06-09 15:53:21 +02:00
|
|
|
super(properties);
|
|
|
|
}
|
2015-07-29 14:41:28 +02:00
|
|
|
|
|
|
|
private static final String ABSTRACT_TO_REPLACE = "Abstract";
|
|
|
|
|
|
|
|
@Override
|
2017-09-06 11:47:13 +02:00
|
|
|
public String getRecordType() {
|
2015-07-29 14:41:28 +02:00
|
|
|
return AbstractServiceUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
2017-05-11 16:38:38 +02:00
|
|
|
|
2015-07-29 14:41:28 +02:00
|
|
|
}
|
2015-06-09 15:53:21 +02:00
|
|
|
|
2017-09-18 15:08:46 +02:00
|
|
|
@JsonIgnore
|
2015-06-26 15:50:39 +02:00
|
|
|
public String getCallerHost() {
|
|
|
|
return (String) this.resourceProperties.get(CALLER_HOST);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public void setCallerHost(String callerHost) throws InvalidValueException {
|
|
|
|
setResourceProperty(CALLER_HOST, callerHost);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2017-09-18 15:08:46 +02:00
|
|
|
@JsonIgnore
|
2015-06-26 15:50:39 +02:00
|
|
|
public String getHost() {
|
|
|
|
return (String) this.resourceProperties.get(HOST);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 15:50:39 +02:00
|
|
|
public void setHost(String host) throws InvalidValueException {
|
|
|
|
setResourceProperty(HOST, host);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
2015-06-18 16:30:42 +02:00
|
|
|
|
2017-09-18 15:08:46 +02:00
|
|
|
@JsonIgnore
|
2015-05-29 16:08:21 +02:00
|
|
|
public String getServiceClass() {
|
2015-06-09 14:54:14 +02:00
|
|
|
return (String) this.resourceProperties.get(SERVICE_CLASS);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setServiceClass(String serviceClass) throws InvalidValueException {
|
2015-06-09 14:54:14 +02:00
|
|
|
setResourceProperty(SERVICE_CLASS, serviceClass);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2017-09-18 15:08:46 +02:00
|
|
|
@JsonIgnore
|
2015-05-29 16:08:21 +02:00
|
|
|
public String getServiceName() {
|
2015-06-09 14:54:14 +02:00
|
|
|
return (String) this.resourceProperties.get(SERVICE_NAME);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
2017-09-14 14:21:23 +02:00
|
|
|
|
2015-05-29 16:08:21 +02:00
|
|
|
public void setServiceName(String serviceName) throws InvalidValueException {
|
2015-06-09 14:54:14 +02:00
|
|
|
setResourceProperty(SERVICE_NAME, serviceName);
|
2015-05-29 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
2017-09-18 15:08:46 +02:00
|
|
|
@JsonIgnore
|
2015-07-13 11:26:50 +02:00
|
|
|
public String getCalledMethod() {
|
|
|
|
return (String) this.resourceProperties.get(CALLED_METHOD);
|
|
|
|
}
|
2017-09-14 14:21:23 +02:00
|
|
|
|
2015-07-13 11:26:50 +02:00
|
|
|
public void setCalledMethod(String calledMethod) throws InvalidValueException {
|
|
|
|
setResourceProperty(CALLED_METHOD, calledMethod);
|
|
|
|
}
|
|
|
|
|
2017-09-18 15:08:46 +02:00
|
|
|
@JsonIgnore
|
2015-06-18 16:30:42 +02:00
|
|
|
public Long getDuration() {
|
|
|
|
return (Long) this.resourceProperties.get(DURATION);
|
|
|
|
}
|
2017-09-14 14:21:23 +02:00
|
|
|
|
2015-06-18 16:34:04 +02:00
|
|
|
public void setDuration(Long duration) throws InvalidValueException {
|
2015-06-18 16:30:42 +02:00
|
|
|
setResourceProperty(DURATION, duration);
|
|
|
|
}
|
2016-09-08 17:21:05 +02:00
|
|
|
|
2017-09-18 15:08:46 +02:00
|
|
|
@JsonIgnore
|
2016-09-08 17:21:05 +02:00
|
|
|
public String getCallerQualifier() {
|
2017-09-06 11:47:13 +02:00
|
|
|
return (String) this.resourceProperties.get(CALLER_QUALIFIER);
|
|
|
|
}
|
|
|
|
|
2016-09-08 17:21:05 +02:00
|
|
|
public void setCallerQualifier(String callerQualifier) throws InvalidValueException {
|
2017-09-06 11:47:13 +02:00
|
|
|
setResourceProperty(CALLER_QUALIFIER, callerQualifier);
|
2016-09-08 17:21:05 +02:00
|
|
|
}
|
|
|
|
|
2015-05-28 13:19:25 +02:00
|
|
|
}
|