social-networking-library-ws/src/main/java/org/gcube/portal/social/networking/ws/inputs/JobNotificationBean.java

148 lines
3.4 KiB
Java

package org.gcube.portal.social.networking.ws.inputs;
import javax.validation.constraints.NotNull;
import org.gcube.portal.databook.shared.JobStatusType;
import org.gcube.portal.databook.shared.RunningJob;
import org.gcube.portal.social.networking.ws.providers.JobStatusTypeDeserializer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.webcohesion.enunciate.metadata.DocumentationExample;
/**
* The job notification bean class.
*/
@JsonIgnoreProperties(ignoreUnknown = true) // ignore in serialization/deserialization
/**
* @label A job notification object
*/
public class JobNotificationBean {
@JsonProperty("recipient")
@NotNull(message="recipient cannot be missing")
/*
* @param "The recipient of the notification",
*/
@DocumentationExample("andrea.rossi")
private String recipient;
/*
* @param jobId The job's identifier, i.e. very likely a UUID
*/
@JsonProperty("job_id")
private String jobId;
@JsonProperty("job_name")
private String jobName;
@JsonProperty("service_name")
@NotNull(message="service_name cannot be missing")
/*
* @param serviceName The name of the service running the job
*/
private String serviceName;
@JsonProperty("status")
@JsonDeserialize(using=JobStatusTypeDeserializer.class)
@NotNull(message="status cannot be missing")
private JobStatusType status;
@JsonProperty("status_message")
private String statusMessage;
public JobNotificationBean() {
super();
}
/**
* @param recipient
* @param jobId
* @param jobName
* @param serviceName
* @param status
* @param statusMessage
*/
public JobNotificationBean(String recipient, String jobId, String jobName,
String serviceName, JobStatusType status, String statusMessage) {
super();
this.recipient = recipient;
this.jobId = jobId;
this.jobName = jobName;
this.serviceName = serviceName;
this.status = status;
this.statusMessage = statusMessage;
}
public String getStatusMessage() {
return statusMessage;
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
public String getRecipient() {
return recipient;
}
public void setRecipient(String recipient) {
this.recipient = recipient;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getJobName() {
return jobName;
}
public void setJobName(String jobName) {
this.jobName = jobName;
}
public JobStatusType getStatus() {
return status;
}
public void setStatus(JobStatusType status) {
this.status = status;
}
public RunningJob getRunningJob(){
return new RunningJob(jobId, jobName, status, statusMessage, serviceName);
}
@Override
public String toString() {
return "JobNotificationBean ["
+ (recipient != null ? "recipient=" + recipient + ", " : "")
+ (jobId != null ? "jobId=" + jobId + ", " : "")
+ (jobName != null ? "jobName=" + jobName + ", " : "")
+ (serviceName != null ? "serviceName=" + serviceName + ", "
: "")
+ (status != null ? "status=" + status + ", " : "")
+ (statusMessage != null ? "statusMessage=" + statusMessage
: "") + "]";
}
}