package tech.easyflow.datacenter.meta.service;

import tech.easyflow.common.entity.LoginAccount;
import tech.easyflow.datacenter.entity.DatacenterTable;
import tech.easyflow.datacenter.entity.DatacenterTableField;
import tech.easyflow.datacenter.execution.model.DatasetRef;
import tech.easyflow.datacenter.meta.entity.DatacenterCatalog;
import tech.easyflow.datacenter.meta.entity.DatacenterSource;
import tech.easyflow.datacenter.meta.model.DatacenterFieldDescriptionUpdate;
import tech.easyflow.datacenter.meta.enums.DatacenterSourceType;
import tech.easyflow.datacenter.meta.model.DatacenterTableDetailMeta;

import java.math.BigInteger;
import java.util.List;

public interface DatacenterDatasetRegistryService {
    DatacenterSource ensureBuiltinSource(DatacenterSourceType sourceType, LoginAccount account);

    DatacenterCatalog ensureCatalog(DatacenterSource source, String catalogName, LoginAccount account);

    DatacenterTable registerTable(DatacenterSource source, DatacenterCatalog catalog, DatacenterTableDetailMeta detail, LoginAccount account);

    DatacenterTable getTableWithFields(BigInteger tableId);

    List<DatacenterTableField> getFields(BigInteger tableId);

    DatasetRef resolveDatasetRef(BigInteger tableId);

    DatacenterSource getSourceRequired(BigInteger sourceId);

    DatacenterCatalog getCatalogById(BigInteger catalogId);

    List<DatacenterTable> listManagedTables(BigInteger sourceId, BigInteger catalogId);

    int removeTables(List<BigInteger> tableIds);

    DatacenterTable saveDescriptions(BigInteger tableId, String tableDesc, List<DatacenterFieldDescriptionUpdate> fields, LoginAccount account);
}
