package com.bytesw.bytebot.model;

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;
import java.time.OffsetDateTime;
import java.time.OffsetTime;

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

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

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

    @Column(name = "WESC_DAY", nullable = false)
    private int dayOfWeek;

    @Column(name = "WESC_FROM", nullable = false)
    private OffsetTime from;

    @Column(name = "WESC_TO", nullable = false)
    private OffsetTime to;

    @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;

}
