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;
|
2015-06-08 17:30:08 +02:00
|
|
|
import org.gcube.accounting.datamodel.decorators.RequiredField;
|
2015-06-08 17:19:09 +02:00
|
|
|
import org.gcube.accounting.datamodel.validations.annotations.NotEmpty;
|
2015-06-18 16:30:42 +02:00
|
|
|
import org.gcube.accounting.datamodel.validations.annotations.ValidLong;
|
2015-05-29 16:08:21 +02:00
|
|
|
import org.gcube.accounting.exception.InvalidValueException;
|
2015-05-28 13:19:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
|
|
|
*
|
|
|
|
*/
|
2015-07-29 14:41:28 +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
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
* KEY for : Service Name
|
|
|
|
*/
|
|
|
|
@RequiredField @NotEmpty
|
|
|
|
public static final String CALLED_METHOD = "calledMethod";
|
|
|
|
|
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-18 16:30:42 +02:00
|
|
|
@RequiredField @ValidLong
|
|
|
|
public static final String DURATION = "duration";
|
|
|
|
|
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
|
|
|
|
2015-11-30 17:49:18 +01:00
|
|
|
public AbstractServiceUsageRecord(Map<String, Comparable<? 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";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
protected String giveMeUsageRecordType() {
|
|
|
|
return AbstractServiceUsageRecord.class.getSimpleName().replace(ABSTRACT_TO_REPLACE, "");
|
|
|
|
}
|
2015-06-09 15:53:21 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-07-13 11:26:50 +02:00
|
|
|
public String getCalledMethod() {
|
|
|
|
return (String) this.resourceProperties.get(CALLED_METHOD);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCalledMethod(String calledMethod) throws InvalidValueException {
|
|
|
|
setResourceProperty(CALLED_METHOD, calledMethod);
|
|
|
|
}
|
|
|
|
|
2015-06-18 16:30:42 +02:00
|
|
|
public Long getDuration() {
|
|
|
|
return (Long) this.resourceProperties.get(DURATION);
|
|
|
|
}
|
2015-07-13 11:26:50 +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);
|
|
|
|
}
|
2015-05-28 13:19:25 +02:00
|
|
|
}
|