package ru.ulstu.timeline.model;

import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.user.model.User;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
public class Event extends BaseEntity {
    public enum EventStatus {
        POSSIBLE("Возможное"), NEW("Новое"), IN_PROGRESS("В процессе"), COMPLETED("Завершено");

        private String name;

        EventStatus(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }
    }

    @NotBlank
    private String title;

    @Enumerated(value = EnumType.STRING)
    private EventStatus status;

    @Column(name = "execute_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date executeDate;

    @Column(name = "create_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createDate;

    @Column(name = "update_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateDate;

    private String description;

    @ManyToMany(fetch = FetchType.EAGER)
    private List<User> recipients;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public EventStatus getStatus() {
        return status;
    }

    public void setStatus(EventStatus status) {
        this.status = status;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<User> getRecipients() {
        return recipients;
    }

    public void setRecipients(List<User> recipients) {
        this.recipients = recipients;
    }

    public Date getExecuteDate() {
        return executeDate;
    }

    public void setExecuteDate(Date executeDate) {
        this.executeDate = executeDate;
    }
}
