package com.purui.prims.headless.server.service;

import com.alibaba.fastjson.JSONArray;
import com.purui.prims.auth.api.authentication.pojo.User;
import com.purui.prims.headless.api.pojo.DataSetSchema;
import com.purui.prims.headless.api.pojo.EntityInfo;
import com.purui.prims.headless.api.pojo.SemanticParseInfo;
import com.purui.prims.headless.api.pojo.request.DimensionValueReq;
import com.purui.prims.headless.api.pojo.request.ExplainSqlReq;
import com.purui.prims.headless.api.pojo.request.QueryMetricReq;
import com.purui.prims.headless.api.pojo.request.SemanticQueryReq;
import com.purui.prims.headless.api.pojo.response.ExplainResp;
import com.purui.prims.headless.api.pojo.response.ItemResp;
import com.purui.prims.headless.api.pojo.response.SemanticQueryResp;

import java.util.List;

/**
 * This interface abstracts functionalities provided by a semantic layer.
 */
public interface SemanticLayerService {

    DataSetSchema getDataSetSchema(Long id);

    SemanticQueryResp queryByReq(SemanticQueryReq queryReq, User user) throws Exception;

    SemanticQueryResp queryByMetric(QueryMetricReq queryMetricReq, User user) throws Exception;

    SemanticQueryResp queryDimensionValue(DimensionValueReq dimensionValueReq, User user);

    <T> ExplainResp explain(ExplainSqlReq<T> explainSqlReq, User user) throws Exception;

    EntityInfo getEntityInfo(SemanticParseInfo parseInfo, DataSetSchema dataSetSchema, User user);

    List<ItemResp> getDomainDataSetTree();

    JSONArray convertToResult(SemanticQueryResp semanticQueryResp);

    String buildSql(SemanticQueryReq semanticQueryReq, User user);
}
