mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
(improvement)(semantic)Simplify datasource related code and support setting filter SQL for dict generation (#397)
* (improvement) (semantic) Simplify datasource related code and support setting filtering SQL for dict generation * (improvement) (semantic) Remove the semicolon at the end of the datasource SQL * (improvement) (common) Update sys parameter init --------- Co-authored-by: jolunoluo
This commit is contained in:
@@ -10,6 +10,7 @@ import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
||||
@@ -32,6 +33,8 @@ public class DatasourceReq extends SchemaItem {
|
||||
|
||||
private List<Measure> measures;
|
||||
|
||||
private String filterSql;
|
||||
|
||||
|
||||
|
||||
public List<Dim> getTimeDimension() {
|
||||
@@ -43,4 +46,11 @@ public class DatasourceReq extends SchemaItem {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public String getSqlQuery() {
|
||||
if (StringUtils.isNotBlank(sqlQuery) && sqlQuery.endsWith(";")) {
|
||||
sqlQuery = sqlQuery.substring(0, sqlQuery.length() - 1);
|
||||
}
|
||||
return sqlQuery;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.tencent.supersonic.semantic.api.model.request;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Data
|
||||
public class SqlExecuteReq {
|
||||
@@ -16,6 +17,9 @@ public class SqlExecuteReq {
|
||||
private String sql;
|
||||
|
||||
public String getSql() {
|
||||
if (StringUtils.isNotBlank(sql) && sql.endsWith(";")) {
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
}
|
||||
return String.format(LIMIT_WRAPPER, sql);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@ public class DatasourceResp extends SchemaItem {
|
||||
|
||||
private String depends;
|
||||
|
||||
|
||||
private String filterSql;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.tencent.supersonic.semantic.materialization.application;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
@@ -309,7 +310,7 @@ public class MaterializationConfServiceImpl implements MaterializationConfServic
|
||||
modelFilter.setModelIds(Arrays.asList(materializationResp.getModelId()));
|
||||
List<ModelSchemaResp> modelSchemaRespList = modelService.fetchModelSchema(modelFilter);
|
||||
List<MeasureResp> measureRespList = datasourceService.getMeasureListOfModel(
|
||||
materializationResp.getModelId());
|
||||
Lists.newArrayList(materializationResp.getModelId()));
|
||||
Map<String, DimSchemaResp> dimSchemaRespMap = new HashMap<>();
|
||||
Map<String, MetricSchemaResp> metricSchemaRespHashMap = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(modelSchemaRespList)) {
|
||||
@@ -379,7 +380,7 @@ public class MaterializationConfServiceImpl implements MaterializationConfServic
|
||||
ModelSchemaFilterReq modelSchemaFilterReq = new ModelSchemaFilterReq();
|
||||
modelSchemaFilterReq.setModelIds(Arrays.asList(modelId));
|
||||
List<ModelSchemaResp> modelSchemaRespList = modelService.fetchModelSchema(modelSchemaFilterReq);
|
||||
List<MeasureResp> measureRespList = datasourceService.getMeasureListOfModel(modelId);
|
||||
List<MeasureResp> measureRespList = datasourceService.getMeasureListOfModel(Lists.newArrayList(modelId));
|
||||
Set<Long> dimensionIds = new HashSet<>();
|
||||
Set<Long> metricIds = new HashSet<>();
|
||||
materializationElementRespList.stream().forEach(e -> {
|
||||
|
||||
@@ -13,13 +13,11 @@ import com.tencent.supersonic.semantic.api.model.pojo.Measure;
|
||||
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.api.model.request.DatasourceRelaReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatasourceReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DateInfoReq;
|
||||
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.response.DatabaseResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceRelaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.common.pojo.ItemDateResp;
|
||||
@@ -30,12 +28,10 @@ import com.tencent.supersonic.semantic.model.domain.DatasourceService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DateInfoDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.manager.DatasourceYamlManager;
|
||||
import com.tencent.supersonic.semantic.model.domain.manager.DimensionYamlManager;
|
||||
import com.tencent.supersonic.semantic.model.domain.manager.MetricYamlManager;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Datasource;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.MetaFilter;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.DatasourceRepository;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.DateInfoRepository;
|
||||
@@ -89,50 +85,26 @@ public class DatasourceServiceImpl implements DatasourceService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Datasource createDatasource(DatasourceReq datasourceReq, User user) throws Exception {
|
||||
public DatasourceResp createDatasource(DatasourceReq datasourceReq, User user) throws Exception {
|
||||
checkName(datasourceReq);
|
||||
checkExist(datasourceReq);
|
||||
Datasource datasource = DatasourceConverter.convert(datasourceReq);
|
||||
saveDatasource(datasource, user);
|
||||
batchCreateDimension(datasource, user);
|
||||
batchCreateMetric(datasource, user);
|
||||
return datasource;
|
||||
DatasourceDO datasourceDO = DatasourceConverter.convert(datasourceReq, user);
|
||||
datasourceRepository.createDatasource(datasourceDO);
|
||||
batchCreateDimension(datasourceDO, user);
|
||||
batchCreateMetric(datasourceDO, user);
|
||||
return DatasourceConverter.convert(datasourceDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Datasource updateDatasource(DatasourceReq datasourceReq, User user) throws Exception {
|
||||
public DatasourceResp updateDatasource(DatasourceReq datasourceReq, User user) throws Exception {
|
||||
checkName(datasourceReq);
|
||||
Datasource datasource = DatasourceConverter.convert(datasourceReq);
|
||||
updateDatasource(datasource, user);
|
||||
batchCreateDimension(datasource, user);
|
||||
batchCreateMetric(datasource, user);
|
||||
return datasource;
|
||||
}
|
||||
|
||||
private DatasourceDO updateDatasource(Datasource datasource, User user) {
|
||||
DatasourceDO datasourceDO = datasourceRepository.getDatasourceById(datasource.getId());
|
||||
datasource.updatedBy(user.getName());
|
||||
datasourceRepository.updateDatasource(DatasourceConverter.convert(datasourceDO, datasource));
|
||||
return datasourceDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MeasureResp> getMeasureListOfModel(Long modelId) {
|
||||
List<DatasourceResp> datasourceResps = getDatasourceList(modelId);
|
||||
List<MeasureResp> measureResps = Lists.newArrayList();
|
||||
if (!CollectionUtils.isEmpty(datasourceResps)) {
|
||||
for (DatasourceResp datasourceDesc : datasourceResps) {
|
||||
DatasourceDetail datasourceDetail = datasourceDesc.getDatasourceDetail();
|
||||
List<Measure> measures = datasourceDetail.getMeasures();
|
||||
if (!CollectionUtils.isEmpty(measures)) {
|
||||
measureResps.addAll(
|
||||
measures.stream().map(measure -> DatasourceConverter.convert(measure, datasourceDesc))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return measureResps;
|
||||
DatasourceDO datasourceDO = datasourceRepository.getDatasourceById(datasourceReq.getId());
|
||||
DatasourceConverter.convert(datasourceDO, datasourceReq, user);
|
||||
datasourceRepository.updateDatasource(datasourceDO);
|
||||
batchCreateDimension(datasourceDO, user);
|
||||
batchCreateMetric(datasourceDO, user);
|
||||
return DatasourceConverter.convert(datasourceDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,13 +129,13 @@ public class DatasourceServiceImpl implements DatasourceService {
|
||||
return measureResps;
|
||||
}
|
||||
|
||||
private void batchCreateDimension(Datasource datasource, User user) throws Exception {
|
||||
List<DimensionReq> dimensionReqs = DatasourceConverter.convertDimensionList(datasource);
|
||||
private void batchCreateDimension(DatasourceDO datasourceDO, User user) throws Exception {
|
||||
List<DimensionReq> dimensionReqs = DatasourceConverter.convertDimensionList(datasourceDO);
|
||||
dimensionService.createDimensionBatch(dimensionReqs, user);
|
||||
}
|
||||
|
||||
private void batchCreateMetric(Datasource datasource, User user) throws Exception {
|
||||
List<MetricReq> exprMetricReqs = DatasourceConverter.convertMetricList(datasource);
|
||||
private void batchCreateMetric(DatasourceDO datasourceDO, User user) throws Exception {
|
||||
List<MetricReq> exprMetricReqs = DatasourceConverter.convertMetricList(datasourceDO);
|
||||
metricService.createMetricBatch(exprMetricReqs, user);
|
||||
}
|
||||
|
||||
@@ -180,13 +152,6 @@ public class DatasourceServiceImpl implements DatasourceService {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
//保存并获取自增ID
|
||||
private void saveDatasource(Datasource datasource, User user) {
|
||||
DatasourceDO datasourceDO = DatasourceConverter.convert(datasource, user);
|
||||
datasourceRepository.createDatasource(datasourceDO);
|
||||
datasource.setId(datasourceDO.getId());
|
||||
}
|
||||
|
||||
private void checkName(DatasourceReq datasourceReq) {
|
||||
if (NameCheckUtils.containsSpecialCharacters(datasourceReq.getName())) {
|
||||
String message = String.format("数据源名称[%s]包含特殊字符, 请修改", datasourceReq.getName());
|
||||
@@ -304,50 +269,6 @@ public class DatasourceServiceImpl implements DatasourceService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<DatasourceRelaResp> convertDatasourceRelaList(List<DatasourceRelaDO> datasourceRelaDOS) {
|
||||
List<DatasourceRelaResp> datasourceRelaResps = Lists.newArrayList();
|
||||
if (CollectionUtils.isEmpty(datasourceRelaDOS)) {
|
||||
return datasourceRelaResps;
|
||||
}
|
||||
return datasourceRelaDOS.stream().map(DatasourceConverter::convert).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public DatasourceRelaResp createOrUpdateDatasourceRela(DatasourceRelaReq datasourceRelaReq, User user) {
|
||||
if (datasourceRelaReq.getId() == null) {
|
||||
DatasourceRelaDO datasourceRelaDO = new DatasourceRelaDO();
|
||||
BeanUtils.copyProperties(datasourceRelaReq, datasourceRelaDO);
|
||||
datasourceRelaDO.setCreatedAt(new Date());
|
||||
datasourceRelaDO.setCreatedBy(user.getName());
|
||||
datasourceRelaDO.setUpdatedAt(new Date());
|
||||
datasourceRelaDO.setUpdatedBy(user.getName());
|
||||
datasourceRepository.createDatasourceRela(datasourceRelaDO);
|
||||
return DatasourceConverter.convert(datasourceRelaDO);
|
||||
}
|
||||
Long id = datasourceRelaReq.getId();
|
||||
DatasourceRelaDO datasourceRelaDO = datasourceRepository.getDatasourceRelaById(id);
|
||||
BeanUtils.copyProperties(datasourceRelaDO, datasourceRelaReq);
|
||||
datasourceRelaDO.setUpdatedAt(new Date());
|
||||
datasourceRelaDO.setUpdatedBy(user.getName());
|
||||
datasourceRepository.updateDatasourceRela(datasourceRelaDO);
|
||||
return DatasourceConverter.convert(datasourceRelaDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DatasourceRelaResp> getDatasourceRelaList(Long modelId) {
|
||||
return convertDatasourceRelaList(datasourceRepository.getDatasourceRelaList(modelId));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteDatasourceRela(Long id) {
|
||||
datasourceRepository.deleteDatasourceRela(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemDateResp getItemDate(ItemDateFilter dimension, ItemDateFilter metric) {
|
||||
List<DateInfoReq> itemDates = new ArrayList<>();
|
||||
|
||||
@@ -349,7 +349,7 @@ public class ModelServiceImpl implements ModelService {
|
||||
private List<MetricSchemaResp> generateMetricSchema(Long modelId, ModelResp modelResp) {
|
||||
List<MetricSchemaResp> metricSchemaDescList = new ArrayList<>();
|
||||
List<MetricResp> metricResps = metricService.getMetrics(new MetaFilter(Lists.newArrayList(modelId)));
|
||||
List<MeasureResp> measureResps = datasourceService.getMeasureListOfModel(modelId);
|
||||
List<MeasureResp> measureResps = datasourceService.getMeasureListOfModel(Lists.newArrayList(modelId));
|
||||
metricResps.stream().forEach(metricResp ->
|
||||
metricSchemaDescList.add(convert(metricResp, metricResps, measureResps, modelResp)));
|
||||
return metricSchemaDescList;
|
||||
|
||||
@@ -6,22 +6,19 @@ import com.tencent.supersonic.semantic.api.model.pojo.ItemDateFilter;
|
||||
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.api.model.request.DatasourceRelaReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatasourceReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceRelaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.common.pojo.ItemDateResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MeasureResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Datasource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface DatasourceService {
|
||||
|
||||
Datasource createDatasource(DatasourceReq datasourceReq, User user) throws Exception;
|
||||
DatasourceResp createDatasource(DatasourceReq datasourceReq, User user) throws Exception;
|
||||
|
||||
Datasource updateDatasource(DatasourceReq datasourceReq, User user) throws Exception;
|
||||
DatasourceResp updateDatasource(DatasourceReq datasourceReq, User user) throws Exception;
|
||||
|
||||
List<DatasourceResp> getDatasourceListNoMeasurePrefix(Long modelId);
|
||||
|
||||
@@ -35,16 +32,8 @@ public interface DatasourceService {
|
||||
|
||||
void deleteDatasource(Long id, User user);
|
||||
|
||||
DatasourceRelaResp createOrUpdateDatasourceRela(DatasourceRelaReq datasourceRelaReq, User user);
|
||||
|
||||
List<DatasourceRelaResp> getDatasourceRelaList(Long modelId);
|
||||
|
||||
void deleteDatasourceRela(Long id);
|
||||
|
||||
ItemDateResp getItemDate(ItemDateFilter dimension, ItemDateFilter metric);
|
||||
|
||||
List<MeasureResp> getMeasureListOfModel(Long modelId);
|
||||
|
||||
List<MeasureResp> getMeasureListOfModel(List<Long> modelIds);
|
||||
|
||||
void getModelYamlTplByModelIds(Set<Long> modelIds, Map<String, List<DimensionYamlTpl>> dimensionYamlMap,
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.tencent.supersonic.semantic.model.domain.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("s2_datasource")
|
||||
public class DatasourceDO {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主题域ID
|
||||
* 模型ID
|
||||
*/
|
||||
private Long modelId;
|
||||
|
||||
@@ -68,211 +73,6 @@ public class DatasourceDO {
|
||||
*/
|
||||
private String depends;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
private String filterSql;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库实例ID
|
||||
* @return database_id 数据库实例ID
|
||||
*/
|
||||
public Long getDatabaseId() {
|
||||
return databaseId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库实例ID
|
||||
* @param databaseId 数据库实例ID
|
||||
*/
|
||||
public void setDatabaseId(Long databaseId) {
|
||||
this.databaseId = databaseId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return status
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param status
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* @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() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
* @param updatedAt 更新时间
|
||||
*/
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
* @return updated_by 更新人
|
||||
*/
|
||||
public String getUpdatedBy() {
|
||||
return updatedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
* @param updatedBy 更新人
|
||||
*/
|
||||
public void setUpdatedBy(String updatedBy) {
|
||||
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据源配置
|
||||
* @return datasource_detail 数据源配置
|
||||
*/
|
||||
public String getDatasourceDetail() {
|
||||
return datasourceDetail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据源配置
|
||||
* @param datasourceDetail 数据源配置
|
||||
*/
|
||||
public void setDatasourceDetail(String datasourceDetail) {
|
||||
this.datasourceDetail = datasourceDetail == null ? null : datasourceDetail.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上游依赖标识
|
||||
* @return depends 上游依赖标识
|
||||
*/
|
||||
public String getDepends() {
|
||||
return depends;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上游依赖标识
|
||||
* @param depends 上游依赖标识
|
||||
*/
|
||||
public void setDepends(String depends) {
|
||||
this.depends = depends == null ? null : depends.trim();
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package com.tencent.supersonic.semantic.model.domain.dataobject;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class DatasourceRelaDO {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long modelId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long datasourceFrom;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long datasourceTo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String joinKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* @return id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return model_id
|
||||
*/
|
||||
public Long getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modelId
|
||||
*/
|
||||
public void setModelId(Long modelId) {
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return datasource_from
|
||||
*/
|
||||
public Long getDatasourceFrom() {
|
||||
return datasourceFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datasourceFrom
|
||||
*/
|
||||
public void setDatasourceFrom(Long datasourceFrom) {
|
||||
this.datasourceFrom = datasourceFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return datasource_to
|
||||
*/
|
||||
public Long getDatasourceTo() {
|
||||
return datasourceTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datasourceTo
|
||||
*/
|
||||
public void setDatasourceTo(Long datasourceTo) {
|
||||
this.datasourceTo = datasourceTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return join_key
|
||||
*/
|
||||
public String getJoinKey() {
|
||||
return joinKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param joinKey
|
||||
*/
|
||||
public void setJoinKey(String joinKey) {
|
||||
this.joinKey = joinKey == null ? null : joinKey.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() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param updatedAt
|
||||
*/
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return updated_by
|
||||
*/
|
||||
public String getUpdatedBy() {
|
||||
return updatedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param updatedBy
|
||||
*/
|
||||
public void setUpdatedBy(String updatedBy) {
|
||||
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
|
||||
}
|
||||
}
|
||||
@@ -1,860 +0,0 @@
|
||||
package com.tencent.supersonic.semantic.model.domain.dataobject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class DatasourceRelaDOExample {
|
||||
/**
|
||||
* s2_datasource_rela
|
||||
*/
|
||||
protected String orderByClause;
|
||||
|
||||
/**
|
||||
* s2_datasource_rela
|
||||
*/
|
||||
protected boolean distinct;
|
||||
|
||||
/**
|
||||
* s2_datasource_rela
|
||||
*/
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
/**
|
||||
* s2_datasource_rela
|
||||
*/
|
||||
protected Integer limitStart;
|
||||
|
||||
/**
|
||||
* s2_datasource_rela
|
||||
*/
|
||||
protected Integer limitEnd;
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public DatasourceRelaDOExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setLimitStart(Integer limitStart) {
|
||||
this.limitStart = limitStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getLimitStart() {
|
||||
return limitStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setLimitEnd(Integer limitEnd) {
|
||||
this.limitEnd = limitEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Integer getLimitEnd() {
|
||||
return limitEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* s2_datasource_rela null
|
||||
*/
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(Long value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(Long value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(Long value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(Long value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Long value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<Long> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<Long> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(Long value1, Long value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(Long value1, Long value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdIsNull() {
|
||||
addCriterion("model_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdIsNotNull() {
|
||||
addCriterion("model_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdEqualTo(Long value) {
|
||||
addCriterion("model_id =", value, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdNotEqualTo(Long value) {
|
||||
addCriterion("model_id <>", value, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdGreaterThan(Long value) {
|
||||
addCriterion("model_id >", value, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("model_id >=", value, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdLessThan(Long value) {
|
||||
addCriterion("model_id <", value, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdLessThanOrEqualTo(Long value) {
|
||||
addCriterion("model_id <=", value, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdIn(List<Long> values) {
|
||||
addCriterion("model_id in", values, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdNotIn(List<Long> values) {
|
||||
addCriterion("model_id not in", values, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdBetween(Long value1, Long value2) {
|
||||
addCriterion("model_id between", value1, value2, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andModelIdNotBetween(Long value1, Long value2) {
|
||||
addCriterion("model_id not between", value1, value2, "modelId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromIsNull() {
|
||||
addCriterion("datasource_from is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromIsNotNull() {
|
||||
addCriterion("datasource_from is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromEqualTo(Long value) {
|
||||
addCriterion("datasource_from =", value, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromNotEqualTo(Long value) {
|
||||
addCriterion("datasource_from <>", value, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromGreaterThan(Long value) {
|
||||
addCriterion("datasource_from >", value, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("datasource_from >=", value, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromLessThan(Long value) {
|
||||
addCriterion("datasource_from <", value, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromLessThanOrEqualTo(Long value) {
|
||||
addCriterion("datasource_from <=", value, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromIn(List<Long> values) {
|
||||
addCriterion("datasource_from in", values, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromNotIn(List<Long> values) {
|
||||
addCriterion("datasource_from not in", values, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromBetween(Long value1, Long value2) {
|
||||
addCriterion("datasource_from between", value1, value2, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceFromNotBetween(Long value1, Long value2) {
|
||||
addCriterion("datasource_from not between", value1, value2, "datasourceFrom");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToIsNull() {
|
||||
addCriterion("datasource_to is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToIsNotNull() {
|
||||
addCriterion("datasource_to is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToEqualTo(Long value) {
|
||||
addCriterion("datasource_to =", value, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToNotEqualTo(Long value) {
|
||||
addCriterion("datasource_to <>", value, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToGreaterThan(Long value) {
|
||||
addCriterion("datasource_to >", value, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("datasource_to >=", value, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToLessThan(Long value) {
|
||||
addCriterion("datasource_to <", value, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToLessThanOrEqualTo(Long value) {
|
||||
addCriterion("datasource_to <=", value, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToIn(List<Long> values) {
|
||||
addCriterion("datasource_to in", values, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToNotIn(List<Long> values) {
|
||||
addCriterion("datasource_to not in", values, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToBetween(Long value1, Long value2) {
|
||||
addCriterion("datasource_to between", value1, value2, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andDatasourceToNotBetween(Long value1, Long value2) {
|
||||
addCriterion("datasource_to not between", value1, value2, "datasourceTo");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyIsNull() {
|
||||
addCriterion("join_key is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyIsNotNull() {
|
||||
addCriterion("join_key is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyEqualTo(String value) {
|
||||
addCriterion("join_key =", value, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyNotEqualTo(String value) {
|
||||
addCriterion("join_key <>", value, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyGreaterThan(String value) {
|
||||
addCriterion("join_key >", value, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("join_key >=", value, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyLessThan(String value) {
|
||||
addCriterion("join_key <", value, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyLessThanOrEqualTo(String value) {
|
||||
addCriterion("join_key <=", value, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyLike(String value) {
|
||||
addCriterion("join_key like", value, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyNotLike(String value) {
|
||||
addCriterion("join_key not like", value, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyIn(List<String> values) {
|
||||
addCriterion("join_key in", values, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyNotIn(List<String> values) {
|
||||
addCriterion("join_key not in", values, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyBetween(String value1, String value2) {
|
||||
addCriterion("join_key between", value1, value2, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andJoinKeyNotBetween(String value1, String value2) {
|
||||
addCriterion("join_key not between", value1, value2, "joinKey");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtIsNull() {
|
||||
addCriterion("created_at is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtIsNotNull() {
|
||||
addCriterion("created_at is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtEqualTo(Date value) {
|
||||
addCriterion("created_at =", value, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtNotEqualTo(Date value) {
|
||||
addCriterion("created_at <>", value, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtGreaterThan(Date value) {
|
||||
addCriterion("created_at >", value, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) {
|
||||
addCriterion("created_at >=", value, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtLessThan(Date value) {
|
||||
addCriterion("created_at <", value, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtLessThanOrEqualTo(Date value) {
|
||||
addCriterion("created_at <=", value, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtIn(List<Date> values) {
|
||||
addCriterion("created_at in", values, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtNotIn(List<Date> values) {
|
||||
addCriterion("created_at not in", values, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtBetween(Date value1, Date value2) {
|
||||
addCriterion("created_at between", value1, value2, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedAtNotBetween(Date value1, Date value2) {
|
||||
addCriterion("created_at not between", value1, value2, "createdAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByIsNull() {
|
||||
addCriterion("created_by is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByIsNotNull() {
|
||||
addCriterion("created_by is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByEqualTo(String value) {
|
||||
addCriterion("created_by =", value, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByNotEqualTo(String value) {
|
||||
addCriterion("created_by <>", value, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByGreaterThan(String value) {
|
||||
addCriterion("created_by >", value, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("created_by >=", value, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByLessThan(String value) {
|
||||
addCriterion("created_by <", value, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByLessThanOrEqualTo(String value) {
|
||||
addCriterion("created_by <=", value, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByLike(String value) {
|
||||
addCriterion("created_by like", value, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByNotLike(String value) {
|
||||
addCriterion("created_by not like", value, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByIn(List<String> values) {
|
||||
addCriterion("created_by in", values, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByNotIn(List<String> values) {
|
||||
addCriterion("created_by not in", values, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByBetween(String value1, String value2) {
|
||||
addCriterion("created_by between", value1, value2, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatedByNotBetween(String value1, String value2) {
|
||||
addCriterion("created_by not between", value1, value2, "createdBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtIsNull() {
|
||||
addCriterion("updated_at is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtIsNotNull() {
|
||||
addCriterion("updated_at is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtEqualTo(Date value) {
|
||||
addCriterion("updated_at =", value, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtNotEqualTo(Date value) {
|
||||
addCriterion("updated_at <>", value, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtGreaterThan(Date value) {
|
||||
addCriterion("updated_at >", value, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) {
|
||||
addCriterion("updated_at >=", value, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtLessThan(Date value) {
|
||||
addCriterion("updated_at <", value, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtLessThanOrEqualTo(Date value) {
|
||||
addCriterion("updated_at <=", value, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtIn(List<Date> values) {
|
||||
addCriterion("updated_at in", values, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtNotIn(List<Date> values) {
|
||||
addCriterion("updated_at not in", values, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtBetween(Date value1, Date value2) {
|
||||
addCriterion("updated_at between", value1, value2, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedAtNotBetween(Date value1, Date value2) {
|
||||
addCriterion("updated_at not between", value1, value2, "updatedAt");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByIsNull() {
|
||||
addCriterion("updated_by is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByIsNotNull() {
|
||||
addCriterion("updated_by is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByEqualTo(String value) {
|
||||
addCriterion("updated_by =", value, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByNotEqualTo(String value) {
|
||||
addCriterion("updated_by <>", value, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByGreaterThan(String value) {
|
||||
addCriterion("updated_by >", value, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("updated_by >=", value, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByLessThan(String value) {
|
||||
addCriterion("updated_by <", value, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByLessThanOrEqualTo(String value) {
|
||||
addCriterion("updated_by <=", value, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByLike(String value) {
|
||||
addCriterion("updated_by like", value, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByNotLike(String value) {
|
||||
addCriterion("updated_by not like", value, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByIn(List<String> values) {
|
||||
addCriterion("updated_by in", values, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByNotIn(List<String> values) {
|
||||
addCriterion("updated_by not in", values, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByBetween(String value1, String value2) {
|
||||
addCriterion("updated_by between", value1, value2, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdatedByNotBetween(String value1, String value2) {
|
||||
addCriterion("updated_by not between", value1, value2, "updatedBy");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* s2_datasource_rela
|
||||
*/
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* s2_datasource_rela null
|
||||
*/
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.tencent.supersonic.semantic.model.domain.repository;
|
||||
|
||||
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DatasourceRepository {
|
||||
@@ -19,13 +19,4 @@ public interface DatasourceRepository {
|
||||
|
||||
DatasourceDO getDatasourceById(Long id);
|
||||
|
||||
void createDatasourceRela(DatasourceRelaDO datasourceRelaDO);
|
||||
|
||||
void updateDatasourceRela(DatasourceRelaDO datasourceRelaDO);
|
||||
|
||||
DatasourceRelaDO getDatasourceRelaById(Long id);
|
||||
|
||||
List<DatasourceRelaDO> getDatasourceRelaList(Long modelId);
|
||||
|
||||
void deleteDatasourceRela(Long id);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,9 @@ import com.tencent.supersonic.semantic.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatasourceReq;
|
||||
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.response.DatasourceRelaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MeasureResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Datasource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -32,61 +30,32 @@ import org.springframework.util.CollectionUtils;
|
||||
public class DatasourceConverter {
|
||||
|
||||
|
||||
public static Datasource convert(DatasourceReq datasourceReq) {
|
||||
Datasource datasource = new Datasource();
|
||||
DatasourceDetail datasourceDetail = new DatasourceDetail();
|
||||
public static DatasourceDO convert(DatasourceReq datasourceReq, User user) {
|
||||
DatasourceDO datasource = new DatasourceDO();
|
||||
DatasourceDetail datasourceDetail = getDatasourceDetail(datasourceReq);
|
||||
datasourceReq.createdBy(user.getName());
|
||||
BeanMapper.mapper(datasourceReq, datasource);
|
||||
BeanMapper.mapper(datasourceReq, datasourceDetail);
|
||||
List<Measure> measures = datasourceDetail.getMeasures();
|
||||
for (Measure measure : measures) {
|
||||
if (StringUtils.isBlank(measure.getExpr())) {
|
||||
measure.setExpr(measure.getBizName());
|
||||
}
|
||||
if (StringUtils.isBlank(measure.getConstraint())) {
|
||||
measure.setConstraint(null);
|
||||
}
|
||||
if (StringUtils.isBlank(measure.getAlias())) {
|
||||
measure.setAlias(null);
|
||||
}
|
||||
measure.setBizName(String.format("%s_%s", datasource.getBizName(), measure.getBizName()));
|
||||
}
|
||||
datasource.setStatus(StatusEnum.ONLINE.getCode());
|
||||
datasource.setDatasourceDetail(datasourceDetail);
|
||||
datasource.setDatasourceDetail(JSONObject.toJSONString(datasourceDetail));
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public static DatasourceRelaResp convert(DatasourceRelaDO datasourceRelaDO) {
|
||||
DatasourceRelaResp datasourceRelaResp = new DatasourceRelaResp();
|
||||
BeanUtils.copyProperties(datasourceRelaDO, datasourceRelaResp);
|
||||
return datasourceRelaResp;
|
||||
}
|
||||
|
||||
|
||||
public static DatasourceDO convert(DatasourceDO datasourceDO, Datasource datasource) {
|
||||
BeanMapper.mapper(datasource, datasourceDO);
|
||||
datasourceDO.setDatasourceDetail(JSONObject.toJSONString((datasource.getDatasourceDetail())));
|
||||
return datasourceDO;
|
||||
}
|
||||
|
||||
|
||||
public static DatasourceDO convert(Datasource datasource, User user) {
|
||||
DatasourceDO datasourceDO = new DatasourceDO();
|
||||
BeanMapper.mapper(datasource, datasourceDO);
|
||||
datasourceDO.setDatasourceDetail(JSONObject.toJSONString(datasource.getDatasourceDetail()));
|
||||
public static DatasourceDO convert(DatasourceDO datasourceDO, DatasourceReq datasourceReq, User user) {
|
||||
DatasourceDetail datasourceDetail = getDatasourceDetail(datasourceReq);
|
||||
BeanMapper.mapper(datasourceReq, datasourceDO);
|
||||
datasourceDO.setDatasourceDetail(JSONObject.toJSONString((datasourceDetail)));
|
||||
datasourceDO.setUpdatedBy(user.getName());
|
||||
datasourceDO.setUpdatedAt(new Date());
|
||||
datasourceDO.setCreatedBy(user.getName());
|
||||
datasourceDO.setCreatedAt(new Date());
|
||||
return datasourceDO;
|
||||
}
|
||||
|
||||
|
||||
public static DatasourceResp convert(DatasourceDO datasourceDO) {
|
||||
DatasourceResp datasourceDesc = new DatasourceResp();
|
||||
BeanUtils.copyProperties(datasourceDO, datasourceDesc);
|
||||
datasourceDesc.setDatasourceDetail(
|
||||
DatasourceResp datasourceResp = new DatasourceResp();
|
||||
BeanUtils.copyProperties(datasourceDO, datasourceResp);
|
||||
datasourceResp.setDatasourceDetail(
|
||||
JSONObject.parseObject(datasourceDO.getDatasourceDetail(), DatasourceDetail.class));
|
||||
return datasourceDesc;
|
||||
return datasourceResp;
|
||||
}
|
||||
|
||||
public static MeasureResp convert(Measure measure, DatasourceResp datasourceResp) {
|
||||
@@ -99,27 +68,27 @@ public class DatasourceConverter {
|
||||
return measureResp;
|
||||
}
|
||||
|
||||
public static DimensionReq convert(Dim dim, Datasource datasource) {
|
||||
public static DimensionReq convert(Dim dim, DatasourceDO datasourceDO) {
|
||||
DimensionReq dimensionReq = new DimensionReq();
|
||||
dimensionReq.setName(dim.getName());
|
||||
dimensionReq.setBizName(dim.getBizName());
|
||||
dimensionReq.setDescription(dim.getName());
|
||||
dimensionReq.setSemanticType("CATEGORY");
|
||||
dimensionReq.setDatasourceId(datasource.getId());
|
||||
dimensionReq.setModelId(datasource.getModelId());
|
||||
dimensionReq.setDatasourceId(datasourceDO.getId());
|
||||
dimensionReq.setModelId(datasourceDO.getModelId());
|
||||
dimensionReq.setExpr(dim.getBizName());
|
||||
dimensionReq.setType("categorical");
|
||||
dimensionReq.setDescription(Objects.isNull(dim.getDescription()) ? "" : dim.getDescription());
|
||||
return dimensionReq;
|
||||
}
|
||||
|
||||
public static MetricReq convert(Measure measure, Datasource datasource) {
|
||||
measure.setDatasourceId(datasource.getId());
|
||||
public static MetricReq convert(Measure measure, DatasourceDO datasourceDO) {
|
||||
measure.setDatasourceId(datasourceDO.getId());
|
||||
MetricReq metricReq = new MetricReq();
|
||||
metricReq.setName(measure.getName());
|
||||
metricReq.setBizName(measure.getBizName().replaceFirst(datasource.getBizName() + "_", ""));
|
||||
metricReq.setBizName(measure.getBizName().replaceFirst(datasourceDO.getBizName() + "_", ""));
|
||||
metricReq.setDescription(measure.getName());
|
||||
metricReq.setModelId(datasource.getModelId());
|
||||
metricReq.setModelId(datasourceDO.getModelId());
|
||||
metricReq.setMetricType(MetricTypeEnum.ATOMIC);
|
||||
MetricTypeParams exprTypeParams = new MetricTypeParams();
|
||||
exprTypeParams.setExpr(measure.getBizName());
|
||||
@@ -128,14 +97,14 @@ public class DatasourceConverter {
|
||||
return metricReq;
|
||||
}
|
||||
|
||||
public static DimensionReq convert(Identify identify, Datasource datasource) {
|
||||
public static DimensionReq convert(Identify identify, DatasourceDO datasourceDO) {
|
||||
DimensionReq dimensionReq = new DimensionReq();
|
||||
dimensionReq.setName(identify.getName());
|
||||
dimensionReq.setBizName(identify.getBizName());
|
||||
dimensionReq.setDescription(identify.getName());
|
||||
dimensionReq.setSemanticType("CATEGORY");
|
||||
dimensionReq.setDatasourceId(datasource.getId());
|
||||
dimensionReq.setModelId(datasource.getModelId());
|
||||
dimensionReq.setDatasourceId(datasourceDO.getId());
|
||||
dimensionReq.setModelId(datasourceDO.getModelId());
|
||||
dimensionReq.setExpr(identify.getBizName());
|
||||
dimensionReq.setType(identify.getType());
|
||||
return dimensionReq;
|
||||
@@ -161,43 +130,47 @@ public class DatasourceConverter {
|
||||
&& StringUtils.isNotBlank(measure.getName());
|
||||
}
|
||||
|
||||
public static List<Dim> getDimToCreateDimension(Datasource datasource) {
|
||||
return datasource.getDatasourceDetail().getDimensions().stream()
|
||||
public static List<Dim> getDimToCreateDimension(DatasourceDetail datasourceDetail) {
|
||||
return datasourceDetail.getDimensions().stream()
|
||||
.filter(DatasourceConverter::isCreateDimension)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<Measure> getMeasureToCreateMetric(Datasource datasource) {
|
||||
return datasource.getDatasourceDetail().getMeasures().stream()
|
||||
public static List<Measure> getMeasureToCreateMetric(DatasourceDetail datasourceDetail) {
|
||||
return datasourceDetail.getMeasures().stream()
|
||||
.filter(DatasourceConverter::isCreateMetric)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<DimensionReq> convertDimensionList(Datasource datasource) {
|
||||
public static List<DimensionReq> convertDimensionList(DatasourceDO datasourceDO) {
|
||||
List<DimensionReq> dimensionReqs = Lists.newArrayList();
|
||||
List<Dim> dims = getDimToCreateDimension(datasource);
|
||||
DatasourceDetail datasourceDetail = JSONObject.parseObject(datasourceDO.getDatasourceDetail(),
|
||||
DatasourceDetail.class);
|
||||
List<Dim> dims = getDimToCreateDimension(datasourceDetail);
|
||||
if (!CollectionUtils.isEmpty(dims)) {
|
||||
dimensionReqs = dims.stream().filter(dim -> StringUtils.isNotBlank(dim.getName()))
|
||||
.map(dim -> convert(dim, datasource)).collect(Collectors.toList());
|
||||
.map(dim -> convert(dim, datasourceDO)).collect(Collectors.toList());
|
||||
}
|
||||
List<Identify> identifies = datasource.getDatasourceDetail().getIdentifiers();
|
||||
List<Identify> identifies = datasourceDetail.getIdentifiers();
|
||||
if (CollectionUtils.isEmpty(identifies)) {
|
||||
return dimensionReqs;
|
||||
}
|
||||
dimensionReqs.addAll(identifies.stream()
|
||||
.filter(i -> i.getType().equalsIgnoreCase("primary"))
|
||||
.filter(i -> StringUtils.isNotBlank(i.getName()))
|
||||
.map(identify -> convert(identify, datasource)).collect(Collectors.toList()));
|
||||
.map(identify -> convert(identify, datasourceDO)).collect(Collectors.toList()));
|
||||
return dimensionReqs;
|
||||
}
|
||||
|
||||
|
||||
public static List<MetricReq> convertMetricList(Datasource datasource) {
|
||||
List<Measure> measures = getMeasureToCreateMetric(datasource);
|
||||
public static List<MetricReq> convertMetricList(DatasourceDO datasourceDO) {
|
||||
DatasourceDetail datasourceDetail = JSONObject.parseObject(datasourceDO.getDatasourceDetail(),
|
||||
DatasourceDetail.class);
|
||||
List<Measure> measures = getMeasureToCreateMetric(datasourceDetail);
|
||||
if (CollectionUtils.isEmpty(measures)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return measures.stream().map(measure -> convert(measure, datasource)).collect(Collectors.toList());
|
||||
return measures.stream().map(measure -> convert(measure, datasourceDO)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static Datasource datasourceInfo2Datasource(DatasourceResp datasourceResp) {
|
||||
@@ -205,4 +178,23 @@ public class DatasourceConverter {
|
||||
BeanUtils.copyProperties(datasourceResp, datasource);
|
||||
return datasource;
|
||||
}
|
||||
|
||||
private static DatasourceDetail getDatasourceDetail(DatasourceReq datasourceReq) {
|
||||
DatasourceDetail datasourceDetail = new DatasourceDetail();
|
||||
BeanMapper.mapper(datasourceReq, datasourceDetail);
|
||||
List<Measure> measures = datasourceDetail.getMeasures();
|
||||
for (Measure measure : measures) {
|
||||
if (StringUtils.isBlank(measure.getExpr())) {
|
||||
measure.setExpr(measure.getBizName());
|
||||
}
|
||||
if (StringUtils.isBlank(measure.getConstraint())) {
|
||||
measure.setConstraint(null);
|
||||
}
|
||||
if (StringUtils.isBlank(measure.getAlias())) {
|
||||
measure.setAlias(null);
|
||||
}
|
||||
measure.setBizName(String.format("%s_%s", datasourceReq.getBizName(), measure.getBizName()));
|
||||
}
|
||||
return datasourceDetail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +1,11 @@
|
||||
package com.tencent.supersonic.semantic.model.infrastructure.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDOExample;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DatasourceDOMapper {
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
long countByExample(DatasourceDOExample example);
|
||||
public interface DatasourceDOMapper extends BaseMapper<DatasourceDO> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int deleteByPrimaryKey(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int insert(DatasourceDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int insertSelective(DatasourceDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
List<DatasourceDO> selectByExampleWithBLOBs(DatasourceDOExample example);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
List<DatasourceDO> selectByExample(DatasourceDOExample example);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
DatasourceDO selectByPrimaryKey(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int updateByPrimaryKeySelective(DatasourceDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int updateByPrimaryKeyWithBLOBs(DatasourceDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int updateByPrimaryKey(DatasourceDO record);
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.tencent.supersonic.semantic.model.infrastructure.mapper;
|
||||
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDOExample;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DatasourceRelaDOMapper {
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
long countByExample(DatasourceRelaDOExample example);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int deleteByPrimaryKey(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int insert(DatasourceRelaDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int insertSelective(DatasourceRelaDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
List<DatasourceRelaDO> selectByExample(DatasourceRelaDOExample example);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
DatasourceRelaDO selectByPrimaryKey(Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int updateByPrimaryKeySelective(DatasourceRelaDO record);
|
||||
|
||||
/**
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
int updateByPrimaryKey(DatasourceRelaDO record);
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.tencent.supersonic.semantic.model.infrastructure.repository;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDOExample;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDOExample;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.DatasourceRepository;
|
||||
import com.tencent.supersonic.semantic.model.infrastructure.mapper.DatasourceDOMapper;
|
||||
import com.tencent.supersonic.semantic.model.infrastructure.mapper.DatasourceRelaDOMapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -18,12 +16,8 @@ public class DatasourceRepositoryImpl implements DatasourceRepository {
|
||||
|
||||
private DatasourceDOMapper datasourceMapper;
|
||||
|
||||
private DatasourceRelaDOMapper datasourceRelaDOMapper;
|
||||
|
||||
public DatasourceRepositoryImpl(DatasourceDOMapper datasourceMapper,
|
||||
DatasourceRelaDOMapper datasourceRelaDOMapper) {
|
||||
public DatasourceRepositoryImpl(DatasourceDOMapper datasourceMapper) {
|
||||
this.datasourceMapper = datasourceMapper;
|
||||
this.datasourceRelaDOMapper = datasourceRelaDOMapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,63 +28,35 @@ public class DatasourceRepositoryImpl implements DatasourceRepository {
|
||||
|
||||
@Override
|
||||
public void updateDatasource(DatasourceDO datasourceDO) {
|
||||
datasourceMapper.updateByPrimaryKeySelective(datasourceDO);
|
||||
datasourceMapper.updateById(datasourceDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DatasourceDO> getDatasourceList() {
|
||||
DatasourceDOExample datasourceExample = new DatasourceDOExample();
|
||||
datasourceExample.createCriteria().andStatusNotEqualTo(StatusEnum.DELETED.getCode());
|
||||
return datasourceMapper.selectByExampleWithBLOBs(datasourceExample);
|
||||
QueryWrapper<DatasourceDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().ne(DatasourceDO::getStatus, StatusEnum.DELETED.getCode());
|
||||
return datasourceMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DatasourceDO> getDatasourceList(Long modelId) {
|
||||
DatasourceDOExample datasourceExample = new DatasourceDOExample();
|
||||
datasourceExample.createCriteria().andModelIdEqualTo(modelId)
|
||||
.andStatusNotEqualTo(StatusEnum.DELETED.getCode());
|
||||
return datasourceMapper.selectByExampleWithBLOBs(datasourceExample);
|
||||
QueryWrapper<DatasourceDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().ne(DatasourceDO::getStatus, StatusEnum.DELETED.getCode())
|
||||
.eq(DatasourceDO::getModelId, modelId);
|
||||
return datasourceMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DatasourceDO> getDatasourceByDatabase(Long databaseId) {
|
||||
DatasourceDOExample datasourceExample = new DatasourceDOExample();
|
||||
datasourceExample.createCriteria().andDatabaseIdEqualTo(databaseId)
|
||||
.andStatusNotEqualTo(StatusEnum.DELETED.getCode());
|
||||
return datasourceMapper.selectByExampleWithBLOBs(datasourceExample);
|
||||
QueryWrapper<DatasourceDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().ne(DatasourceDO::getStatus, StatusEnum.DELETED.getCode())
|
||||
.eq(DatasourceDO::getDatabaseId, databaseId);
|
||||
return datasourceMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasourceDO getDatasourceById(Long id) {
|
||||
return datasourceMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDatasourceRela(DatasourceRelaDO datasourceRelaDO) {
|
||||
datasourceRelaDOMapper.insert(datasourceRelaDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDatasourceRela(DatasourceRelaDO datasourceRelaDO) {
|
||||
datasourceRelaDOMapper.updateByPrimaryKey(datasourceRelaDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasourceRelaDO getDatasourceRelaById(Long id) {
|
||||
return datasourceRelaDOMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DatasourceRelaDO> getDatasourceRelaList(Long modelId) {
|
||||
DatasourceRelaDOExample datasourceRelaDOExample = new DatasourceRelaDOExample();
|
||||
datasourceRelaDOExample.createCriteria().andModelIdEqualTo(modelId);
|
||||
return datasourceRelaDOMapper.selectByExample(datasourceRelaDOExample);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDatasourceRela(Long id) {
|
||||
datasourceRelaDOMapper.deleteByPrimaryKey(id);
|
||||
return datasourceMapper.selectById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package com.tencent.supersonic.semantic.model.rest;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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.request.DatasourceRelaReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatasourceReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceRelaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MeasureResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatasourceService;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.Datasource;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -32,7 +30,7 @@ public class DatasourceController {
|
||||
}
|
||||
|
||||
@PostMapping("/createDatasource")
|
||||
public Datasource createDatasource(@RequestBody DatasourceReq datasourceReq,
|
||||
public DatasourceResp createDatasource(@RequestBody DatasourceReq datasourceReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
@@ -40,7 +38,7 @@ public class DatasourceController {
|
||||
}
|
||||
|
||||
@PostMapping("/updateDatasource")
|
||||
public Datasource updateDatasource(@RequestBody DatasourceReq datasourceReq,
|
||||
public DatasourceResp updateDatasource(@RequestBody DatasourceReq datasourceReq,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
@@ -54,7 +52,7 @@ public class DatasourceController {
|
||||
|
||||
@GetMapping("/getMeasureListOfModel/{modelId}")
|
||||
public List<MeasureResp> getMeasureListOfModel(@PathVariable("modelId") Long modelId) {
|
||||
return datasourceService.getMeasureListOfModel(modelId);
|
||||
return datasourceService.getMeasureListOfModel(Lists.newArrayList(modelId));
|
||||
}
|
||||
|
||||
@DeleteMapping("deleteDatasource/{id}")
|
||||
@@ -65,24 +63,4 @@ public class DatasourceController {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param datasourceRelaReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/createOrUpdateDatasourceRela")
|
||||
public DatasourceRelaResp createOrUpdateDatasourceRela(@RequestBody DatasourceRelaReq datasourceRelaReq,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
return datasourceService.createOrUpdateDatasourceRela(datasourceRelaReq, user);
|
||||
}
|
||||
|
||||
@GetMapping("/getDatasourceRelaList/{modelId}")
|
||||
public List<DatasourceRelaResp> getDatasourceRelaList(@PathVariable("modelId") Long modelId) {
|
||||
return datasourceService.getDatasourceRelaList(modelId);
|
||||
}
|
||||
|
||||
@DeleteMapping("/deleteDatasourceRela/{id}")
|
||||
public void deleteDatasourceRela(@PathVariable("id") Long id) {
|
||||
datasourceService.deleteDatasourceRela(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,277 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tencent.supersonic.semantic.model.infrastructure.mapper.DatasourceDOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="model_id" jdbcType="BIGINT" property="modelId" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
<result column="database_id" jdbcType="BIGINT" property="databaseId" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
|
||||
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
|
||||
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO">
|
||||
<result column="datasource_detail" jdbcType="LONGVARCHAR" property="datasourceDetail" />
|
||||
<result column="depends" jdbcType="LONGVARCHAR" property="depends" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, model_id, name, biz_name, description, database_id, status, created_at, created_by,
|
||||
updated_at, updated_by
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
datasource_detail, depends
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDOExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from s2_datasource
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByExample" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDOExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from s2_datasource
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
<if test="limitStart != null and limitStart>=0">
|
||||
limit #{limitStart} , #{limitEnd}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from s2_datasource
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from s2_datasource
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into s2_datasource (id, model_id, name,
|
||||
biz_name, description, database_id,
|
||||
status, created_at, created_by,
|
||||
updated_at, updated_by, datasource_detail,
|
||||
depends)
|
||||
values (#{id,jdbcType=BIGINT}, #{modelId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
|
||||
#{bizName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{databaseId,jdbcType=BIGINT},
|
||||
#{status,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR},
|
||||
#{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR}, #{datasourceDetail,jdbcType=LONGVARCHAR},
|
||||
#{depends,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO">
|
||||
insert into s2_datasource
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="modelId != null">
|
||||
model_id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="bizName != null">
|
||||
biz_name,
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description,
|
||||
</if>
|
||||
<if test="databaseId != null">
|
||||
database_id,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status,
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
created_at,
|
||||
</if>
|
||||
<if test="createdBy != null">
|
||||
created_by,
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
updated_at,
|
||||
</if>
|
||||
<if test="updatedBy != null">
|
||||
updated_by,
|
||||
</if>
|
||||
<if test="datasourceDetail != null">
|
||||
datasource_detail,
|
||||
</if>
|
||||
<if test="depends != null">
|
||||
depends,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="modelId != null">
|
||||
#{modelId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="bizName != null">
|
||||
#{bizName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
#{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="databaseId != null">
|
||||
#{databaseId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
#{createdAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="createdBy != null">
|
||||
#{createdBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
#{updatedAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updatedBy != null">
|
||||
#{updatedBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="datasourceDetail != null">
|
||||
#{datasourceDetail,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="depends != null">
|
||||
#{depends,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDOExample" resultType="java.lang.Long">
|
||||
select count(*) from s2_datasource
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO">
|
||||
update s2_datasource
|
||||
<set>
|
||||
<if test="modelId != null">
|
||||
model_id = #{modelId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="bizName != null">
|
||||
biz_name = #{bizName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="databaseId != null">
|
||||
database_id = #{databaseId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
created_at = #{createdAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="createdBy != null">
|
||||
created_by = #{createdBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updatedBy != null">
|
||||
updated_by = #{updatedBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="datasourceDetail != null">
|
||||
datasource_detail = #{datasourceDetail,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="depends != null">
|
||||
depends = #{depends,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO">
|
||||
update s2_datasource
|
||||
set model_id = #{modelId,jdbcType=BIGINT},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
biz_name = #{bizName,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
database_id = #{databaseId,jdbcType=BIGINT},
|
||||
status = #{status,jdbcType=INTEGER},
|
||||
created_at = #{createdAt,jdbcType=TIMESTAMP},
|
||||
created_by = #{createdBy,jdbcType=VARCHAR},
|
||||
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
|
||||
updated_by = #{updatedBy,jdbcType=VARCHAR},
|
||||
datasource_detail = #{datasourceDetail,jdbcType=LONGVARCHAR},
|
||||
depends = #{depends,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO">
|
||||
update s2_datasource
|
||||
set model_id = #{modelId,jdbcType=BIGINT},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
biz_name = #{bizName,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
database_id = #{databaseId,jdbcType=BIGINT},
|
||||
status = #{status,jdbcType=INTEGER},
|
||||
created_at = #{createdAt,jdbcType=TIMESTAMP},
|
||||
created_by = #{createdBy,jdbcType=VARCHAR},
|
||||
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
|
||||
updated_by = #{updatedBy,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,194 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tencent.supersonic.semantic.model.infrastructure.mapper.DatasourceRelaDOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="model_id" jdbcType="BIGINT" property="modelId" />
|
||||
<result column="datasource_from" jdbcType="BIGINT" property="datasourceFrom" />
|
||||
<result column="datasource_to" jdbcType="BIGINT" property="datasourceTo" />
|
||||
<result column="join_key" jdbcType="VARCHAR" property="joinKey" />
|
||||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
|
||||
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
|
||||
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, model_id, datasource_from, datasource_to, join_key, created_at, created_by, updated_at,
|
||||
updated_by
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDOExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from s2_datasource_rela
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
<if test="limitStart != null and limitStart>=0">
|
||||
limit #{limitStart} , #{limitEnd}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from s2_datasource_rela
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from s2_datasource_rela
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO">
|
||||
insert into s2_datasource_rela (id, model_id, datasource_from,
|
||||
datasource_to, join_key, created_at,
|
||||
created_by, updated_at, updated_by
|
||||
)
|
||||
values (#{id,jdbcType=BIGINT}, #{modelId,jdbcType=BIGINT}, #{datasourceFrom,jdbcType=BIGINT},
|
||||
#{datasourceTo,jdbcType=BIGINT}, #{joinKey,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP},
|
||||
#{createdBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO">
|
||||
insert into s2_datasource_rela
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="modelId != null">
|
||||
model_id,
|
||||
</if>
|
||||
<if test="datasourceFrom != null">
|
||||
datasource_from,
|
||||
</if>
|
||||
<if test="datasourceTo != null">
|
||||
datasource_to,
|
||||
</if>
|
||||
<if test="joinKey != null">
|
||||
join_key,
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
created_at,
|
||||
</if>
|
||||
<if test="createdBy != null">
|
||||
created_by,
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
updated_at,
|
||||
</if>
|
||||
<if test="updatedBy != null">
|
||||
updated_by,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="modelId != null">
|
||||
#{modelId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="datasourceFrom != null">
|
||||
#{datasourceFrom,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="datasourceTo != null">
|
||||
#{datasourceTo,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="joinKey != null">
|
||||
#{joinKey,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
#{createdAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="createdBy != null">
|
||||
#{createdBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
#{updatedAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updatedBy != null">
|
||||
#{updatedBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDOExample" resultType="java.lang.Long">
|
||||
select count(*) from s2_datasource_rela
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO">
|
||||
update s2_datasource_rela
|
||||
<set>
|
||||
<if test="modelId != null">
|
||||
model_id = #{modelId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="datasourceFrom != null">
|
||||
datasource_from = #{datasourceFrom,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="datasourceTo != null">
|
||||
datasource_to = #{datasourceTo,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="joinKey != null">
|
||||
join_key = #{joinKey,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
created_at = #{createdAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="createdBy != null">
|
||||
created_by = #{createdBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updatedBy != null">
|
||||
updated_by = #{updatedBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceRelaDO">
|
||||
update s2_datasource_rela
|
||||
set model_id = #{modelId,jdbcType=BIGINT},
|
||||
datasource_from = #{datasourceFrom,jdbcType=BIGINT},
|
||||
datasource_to = #{datasourceTo,jdbcType=BIGINT},
|
||||
join_key = #{joinKey,jdbcType=VARCHAR},
|
||||
created_at = #{createdAt,jdbcType=TIMESTAMP},
|
||||
created_by = #{createdBy,jdbcType=VARCHAR},
|
||||
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
|
||||
updated_by = #{updatedBy,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.tencent.supersonic.semantic.model.application;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.enums.DimensionTypeEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.enums.IdentifyTypeEnum;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DatasourceDetail;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Dim;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DimensionTimeTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Identify;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.semantic.api.model.request.DatasourceReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatabaseService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DatasourceDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.DatasourceRepository;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.DateInfoRepository;
|
||||
import com.tencent.supersonic.semantic.model.domain.utils.DatasourceConverter;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class DatasourceServiceImplTest {
|
||||
|
||||
@Test
|
||||
void createDatasource() throws Exception {
|
||||
MetricService metricService = Mockito.mock(MetricService.class);
|
||||
DimensionService dimensionService = Mockito.mock(DimensionService.class);
|
||||
DatasourceRepository datasourceRepository = Mockito.mock(DatasourceRepository.class);
|
||||
DatabaseService databaseService = Mockito.mock(DatabaseService.class);
|
||||
DateInfoRepository dateInfoRepository = Mockito.mock(DateInfoRepository.class);
|
||||
DatasourceServiceImpl datasourceService = new DatasourceServiceImpl(datasourceRepository, databaseService,
|
||||
dimensionService, metricService, dateInfoRepository);
|
||||
DatasourceResp actualDatasourceResp = datasourceService.createDatasource(
|
||||
mockDatasourceReq(), User.getFakeUser());
|
||||
DatasourceResp expectedDatasourceResp = buildExpectedDatasourceResp();
|
||||
Assertions.assertEquals(expectedDatasourceResp, actualDatasourceResp);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateDatasource() throws Exception {
|
||||
MetricService metricService = Mockito.mock(MetricService.class);
|
||||
DimensionService dimensionService = Mockito.mock(DimensionService.class);
|
||||
DatasourceRepository datasourceRepository = Mockito.mock(DatasourceRepository.class);
|
||||
DatabaseService databaseService = Mockito.mock(DatabaseService.class);
|
||||
DateInfoRepository dateInfoRepository = Mockito.mock(DateInfoRepository.class);
|
||||
DatasourceServiceImpl datasourceService = new DatasourceServiceImpl(datasourceRepository, databaseService,
|
||||
dimensionService, metricService, dateInfoRepository);
|
||||
DatasourceReq datasourceReq = mockDatasourceReq_update();
|
||||
DatasourceDO datasourceDO = DatasourceConverter.convert(mockDatasourceReq(), User.getFakeUser());
|
||||
when(datasourceRepository.getDatasourceById(datasourceReq.getId())).thenReturn(datasourceDO);
|
||||
User user = User.getFakeUser();
|
||||
user.setName("alice");
|
||||
DatasourceResp actualDatasourceResp = datasourceService.updateDatasource(mockDatasourceReq_update(), user);
|
||||
DatasourceResp expectedDatasourceResp = buildExpectedDatasourceResp_update();
|
||||
Assertions.assertEquals(expectedDatasourceResp, actualDatasourceResp);
|
||||
Assertions.assertEquals("admin", actualDatasourceResp.getCreatedBy());
|
||||
Assertions.assertEquals("alice", actualDatasourceResp.getUpdatedBy());
|
||||
}
|
||||
|
||||
|
||||
private DatasourceReq mockDatasourceReq() {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setName("PVUV统计");
|
||||
datasourceReq.setBizName("s2_pv_uv_statis");
|
||||
datasourceReq.setDescription("PVUV统计");
|
||||
datasourceReq.setDatabaseId(1L);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("用户名", IdentifyTypeEnum.primary.name(), "user_name"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
Dim dimension2 = new Dim("", "page", DimensionTypeEnum.categorical.name(), 0);
|
||||
dimension2.setExpr("page");
|
||||
dimensions.add(dimension2);
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
Measure measure1 = new Measure("访问次数", "pv", AggOperatorEnum.SUM.name(), 1);
|
||||
measures.add(measure1);
|
||||
|
||||
Measure measure2 = new Measure("访问人数", "uv", AggOperatorEnum.COUNT_DISTINCT.name(), 1);
|
||||
measures.add(measure2);
|
||||
|
||||
datasourceReq.setMeasures(measures);
|
||||
datasourceReq.setSqlQuery("SELECT imp_date, user_name, page, 1 as pv, user_name as uv FROM s2_pv_uv_statis");
|
||||
datasourceReq.setQueryType("sql_query");
|
||||
datasourceReq.setModelId(1L);
|
||||
datasourceReq.setFilterSql("where user_name = 'alice'");
|
||||
return datasourceReq;
|
||||
}
|
||||
|
||||
private DatasourceReq mockDatasourceReq_update() {
|
||||
DatasourceReq datasourceReq = new DatasourceReq();
|
||||
datasourceReq.setId(1L);
|
||||
datasourceReq.setName("PVUV统计_a");
|
||||
datasourceReq.setBizName("s2_pv_uv_statis_a");
|
||||
datasourceReq.setDescription("PVUV统计_a");
|
||||
datasourceReq.setDatabaseId(2L);
|
||||
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("用户名_a", IdentifyTypeEnum.primary.name(), "user_name_a"));
|
||||
datasourceReq.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date_a", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
Dim dimension2 = new Dim("", "page_a", DimensionTypeEnum.categorical.name(), 0);
|
||||
dimension2.setExpr("page_a");
|
||||
dimensions.add(dimension2);
|
||||
datasourceReq.setDimensions(dimensions);
|
||||
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
Measure measure1 = new Measure("访问次数_a", "pv_a", AggOperatorEnum.SUM.name(), 1);
|
||||
measures.add(measure1);
|
||||
|
||||
Measure measure2 = new Measure("访问人数_a", "uv_a", AggOperatorEnum.COUNT_DISTINCT.name(), 1);
|
||||
measures.add(measure2);
|
||||
|
||||
datasourceReq.setMeasures(measures);
|
||||
datasourceReq.setSqlQuery("SELECT imp_date_a, user_name_a, page_a, 1 as pv_a, user_name "
|
||||
+ "as uv_a FROM s2_pv_uv_statis");
|
||||
datasourceReq.setQueryType("sql_query");
|
||||
datasourceReq.setModelId(1L);
|
||||
datasourceReq.setFilterSql("where user_name = 'tom'");
|
||||
return datasourceReq;
|
||||
}
|
||||
|
||||
private DatasourceResp buildExpectedDatasourceResp() {
|
||||
DatasourceResp datasourceResp = new DatasourceResp();
|
||||
datasourceResp.setName("PVUV统计");
|
||||
datasourceResp.setBizName("s2_pv_uv_statis");
|
||||
datasourceResp.setDescription("PVUV统计");
|
||||
datasourceResp.setDatabaseId(1L);
|
||||
DatasourceDetail datasourceDetail = new DatasourceDetail();
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("用户名", IdentifyTypeEnum.primary.name(), "user_name"));
|
||||
datasourceDetail.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
Dim dimension2 = new Dim("", "page", DimensionTypeEnum.categorical.name(), 0);
|
||||
dimension2.setExpr("page");
|
||||
dimensions.add(dimension2);
|
||||
datasourceDetail.setDimensions(dimensions);
|
||||
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
Measure measure1 = new Measure("访问次数", "s2_pv_uv_statis_pv", AggOperatorEnum.SUM.name(), 1);
|
||||
measure1.setExpr("pv");
|
||||
measures.add(measure1);
|
||||
|
||||
Measure measure2 = new Measure("访问人数", "s2_pv_uv_statis_uv", AggOperatorEnum.COUNT_DISTINCT.name(), 1);
|
||||
measure2.setExpr("uv");
|
||||
measures.add(measure2);
|
||||
|
||||
datasourceDetail.setMeasures(measures);
|
||||
datasourceDetail.setSqlQuery("SELECT imp_date, user_name, page, 1 as pv, user_name as uv FROM s2_pv_uv_statis");
|
||||
datasourceDetail.setQueryType("sql_query");
|
||||
datasourceResp.setDatasourceDetail(datasourceDetail);
|
||||
datasourceResp.setModelId(1L);
|
||||
datasourceResp.setFilterSql("where user_name = 'alice'");
|
||||
return datasourceResp;
|
||||
}
|
||||
|
||||
private DatasourceResp buildExpectedDatasourceResp_update() {
|
||||
DatasourceResp datasourceResp = new DatasourceResp();
|
||||
datasourceResp.setName("PVUV统计_a");
|
||||
datasourceResp.setBizName("s2_pv_uv_statis_a");
|
||||
datasourceResp.setDescription("PVUV统计_a");
|
||||
datasourceResp.setDatabaseId(2L);
|
||||
DatasourceDetail datasourceDetail = new DatasourceDetail();
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("用户名_a", IdentifyTypeEnum.primary.name(), "user_name_a"));
|
||||
datasourceDetail.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
Dim dimension1 = new Dim("", "imp_date_a", DimensionTypeEnum.time.name(), 0);
|
||||
dimension1.setTypeParams(new DimensionTimeTypeParams());
|
||||
dimensions.add(dimension1);
|
||||
Dim dimension2 = new Dim("", "page_a", DimensionTypeEnum.categorical.name(), 0);
|
||||
dimension2.setExpr("page_a");
|
||||
dimensions.add(dimension2);
|
||||
datasourceDetail.setDimensions(dimensions);
|
||||
|
||||
List<Measure> measures = new ArrayList<>();
|
||||
Measure measure1 = new Measure("访问次数_a", "s2_pv_uv_statis_a_pv_a",
|
||||
AggOperatorEnum.SUM.name(), 1);
|
||||
measure1.setExpr("pv_a");
|
||||
measures.add(measure1);
|
||||
|
||||
Measure measure2 = new Measure("访问人数_a", "s2_pv_uv_statis_a_uv_a",
|
||||
AggOperatorEnum.COUNT_DISTINCT.name(), 1);
|
||||
measure2.setExpr("uv_a");
|
||||
measures.add(measure2);
|
||||
|
||||
datasourceDetail.setMeasures(measures);
|
||||
datasourceDetail.setSqlQuery("SELECT imp_date_a, user_name_a, page_a, 1 as pv_a, "
|
||||
+ "user_name as uv_a FROM s2_pv_uv_statis");
|
||||
datasourceDetail.setQueryType("sql_query");
|
||||
datasourceResp.setDatasourceDetail(datasourceDetail);
|
||||
datasourceResp.setModelId(1L);
|
||||
datasourceResp.setFilterSql("where user_name = 'tom'");
|
||||
return datasourceResp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.tencent.supersonic.semantic.query.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.semantic.api.materialization.request.MaterializationSourceReq;
|
||||
import com.tencent.supersonic.semantic.api.materialization.response.MaterializationSourceResp;
|
||||
@@ -72,7 +73,7 @@ public class MaterializationServiceImpl implements MaterializationService {
|
||||
modelFilter.setModelIds(Arrays.asList(materializationSourceResp.getModelId()));
|
||||
List<ModelSchemaResp> modelSchemaRespList = modelService.fetchModelSchema(modelFilter);
|
||||
List<MeasureResp> measureRespList = datasourceService.getMeasureListOfModel(
|
||||
materializationSourceResp.getModelId());
|
||||
Lists.newArrayList(materializationSourceResp.getModelId()));
|
||||
modelSchemaRespList.stream().forEach(m -> {
|
||||
m.getDimensions().stream()
|
||||
.filter(mm -> mm.getDatasourceId().equals(materializationSourceReq.getDataSourceId())
|
||||
|
||||
Reference in New Issue
Block a user