package vn.azteam.tpf.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

import org.springframework.data.elasticsearch.annotations.Document;
import java.io.Serializable;
import java.time.Instant;
import java.util.Objects;

/**
 * A TBActivity.
 */
@Entity
@Table(name = "tb_activity")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "smf_tbactivity")
public class TBActivity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "age_day")
    private Integer ageDay;

    @Column(name = "total_cost")
    private Double totalCost;

    @Column(name = "media")
    private String media;

    @Column(name = "external_table")
    private String externalTable;

    @Column(name = "execute_date")
    private Instant executeDate;

    @Column(name = "description")
    private String description;

    @Column(name = "created_date")
    private Instant createdDate;

    @Column(name = "modified_date")
    private Instant modifiedDate;

    @Column(name = "deleted_date")
    private Instant deletedDate;

    @ManyToOne(fetch=FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "created_by")
    private TBDetailUser createdBy;

    @ManyToOne(fetch=FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "modified_by")
    private TBDetailUser modifiedBy;

    @ManyToOne(fetch=FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "deleted_by")
    private TBDetailUser deletedBy;

    @ManyToOne(fetch=FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "activity_type")
    private TBActivityType activityType;

    @ManyToOne(fetch=FetchType.LAZY)
    @JsonIgnoreProperties("")
    @JoinColumn(name = "tb_crop_id")
    private TBCrop crop;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

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

    public Integer getAgeDay() {
        return ageDay;
    }

    public TBActivity ageDay(Integer ageDay) {
        this.ageDay = ageDay;
        return this;
    }

    public void setAgeDay(Integer ageDay) {
        this.ageDay = ageDay;
    }

    public Double getTotalCost() {
        return totalCost;
    }

    public TBActivity totalCost(Double totalCost) {
        this.totalCost = totalCost;
        return this;
    }

    public void setTotalCost(Double totalCost) {
        this.totalCost = totalCost;
    }

    public String getMedia() {
        return media;
    }

    public TBActivity media(String media) {
        this.media = media;
        return this;
    }

    public void setMedia(String media) {
        this.media = media;
    }

    public String getExternalTable() {
        return  externalTable;
    }

    public TBActivity externalTable(String externalTable) {
        this.externalTable = externalTable;
        return this;
    }

    public void setExternalTable(String externalTable) {
        this.externalTable = externalTable;
    }

    public Instant getExecuteDate() {
        return executeDate;
    }

    public TBActivity executeDate(Instant executeDate) {
        this.executeDate = executeDate;
        return this;
    }

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

    public String getDescription() {
        return description;
    }

    public TBActivity description(String description) {
        this.description = description;
        return this;
    }

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

    public Instant getCreatedDate() {
        return createdDate;
    }

    public TBActivity createdDate(Instant createdDate) {
        this.createdDate = createdDate;
        return this;
    }

    public void setCreatedDate(Instant createdDate) {
        this.createdDate = createdDate;
    }

    public Instant getModifiedDate() {
        return modifiedDate;
    }

    public TBActivity modifiedDate(Instant modifiedDate) {
        this.modifiedDate = modifiedDate;
        return this;
    }

    public void setModifiedDate(Instant modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    public Instant getDeletedDate() {
        return deletedDate;
    }

    public TBActivity deletedDate(Instant deletedDate) {
        this.deletedDate = deletedDate;
        return this;
    }

    public void setDeletedDate(Instant deletedDate) {
        this.deletedDate = deletedDate;
    }

    public TBDetailUser getDeletedBy() {
        return deletedBy;
    }

    public TBActivity deletedBy(TBDetailUser tBDetailUser) {
        this.deletedBy = tBDetailUser;
        return this;
    }

    public void setDeletedBy(TBDetailUser tBDetailUser) {
        this.deletedBy = tBDetailUser;
    }

    public TBDetailUser getCreatedBy() {
        return createdBy;
    }

    public TBActivity createdBy(TBDetailUser tBDetailUser) {
        this.createdBy = tBDetailUser;
        return this;
    }

    public void setCreatedBy(TBDetailUser tBDetailUser) {
        this.createdBy = tBDetailUser;
    }

    public TBDetailUser getModifiedBy() {
        return modifiedBy;
    }

    public TBActivity modifiedBy(TBDetailUser tBDetailUser) {
        this.modifiedBy = tBDetailUser;
        return this;
    }

    public void setModifiedBy(TBDetailUser tBDetailUser) {
        this.modifiedBy = tBDetailUser;
    }

    public TBActivityType getActivityType() {
        return activityType;
    }

    public TBActivity activityType(TBActivityType tBActivityType) {
        this.activityType = tBActivityType;
        return this;
    }

    public void setActivityType(TBActivityType tBActivityType) {
        this.activityType = tBActivityType;
    }


    public TBCrop getCrop() {
        return crop;
    }

    public TBActivity crop(TBCrop crop) {
        this.crop = crop;
        return this;
    }

    public void setCrop(TBCrop crop) {
        this.crop = crop;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TBActivity tBActivity = (TBActivity) o;
        if (tBActivity.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), tBActivity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "TBActivity{" +
            "id=" + getId() +
            ", ageDay=" + getAgeDay() +
            ", totalCost=" + getTotalCost() +
            ", media='" + getMedia() + "'" +
            ", executeDate='" + getExecuteDate() + "'" +
            ", description='" + getDescription() + "'" +
            ", createdDate='" + getCreatedDate() + "'" +
            ", modifiedDate='" + getModifiedDate() + "'" +
            ", deletedDate='" + getDeletedDate() + "'" +
            "}";
    }
}
