package com.bytesw.bytebot.model;

import com.bytesw.bytebot.model.converters.StatusConverter;
import com.bytesw.bytebot.model.enums.StatusEnum;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;

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

/**
 * @author Sebastian Chicoma Sandmann
 * @version 09-sep-2020
 *
 * Copyright (c) 2020 Byte, S.A. Todos los derechos reservados.
 *
 * Este software constituye información confidencial y propietaria de Byte, S.A.
 * ("Información Confidencial"). Usted no debe develar dicha Información
 * Confidencial y debe usarla de acuerdo con los términos de aceptación de
 * licencia de uso que firmó con Byte.
 */
@Audited
@Entity
@Table(name = "AVB_DEPLOYMENT_CHANNEL")
@Getter
@Setter
@EqualsAndHashCode(of = {"id"}, callSuper = false)
public class DeploymentChannel {

    @Id
    @Column(name = "DCHA_ID")
    @SequenceGenerator(name = "AVB_DEPLOYMENT_CHANNEL_GENERATOR", sequenceName = "AVB_DEPLOYMENT_CHANNEL_SEQ", initialValue = 1, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_DEPLOYMENT_CHANNEL_GENERATOR")
    private Long id;

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

    @ManyToOne
    @JoinColumn(name = "AGEN_ID", referencedColumnName = "AGEN_ID")
    private Agent agent;

    @Column(name = "DCHA_STATE")
    @Convert(converter = StatusConverter.class)
    private StatusEnum status;

    @ManyToOne
    @JoinColumn(name = "CHAN_ID", referencedColumnName = "CHAN_ID")
    private Channel channel;

    @OneToMany(mappedBy = "deploymentChannel")
    private List<DeploymentChannelParamValue> parameters;
}
