package com.bytesw.bytebot.model;

import com.bytesw.bytebot.model.converters.CalendarExceptionTypeConverter;
import com.bytesw.bytebot.model.enums.CalendarExceptionType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;

@Entity
@Inheritance(
        strategy = InheritanceType.SINGLE_TABLE
)
@DiscriminatorColumn(name="CALE_EXC_FRECU", discriminatorType = DiscriminatorType.STRING)
@Table(name = "AVB_CALENDAR_EXCEPTION")
@Getter
@Setter
@EqualsAndHashCode
@ToString(exclude = "id")
public class CalendarExceptionFull implements Serializable {

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

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

    @Column(name = "CALE_EXC_TYPE")
    @Convert(converter = CalendarExceptionTypeConverter.class)
    private CalendarExceptionType calendarExceptionType;

    @Column(name = "CALE_EXC_FRECU", insertable = false, updatable = false)
    private String frequencyType;

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

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

    @Column(name = "CALE_EXC_MONTH")
    private BigInteger month;

    @Column(name = "CALE_EXC_DAYMO")
    private BigInteger dayOfMonth;

    @Column(name = "CALE_EXC_WEEK")
    private BigInteger weekOfMonth;

    @Column(name = "CALE_EXC_DAYWE")
    private BigInteger dayOfWeek;

    @Column(name = "CALE_EXC_DATE")
    private LocalDate date;

    @Column(name = "CALE_EXC_FROM")
    private OffsetDateTime from;

    @Column(name = "CALE_EXC_TO")
    private OffsetDateTime to;

}