mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 06:27:21 +00:00
[release][project] supersonic 0.7.3 version backend update (#40)
* [improvement] add some features * [improvement] revise CHANGELOG --------- Co-authored-by: zuopengge <hwzuopengge@tencent.com>
This commit is contained in:
@@ -4,11 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: kanedai
|
||||
* @date: 2023/7/24
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DimValueMap {
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.tencent.supersonic.semantic.api.model.request;
|
||||
|
||||
|
||||
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
package com.tencent.supersonic.semantic.model.application;
|
||||
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.ItemDateFilter;
|
||||
import com.tencent.supersonic.semantic.api.model.response.*;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatabaseResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ItemDateResp;
|
||||
import com.tencent.supersonic.semantic.api.model.yaml.DatasourceYamlTpl;
|
||||
import com.tencent.supersonic.semantic.api.model.yaml.DimensionYamlTpl;
|
||||
import com.tencent.supersonic.semantic.api.model.yaml.MetricYamlTpl;
|
||||
import com.tencent.supersonic.semantic.model.domain.*;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatabaseService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatasourceService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.Catalog;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -2,22 +2,22 @@ package com.tencent.supersonic.semantic.model.application;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatabaseReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatabaseResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.QueryResultWithSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.SqlParserResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatabaseService;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatabaseResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.QueryResultWithSchemaResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import com.tencent.supersonic.semantic.model.domain.adaptor.engineadapter.EngineAdaptor;
|
||||
import com.tencent.supersonic.semantic.model.domain.adaptor.engineadapter.EngineAdaptorFactory;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatabaseDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Database;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.DatabaseRepository;
|
||||
import com.tencent.supersonic.semantic.model.domain.utils.DatabaseConverter;
|
||||
import com.tencent.supersonic.semantic.model.domain.utils.JdbcDataSourceUtils;
|
||||
import com.tencent.supersonic.semantic.model.domain.utils.SqlUtils;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatabaseService;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Database;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -38,9 +38,9 @@ public class DatabaseServiceImpl implements DatabaseService {
|
||||
private ModelService modelService;
|
||||
|
||||
public DatabaseServiceImpl(DatabaseRepository databaseRepository,
|
||||
SqlUtils sqlUtils,
|
||||
DomainService domainService,
|
||||
ModelService modelService) {
|
||||
SqlUtils sqlUtils,
|
||||
DomainService domainService,
|
||||
ModelService modelService) {
|
||||
this.databaseRepository = databaseRepository;
|
||||
this.sqlUtils = sqlUtils;
|
||||
this.modelService = modelService;
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.QueryColumn;
|
||||
import com.tencent.supersonic.common.util.ChatGptHelper;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DatasourceDetail;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DimValueMap;
|
||||
@@ -28,9 +27,11 @@ import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Dimension;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.DimensionFilter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -55,14 +56,14 @@ public class DimensionServiceImpl implements DimensionService {
|
||||
|
||||
|
||||
public DimensionServiceImpl(DimensionRepository dimensionRepository,
|
||||
DomainService domainService,
|
||||
DatasourceService datasourceService,
|
||||
DomainService domainService,
|
||||
DatasourceService datasourceService,
|
||||
ChatGptHelper chatGptHelper,
|
||||
DatabaseService databaseService) {
|
||||
this.domainService = domainService;
|
||||
this.dimensionRepository = dimensionRepository;
|
||||
this.datasourceService = datasourceService;
|
||||
this.chatGptHelper = chatGptHelper;
|
||||
this.chatGptHelper = chatGptHelper;
|
||||
this.databaseService = databaseService;
|
||||
|
||||
}
|
||||
@@ -181,7 +182,7 @@ public class DimensionServiceImpl implements DimensionService {
|
||||
}
|
||||
|
||||
private List<DimensionResp> convertList(List<DimensionDO> dimensionDOS,
|
||||
Map<Long, DatasourceResp> datasourceRespMap) {
|
||||
Map<Long, DatasourceResp> datasourceRespMap) {
|
||||
List<DimensionResp> dimensionResps = Lists.newArrayList();
|
||||
Map<Long, String> fullDomainPathMap = domainService.getDomainFullPath();
|
||||
if (!CollectionUtils.isEmpty(dimensionDOS)) {
|
||||
@@ -259,17 +260,20 @@ public class DimensionServiceImpl implements DimensionService {
|
||||
|
||||
@Override
|
||||
public List<String> mockAlias(DimensionReq dimensionReq, String mockType, User user) {
|
||||
String mockAlias = chatGptHelper.mockAlias(mockType,dimensionReq.getName(), dimensionReq.getBizName(), "", dimensionReq.getDescription() ,false);
|
||||
return JSONObject.parseObject(mockAlias, new TypeReference<List<String>>() {});
|
||||
String mockAlias = chatGptHelper.mockAlias(mockType, dimensionReq.getName(), dimensionReq.getBizName(),
|
||||
"", dimensionReq.getDescription(), false);
|
||||
return JSONObject.parseObject(mockAlias, new TypeReference<List<String>>() {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DimValueMap> mockDimensionValueAlias(DimensionReq dimensionReq, User user) {
|
||||
|
||||
List<DatasourceResp> datasourceList = datasourceService.getDatasourceList();
|
||||
List<DatasourceResp> collect = datasourceList.stream().filter(datasourceResp -> datasourceResp.getId().equals(dimensionReq.getDatasourceId())).collect(Collectors.toList());
|
||||
List<DatasourceResp> collect = datasourceList.stream().filter(datasourceResp ->
|
||||
datasourceResp.getId().equals(dimensionReq.getDatasourceId())).collect(Collectors.toList());
|
||||
|
||||
if (collect.isEmpty()){
|
||||
if (collect.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
DatasourceResp datasourceResp = collect.get(0);
|
||||
@@ -278,7 +282,8 @@ public class DimensionServiceImpl implements DimensionService {
|
||||
|
||||
DatabaseResp database = databaseService.getDatabase(datasourceResp.getDatabaseId());
|
||||
|
||||
String sql = "select ai_talk."+dimensionReq.getBizName()+" from ("+sqlQuery +") as ai_talk group by ai_talk."+dimensionReq.getBizName();
|
||||
String sql = "select ai_talk." + dimensionReq.getBizName() + " from (" + sqlQuery
|
||||
+ ") as ai_talk group by ai_talk." + dimensionReq.getBizName();
|
||||
QueryResultWithSchemaResp queryResultWithSchemaResp = databaseService.executeSql(sql, database);
|
||||
List<Map<String, Object>> resultList = queryResultWithSchemaResp.getResultList();
|
||||
List<String> valueList = new ArrayList<>();
|
||||
@@ -287,7 +292,7 @@ public class DimensionServiceImpl implements DimensionService {
|
||||
valueList.add(value);
|
||||
}
|
||||
String json = chatGptHelper.mockDimensionValueAlias(JSON.toJSONString(valueList));
|
||||
log.info("return llm res is :{}",json);
|
||||
log.info("return llm res is :{}", json);
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(json);
|
||||
|
||||
@@ -297,9 +302,10 @@ public class DimensionServiceImpl implements DimensionService {
|
||||
DimValueMap dimValueMap = new DimValueMap();
|
||||
dimValueMap.setTechName((String) stringObjectMap.get(dimensionReq.getBizName()));
|
||||
dimValueMap.setBizName(jsonObject.getJSONArray("tran").getString(i));
|
||||
dimValueMap. setAlias(jsonObject.getJSONObject("alias").getJSONArray((String) stringObjectMap.get(dimensionReq.getBizName())).toJavaList(String.class));
|
||||
dimValueMap.setAlias(jsonObject.getJSONObject("alias").getJSONArray(
|
||||
(String) stringObjectMap.get(dimensionReq.getBizName())).toJavaList(String.class));
|
||||
dimValueMapsResp.add(dimValueMap);
|
||||
i ++ ;
|
||||
i++;
|
||||
}
|
||||
return dimValueMapsResp;
|
||||
}
|
||||
|
||||
@@ -4,20 +4,29 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
||||
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.common.util.BeanMapper;
|
||||
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DomainReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DomainUpdateReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DomainDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Domain;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.DomainRepository;
|
||||
import com.tencent.supersonic.semantic.model.domain.utils.DomainConvert;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Queue;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.assertj.core.util.Sets;
|
||||
@@ -36,8 +45,8 @@ public class DomainServiceImpl implements DomainService {
|
||||
|
||||
|
||||
public DomainServiceImpl(DomainRepository domainRepository,
|
||||
@Lazy ModelService modelService,
|
||||
UserService userService) {
|
||||
@Lazy ModelService modelService,
|
||||
UserService userService) {
|
||||
this.domainRepository = domainRepository;
|
||||
this.modelService = modelService;
|
||||
this.userService = userService;
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.TypeReference;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.plexpt.chatgpt.ChatGPT;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.util.ChatGptHelper;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Measure;
|
||||
@@ -81,7 +80,7 @@ public class MetricServiceImpl implements MetricService {
|
||||
log.info("[insert metric] object:{}", JSONObject.toJSONString(metricToInsert));
|
||||
saveMetricBatch(metricToInsert, user);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<MetricResp> getMetrics(Long modelId) {
|
||||
return convertList(metricRepository.getMetricList(modelId));
|
||||
@@ -209,10 +208,12 @@ public class MetricServiceImpl implements MetricService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> mockAlias(MetricReq metricReq,String mockType,User user) {
|
||||
public List<String> mockAlias(MetricReq metricReq, String mockType, User user) {
|
||||
|
||||
String mockAlias = chatGptHelper.mockAlias(mockType,metricReq.getName(), metricReq.getBizName(), "", metricReq.getDescription() ,!"".equals(metricReq.getDataFormatType()));
|
||||
return JSONObject.parseObject(mockAlias, new TypeReference<List<String>>() {});
|
||||
String mockAlias = chatGptHelper.mockAlias(mockType, metricReq.getName(), metricReq.getBizName(), "",
|
||||
metricReq.getDescription(), !"".equals(metricReq.getDataFormatType()));
|
||||
return JSONObject.parseObject(mockAlias, new TypeReference<List<String>>() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,41 +4,42 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authentication.service.UserService;
|
||||
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.common.util.BeanMapper;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelSchemaFilterReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatasourceService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatasourceService;
|
||||
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.ModelDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Model;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.ModelRepository;
|
||||
import com.tencent.supersonic.semantic.model.domain.utils.ModelConvert;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.HashSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -52,8 +53,8 @@ public class ModelServiceImpl implements ModelService {
|
||||
private final UserService userService;
|
||||
|
||||
public ModelServiceImpl(ModelRepository modelRepository, @Lazy MetricService metricService,
|
||||
@Lazy DimensionService dimensionService, @Lazy DatasourceService datasourceService,
|
||||
@Lazy DomainService domainService, UserService userService) {
|
||||
@Lazy DimensionService dimensionService, @Lazy DatasourceService datasourceService,
|
||||
@Lazy DomainService domainService, UserService userService) {
|
||||
this.modelRepository = modelRepository;
|
||||
this.metricService = metricService;
|
||||
this.dimensionService = dimensionService;
|
||||
@@ -161,7 +162,7 @@ public class ModelServiceImpl implements ModelService {
|
||||
@Override
|
||||
public ModelResp getModel(Long id) {
|
||||
Map<Long, DomainResp> domainRespMap = domainService.getDomainList().stream()
|
||||
.collect(Collectors.toMap(DomainResp::getId, d -> d));
|
||||
.collect(Collectors.toMap(DomainResp::getId, d -> d));
|
||||
return ModelConvert.convert(getModelDO(id), domainRespMap);
|
||||
}
|
||||
|
||||
@@ -186,8 +187,8 @@ public class ModelServiceImpl implements ModelService {
|
||||
if (CollectionUtils.isEmpty(modelDOS)) {
|
||||
return modelResps;
|
||||
}
|
||||
Map<Long, DomainResp> domainRespMap = domainService.getDomainList().stream()
|
||||
.collect(Collectors.toMap(DomainResp::getId, d -> d));
|
||||
Map<Long, DomainResp> domainRespMap = domainService.getDomainList()
|
||||
.stream().collect(Collectors.toMap(DomainResp::getId, d -> d));
|
||||
return modelDOS.stream()
|
||||
.map(modelDO -> ModelConvert.convert(modelDO, domainRespMap))
|
||||
.collect(Collectors.toList());
|
||||
@@ -216,8 +217,29 @@ public class ModelServiceImpl implements ModelService {
|
||||
|
||||
@Override
|
||||
public Map<Long, String> getModelFullPathMap() {
|
||||
return getModelList().stream()
|
||||
.collect(Collectors.toMap(ModelResp::getId, ModelResp::getFullPath, (k1, k2) -> k1));
|
||||
return getModelList().stream().collect(Collectors.toMap(ModelResp::getId,
|
||||
ModelResp::getFullPath, (k1, k2) -> k1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getModelAdmin(Long id) {
|
||||
ModelResp modelResp = getModel(id);
|
||||
if (modelResp == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(modelResp.getAdmins())) {
|
||||
return modelResp.getAdmins();
|
||||
}
|
||||
Long domainId = modelResp.getDomainId();
|
||||
DomainResp domainResp = domainService.getDomain(domainId);
|
||||
while (domainResp != null) {
|
||||
if (!CollectionUtils.isEmpty(domainResp.getAdmins())) {
|
||||
return domainResp.getAdmins();
|
||||
}
|
||||
domainId = domainResp.getParentId();
|
||||
domainResp = domainService.getDomain(domainId);
|
||||
}
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
protected ModelDO getModelDO(Long id) {
|
||||
|
||||
@@ -11,10 +11,10 @@ public interface DatabaseService {
|
||||
|
||||
QueryResultWithSchemaResp executeSql(String sql, DatabaseResp databaseResp);
|
||||
|
||||
DatabaseResp getDatabaseByModelId(Long modelId);
|
||||
|
||||
QueryResultWithSchemaResp executeSql(String sql, Long domainId);
|
||||
|
||||
DatabaseResp getDatabaseByModelId(Long modelId);
|
||||
|
||||
boolean testConnect(DatabaseReq databaseReq, User user);
|
||||
|
||||
DatabaseResp createOrUpdateDatabase(DatabaseReq databaseReq, User user);
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.github.pagehelper.PageInfo;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DimValueMap;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DimensionReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.MetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageDimensionReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import java.util.List;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.semantic.api.model.request.MetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageMetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MetricService {
|
||||
@@ -33,5 +34,5 @@ public interface MetricService {
|
||||
|
||||
void deleteMetric(Long id) throws Exception;
|
||||
|
||||
List<String> mockAlias(MetricReq metricReq,String mockType,User user);
|
||||
List<String> mockAlias(MetricReq metricReq, String mockType, User user);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ public interface ModelService {
|
||||
|
||||
Map<Long, String> getModelFullPathMap();
|
||||
|
||||
List<String> getModelAdmin(Long id);
|
||||
|
||||
ModelSchemaResp fetchSingleModelSchema(Long modelId);
|
||||
|
||||
List<ModelSchemaResp> fetchModelSchema(ModelSchemaFilterReq modelSchemaFilterReq);
|
||||
|
||||
@@ -29,8 +29,8 @@ public class H2Adaptor extends EngineAdaptor {
|
||||
|
||||
@Override
|
||||
public String getColumnMetaQueryTpl() {
|
||||
return "SELECT COLUMN_NAME AS name, DATA_TYPE AS dataType\n" +
|
||||
"FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA ='%s' AND TABLE_NAME = '%s'";
|
||||
return "SELECT COLUMN_NAME AS name, DATA_TYPE AS dataType\n"
|
||||
+ "FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA ='%s' AND TABLE_NAME = '%s'";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,6 +40,7 @@ public class H2Adaptor extends EngineAdaptor {
|
||||
|
||||
@Override
|
||||
public String getTableMetaQueryTpl() {
|
||||
return "SELECT TABLE_NAME as name FROM INFORMATION_SCHEMA.TABLES WHERE STORAGE_TYPE = 'MEMORY' AND TABLE_SCHEMA = '%s'";
|
||||
return "SELECT TABLE_NAME as name FROM INFORMATION_SCHEMA.TABLES "
|
||||
+ "WHERE STORAGE_TYPE = 'MEMORY' AND TABLE_SCHEMA = '%s'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ public class MysqlAdaptor extends EngineAdaptor {
|
||||
|
||||
@Override
|
||||
public String getDbMetaQueryTpl() {
|
||||
return "select distinct TABLE_SCHEMA as name from information_schema.tables where TABLE_SCHEMA not in ('information_schema','mysql','performance_schema','sys');";
|
||||
return "select distinct TABLE_SCHEMA as name from information_schema.tables "
|
||||
+ "where TABLE_SCHEMA not in ('information_schema','mysql','performance_schema','sys');";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,8 +46,8 @@ public class MysqlAdaptor extends EngineAdaptor {
|
||||
|
||||
@Override
|
||||
public String getColumnMetaQueryTpl() {
|
||||
return "SELECT COLUMN_NAME as name, DATA_TYPE as dataType, COLUMN_COMMENT as comment " +
|
||||
"FROM information_schema.columns WHERE table_schema ='%s' AND table_name = '%s'";
|
||||
return "SELECT COLUMN_NAME as name, DATA_TYPE as dataType, COLUMN_COMMENT as comment "
|
||||
+ "FROM information_schema.columns WHERE table_schema ='%s' AND table_name = '%s'";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -248,4 +248,4 @@ public class DatabaseDO {
|
||||
public void setConfig(String config) {
|
||||
this.config = config == null ? null : config.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -882,38 +882,6 @@ public class DatabaseDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -949,5 +917,37 @@ public class DatabaseDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,4 +252,4 @@ public class DatasourceDO {
|
||||
public void setDatasourceDetail(String datasourceDetail) {
|
||||
this.datasourceDetail = datasourceDetail == null ? null : datasourceDetail.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -872,38 +872,6 @@ public class DatasourceDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -939,5 +907,37 @@ public class DatasourceDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,4 +174,4 @@ public class DatasourceRelaDO {
|
||||
public void setUpdatedBy(String updatedBy) {
|
||||
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,38 +792,6 @@ public class DatasourceRelaDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -859,5 +827,37 @@ public class DatasourceRelaDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,4 +432,4 @@ public class DimensionDO {
|
||||
public void setExpr(String expr) {
|
||||
this.expr = expr == null ? null : expr.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1342,38 +1342,6 @@ public class DimensionDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -1409,5 +1377,37 @@ public class DimensionDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1142,38 +1142,6 @@ public class DomainDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -1209,5 +1177,37 @@ public class DomainDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,265 +4,121 @@ import java.util.Date;
|
||||
|
||||
public class MetricDO {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主体域ID
|
||||
*/
|
||||
private Long modelId;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
private String bizName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 指标状态,0正常,1下架,2删除
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 敏感级别
|
||||
*/
|
||||
private Integer sensitiveLevel;
|
||||
|
||||
/**
|
||||
* 指标类型 proxy,expr
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 数值类型
|
||||
*/
|
||||
private String dataFormatType;
|
||||
|
||||
/**
|
||||
* 数值类型参数
|
||||
*/
|
||||
private String dataFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String alias;
|
||||
|
||||
/**
|
||||
* 类型参数
|
||||
*/
|
||||
private String typeParams;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主体域ID
|
||||
*
|
||||
* @return model_id 主体域ID
|
||||
*/
|
||||
public Long getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主体域ID
|
||||
*
|
||||
* @param modelId 主体域ID
|
||||
*/
|
||||
public void setModelId(Long modelId) {
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*
|
||||
* @return name 指标名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*
|
||||
* @param name 指标名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*
|
||||
* @return biz_name 字段名称
|
||||
*/
|
||||
public String getBizName() {
|
||||
return bizName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*
|
||||
* @param bizName 字段名称
|
||||
*/
|
||||
public void setBizName(String bizName) {
|
||||
this.bizName = bizName == null ? null : bizName.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*
|
||||
* @return description 描述
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*
|
||||
* @param description 描述
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description == null ? null : description.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标状态,0正常,1下架,2删除
|
||||
*
|
||||
* @return status 指标状态,0正常,1下架,2删除
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标状态,0正常,1下架,2删除
|
||||
*
|
||||
* @param status 指标状态,0正常,1下架,2删除
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 敏感级别
|
||||
*
|
||||
* @return sensitive_level 敏感级别
|
||||
*/
|
||||
public Integer getSensitiveLevel() {
|
||||
return sensitiveLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 敏感级别
|
||||
*
|
||||
* @param sensitiveLevel 敏感级别
|
||||
*/
|
||||
public void setSensitiveLevel(Integer sensitiveLevel) {
|
||||
this.sensitiveLevel = sensitiveLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标类型 proxy,expr
|
||||
*
|
||||
* @return type 指标类型 proxy,expr
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标类型 proxy,expr
|
||||
*
|
||||
* @param type 指标类型 proxy,expr
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type == null ? null : type.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*
|
||||
* @return created_at 创建时间
|
||||
*/
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*
|
||||
* @param createdAt 创建时间
|
||||
*/
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*
|
||||
* @return created_by 创建人
|
||||
*/
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*
|
||||
* @param createdBy 创建人
|
||||
*/
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy == null ? null : createdBy.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*
|
||||
* @return updated_at 更新时间
|
||||
*/
|
||||
public Date getUpdatedAt() {
|
||||
@@ -271,7 +127,6 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*
|
||||
* @param updatedAt 更新时间
|
||||
*/
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
@@ -280,7 +135,6 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*
|
||||
* @return updated_by 更新人
|
||||
*/
|
||||
public String getUpdatedBy() {
|
||||
@@ -289,7 +143,6 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*
|
||||
* @param updatedBy 更新人
|
||||
*/
|
||||
public void setUpdatedBy(String updatedBy) {
|
||||
@@ -298,7 +151,6 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 数值类型
|
||||
*
|
||||
* @return data_format_type 数值类型
|
||||
*/
|
||||
public String getDataFormatType() {
|
||||
@@ -307,7 +159,6 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 数值类型
|
||||
*
|
||||
* @param dataFormatType 数值类型
|
||||
*/
|
||||
public void setDataFormatType(String dataFormatType) {
|
||||
@@ -316,7 +167,6 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 数值类型参数
|
||||
*
|
||||
* @return data_format 数值类型参数
|
||||
*/
|
||||
public String getDataFormat() {
|
||||
@@ -325,7 +175,6 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 数值类型参数
|
||||
*
|
||||
* @param dataFormat 数值类型参数
|
||||
*/
|
||||
public void setDataFormat(String dataFormat) {
|
||||
@@ -333,6 +182,7 @@ public class MetricDO {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return alias
|
||||
*/
|
||||
public String getAlias() {
|
||||
@@ -340,6 +190,7 @@ public class MetricDO {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param alias
|
||||
*/
|
||||
public void setAlias(String alias) {
|
||||
@@ -348,7 +199,6 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 类型参数
|
||||
*
|
||||
* @return type_params 类型参数
|
||||
*/
|
||||
public String getTypeParams() {
|
||||
@@ -357,10 +207,9 @@ public class MetricDO {
|
||||
|
||||
/**
|
||||
* 类型参数
|
||||
*
|
||||
* @param typeParams 类型参数
|
||||
*/
|
||||
public void setTypeParams(String typeParams) {
|
||||
this.typeParams = typeParams == null ? null : typeParams.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1212,38 +1212,6 @@ public class MetricDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -1279,5 +1247,37 @@ public class MetricDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,269 +4,143 @@ import java.util.Date;
|
||||
|
||||
public class ModelDO {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String bizName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long domainId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String viewer;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String viewOrg;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String admin;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String adminOrg;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isOpen;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String entity;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return biz_name
|
||||
*/
|
||||
public String getBizName() {
|
||||
return bizName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bizName
|
||||
*/
|
||||
public void setBizName(String bizName) {
|
||||
this.bizName = bizName == null ? null : bizName.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return domain_id
|
||||
*/
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param domainId
|
||||
*/
|
||||
public void setDomainId(Long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return viewer
|
||||
*/
|
||||
public String getViewer() {
|
||||
return viewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param viewer
|
||||
*/
|
||||
public void setViewer(String viewer) {
|
||||
this.viewer = viewer == null ? null : viewer.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return view_org
|
||||
*/
|
||||
public String getViewOrg() {
|
||||
return viewOrg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param viewOrg
|
||||
*/
|
||||
public void setViewOrg(String viewOrg) {
|
||||
this.viewOrg = viewOrg == null ? null : viewOrg.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return admin
|
||||
*/
|
||||
public String getAdmin() {
|
||||
return admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param admin
|
||||
*/
|
||||
public void setAdmin(String admin) {
|
||||
this.admin = admin == null ? null : admin.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return admin_org
|
||||
*/
|
||||
public String getAdminOrg() {
|
||||
return adminOrg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param adminOrg
|
||||
*/
|
||||
public void setAdminOrg(String adminOrg) {
|
||||
this.adminOrg = adminOrg == null ? null : adminOrg.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return is_open
|
||||
*/
|
||||
public Integer getIsOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isOpen
|
||||
*/
|
||||
public void setIsOpen(Integer isOpen) {
|
||||
this.isOpen = isOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return created_by
|
||||
*/
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createdBy
|
||||
*/
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy == null ? null : createdBy.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return created_at
|
||||
*/
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createdAt
|
||||
*/
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return updated_by
|
||||
*/
|
||||
public String getUpdatedBy() {
|
||||
return updatedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param updatedBy
|
||||
*/
|
||||
public void setUpdatedBy(String updatedBy) {
|
||||
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return updated_at
|
||||
*/
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param updatedAt
|
||||
*/
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return entity
|
||||
*/
|
||||
public String getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
*/
|
||||
public void setEntity(String entity) {
|
||||
this.entity = entity == null ? null : entity.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,38 +1082,6 @@ public class ModelDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -1149,5 +1117,37 @@ public class ModelDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,11 @@ package com.tencent.supersonic.semantic.model.domain.dataobject;
|
||||
import java.util.Date;
|
||||
|
||||
public class ViewInfoDO {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long modelId;
|
||||
|
||||
@@ -20,22 +17,18 @@ public class ViewInfoDO {
|
||||
private String type;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
@@ -74,7 +67,6 @@ public class ViewInfoDO {
|
||||
|
||||
/**
|
||||
* datasource、dimension、metric
|
||||
*
|
||||
* @return type datasource、dimension、metric
|
||||
*/
|
||||
public String getType() {
|
||||
@@ -83,7 +75,6 @@ public class ViewInfoDO {
|
||||
|
||||
/**
|
||||
* datasource、dimension、metric
|
||||
*
|
||||
* @param type datasource、dimension、metric
|
||||
*/
|
||||
public void setType(String type) {
|
||||
@@ -148,7 +139,6 @@ public class ViewInfoDO {
|
||||
|
||||
/**
|
||||
* config detail
|
||||
*
|
||||
* @return config config detail
|
||||
*/
|
||||
public String getConfig() {
|
||||
@@ -157,10 +147,9 @@ public class ViewInfoDO {
|
||||
|
||||
/**
|
||||
* config detail
|
||||
*
|
||||
* @param config config detail
|
||||
*/
|
||||
public void setConfig(String config) {
|
||||
this.config = config == null ? null : config.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,38 +672,6 @@ public class ViewInfoDOExample {
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
@@ -739,5 +707,37 @@ public class ViewInfoDOExample {
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,19 @@ package com.tencent.supersonic.semantic.model.domain.utils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DomainReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DomainDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Domain;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
@@ -56,7 +58,8 @@ public class DomainConvert {
|
||||
}
|
||||
|
||||
public static DomainResp convert(DomainDO domainDO, Map<Long, String> domainFullPathMap,
|
||||
Map<Long, List<DimensionResp>> dimensionMap, Map<Long, List<MetricResp>> metricMap) {
|
||||
Map<Long, List<DimensionResp>> dimensionMap,
|
||||
Map<Long, List<MetricResp>> metricMap) {
|
||||
DomainResp domainResp = convert(domainDO, domainFullPathMap);
|
||||
domainResp.setDimensionCnt(dimensionMap.getOrDefault(domainResp.getId(), Lists.newArrayList()).size());
|
||||
domainResp.setMetricCnt(metricMap.getOrDefault(domainResp.getId(), Lists.newArrayList()).size());
|
||||
|
||||
@@ -3,21 +3,22 @@ package com.tencent.supersonic.semantic.model.domain.utils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.common.util.BeanMapper;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.request.MetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.yaml.MeasureYamlTpl;
|
||||
import com.tencent.supersonic.semantic.api.model.yaml.MetricTypeParamsYamlTpl;
|
||||
import com.tencent.supersonic.semantic.api.model.yaml.MetricYamlTpl;
|
||||
import com.tencent.supersonic.semantic.api.model.request.MetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.common.util.BeanMapper;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Metric;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
public class MetricConverter {
|
||||
|
||||
@@ -5,15 +5,14 @@ import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DimValueMap;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DimensionReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.MetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageDimensionReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -27,14 +26,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/api/semantic/dimension")
|
||||
public class DimensionController {
|
||||
|
||||
|
||||
private DimensionService dimensionService;
|
||||
|
||||
|
||||
private MetricService metricService;
|
||||
|
||||
public DimensionController(DimensionService dimensionService,MetricService metricService) {
|
||||
this.metricService = metricService;
|
||||
public DimensionController(DimensionService dimensionService) {
|
||||
this.dimensionService = dimensionService;
|
||||
}
|
||||
|
||||
@@ -46,8 +40,8 @@ public class DimensionController {
|
||||
*/
|
||||
@PostMapping("/createDimension")
|
||||
public Boolean createDimension(@RequestBody DimensionReq dimensionReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
dimensionService.createDimension(dimensionReq, user);
|
||||
return true;
|
||||
@@ -56,8 +50,8 @@ public class DimensionController {
|
||||
|
||||
@PostMapping("/updateDimension")
|
||||
public Boolean updateDimension(@RequestBody DimensionReq dimensionReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
dimensionService.updateDimension(dimensionReq, user);
|
||||
return true;
|
||||
@@ -66,18 +60,18 @@ public class DimensionController {
|
||||
@PostMapping("/mockDimensionAlias")
|
||||
public List<String> mockMetricAlias(@RequestBody DimensionReq dimensionReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response){
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return dimensionService.mockAlias(dimensionReq,"dimension",user);
|
||||
return dimensionService.mockAlias(dimensionReq, "dimension", user);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/mockDimensionValuesAlias")
|
||||
public List<DimValueMap> mockDimensionValuesAlias(@RequestBody DimensionReq dimensionReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response){
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return dimensionService.mockDimensionValueAlias(dimensionReq,user);
|
||||
return dimensionService.mockDimensionValueAlias(dimensionReq, user);
|
||||
}
|
||||
|
||||
@GetMapping("/getDimensionList/{modelId}")
|
||||
@@ -88,7 +82,7 @@ public class DimensionController {
|
||||
|
||||
@GetMapping("/{modelId}/{dimensionName}")
|
||||
public DimensionResp getDimensionDescByNameAndId(@PathVariable("modelId") Long modelId,
|
||||
@PathVariable("dimensionName") String dimensionBizName) {
|
||||
@PathVariable("dimensionName") String dimensionBizName) {
|
||||
return dimensionService.getDimension(dimensionBizName, modelId);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,13 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
||||
|
||||
@RestController
|
||||
@@ -51,9 +56,9 @@ public class MetricController {
|
||||
@PostMapping("/mockMetricAlias")
|
||||
public List<String> mockMetricAlias(@RequestBody MetricReq metricReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response){
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return metricService.mockAlias(metricReq,"indicator",user);
|
||||
return metricService.mockAlias(metricReq, "indicator", user);
|
||||
}
|
||||
|
||||
@GetMapping("/getMetricList/{modelId}")
|
||||
|
||||
@@ -6,18 +6,18 @@ import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
@@ -32,8 +32,8 @@ public class ModelController {
|
||||
|
||||
@PostMapping("/createModel")
|
||||
public Boolean createModel(@RequestBody ModelReq modelReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
modelService.createModel(modelReq, user);
|
||||
return true;
|
||||
@@ -41,8 +41,8 @@ public class ModelController {
|
||||
|
||||
@PostMapping("/updateModel")
|
||||
public Boolean updateModel(@RequestBody ModelReq modelReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
modelService.updateModel(modelReq, user);
|
||||
return true;
|
||||
@@ -56,8 +56,8 @@ public class ModelController {
|
||||
|
||||
@GetMapping("/getModelList/{domainId}")
|
||||
public List<ModelResp> getModelList(@PathVariable("domainId") Long domainId,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return modelService.getModelListWithAuth(user.getName(), domainId, AuthType.ADMIN);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
<if test="bizName != null and bizName != ''">
|
||||
and biz_name like CONCAT('%',#{bizName , jdbcType=VARCHAR},'%')
|
||||
</if>
|
||||
<if test="sensitiveLevel != null and sensitiveLevel != ''">
|
||||
<if test="sensitiveLevel != null">
|
||||
and sensitive_level = #{sensitiveLevel}
|
||||
</if>
|
||||
<if test="modelIds != null and modelIds.size >0">
|
||||
|
||||
@@ -79,7 +79,6 @@ public abstract class Renderer {
|
||||
if (measure.get().getConstraint() != null && !measure.get().getConstraint().isEmpty()) {
|
||||
metricNode.getMeasureFilter()
|
||||
.put(measure.get().getName(), SemanticNode.parse(measure.get().getConstraint(), scope));
|
||||
;
|
||||
}
|
||||
}
|
||||
return metricNode;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.tencent.supersonic.semantic.query.parser.calcite.dsl.Constants;
|
||||
import com.tencent.supersonic.semantic.query.parser.calcite.dsl.DataSource;
|
||||
import com.tencent.supersonic.semantic.query.parser.calcite.dsl.Dimension;
|
||||
import com.tencent.supersonic.semantic.query.parser.calcite.schema.SemanticSchema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
@@ -17,6 +18,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.calcite.sql.SqlNode;
|
||||
import org.apache.calcite.sql.parser.SqlParser;
|
||||
@@ -50,7 +52,7 @@ public class DataSourceNode extends SemanticNode {
|
||||
}
|
||||
|
||||
public static void getQueryDimensionMeasure(SemanticSchema schema, MetricReq metricCommand,
|
||||
Set<String> queryDimension, List<String> measures) {
|
||||
Set<String> queryDimension, List<String> measures) {
|
||||
queryDimension.addAll(metricCommand.getDimensions().stream()
|
||||
.map(d -> d.contains(Constants.DIMENSION_IDENTIFY) ? d.split(Constants.DIMENSION_IDENTIFY)[1] : d)
|
||||
.collect(Collectors.toSet()));
|
||||
@@ -62,17 +64,18 @@ public class DataSourceNode extends SemanticNode {
|
||||
}
|
||||
|
||||
public static void mergeQueryFilterDimensionMeasure(SemanticSchema schema, MetricReq metricCommand,
|
||||
Set<String> queryDimension, List<String> measures, SqlValidatorScope scope) throws Exception {
|
||||
Set<String> queryDimension, List<String> measures,
|
||||
SqlValidatorScope scope) throws Exception {
|
||||
if (Objects.nonNull(metricCommand.getWhere()) && !metricCommand.getWhere().isEmpty()) {
|
||||
Set<String> filterConditions = new HashSet<>();
|
||||
FilterNode.getFilterField(parse(metricCommand.getWhere(), scope), filterConditions);
|
||||
Set<String> queryMeasures = new HashSet<>(measures);
|
||||
Set<String> schemaMetricName = schema.getMetrics().stream().map(m -> m.getName())
|
||||
.collect(Collectors.toSet());
|
||||
Set<String> schemaMetricName = schema.getMetrics().stream()
|
||||
.map(m -> m.getName()).collect(Collectors.toSet());
|
||||
for (String filterCondition : filterConditions) {
|
||||
if (schemaMetricName.contains(filterCondition)) {
|
||||
schema.getMetrics().stream().filter(m -> m.getName().equalsIgnoreCase(filterCondition)).forEach(
|
||||
m -> m.getMetricTypeParams().getMeasures().stream()
|
||||
schema.getMetrics().stream().filter(m -> m.getName().equalsIgnoreCase(filterCondition))
|
||||
.forEach(m -> m.getMetricTypeParams().getMeasures().stream()
|
||||
.forEach(mm -> queryMeasures.add(mm.getName())));
|
||||
continue;
|
||||
}
|
||||
@@ -84,14 +87,13 @@ public class DataSourceNode extends SemanticNode {
|
||||
}
|
||||
|
||||
public static List<DataSource> getMatchDataSources(SqlValidatorScope scope, SemanticSchema schema,
|
||||
MetricReq metricCommand) throws Exception {
|
||||
MetricReq metricCommand) throws Exception {
|
||||
List<DataSource> dataSources = new ArrayList<>();
|
||||
|
||||
// check by metric
|
||||
List<String> measures = new ArrayList<>();
|
||||
Set<String> queryDimension = new HashSet<>();
|
||||
getQueryDimensionMeasure(schema, metricCommand, queryDimension, measures);
|
||||
String sourceName = "";
|
||||
DataSource baseDataSource = null;
|
||||
// one , match measure count
|
||||
Map<String, Integer> dataSourceMeasures = new HashMap<>();
|
||||
@@ -148,8 +150,12 @@ public class DataSourceNode extends SemanticNode {
|
||||
return dataSources;
|
||||
}
|
||||
|
||||
private static boolean checkMatch(Set<String> sourceMeasure, Set<String> queryDimension, List<String> measures,
|
||||
Set<String> dimension, MetricReq metricCommand, SqlValidatorScope scope) throws Exception {
|
||||
private static boolean checkMatch(Set<String> sourceMeasure,
|
||||
Set<String> queryDimension,
|
||||
List<String> measures,
|
||||
Set<String> dimension,
|
||||
MetricReq metricCommand,
|
||||
SqlValidatorScope scope) throws Exception {
|
||||
boolean isAllMatch = true;
|
||||
sourceMeasure.retainAll(measures);
|
||||
if (sourceMeasure.size() < measures.size()) {
|
||||
@@ -173,8 +179,11 @@ public class DataSourceNode extends SemanticNode {
|
||||
return isAllMatch;
|
||||
}
|
||||
|
||||
private static List<DataSource> getLinkDataSources(Set<String> baseIdentifiers, Set<String> queryDimension,
|
||||
List<String> measures, DataSource baseDataSource, SemanticSchema schema) {
|
||||
private static List<DataSource> getLinkDataSources(Set<String> baseIdentifiers,
|
||||
Set<String> queryDimension,
|
||||
List<String> measures,
|
||||
DataSource baseDataSource,
|
||||
SemanticSchema schema) {
|
||||
Set<String> linkDataSourceName = new HashSet<>();
|
||||
List<DataSource> linkDataSources = new ArrayList<>();
|
||||
for (Map.Entry<String, DataSource> entry : schema.getDatasource().entrySet()) {
|
||||
@@ -200,7 +209,6 @@ public class DataSourceNode extends SemanticNode {
|
||||
linkMeasure.retainAll(measures);
|
||||
if (!linkMeasure.isEmpty()) {
|
||||
isMatch = true;
|
||||
;
|
||||
}
|
||||
}
|
||||
if (isMatch) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -106,10 +105,7 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
if (CollectionUtils.isEmpty(queryStructCmd.getAggregators())) {
|
||||
return false;
|
||||
}
|
||||
//todo ck类型暂不拼with语句
|
||||
if (queryStructCmd.getModelId().equals(34L)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int nonSumFunction = 0;
|
||||
for (Aggregator agg : queryStructCmd.getAggregators()) {
|
||||
if (agg.getFunc() == null || "".equals(agg.getFunc())) {
|
||||
@@ -118,9 +114,7 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
if (agg.getFunc().equals(AggOperatorEnum.UNKNOWN)) {
|
||||
return false;
|
||||
}
|
||||
if (agg.getFunc() != null
|
||||
// && !agg.getFunc().equalsIgnoreCase(MetricAggDefault)
|
||||
) {
|
||||
if (agg.getFunc() != null) {
|
||||
nonSumFunction++;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +123,7 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
|
||||
@Override
|
||||
public void converter(Catalog catalog, QueryStructReq queryStructCmd, ParseSqlReq sqlCommend,
|
||||
MetricReq metricCommand) throws Exception {
|
||||
MetricReq metricCommand) throws Exception {
|
||||
DatabaseResp databaseResp = catalog.getDatabaseByModelId(queryStructCmd.getModelId());
|
||||
ParseSqlReq parseSqlReq = generateSqlCommend(queryStructCmd,
|
||||
EngineTypeEnum.valueOf(databaseResp.getType().toUpperCase()), databaseResp.getVersion());
|
||||
@@ -156,7 +150,7 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
}
|
||||
|
||||
public ParseSqlReq generateRatioSqlCommand(QueryStructReq queryStructCmd, EngineTypeEnum engineTypeEnum,
|
||||
String version)
|
||||
String version)
|
||||
throws Exception {
|
||||
check(queryStructCmd);
|
||||
ParseSqlReq sqlCommand = new ParseSqlReq();
|
||||
@@ -178,15 +172,17 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
sql = new H2EngineSql().sql(queryStructCmd, isOver, metricTableName);
|
||||
break;
|
||||
case MYSQL:
|
||||
if (Objects.nonNull(version) && version.startsWith(mysqlLowVersion)) {
|
||||
sqlCommand.setSupportWith(false);
|
||||
sql = new MysqlEngineSql().sql(queryStructCmd, isOver, metricTableName);
|
||||
break;
|
||||
}
|
||||
case DORIS:
|
||||
case CLICKHOUSE:
|
||||
sql = new CkEngineSql().sql(queryStructCmd, isOver, metricTableName);
|
||||
if (engineTypeEnum.equals(EngineTypeEnum.MYSQL) && Objects.nonNull(version) && version.startsWith(
|
||||
mysqlLowVersion)) {
|
||||
sqlCommand.setSupportWith(false);
|
||||
sql = new MysqlEngineSql().sql(queryStructCmd, isOver, metricTableName);
|
||||
} else {
|
||||
sql = new CkEngineSql().sql(queryStructCmd, isOver, metricTableName);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
sqlCommand.setSql(sql);
|
||||
return sqlCommand;
|
||||
@@ -275,7 +271,7 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
String aggStr = queryStructCmd.getAggregators().stream().map(f -> {
|
||||
if (f.getFunc().equals(AggOperatorEnum.RATIO_OVER) || f.getFunc().equals(AggOperatorEnum.RATIO_ROLL)) {
|
||||
if (queryStructCmd.getDateInfo().getPeriod().equals(Constants.MONTH)) {
|
||||
return String.format("toDate(CONCAT(%s,'-01')) = date_add(toDate(CONCAT(%s','-01')),%s) ",
|
||||
return String.format("toDate(CONCAT(%s,'-01')) = date_add(toDate(CONCAT(%s,'-01')),%s) ",
|
||||
aliasLeft + timeDim, aliasRight + timeDim, timeSpan);
|
||||
}
|
||||
if (queryStructCmd.getDateInfo().getPeriod().equals(Constants.WEEK) && isOver) {
|
||||
@@ -302,7 +298,8 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
@Override
|
||||
public String sql(QueryStructReq queryStructCmd, boolean isOver, String metricSql) {
|
||||
String sql = String.format(
|
||||
",t0 as (select * from %s),t1 as (select * from %s) select %s from ( select %s , %s from t0 left join t1 on %s ) metric_tb_src %s %s ",
|
||||
",t0 as (select * from %s),t1 as (select * from %s) select %s from ( select %s , %s "
|
||||
+ "from t0 left join t1 on %s ) metric_tb_src %s %s ",
|
||||
metricSql, metricSql, getOverSelect(queryStructCmd, isOver), getAllSelect(queryStructCmd, "t0."),
|
||||
getAllJoinSelect(queryStructCmd, "t1."),
|
||||
getJoinOn(queryStructCmd, isOver, "t0.", "t1."),
|
||||
@@ -330,8 +327,6 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
}
|
||||
|
||||
public String getOverSelect(QueryStructReq queryStructCmd, boolean isOver) {
|
||||
String timeDim = getTimeDim(queryStructCmd);
|
||||
String timeSpan = "INTERVAL " + getTimeSpan(queryStructCmd, isOver, true);
|
||||
String aggStr = queryStructCmd.getAggregators().stream().map(f -> {
|
||||
if (f.getFunc().equals(AggOperatorEnum.RATIO_OVER) || f.getFunc().equals(AggOperatorEnum.RATIO_ROLL)) {
|
||||
return String.format(
|
||||
@@ -460,9 +455,6 @@ public class CalculateAggConverter implements SemanticConverter {
|
||||
}
|
||||
|
||||
private void check(QueryStructReq queryStructCmd) throws Exception {
|
||||
Set<String> aggFunctions = queryStructCmd.getAggregators().stream()
|
||||
.filter(f -> f.getArgs() != null && f.getArgs().get(0) != null)
|
||||
.map(agg -> agg.getArgs().get(0).toLowerCase()).collect(Collectors.toSet());
|
||||
Long ratioOverNum = queryStructCmd.getAggregators().stream()
|
||||
.filter(f -> f.getFunc().equals(AggOperatorEnum.RATIO_OVER)).count();
|
||||
Long ratioRollNum = queryStructCmd.getAggregators().stream()
|
||||
|
||||
@@ -8,11 +8,11 @@ import com.tencent.supersonic.semantic.api.query.request.ParseSqlReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.QueryStructReq;
|
||||
import com.tencent.supersonic.semantic.model.domain.Catalog;
|
||||
import com.tencent.supersonic.semantic.query.parser.SemanticConverter;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component("DefaultDimValueConverter")
|
||||
@@ -24,8 +24,8 @@ public class DefaultDimValueConverter implements SemanticConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void converter(Catalog catalog, QueryStructReq queryStructCmd, ParseSqlReq sqlCommend,
|
||||
MetricReq metricCommand) throws Exception {
|
||||
public void converter(Catalog catalog, QueryStructReq queryStructCmd,
|
||||
ParseSqlReq sqlCommend, MetricReq metricCommand) throws Exception {
|
||||
List<DimensionResp> dimensionResps = catalog.getDimensions(queryStructCmd.getModelId());
|
||||
//dimension which has default values
|
||||
dimensionResps = dimensionResps.stream()
|
||||
|
||||
@@ -132,6 +132,4 @@ public class MultiSourceJoin implements SemanticConverter {
|
||||
MetricReq metricCommand) throws Exception {
|
||||
buildJoinPrefix(queryStructCmd);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.tencent.supersonic.semantic.query.parser.convert;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.Constants.UNDERLINE;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.ColumnOrder;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.query.pojo.Param;
|
||||
import com.tencent.supersonic.semantic.api.query.request.MetricReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.ParseSqlReq;
|
||||
@@ -13,9 +10,7 @@ import com.tencent.supersonic.semantic.query.parser.SemanticConverter;
|
||||
import com.tencent.supersonic.semantic.query.utils.QueryStructUtils;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -68,7 +63,8 @@ public class ParserDefaultConverter implements SemanticConverter {
|
||||
// todo tmp delete
|
||||
// support detail query
|
||||
if (queryStructCmd.getNativeQuery() && CollectionUtils.isEmpty(sqlCommend.getMetrics())) {
|
||||
String internalMetricName = queryStructUtils.generateInternalMetricName(queryStructCmd.getModelId(), queryStructCmd.getGroups());
|
||||
String internalMetricName = queryStructUtils.generateInternalMetricName(
|
||||
queryStructCmd.getModelId(), queryStructCmd.getGroups());
|
||||
sqlCommend.getMetrics().add(internalMetricName);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ package com.tencent.supersonic.semantic.query.rest;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
||||
import com.tencent.supersonic.semantic.api.model.response.SqlParserResp;
|
||||
import com.tencent.supersonic.semantic.api.query.request.ItemUseReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.ParseSqlReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.QueryDslReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.QueryMultiStructReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.ParseSqlReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.QueryStructReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.QueryMultiStructReq;
|
||||
import com.tencent.supersonic.semantic.api.query.request.ItemUseReq;
|
||||
import com.tencent.supersonic.semantic.api.query.response.ItemUseResp;
|
||||
import com.tencent.supersonic.semantic.query.persistence.pojo.QueryStatement;
|
||||
import com.tencent.supersonic.semantic.query.service.QueryService;
|
||||
import com.tencent.supersonic.semantic.query.service.SemanticQueryEngine;
|
||||
import com.tencent.supersonic.semantic.query.service.QueryService;
|
||||
import com.tencent.supersonic.semantic.query.persistence.pojo.QueryStatement;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -57,7 +57,6 @@ public class QueryController {
|
||||
public SqlParserResp parseByStruct(@RequestBody ParseSqlReq parseSqlReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
QueryStatement queryStatement = semanticQueryEngine.physicalSql(parseSqlReq);
|
||||
SqlParserResp sqlParserResp = new SqlParserResp();
|
||||
BeanUtils.copyProperties(queryStatement, sqlParserResp);
|
||||
|
||||
@@ -7,22 +7,22 @@ import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelSchemaFilterReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageDimensionReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageMetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.query.service.SchemaService;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/semantic/schema")
|
||||
@@ -33,24 +33,24 @@ public class SchemaController {
|
||||
|
||||
@PostMapping
|
||||
public List<ModelSchemaResp> fetchModelSchema(@RequestBody ModelSchemaFilterReq filter,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return schemaService.fetchModelSchema(filter, user);
|
||||
}
|
||||
|
||||
@GetMapping("/domain/list")
|
||||
public List<DomainResp> getDomainList(HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return schemaService.getDomainList(user);
|
||||
}
|
||||
|
||||
@GetMapping("/model/list")
|
||||
public List<ModelResp> getModelList(@RequestParam("domainId") Long domainId,
|
||||
@RequestParam("authType") String authType,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
@RequestParam("authType") String authType,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return schemaService.getModelList(user, AuthType.valueOf(authType), domainId);
|
||||
}
|
||||
@@ -71,4 +71,4 @@ public class SchemaController {
|
||||
return schemaService.queryMetric(pageMetricCmd, user);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@ package com.tencent.supersonic.semantic.query.service;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.util.ContextUtils;
|
||||
import com.tencent.supersonic.common.util.cache.CacheUtils;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.QueryStat;
|
||||
import com.tencent.supersonic.common.util.ContextUtils;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelSchemaFilterReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.QueryResultWithSchemaResp;
|
||||
|
||||
@@ -6,11 +6,12 @@ import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelSchemaFilterReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageDimensionReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageMetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SchemaService {
|
||||
|
||||
@@ -5,23 +5,23 @@ import static com.tencent.supersonic.common.pojo.Constants.AT_SYMBOL;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.semantic.api.model.request.ModelSchemaFilterReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageDimensionReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageMetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.query.request.ItemUseReq;
|
||||
import com.tencent.supersonic.semantic.api.query.response.ItemUseResp;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -40,10 +40,10 @@ public class SchemaServiceImpl implements SchemaService {
|
||||
private final DomainService domainService;
|
||||
|
||||
public SchemaServiceImpl(QueryService queryService,
|
||||
ModelService modelService,
|
||||
DimensionService dimensionService,
|
||||
MetricService metricService,
|
||||
DomainService domainService) {
|
||||
ModelService modelService,
|
||||
DimensionService dimensionService,
|
||||
MetricService metricService,
|
||||
DomainService domainService) {
|
||||
this.queryService = queryService;
|
||||
this.modelService = modelService;
|
||||
this.dimensionService = dimensionService;
|
||||
|
||||
@@ -12,23 +12,20 @@ import com.tencent.supersonic.auth.api.authorization.pojo.DimensionFilter;
|
||||
import com.tencent.supersonic.auth.api.authorization.request.QueryAuthResReq;
|
||||
import com.tencent.supersonic.auth.api.authorization.response.AuthorizedResourceResp;
|
||||
import com.tencent.supersonic.auth.api.authorization.service.AuthService;
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import com.tencent.supersonic.common.pojo.QueryAuthorization;
|
||||
import com.tencent.supersonic.common.pojo.QueryColumn;
|
||||
import com.tencent.supersonic.common.pojo.enums.AuthType;
|
||||
import com.tencent.supersonic.common.pojo.exception.InvalidArgumentException;
|
||||
import com.tencent.supersonic.common.pojo.exception.InvalidPermissionException;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem;
|
||||
import com.tencent.supersonic.semantic.api.model.response.QueryResultWithSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.QueryResultWithSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.query.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.semantic.api.query.pojo.Filter;
|
||||
import com.tencent.supersonic.semantic.api.query.request.QueryStructReq;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import com.tencent.supersonic.common.pojo.exception.InvalidArgumentException;
|
||||
import com.tencent.supersonic.common.pojo.exception.InvalidPermissionException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -39,13 +36,16 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.assertj.core.util.Sets;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -133,14 +133,14 @@ public class DataPermissionAOP {
|
||||
.collect(Collectors.toSet());
|
||||
QueryResultWithSchemaResp queryResultAfterDesensitization = desensitizationData(queryResultWithColumns,
|
||||
need2Apply);
|
||||
addPromptInfoInfo(modelId, queryResultAfterDesensitization, authorizedResource);
|
||||
addPromptInfoInfo(modelId, queryResultAfterDesensitization, authorizedResource, need2Apply);
|
||||
|
||||
return queryResultAfterDesensitization;
|
||||
|
||||
}
|
||||
|
||||
private boolean doModelAdmin(User user, QueryStructReq queryStructCmd) {
|
||||
Long modelId = queryStructCmd.getModelId();
|
||||
private boolean doModelAdmin(User user, QueryStructReq queryStructReq) {
|
||||
Long modelId = queryStructReq.getModelId();
|
||||
List<ModelResp> modelListAdmin = modelService.getModelListWithAuth(user.getName(), null, AuthType.ADMIN);
|
||||
if (CollectionUtils.isEmpty(modelListAdmin)) {
|
||||
return false;
|
||||
@@ -151,69 +151,60 @@ public class DataPermissionAOP {
|
||||
}
|
||||
}
|
||||
|
||||
private void doModelVisible(User user, QueryStructReq queryStructCmd) {
|
||||
private void doModelVisible(User user, QueryStructReq queryStructReq) {
|
||||
Boolean visible = true;
|
||||
Long domainId = queryStructCmd.getModelId();
|
||||
Long modelId = queryStructReq.getModelId();
|
||||
List<ModelResp> modelListVisible = modelService.getModelListWithAuth(user.getName(), null, AuthType.VISIBLE);
|
||||
if (CollectionUtils.isEmpty(modelListVisible)) {
|
||||
visible = false;
|
||||
} else {
|
||||
Map<Long, List<ModelResp>> id2domainDesc = modelListVisible.stream()
|
||||
.collect(Collectors.groupingBy(SchemaItem::getId));
|
||||
if (!CollectionUtils.isEmpty(id2domainDesc) && !id2domainDesc.containsKey(domainId)) {
|
||||
if (!CollectionUtils.isEmpty(id2domainDesc) && !id2domainDesc.containsKey(modelId)) {
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!visible) {
|
||||
List<Long> modelIds = new ArrayList<>();
|
||||
modelIds.add(domainId);
|
||||
List<ModelResp> modelInfos = modelService.getModelList(modelIds);
|
||||
if (CollectionUtils.isEmpty(modelInfos)) {
|
||||
throw new InvalidArgumentException(
|
||||
"invalid domainId:" + domainId + ", please contact admin for details");
|
||||
}
|
||||
String domainName = modelInfos.get(0).getName();
|
||||
throw new InvalidPermissionException(
|
||||
"You do not have domain:" + domainName + " permission, please contact admin for details");
|
||||
|
||||
ModelResp modelResp = modelService.getModel(modelId);
|
||||
String modelName = modelResp.getName();
|
||||
List<String> admins = modelService.getModelAdmin(modelResp.getId());
|
||||
String message = String.format("您没有主题域[%s]权限,请联系管理员%s开通", modelName, admins);
|
||||
throw new InvalidArgumentException(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private QueryResultWithSchemaResp getQueryResultWithColumns(QueryResultWithSchemaResp resultWithColumns,
|
||||
Long domainId, AuthorizedResourceResp authResource) {
|
||||
addPromptInfoInfo(domainId, resultWithColumns, authResource);
|
||||
addPromptInfoInfo(domainId, resultWithColumns, authResource, Sets.newHashSet());
|
||||
return resultWithColumns;
|
||||
}
|
||||
|
||||
private void addPromptInfoInfo(Long domainId, QueryResultWithSchemaResp queryResultWithColumns,
|
||||
AuthorizedResourceResp authorizedResource) {
|
||||
private void addPromptInfoInfo(Long modelId, QueryResultWithSchemaResp queryResultWithColumns,
|
||||
AuthorizedResourceResp authorizedResource, Set<String> need2Apply) {
|
||||
List<DimensionFilter> filters = authorizedResource.getFilters();
|
||||
if (CollectionUtils.isEmpty(need2Apply) && CollectionUtils.isEmpty(filters)) {
|
||||
return;
|
||||
}
|
||||
List<String> admins = modelService.getModelAdmin(modelId);
|
||||
if (!CollectionUtils.isEmpty(need2Apply)) {
|
||||
String promptInfo = String.format("当前结果已经过脱敏处理, 申请权限请联系管理员%s", admins);
|
||||
queryResultWithColumns.setQueryAuthorization(new QueryAuthorization(promptInfo));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(filters)) {
|
||||
log.debug("dimensionFilters:{}", filters);
|
||||
|
||||
List<Long> modelIds = new ArrayList<>();
|
||||
modelIds.add(domainId);
|
||||
List<ModelResp> modelInfos = modelService.getModelList(modelIds);
|
||||
String modelNameCn = "";
|
||||
if (!CollectionUtils.isEmpty(modelInfos)) {
|
||||
modelNameCn = modelInfos.get(0).getName();
|
||||
}
|
||||
|
||||
ModelResp modelResp = modelService.getModel(modelId);
|
||||
List<String> exprList = new ArrayList<>();
|
||||
List<String> descList = new ArrayList<>();
|
||||
filters.stream().forEach(filter -> {
|
||||
descList.add(filter.getDescription());
|
||||
exprList.add(filter.getExpressions().toString());
|
||||
});
|
||||
|
||||
String promptInfo = "the current data has been controlled by permissions,"
|
||||
+ " related information:%s, please contact admin for details";
|
||||
String message = String.format(promptInfo, CollectionUtils.isEmpty(descList) ? exprList : descList);
|
||||
String promptInfo = "当前结果已经过行权限过滤,详细过滤条件如下:%s, 申请权限请联系管理员%s";
|
||||
String message = String.format(promptInfo, CollectionUtils.isEmpty(descList) ? exprList : descList, admins);
|
||||
|
||||
queryResultWithColumns.setQueryAuthorization(
|
||||
new QueryAuthorization(modelNameCn, exprList, descList, message));
|
||||
new QueryAuthorization(modelResp.getName(), exprList, descList, message));
|
||||
log.info("queryResultWithColumns:{}", queryResultWithColumns);
|
||||
}
|
||||
}
|
||||
@@ -292,7 +283,7 @@ public class DataPermissionAOP {
|
||||
return highSensitiveCols;
|
||||
}
|
||||
|
||||
private void doRowPermission(QueryStructReq queryStructCmd, AuthorizedResourceResp authorizedResource) {
|
||||
private void doRowPermission(QueryStructReq queryStructReq, AuthorizedResourceResp authorizedResource) {
|
||||
log.debug("start doRowPermission logic");
|
||||
StringJoiner joiner = new StringJoiner(" OR ");
|
||||
List<String> dimensionFilters = new ArrayList<>();
|
||||
@@ -313,13 +304,13 @@ public class DataPermissionAOP {
|
||||
});
|
||||
|
||||
if (StringUtils.isNotEmpty(joiner.toString())) {
|
||||
log.info("before doRowPermission, queryStructCmd:{}", queryStructCmd);
|
||||
log.info("before doRowPermission, queryStructReq:{}", queryStructReq);
|
||||
Filter filter = new Filter("", FilterOperatorEnum.SQL_PART, joiner.toString());
|
||||
List<Filter> filters = Objects.isNull(queryStructCmd.getOriginalFilter()) ? new ArrayList<>()
|
||||
: queryStructCmd.getOriginalFilter();
|
||||
List<Filter> filters = Objects.isNull(queryStructReq.getOriginalFilter()) ? new ArrayList<>()
|
||||
: queryStructReq.getOriginalFilter();
|
||||
filters.add(filter);
|
||||
queryStructCmd.setDimensionFilters(filters);
|
||||
log.info("after doRowPermission, queryStructCmd:{}", queryStructCmd);
|
||||
queryStructReq.setDimensionFilters(filters);
|
||||
log.info("after doRowPermission, queryStructReq:{}", queryStructReq);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -348,7 +339,7 @@ public class DataPermissionAOP {
|
||||
try {
|
||||
queryResultWithColumns = deepCopyResult(raw);
|
||||
} catch (Exception e) {
|
||||
log.warn("deepCopyResult, e:{}", e);
|
||||
log.warn("deepCopyResult: ", e);
|
||||
}
|
||||
addAuthorizedSchemaInfo(queryResultWithColumns.getColumns(), need2Apply);
|
||||
desensitizationInternal(queryResultWithColumns.getResultList(), need2Apply);
|
||||
@@ -382,30 +373,32 @@ public class DataPermissionAOP {
|
||||
}
|
||||
}
|
||||
|
||||
private void doFilterCheckLogic(QueryStructReq queryStructCmd, Set<String> resAuthName,
|
||||
private void doFilterCheckLogic(QueryStructReq queryStructReq, Set<String> resAuthName,
|
||||
Set<String> sensitiveResReq) {
|
||||
Set<String> resFilterSet = queryStructUtils.getFilterResNameEnExceptInternalCol(queryStructCmd);
|
||||
Set<String> resFilterSet = queryStructUtils.getFilterResNameEnExceptInternalCol(queryStructReq);
|
||||
Set<String> need2Apply = resFilterSet.stream()
|
||||
.filter(res -> !resAuthName.contains(res) && sensitiveResReq.contains(res)).collect(Collectors.toSet());
|
||||
Set<String> nameCnSet = new HashSet<>();
|
||||
|
||||
List<Long> modelIds = new ArrayList<>();
|
||||
modelIds.add(queryStructCmd.getModelId());
|
||||
modelIds.add(queryStructReq.getModelId());
|
||||
List<ModelResp> modelInfos = modelService.getModelList(modelIds);
|
||||
String modelNameCn = Constants.EMPTY;
|
||||
if (!CollectionUtils.isEmpty(modelInfos)) {
|
||||
modelNameCn = modelInfos.get(0).getName();
|
||||
}
|
||||
|
||||
List<DimensionResp> dimensionDescList = dimensionService.getDimensions(queryStructCmd.getModelId());
|
||||
List<DimensionResp> dimensionDescList = dimensionService.getDimensions(queryStructReq.getModelId());
|
||||
String finalDomainNameCn = modelNameCn;
|
||||
dimensionDescList.stream().filter(dim -> need2Apply.contains(dim.getBizName()))
|
||||
.forEach(dim -> nameCnSet.add(finalDomainNameCn + MINUS + dim.getName()));
|
||||
|
||||
if (!CollectionUtils.isEmpty(need2Apply)) {
|
||||
log.warn("in doFilterLogic, need2Apply:{}", need2Apply);
|
||||
throw new InvalidPermissionException(
|
||||
"you do not have data permission:" + nameCnSet + ", please contact admin for details");
|
||||
ModelResp modelResp = modelInfos.get(0);
|
||||
List<String> admins = modelService.getModelAdmin(modelResp.getId());
|
||||
log.info("in doFilterLogic, need2Apply:{}", need2Apply);
|
||||
String message = String.format("您没有以下维度%s权限, 请联系管理员%s开通", nameCnSet, admins);
|
||||
throw new InvalidPermissionException(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,4 +408,4 @@ public class DataPermissionAOP {
|
||||
return authService.queryAuthorizedResources(queryAuthResReq, user);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,19 @@ public class DateUtils {
|
||||
* @return
|
||||
*/
|
||||
public String betweenDateStr(ItemDateResp dateDate, DateConf dateInfo) {
|
||||
if (MONTH.equalsIgnoreCase(dateInfo.getPeriod())) {
|
||||
LocalDate endData = LocalDate.parse(dateInfo.getEndDate(),
|
||||
DateTimeFormatter.ofPattern(DAY_FORMAT));
|
||||
LocalDate startData = LocalDate.parse(dateInfo.getStartDate(),
|
||||
DateTimeFormatter.ofPattern(DAY_FORMAT));
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(MONTH_FORMAT);
|
||||
return String.format("%s >= '%s' and %s <= '%s'",
|
||||
sysDateMonthCol, startData.format(formatter), sysDateMonthCol, endData.format(formatter));
|
||||
}
|
||||
if (WEEK.equalsIgnoreCase(dateInfo.getPeriod())) {
|
||||
return String.format("%s >= '%s' and %s <= '%s'",
|
||||
sysDateWeekCol, dateInfo.getStartDate(), sysDateWeekCol, dateInfo.getEndDate());
|
||||
}
|
||||
return String.format("%s >= '%s' and %s <= '%s'",
|
||||
sysDateCol, dateInfo.getStartDate(), sysDateCol, dateInfo.getEndDate());
|
||||
}
|
||||
|
||||
@@ -7,12 +7,6 @@ import com.tencent.supersonic.semantic.api.model.response.QueryResultWithSchemaR
|
||||
import com.tencent.supersonic.semantic.api.query.pojo.Filter;
|
||||
import com.tencent.supersonic.semantic.api.query.request.QueryStructReq;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
@@ -23,6 +17,13 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -34,9 +35,9 @@ public class DimValueAspect {
|
||||
@Autowired
|
||||
private DimensionService dimensionService;
|
||||
|
||||
@Around("execution(* com.tencent.supersonic.semantic.query.rest.QueryController.queryByStruct(..))" +
|
||||
" || execution(* com.tencent.supersonic.semantic.query.service.QueryService.queryByStruct(..))" +
|
||||
" || execution(* com.tencent.supersonic.semantic.query.service.QueryService.queryByStructWithAuth(..))")
|
||||
@Around("execution(* com.tencent.supersonic.semantic.query.rest.QueryController.queryByStruct(..))"
|
||||
+ " || execution(* com.tencent.supersonic.semantic.query.service.QueryService.queryByStruct(..))"
|
||||
+ " || execution(* com.tencent.supersonic.semantic.query.service.QueryService.queryByStructWithAuth(..))")
|
||||
public Object handleDimValue(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
|
||||
if (!dimensionValueMapEnable) {
|
||||
@@ -65,15 +66,15 @@ public class DimValueAspect {
|
||||
}
|
||||
|
||||
private void rewriteDimValue(QueryResultWithSchemaResp queryResultWithColumns,
|
||||
Map<String, Map<String, String>> dimAndTechNameAndBizNamePair) {
|
||||
Map<String, Map<String, String>> dimAndTechNameAndBizNamePair) {
|
||||
if (!selectDimValueMap(queryResultWithColumns.getColumns(), dimAndTechNameAndBizNamePair)) {
|
||||
return;
|
||||
}
|
||||
log.debug("start rewriteDimValue for resultList");
|
||||
for (Map<String, Object> line : queryResultWithColumns.getResultList()) {
|
||||
for (String bizName : line.keySet()) {
|
||||
String techName = line.get(bizName).toString();
|
||||
if (dimAndTechNameAndBizNamePair.containsKey(bizName)) {
|
||||
if (dimAndTechNameAndBizNamePair.containsKey(bizName) && Objects.nonNull(line.get(bizName))) {
|
||||
String techName = line.get(bizName).toString();
|
||||
Map<String, String> techAndBizPair = dimAndTechNameAndBizNamePair.get(bizName);
|
||||
if (!CollectionUtils.isEmpty(techAndBizPair) && techAndBizPair.containsKey(techName)) {
|
||||
String bizValueName = techAndBizPair.get(techName);
|
||||
@@ -86,10 +87,10 @@ public class DimValueAspect {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean selectDimValueMap(List<QueryColumn> columns,
|
||||
Map<String, Map<String, String>> dimAndTechNameAndBizNamePair) {
|
||||
if (CollectionUtils.isEmpty(dimAndTechNameAndBizNamePair) || CollectionUtils.isEmpty(
|
||||
dimAndTechNameAndBizNamePair)) {
|
||||
private boolean selectDimValueMap(List<QueryColumn> columns, Map<String,
|
||||
Map<String, String>> dimAndTechNameAndBizNamePair) {
|
||||
if (CollectionUtils.isEmpty(dimAndTechNameAndBizNamePair)
|
||||
|| CollectionUtils.isEmpty(dimAndTechNameAndBizNamePair)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -118,9 +119,11 @@ public class DimValueAspect {
|
||||
List<String> values = (List) value;
|
||||
List<String> valuesNew = new ArrayList<>();
|
||||
for (String valueSingle : values) {
|
||||
boolean f =
|
||||
aliasPair.containsKey(valueSingle) ? valuesNew.add(aliasPair.get(valueSingle))
|
||||
: valuesNew.add(valueSingle);
|
||||
if (aliasPair.containsKey(valueSingle)) {
|
||||
valuesNew.add(aliasPair.get(valueSingle));
|
||||
} else {
|
||||
valuesNew.add(valueSingle);
|
||||
}
|
||||
}
|
||||
filter.setValue(valuesNew);
|
||||
}
|
||||
@@ -138,9 +141,9 @@ public class DimValueAspect {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateAliasAndTechNamePair(List<DimensionResp> dimensions
|
||||
, Map<String, Map<String, String>> dimAndAliasAndTechNamePair
|
||||
, Map<String, Map<String, String>> dimAndTechNameAndBizNamePair) {
|
||||
private void generateAliasAndTechNamePair(List<DimensionResp> dimensions,
|
||||
Map<String, Map<String, String>> dimAndAliasAndTechNamePair,
|
||||
Map<String, Map<String, String>> dimAndTechNameAndBizNamePair) {
|
||||
if (CollectionUtils.isEmpty(dimensions)) {
|
||||
return;
|
||||
}
|
||||
@@ -184,4 +187,4 @@ public class DimValueAspect {
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tencent.supersonic.semantic.query.utils;
|
||||
|
||||
import com.tencent.supersonic.common.util.jsqlparser.CCJSqlParserUtils;
|
||||
import com.tencent.supersonic.common.util.jsqlparser.SqlParserSelectHelper;
|
||||
import com.tencent.supersonic.semantic.api.model.request.SqlExecuteReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.query.pojo.MetricTable;
|
||||
@@ -38,8 +38,8 @@ public class QueryReqConverter {
|
||||
MetricTable metricTable = new MetricTable();
|
||||
String sql = databaseReq.getSql();
|
||||
|
||||
List<String> allFields = CCJSqlParserUtils.getAllFields(sql);
|
||||
String tableName = CCJSqlParserUtils.getTableName(sql);
|
||||
List<String> allFields = SqlParserSelectHelper.getAllFields(sql);
|
||||
String tableName = SqlParserSelectHelper.getTableName(sql);
|
||||
|
||||
if (CollectionUtils.isEmpty(domainSchemas) || StringUtils.isEmpty(tableName)) {
|
||||
return new QueryStatement();
|
||||
|
||||
@@ -33,17 +33,14 @@ import org.springframework.util.CollectionUtils;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class QueryStructUtils {
|
||||
|
||||
public static Set<String> internalCols = new HashSet<>(
|
||||
Arrays.asList("dayno", "plat_sys_var", "sys_imp_date", "sys_imp_week", "sys_imp_month"));
|
||||
private final DateUtils dateUtils;
|
||||
private final SqlFilterUtils sqlFilterUtils;
|
||||
private final Catalog catalog;
|
||||
|
||||
@Value("${internal.metric.cnt.suffix:internal_cnt}")
|
||||
private String internalMetricNameSuffix;
|
||||
|
||||
public static Set<String> internalCols = new HashSet<>(
|
||||
Arrays.asList("dayno", "plat_sys_var", "sys_imp_date", "sys_imp_week", "sys_imp_month"));
|
||||
|
||||
public QueryStructUtils(
|
||||
DateUtils dateUtils,
|
||||
SqlFilterUtils sqlFilterUtils, Catalog catalog) {
|
||||
|
||||
@@ -40,16 +40,6 @@ public class QueryUtils {
|
||||
@Value("${query.cache.enable:true}")
|
||||
private Boolean cacheEnable;
|
||||
|
||||
@PostConstruct
|
||||
public void fillPattern() {
|
||||
Set<String> aggFunctions = new HashSet<>(Arrays.asList("MAX", "MIN", "SUM", "AVG"));
|
||||
String patternStr = "\\s*(%s\\((.*)\\)) AS";
|
||||
for (String agg : aggFunctions) {
|
||||
patterns.add(Pattern.compile(String.format(patternStr, agg)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final CacheUtils cacheUtils;
|
||||
private final StatUtils statUtils;
|
||||
|
||||
@@ -63,12 +53,20 @@ public class QueryUtils {
|
||||
this.catalog = catalog;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void fillPattern() {
|
||||
Set<String> aggFunctions = new HashSet<>(Arrays.asList("MAX", "MIN", "SUM", "AVG"));
|
||||
String patternStr = "\\s*(%s\\((.*)\\)) AS";
|
||||
for (String agg : aggFunctions) {
|
||||
patterns.add(Pattern.compile(String.format(patternStr, agg)));
|
||||
}
|
||||
}
|
||||
|
||||
public void fillItemNameInfo(QueryResultWithSchemaResp queryResultWithColumns, Long modelId) {
|
||||
List<MetricResp> metricDescList = catalog.getMetrics(modelId);
|
||||
List<DimensionResp> dimensionDescList = catalog.getDimensions(modelId);
|
||||
Map<String,MetricResp> metricRespMap =
|
||||
metricDescList.stream().collect(Collectors.toMap(MetricResp::getBizName, a -> a,(k1, k2)->k1));
|
||||
Map<String, MetricResp> metricRespMap =
|
||||
metricDescList.stream().collect(Collectors.toMap(MetricResp::getBizName, a -> a, (k1, k2) -> k1));
|
||||
Map<String, String> namePair = new HashMap<>();
|
||||
Map<String, String> nameTypePair = new HashMap<>();
|
||||
addSysTimeDimension(namePair, nameTypePair);
|
||||
@@ -95,24 +93,13 @@ public class QueryUtils {
|
||||
if (!nameTypePair.containsKey(nameEn) && isNumberType(column.getType())) {
|
||||
column.setShowType("NUMBER");
|
||||
}
|
||||
if(metricRespMap.containsKey(nameEn)){
|
||||
if (metricRespMap.containsKey(nameEn)) {
|
||||
column.setDataFormatType(metricRespMap.get(nameEn).getDataFormatType());
|
||||
column.setDataFormat(metricRespMap.get(nameEn).getDataFormat());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isNumberType(String type) {
|
||||
if (StringUtils.isBlank(type)) {
|
||||
return false;
|
||||
}
|
||||
if (type.equalsIgnoreCase("int") || type.equalsIgnoreCase("bigint")
|
||||
|| type.equalsIgnoreCase("float") || type.equalsIgnoreCase("double")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void fillItemNameInfo(QueryResultWithSchemaResp queryResultWithColumns,
|
||||
QueryMultiStructReq queryMultiStructCmd) {
|
||||
List<Aggregator> aggregators = queryMultiStructCmd.getQueryStructReqs().stream()
|
||||
@@ -152,6 +139,17 @@ public class QueryUtils {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isNumberType(String type) {
|
||||
if (StringUtils.isBlank(type)) {
|
||||
return false;
|
||||
}
|
||||
if (type.equalsIgnoreCase("int") || type.equalsIgnoreCase("bigint")
|
||||
|| type.equalsIgnoreCase("float") || type.equalsIgnoreCase("double")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Map<String, String> getMetricNameFromAgg(List<Aggregator> aggregators) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (CollectionUtils.isEmpty(aggregators)) {
|
||||
|
||||
Reference in New Issue
Block a user