package org.bench4q.share.models.agent;

import java.io.ByteArrayOutputStream;
import java.util.Date;
import java.util.UUID;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "behaviorResultModel")
public class BehaviorResultModel {
	private UUID id;
	private String pluginId;
	private String pluginName;
	private String behaviorName;
	private Date startDate;
	private Date endDate;
	private long responseTime;
	private int successCount;
	private int failCount;

	private int behaviorId;
	private long contentLength;
	private int statusCode;
	private String contentType;
	private boolean shouldBeCountResponseTime;

	@XmlElement
	public UUID getId() {
		return id;
	}

	public void setId(UUID id) {
		this.id = id;
	}

	@XmlElement
	public String getPluginId() {
		return pluginId;
	}

	public void setPluginId(String pluginId) {
		this.pluginId = pluginId;
	}

	@XmlElement
	public String getPluginName() {
		return pluginName;
	}

	public void setPluginName(String pluginName) {
		this.pluginName = pluginName;
	}

	@XmlElement
	public String getBehaviorName() {
		return behaviorName;
	}

	public void setBehaviorName(String behaviorName) {
		this.behaviorName = behaviorName;
	}

	@XmlElement
	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	@XmlElement
	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	@XmlElement
	public long getResponseTime() {
		return responseTime;
	}

	public void setResponseTime(long responseTime) {
		this.responseTime = responseTime;
	}

	@XmlElement
	public int getSuccessCount() {
		return successCount;
	}

	public void setSuccessCount(int successCount) {
		this.successCount = successCount;
	}

	@XmlElement
	public int getFailCount() {
		return failCount;
	}

	public void setFailCount(int failCount) {
		this.failCount = failCount;
	}

	@XmlElement
	public int getBehaviorId() {
		return behaviorId;
	}

	public void setBehaviorId(int behaviorId) {
		this.behaviorId = behaviorId;
	}

	@XmlElement
	public long getContentLength() {
		return contentLength;
	}

	public void setContentLength(long contentLength) {
		this.contentLength = contentLength;
	}

	@XmlElement
	public int getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}

	@XmlElement
	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	@XmlElement
	public boolean isShouldBeCountResponseTime() {
		return shouldBeCountResponseTime;
	}

	public void setShouldBeCountResponseTime(boolean shouldBeCountResponseTime) {
		this.shouldBeCountResponseTime = shouldBeCountResponseTime;
	}

	public String getModelString() {
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		Marshaller marshaller;
		try {
			marshaller = JAXBContext.newInstance(BehaviorResultModel.class)
					.createMarshaller();
			marshaller.marshal(this, outputStream);
			return outputStream.toString();
		} catch (JAXBException e) {
			return "";
		}

	}
}
