package com.bytesw.bytebot.model;

import com.bytesw.xdf.model.converter.BooleanToStringConverter;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.envers.Audited;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;

@Audited
@Entity
@Table(name = "AVB_SCHEDULER_TASK")
@NamedQuery(name = "SchedulerTask.findByPK", query = "Select u from SchedulerTask u where u.id = ?1")
@Getter
@Setter
@EqualsAndHashCode
@ToString(exclude = "id")
public class SchedulerTask implements Serializable {

    @Id
    @Column(name = "SHTA_ID")
    @SequenceGenerator(name = "AVB_SCHEDULER_TASK_GENERATOR", sequenceName = "AVB_SCHEDULER_TASK_SEQ", initialValue = 1, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_SCHEDULER_TASK_GENERATOR")
    private BigInteger id;

    @Version
    @Column(name = "SHTA_VERSION")
    @Basic(optional = false)
    private long version;

    @Column(name = "SHTA_DESCR", nullable = false)
    private String description;

    @Column(name = "SHTA_INTER", nullable = false)
    @Convert(converter = BooleanToStringConverter.class)
    private Boolean internals;

    @Column(name = "SHTA_CROEX", nullable = false)
    private String cronExpression;

    @Column(name = "SHTA_PARAM")
    private String stringParameters;

    @Column(name= "cale_id")
    private String calendarID;

//    @ManyToOne(optional = false)
//    @NotFound(action = NotFoundAction.IGNORE)
//    @JoinColumn(name = "CALE_ID", referencedColumnName = "CALE_ID", nullable = false)
//    private Calendar calendar;


    /*@ManyToOne(optional = false)
    @JoinColumn(name = "ETL_ID", referencedColumnName = "ETL_ID", nullable = false)
    private ProcessETL processETL;*/

    @Column(name = "etl_id")
    private Integer processETL;
}
