package com.its.api.bis.model.entity;

import com.its.api.bis.model.dto.BisProcessDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 *  Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("PROCESS")
@Entity
@Table(name = "PROCESS")
public class BisProcess implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("PROCESSID")  // N NUMBER(6)
    @Column(name = "PROCESSID", nullable = false, columnDefinition = "NUMBER", length = 6)
    @Id
    private Integer processid;

    @ApiModelProperty("PROCESSNAME")  // Y VARCHAR(50)
    @Column(name = "PROCESSNAME", length = 50)
    private String processname;

    @ApiModelProperty("PROCESSOS")  // Y VARCHAR(50)
    @Column(name = "PROCESSOS", length = 50)
    private String processos;

    @ApiModelProperty("PROCESSLOCATION")  // Y VARCHAR(100)
    @Column(name = "PROCESSLOCATION", length = 100)
    private String processlocation;

    @ApiModelProperty("PROCESSVER")  // Y VARCHAR(8)
    @Column(name = "PROCESSVER", length = 8)
    private String processver;

    @ApiModelProperty("PROCESSDESC")  // Y VARCHAR(100)
    @Column(name = "PROCESSDESC", length = 100)
    private String processdesc;

    @ApiModelProperty("PORT")  // Y NUMBER(5)
    @Column(name = "PORT", columnDefinition = "NUMBER", length = 5)
    private Integer port;

    @ApiModelProperty("PROCESSTIME")  // Y NUMBER(5)
    @Column(name = "PROCESSTIME", columnDefinition = "NUMBER", length = 5)
    private Integer processtime;

    public BisProcessDto toDto() {
        return BisProcessDto.builder()
                .processid(this.processid)
                .processname(this.processname)
                .processos(this.processos)
                .processlocation(this.processlocation)
                .processver(this.processver)
                .processdesc(this.processdesc)
                .port(this.port)
                .processtime(this.processtime)
                .build();
    }

}
