package com.eactive.testmaster.client.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ApiLayoutDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    @JsonProperty("id")
    private String id;

    @JsonProperty("APIREQUESTID")
    private String apiRequestId;

    @JsonProperty("LOUTNAME")
    private String loutName;

    @JsonProperty("LOUTPTRNNAME")
    private String loutPtrnName;

    @JsonProperty("LOUTDESC")
    private String loutDesc;

    @JsonProperty("EAIBZWKDSTCD")
    private String eaiBzwkDstCd;

    @JsonProperty("UAPPLNAME")
    private String uApplName;

    @JsonProperty("SYSINTFACNAME")
    private String sysIntFacName;

    @JsonProperty("AUTHOR")
    private String author;

    @JsonProperty("EAISEVRDSTCD")
    private String eaiSevRdStCd;

    @JsonProperty("MODFMGTSTUSDSTCD")
    private String modfMgtStusDstCd;

    @JsonProperty("USEYN")
    private String useYn;

    @JsonProperty("VERINFO")
    private String verInfo;

    @JsonProperty("layoutItems")
    List<ApiLayoutItemDTO> layoutItems = new ArrayList<>();

    @JsonProperty("computedLayoutItemRoot")
    private ApiLayoutItemDTO computedLayoutItemRoot = null;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getApiRequestId() {
        return apiRequestId;
    }

    public void setApiRequestId(String apiRequestId) {
        this.apiRequestId = apiRequestId;
    }

    public String getLoutName() {
        return loutName;
    }

    public void setLoutName(String loutName) {
        this.loutName = loutName;
    }

    public String getLoutPtrnName() {
        return loutPtrnName;
    }

    public void setLoutPtrnName(String loutPtrnName) {
        this.loutPtrnName = loutPtrnName;
    }

    public String getLoutDesc() {
        return loutDesc;
    }

    public void setLoutDesc(String loutDesc) {
        this.loutDesc = loutDesc;
    }

    public String getEaiBzwkDstCd() {
        return eaiBzwkDstCd;
    }

    public void setEaiBzwkDstCd(String eaiBzwkDstCd) {
        this.eaiBzwkDstCd = eaiBzwkDstCd;
    }

    public String getuApplName() {
        return uApplName;
    }

    public void setuApplName(String uApplName) {
        this.uApplName = uApplName;
    }

    public String getSysIntFacName() {
        return sysIntFacName;
    }

    public void setSysIntFacName(String sysIntFacName) {
        this.sysIntFacName = sysIntFacName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getEaiSevRdStCd() {
        return eaiSevRdStCd;
    }

    public void setEaiSevRdStCd(String eaiSevRdStCd) {
        this.eaiSevRdStCd = eaiSevRdStCd;
    }

    public String getModfMgtStusDstCd() {
        return modfMgtStusDstCd;
    }

    public void setModfMgtStusDstCd(String modfMgtStusDstCd) {
        this.modfMgtStusDstCd = modfMgtStusDstCd;
    }

    public String getUseYn() {
        return useYn;
    }

    public void setUseYn(String useYn) {
        this.useYn = useYn;
    }

    public String getVerInfo() {
        return verInfo;
    }

    public void setVerInfo(String verInfo) {
        this.verInfo = verInfo;
    }

    public List<ApiLayoutItemDTO> getLayoutItems() {
        return layoutItems;
    }

    public void setLayoutItems(List<ApiLayoutItemDTO> layoutItems) {
        this.layoutItems = layoutItems;
    }

    public ApiLayoutItemDTO getComputedLayoutItemRoot() {
        return computedLayoutItemRoot;
    }

    public void setComputedLayoutItemRoot(ApiLayoutItemDTO computedLayoutItemRoot) {
        this.computedLayoutItemRoot = computedLayoutItemRoot;
    }

    @JsonIgnore
    public String buildMessage() {
        if (computedLayoutItemRoot == null || computedLayoutItemRoot.getChildren().isEmpty()) {
            return "";
        }

        StringBuilder message = new StringBuilder();
        for (ApiLayoutItemDTO item : computedLayoutItemRoot.getChildren()) {
            message.append(item.buildMessage());
        }

        return message.toString();
    }




}
