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

import com.purui.prims.auth.api.authentication.pojo.User;
import com.purui.prims.headless.api.pojo.request.QueryDataSetReq;
import com.purui.prims.headless.api.pojo.request.SemanticQueryReq;
import com.purui.prims.headless.api.pojo.request.DataSetReq;
import com.purui.prims.headless.api.pojo.response.DataSetResp;
import com.purui.prims.headless.api.pojo.response.SemanticQueryResp;
import com.purui.prims.headless.server.pojo.MetaFilter;

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

public interface DataSetService {

    DataSetResp save(DataSetReq dataSetReq, User user);

    DataSetResp update(DataSetReq dataSetReq, User user);

    DataSetResp getDataSet(Long id);

    List<DataSetResp> getDataSetList(MetaFilter metaFilter);

    List<DataSetResp> getDataSetList(MetaFilter metaFilter, User user);

    void delete(Long id, User user);

    Map<Long, List<Long>> getModelIdToDataSetIds(List<Long> dataSetIds, User user);

    Map<Long, List<Long>> getModelIdToDataSetIds();

    List<DataSetResp> getDataSets(User user);

    List<DataSetResp> getDataSets(String dataSetName, User user);

    List<DataSetResp> getDataSets(List<String> dataSetNames, User user);

    boolean publish(Long id, User user);

    boolean unPublish(Long id, User user);

    SemanticQueryReq convert(QueryDataSetReq queryDataSetReq) throws Exception;

    String buildSql(Long id);

    String buildAsSelectSql(Long id);

    Long getDataSetIdFromSql(String sql, User user);

    SemanticQueryResp queryByDataSet(QueryDataSetReq queryDataSetReq, User user);

}
