package com.inspect.metadata.prodevmnt.domain;

import com.inspect.metadata.area.domain.BaseDataArea;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

import java.util.List;
import java.util.stream.Collectors;

public class TreeModule {
    private long id;
    private String label;
    private String type;
    private long areaId;
    @JsonInclude(Include.NON_EMPTY)
    private List children;
    @JsonInclude(Include.NON_EMPTY)
    private Long parentId;

    public TreeModule() {
    }

    public TreeModule(BaseDataArea area) {
        this.id = area.getAreaId();
        this.type = "area";
        this.label = area.getAreaName();
        this.parentId = area.getParentId();
        this.children = (List) area.getChildren().stream().map(TreeModule::new).collect(Collectors.toList());
    }

    public long getAreaId() {
        return this.areaId;
    }

    public void setAreaId(long areaId) {
        this.areaId = areaId;
    }

    public String getLabel() {
        return this.label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public long getId() {
        return this.id;
    }

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

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<TreeModule> getChildren() {
        return this.children;
    }

    public void setChildren(List<TreeModule> children) {
        this.children = children;
    }

    public Long getParentId() {
        return this.parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }
}
