package com.purui.prims.headless.api.pojo.request;


import com.google.common.collect.Lists;
import com.purui.prims.headless.api.pojo.Dim;
import com.purui.prims.headless.api.pojo.DrillDownDimension;
import com.purui.prims.headless.api.pojo.ModelDetail;
import com.purui.prims.headless.api.pojo.SchemaItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;
import java.util.Map;


@Data
@ApiModel(value = "模型Req")
public class ModelReq extends SchemaItem {

    @ApiModelProperty(value = "数据库ID")
    private Long databaseId;

    @ApiModelProperty(value = "数据库名称")
    private String dbName;

    @ApiModelProperty(value = "主题域ID")
    private Long domainId;

    @ApiModelProperty(value = "过滤SQL")
    private String filterSql;

    @ApiModelProperty(value = "是否公开")
    private Integer isOpen;

    @ApiModelProperty(value = "相关维度")
    private List<DrillDownDimension> drillDownDimensions;

    @ApiModelProperty(value = "别名")
    private String alias;

    @ApiModelProperty(value = "来源类型")
    private String sourceType;

    @ApiModelProperty(value = "模型详情")
    private ModelDetail modelDetail;

    @ApiModelProperty(value = "扩展信息")
    private Map<String, Object> ext;

    public List<Dim> getTimeDimension() {
        if (modelDetail == null) {
            return Lists.newArrayList();
        }
        return modelDetail.filterTimeDims();
    }

}
