package dst.ass3.event.model.events;

import java.io.Serializable;

import dst.ass3.event.model.domain.IUploadEventInfo;
import dst.ass3.event.model.domain.RequestType;
import dst.ass3.event.model.domain.UploadState;

/**
 * Indicates a change in the lifecycle state of an IUploadEventInfo.
 */
public class LifecycleEvent implements Serializable {

    private static final long serialVersionUID = 8665269919851487210L;

    /**
     * The id of the UploadRequest (the MOOC business concept), as returned by {@link IUploadEventInfo#getRequestId()}.
     */
    private long requestId;

    private UploadState state;
    private String server;
    private RequestType requestType;

    /**
     * The instant the event was recorded (unix epoch in milliseconds)
     */
    private long timestamp;

    public LifecycleEvent() {
    }

    public LifecycleEvent(IUploadEventInfo eventInfo) {
        this(eventInfo.getRequestId(), eventInfo.getState(), eventInfo.getServer(), eventInfo.getRequestType(), eventInfo.getTimestamp());
    }

    public LifecycleEvent(long requestId, UploadState state, String server, RequestType requestType, long timestamp) {
        this.requestId = requestId;
        this.state = state;
        this.server = server;
        this.requestType = requestType;
        this.timestamp = timestamp;
    }

    public long getRequestId() {
        return requestId;
    }

    public void setRequestId(long requestId) {
        this.requestId = requestId;
    }

    public UploadState getState() {
        return state;
    }

    public void setState(UploadState state) {
        this.state = state;
    }

    public String getServer() {
        return server;
    }

    public void setServer(String server) {
        this.server = server;
    }

    public RequestType getRequestType() {
        return requestType;
    }

    public void setRequestType(RequestType requestType) {
        this.requestType = requestType;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public String toString() {
        return "LifecycleEvent{" +
                "requestId=" + requestId +
                ", state=" + state +
                ", server='" + server + '\'' +
                ", requestType=" + requestType +
                ", timestamp=" + timestamp +
                '}';
    }
}
