mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(improvement)(semantic) Change 'semantic' to 'headless' (#555)
This commit is contained in:
69
headless/api/pom.xml
Normal file
69
headless/api/pom.xml
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>headless</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>headless-api</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>ru.yandex.clickhouse</groupId>-->
|
||||
<!-- <artifactId>clickhouse-jdbc</artifactId>-->
|
||||
<!-- <version>${clickhouse.jdbc.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.clickhouse</groupId>
|
||||
<artifactId>clickhouse-jdbc</artifactId>
|
||||
<version>${clickhouse.jdbc.version}</version>
|
||||
<!-- use uber jar with all dependencies included, change classifier to http for smaller jar -->
|
||||
<classifier>all</classifier>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>auth-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.enums;
|
||||
|
||||
public enum ElementFrequencyEnum {
|
||||
|
||||
UNKNOWN,
|
||||
HIGH,
|
||||
LOW
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.enums;
|
||||
|
||||
public enum ElementTypeEnum {
|
||||
|
||||
VARCHAR,
|
||||
DOUBLE,
|
||||
BIGINT,
|
||||
INT,
|
||||
DATE,
|
||||
ARRAY
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.enums;
|
||||
|
||||
|
||||
public enum UpdateCycleEnum {
|
||||
DAY,
|
||||
WEEK,
|
||||
MONTH
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class MaterializationConfFilter extends MaterializationFilter {
|
||||
|
||||
private Long id;
|
||||
private Boolean containElements = false;
|
||||
|
||||
private TypeEnums type;
|
||||
private Long materializationId;
|
||||
private Long elementId;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class MaterializationDateFilter {
|
||||
|
||||
private Long modelId;
|
||||
private List<String> dimensions;
|
||||
private List<String> metrics;
|
||||
private Date createdAt;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.pojo;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.UpdateCycleEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MaterializationFilter {
|
||||
|
||||
private Long materializationId;
|
||||
private String name;
|
||||
private ModelSourceTypeEnum materializedType;
|
||||
private UpdateCycleEnum updateCycle;
|
||||
private Long modelId;
|
||||
private Long databaseId;
|
||||
private Integer level;
|
||||
private String createdBy;
|
||||
private String destinationTable;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.pojo;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class MaterializationRecordFilter {
|
||||
|
||||
private Long id;
|
||||
private Long materializationId;
|
||||
private TypeEnums elementType;
|
||||
private Long elementId;
|
||||
private String elementName;
|
||||
private List<TaskStatusEnum> taskStatus;
|
||||
private String taskId;
|
||||
private String createdBy;
|
||||
private Date createdAt;
|
||||
private String startDataTime;
|
||||
private String endDataTime;
|
||||
private List<Long> materializationIds;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementFrequencyEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementTypeEnum;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class MaterializationElementReq extends RecordInfo {
|
||||
private Long id;
|
||||
private TypeEnums type;
|
||||
private Long materializationId;
|
||||
private String depends;
|
||||
private ElementTypeEnum elementType;
|
||||
private String defaultValue;
|
||||
private String outlier;
|
||||
private ElementFrequencyEnum frequency;
|
||||
private String description;
|
||||
private StatusEnum status;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterializationRecordReq extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
private Long materializationId;
|
||||
private TypeEnums elementType;
|
||||
private Long elementId;
|
||||
private String elementName;
|
||||
private String dataTime;
|
||||
private TaskStatusEnum taskStatus;
|
||||
private String taskId;
|
||||
private Long retryCount;
|
||||
private Long sourceCount;
|
||||
private Long sinkCount;
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.UpdateCycleEnum;
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MaterializationReq extends RecordInfo {
|
||||
private Long id;
|
||||
private String name;
|
||||
private ModelSourceTypeEnum materializedType;
|
||||
private UpdateCycleEnum updateCycle;
|
||||
private Long modelId;
|
||||
private Long databaseId;
|
||||
private Integer level;
|
||||
private String destinationTable;
|
||||
private String dateInfo;
|
||||
private String entities;
|
||||
private List<String> principals;
|
||||
private String description;
|
||||
private StatusEnum status;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterializationSourceReq {
|
||||
|
||||
private Long materializationId = 0L;
|
||||
private Long dataSourceId = 0L;
|
||||
private String dataTime;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MaterializationDateResp {
|
||||
|
||||
private Long modelId;
|
||||
private TypeEnums elementType;
|
||||
private Long elementId;
|
||||
private String elementName;
|
||||
private String dateFormat;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private List<String> unavailableDateList = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Measure;
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class MaterializationElementModelResp {
|
||||
private Long id;
|
||||
private TypeEnums type;
|
||||
private String bizName;
|
||||
private String expr;
|
||||
private List<Measure> measures = Lists.newArrayList();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementFrequencyEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterializationElementResp extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
private TypeEnums type;
|
||||
private Long materializationId;
|
||||
private String depends;
|
||||
private ElementTypeEnum elementType;
|
||||
private String defaultValue;
|
||||
private String outlier;
|
||||
private ElementFrequencyEnum frequency;
|
||||
private String description;
|
||||
private String bizName;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MaterializationRecordResp extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
private Long materializationId;
|
||||
private TypeEnums elementType;
|
||||
private Long elementId;
|
||||
private String elementName;
|
||||
private String dataTime;
|
||||
private TaskStatusEnum taskStatus;
|
||||
private String taskId;
|
||||
private Integer retryCount;
|
||||
private Long sourceCount;
|
||||
private Long sinkCount;
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.UpdateCycleEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MaterializationResp extends RecordInfo {
|
||||
private Long id;
|
||||
private String name;
|
||||
private ModelSourceTypeEnum materializedType;
|
||||
private UpdateCycleEnum updateCycle;
|
||||
private Long modelId;
|
||||
private Long databaseId;
|
||||
private Integer level;
|
||||
private String destinationTable;
|
||||
private String dateInfo;
|
||||
private String entities;
|
||||
private List<String> principals;
|
||||
private String description;
|
||||
private List<MaterializationElementResp> materializationElementRespList;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.tencent.supersonic.headless.api.materialization.response;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.model.response.DatabaseResp;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.UpdateCycleEnum;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class MaterializationSourceResp {
|
||||
|
||||
private Long materializationId;
|
||||
private Long dataSourceId;
|
||||
private Long modelId;
|
||||
private String sql;
|
||||
private List<String> fields;
|
||||
private String sourceDb;
|
||||
private String sourceTable;
|
||||
|
||||
private String dateInfo;
|
||||
private String entities;
|
||||
private ModelSourceTypeEnum materializedType;
|
||||
private UpdateCycleEnum updateCycle;
|
||||
private DatabaseResp databaseResp;
|
||||
private String depends;
|
||||
private Map<Long, String> dimensions;
|
||||
private Map<Long, String> metrics;
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public enum DataTypeEnum {
|
||||
|
||||
MYSQL("mysql", "mysql", "com.mysql.cj.jdbc.Driver", "`", "`", "'", "'"),
|
||||
|
||||
HIVE2("hive2", "hive", "org.apache.hive.jdbc.HiveDriver", "`", "`", "`", "`"),
|
||||
|
||||
ORACLE("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
SQLSERVER("sqlserver", "sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
H2("h2", "h2", "org.h2.Driver", "`", "`", "\"", "\""),
|
||||
|
||||
PHOENIX("phoenix", "hbase phoenix", "org.apache.phoenix.jdbc.PhoenixDriver", "", "", "\"", "\""),
|
||||
|
||||
MONGODB("mongo", "mongodb", "mongodb.jdbc.MongoDriver", "`", "`", "\"", "\""),
|
||||
|
||||
ELASTICSEARCH("elasticsearch", "elasticsearch", "com.amazon.opendistroforelasticsearch.jdbc.Driver", "", "", "'",
|
||||
"'"),
|
||||
|
||||
PRESTO("presto", "presto", "com.facebook.presto.jdbc.PrestoDriver", "\"", "\"", "\"", "\""),
|
||||
|
||||
MOONBOX("moonbox", "moonbox", "moonbox.jdbc.MbDriver", "`", "`", "`", "`"),
|
||||
|
||||
CASSANDRA("cassandra", "cassandra", "com.github.adejanovski.cassandra.jdbc.CassandraDriver", "", "", "'", "'"),
|
||||
|
||||
CLICKHOUSE("clickhouse", "clickhouse", "ru.yandex.clickhouse.ClickHouseDriver", "", "", "\"", "\""),
|
||||
|
||||
KYLIN("kylin", "kylin", "org.apache.kylin.jdbc.Driver", "\"", "\"", "\"", "\""),
|
||||
|
||||
VERTICA("vertica", "vertica", "com.vertica.jdbc.Driver", "", "", "'", "'"),
|
||||
|
||||
HANA("sap", "sap hana", "com.sap.db.jdbc.Driver", "", "", "'", "'"),
|
||||
|
||||
IMPALA("impala", "impala", "com.cloudera.impala.jdbc41.Driver", "", "", "'", "'"),
|
||||
|
||||
TDENGINE("TAOS", "TAOS", "com.taosdata.jdbc.TSDBDriver", "'", "'", "\"", "\"");
|
||||
|
||||
private String feature;
|
||||
private String desc;
|
||||
private String driver;
|
||||
private String keywordPrefix;
|
||||
private String keywordSuffix;
|
||||
private String aliasPrefix;
|
||||
private String aliasSuffix;
|
||||
|
||||
DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix,
|
||||
String aliasPrefix, String aliasSuffix) {
|
||||
this.feature = feature;
|
||||
this.desc = desc;
|
||||
this.driver = driver;
|
||||
this.keywordPrefix = keywordPrefix;
|
||||
this.keywordSuffix = keywordSuffix;
|
||||
this.aliasPrefix = aliasPrefix;
|
||||
this.aliasSuffix = aliasSuffix;
|
||||
}
|
||||
|
||||
public static DataTypeEnum urlOf(String jdbcUrl) throws RuntimeException {
|
||||
String url = jdbcUrl.toLowerCase().trim();
|
||||
for (DataTypeEnum dataTypeEnum : values()) {
|
||||
if (url.startsWith(String.format(Constants.JDBC_PREFIX_FORMATTER, dataTypeEnum.feature))) {
|
||||
return dataTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Set<String> getAllSupportedDatasourceNameSet() {
|
||||
Set<String> datasourceSet = new HashSet<>();
|
||||
for (DataTypeEnum datasource : values()) {
|
||||
datasourceSet.add(datasource.getFeature());
|
||||
}
|
||||
return datasourceSet;
|
||||
}
|
||||
|
||||
public String getFeature() {
|
||||
return feature;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public String getKeywordPrefix() {
|
||||
return keywordPrefix;
|
||||
}
|
||||
|
||||
public String getKeywordSuffix() {
|
||||
return keywordSuffix;
|
||||
}
|
||||
|
||||
public String getAliasPrefix() {
|
||||
return aliasPrefix;
|
||||
}
|
||||
|
||||
public String getAliasSuffix() {
|
||||
return aliasSuffix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
public enum DimensionTypeEnum {
|
||||
|
||||
categorical,
|
||||
time
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum IdentifyTypeEnum {
|
||||
|
||||
primary,
|
||||
|
||||
foreign,
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
public enum MetricTypeEnum {
|
||||
|
||||
ATOMIC,
|
||||
DERIVED
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public enum ModelSourceTypeEnum {
|
||||
FULL,
|
||||
PARTITION,
|
||||
ZIPPER;
|
||||
|
||||
public static ModelSourceTypeEnum of(String src) {
|
||||
for (ModelSourceTypeEnum modelSourceTypeEnum : ModelSourceTypeEnum.values()) {
|
||||
if (Objects.nonNull(src) && src.equalsIgnoreCase(modelSourceTypeEnum.name())) {
|
||||
return modelSourceTypeEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isZipper(ModelSourceTypeEnum modelSourceTypeEnum) {
|
||||
return Objects.nonNull(modelSourceTypeEnum) && ZIPPER.equals(modelSourceTypeEnum);
|
||||
}
|
||||
|
||||
public static boolean isZipper(String str) {
|
||||
ModelSourceTypeEnum modelSourceTypeEnum = of(str);
|
||||
return Objects.nonNull(modelSourceTypeEnum) && isZipper(modelSourceTypeEnum);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum OperatorEnum {
|
||||
|
||||
MAX("MAX"),
|
||||
|
||||
MIN("MIN"),
|
||||
|
||||
AVG("AVG"),
|
||||
|
||||
SUM("SUM"),
|
||||
|
||||
DISTINCT("DISTINCT"),
|
||||
|
||||
TOPN("TOPN"),
|
||||
|
||||
PERCENTILE("PERCENTILE"),
|
||||
|
||||
UNKNOWN("UNKNOWN");
|
||||
|
||||
|
||||
private String operator;
|
||||
|
||||
OperatorEnum(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum QueryOptMode {
|
||||
|
||||
NONE,
|
||||
|
||||
MATERIALIZATION
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
public enum QueryTypeBackEnum {
|
||||
NORMAL("NORMAL", 0),
|
||||
|
||||
PRE_FLUSH("PRE_FLUSH", 1);
|
||||
|
||||
private String value;
|
||||
private Integer state;
|
||||
|
||||
QueryTypeBackEnum(String value, Integer state) {
|
||||
this.value = value;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public static QueryTypeBackEnum of(String src) {
|
||||
for (QueryTypeBackEnum operatorEnum : QueryTypeBackEnum.values()) {
|
||||
if (src.toUpperCase().contains(operatorEnum.value)) {
|
||||
return operatorEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
|
||||
public enum QueryTypeEnum {
|
||||
SQL("SQL"),
|
||||
|
||||
STRUCT("STRUCT");
|
||||
|
||||
private String value;
|
||||
|
||||
QueryTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static QueryTypeEnum of(String src) {
|
||||
for (QueryTypeEnum operatorEnum : QueryTypeEnum.values()) {
|
||||
if (src.toUpperCase().contains(operatorEnum.value)) {
|
||||
return operatorEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.tencent.supersonic.headless.api.model.enums;
|
||||
|
||||
public enum SemanticTypeEnum {
|
||||
|
||||
CATEGORY,
|
||||
ID,
|
||||
DATE,
|
||||
NUMBER
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DatasourceType {
|
||||
|
||||
private String name;
|
||||
private String prefix;
|
||||
private List<String> versions;
|
||||
|
||||
public DatasourceType(String name, List<String> versions) {
|
||||
this.name = name;
|
||||
this.prefix = String.format(Constants.JDBC_PREFIX_FORMATTER, name);
|
||||
this.versions = versions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Dim {
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String dateFormat = Constants.DAY_FORMAT;
|
||||
|
||||
private DimensionTimeTypeParams typeParams;
|
||||
|
||||
private Integer isCreateDimension = 0;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private String description;
|
||||
|
||||
private int isTag;
|
||||
|
||||
public Dim(String name, String bizName, String type, Integer isCreateDimension) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.isCreateDimension = isCreateDimension;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
|
||||
public Dim(String name, String bizName, String type, Integer isCreateDimension, int isTag) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.isCreateDimension = isCreateDimension;
|
||||
this.bizName = bizName;
|
||||
this.isTag = isTag;
|
||||
}
|
||||
|
||||
public Dim(String name, String type, String expr, String dateFormat, DimensionTimeTypeParams typeParams,
|
||||
Integer isCreateDimension, String bizName) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.expr = expr;
|
||||
this.dateFormat = dateFormat;
|
||||
this.typeParams = typeParams;
|
||||
this.isCreateDimension = isCreateDimension;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
|
||||
public static Dim getDefault() {
|
||||
return new Dim("日期", "time", "2023-05-28",
|
||||
Constants.DAY_FORMAT,
|
||||
new DimensionTimeTypeParams("true", "day"),
|
||||
0, "imp_date"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DimValueMap {
|
||||
|
||||
/**
|
||||
* dimension value in db
|
||||
*/
|
||||
private String techName;
|
||||
|
||||
/**
|
||||
* dimension value for result show
|
||||
*/
|
||||
private String bizName;
|
||||
|
||||
/**
|
||||
* dimension value for user query
|
||||
*/
|
||||
private List<String> alias = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DimensionTimeTypeParams {
|
||||
|
||||
private String isPrimary = "true";
|
||||
|
||||
private String timeGranularity = "day";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DrillDownDimension {
|
||||
|
||||
private Long dimensionId;
|
||||
|
||||
private boolean necessary;
|
||||
|
||||
public DrillDownDimension(Long dimensionId) {
|
||||
this.dimensionId = dimensionId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Entity {
|
||||
|
||||
|
||||
/**
|
||||
* uniquely identifies an entity
|
||||
*/
|
||||
private Long entityId;
|
||||
|
||||
/**
|
||||
* entity name list
|
||||
*/
|
||||
private List<String> names;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Identify {
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* primary, foreign
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private List<String> entityNames;
|
||||
|
||||
public Identify(String name, String type, String bizName) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class ItemDateFilter {
|
||||
|
||||
private List<Long> itemIds;
|
||||
@NonNull
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Measure {
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
private String agg;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String constraint;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String createMetric;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private Integer isCreateMetric = 0;
|
||||
|
||||
public Measure(String name, String bizName, String agg, Integer isCreateMetric) {
|
||||
this.name = name;
|
||||
this.agg = agg;
|
||||
this.isCreateMetric = isCreateMetric;
|
||||
this.bizName = bizName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricQueryDefaultConfig extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long metricId;
|
||||
|
||||
private String userName;
|
||||
|
||||
//string of queryStruct
|
||||
private String defaultConfig;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import java.util.List;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricTypeParams {
|
||||
|
||||
private List<Measure> measures = Lists.newArrayList();
|
||||
|
||||
private String expr;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.enums.DimensionTypeEnum;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Data
|
||||
public class ModelDetail {
|
||||
|
||||
private String queryType;
|
||||
|
||||
private String sqlQuery;
|
||||
|
||||
private String tableQuery;
|
||||
|
||||
private List<Identify> identifiers;
|
||||
|
||||
private List<Dim> dimensions;
|
||||
|
||||
private List<Measure> measures;
|
||||
|
||||
public String getSqlQuery() {
|
||||
if (StringUtils.isNotBlank(sqlQuery) && sqlQuery.endsWith(";")) {
|
||||
sqlQuery = sqlQuery.substring(0, sqlQuery.length() - 1);
|
||||
}
|
||||
return sqlQuery;
|
||||
}
|
||||
|
||||
public List<Dim> getTimeDims() {
|
||||
if (CollectionUtils.isEmpty(dimensions)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return dimensions.stream()
|
||||
.filter(dim -> DimensionTypeEnum.time.name().equalsIgnoreCase(dim.getType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryResult<T> implements Serializable {
|
||||
|
||||
private int pageNo = -1;
|
||||
private int pageSize = -1;
|
||||
private long totalCount = -1;
|
||||
private List<T> resultList = new ArrayList<T>();
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryStat {
|
||||
|
||||
private Long id;
|
||||
private String traceId;
|
||||
private Long modelId;
|
||||
private String user;
|
||||
private String createdAt;
|
||||
/**
|
||||
* corresponding type, such as sql, struct, etc
|
||||
*/
|
||||
private String queryType;
|
||||
/**
|
||||
* NORMAL, PRE_FLUSH
|
||||
*/
|
||||
private Integer queryTypeBack;
|
||||
private String querySqlCmd;
|
||||
private String querySqlCmdMd5;
|
||||
private String queryStructCmd;
|
||||
private String queryStructCmdMd5;
|
||||
private String sql;
|
||||
private String sqlMd5;
|
||||
private String queryEngine;
|
||||
private Long startTime;
|
||||
private Long elapsedMs;
|
||||
private String queryState;
|
||||
private Boolean nativeQuery;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String dimensions;
|
||||
private String metrics;
|
||||
private String selectCols;
|
||||
private String aggCols;
|
||||
private String filterCols;
|
||||
private String groupByCols;
|
||||
private String orderByCols;
|
||||
private Boolean useResultCache;
|
||||
private Boolean useSqlCache;
|
||||
private String sqlCacheKey;
|
||||
private String resultCacheKey;
|
||||
private String queryOptMode;
|
||||
|
||||
public QueryStat setQueryOptMode(String queryOptMode) {
|
||||
this.queryOptMode = queryOptMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQuerySqlCmdMd5(String querySqlCmdMd5) {
|
||||
this.querySqlCmdMd5 = querySqlCmdMd5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryStructCmdMd5(String queryStructCmdMd5) {
|
||||
this.queryStructCmdMd5 = queryStructCmdMd5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryTypeBack(Integer queryTypeBack) {
|
||||
this.queryTypeBack = queryTypeBack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setNativeQuery(Boolean nativeQuery) {
|
||||
this.nativeQuery = nativeQuery;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setTraceId(String traceId) {
|
||||
this.traceId = traceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setModelId(Long modelId) {
|
||||
this.modelId = modelId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setUser(String user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryType(String queryType) {
|
||||
this.queryType = queryType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQuerySqlCmd(String querySqlCmd) {
|
||||
this.querySqlCmd = querySqlCmd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryStructCmd(String queryStructCmd) {
|
||||
this.queryStructCmd = queryStructCmd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setSql(String sql) {
|
||||
this.sql = sql;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setSqlMd5(String sqlMd5) {
|
||||
this.sqlMd5 = sqlMd5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryEngine(String queryEngine) {
|
||||
this.queryEngine = queryEngine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setElapsedMs(Long elapsedMs) {
|
||||
this.elapsedMs = elapsedMs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setQueryState(String queryState) {
|
||||
this.queryState = queryState;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setDimensions(String dimensions) {
|
||||
this.dimensions = dimensions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setMetrics(String metrics) {
|
||||
this.metrics = metrics;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setSelectCols(String selectCols) {
|
||||
this.selectCols = selectCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setAggCols(String aggCols) {
|
||||
this.aggCols = aggCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setFilterCols(String filterCols) {
|
||||
this.filterCols = filterCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setGroupByCols(String groupByCols) {
|
||||
this.groupByCols = groupByCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setOrderByCols(String orderByCols) {
|
||||
this.orderByCols = orderByCols;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setUseResultCache(Boolean useResultCache) {
|
||||
this.useResultCache = useResultCache;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setUseSqlCache(Boolean useSqlCache) {
|
||||
this.useSqlCache = useSqlCache;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setSqlCacheKey(String sqlCacheKey) {
|
||||
this.sqlCacheKey = sqlCacheKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setResultCacheKey(String resultCacheKey) {
|
||||
this.resultCacheKey = resultCacheKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setId(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public QueryStat setCreatedAt(String createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getMetricListBizName() {
|
||||
if (Objects.isNull(metrics)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return JSONObject.parseArray(metrics, String.class);
|
||||
}
|
||||
|
||||
public List<String> getDimensionListBizName() {
|
||||
return JSONObject.parseArray(dimensions, String.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class RelateDimension {
|
||||
|
||||
List<DrillDownDimension> drillDownDimensions = Lists.newArrayList();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.tencent.supersonic.headless.api.model.pojo;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.SensitiveLevelEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class SchemaItem extends RecordInfo {
|
||||
|
||||
private static String aliasSplit = ",";
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private String description;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private TypeEnums typeEnum;
|
||||
|
||||
private Integer sensitiveLevel = SensitiveLevelEnum.LOW.getCode();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
SchemaItem that = (SchemaItem) o;
|
||||
return Objects.equal(id, that.id) && Objects.equal(name, that.name)
|
||||
&& Objects.equal(bizName, that.bizName) && Objects.equal(
|
||||
description, that.description) && Objects.equal(status, that.status)
|
||||
&& typeEnum == that.typeEnum && Objects.equal(sensitiveLevel, that.sensitiveLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), id, name, bizName, description, status, typeEnum, sensitiveLevel);
|
||||
}
|
||||
|
||||
public static List<String> getAliasList(String alias) {
|
||||
if (StringUtils.isEmpty(alias)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return Arrays.asList(alias.split(aliasSplit));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.enums.DataTypeEnum;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class DatabaseReq {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private String host;
|
||||
|
||||
private String port;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String database;
|
||||
|
||||
private String version;
|
||||
|
||||
private String description;
|
||||
|
||||
private String url;
|
||||
|
||||
private List<String> admins = Lists.newArrayList();
|
||||
|
||||
private List<String> viewers = Lists.newArrayList();
|
||||
|
||||
public String getConnectUrl() {
|
||||
if (StringUtils.isNotBlank(url)) {
|
||||
return url;
|
||||
}
|
||||
String databaseUrl = database;
|
||||
if (StringUtils.isBlank(databaseUrl)) {
|
||||
databaseUrl = "";
|
||||
} else {
|
||||
databaseUrl = "/" + database;
|
||||
}
|
||||
if (type.equalsIgnoreCase(DataTypeEnum.MYSQL.getFeature())) {
|
||||
return String.format("jdbc:%s://%s:%s%s?sessionVariables=sql_mode='IGNORE_SPACE'&allowMultiQueries=true",
|
||||
type, host, port, databaseUrl);
|
||||
}
|
||||
return String.format("jdbc:%s://%s:%s%s", type, host, port, databaseUrl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DateInfoReq {
|
||||
|
||||
private String type;
|
||||
private Long itemId;
|
||||
private String dateFormat;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String datePeriod;
|
||||
private List<String> unavailableDateList = new ArrayList<>();
|
||||
|
||||
public DateInfoReq(String type, Long itemId, String dateFormat, String startDate, String endDate) {
|
||||
this.type = type;
|
||||
this.itemId = itemId;
|
||||
this.dateFormat = dateFormat;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public DateInfoReq(String type, Long itemId, String dateFormat, String startDate, String endDate,
|
||||
List<String> unavailableDateList) {
|
||||
this.type = type;
|
||||
this.itemId = itemId;
|
||||
this.dateFormat = dateFormat;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.unavailableDateList = unavailableDateList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DimValueMap;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DimensionReq extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private String type;
|
||||
|
||||
@NotNull(message = "expr can not be null")
|
||||
private String expr;
|
||||
|
||||
//DATE ID CATEGORY
|
||||
private String semanticType = "CATEGORY";
|
||||
|
||||
private String alias;
|
||||
|
||||
private List<String> defaultValues;
|
||||
|
||||
private List<DimValueMap> dimValueMaps;
|
||||
|
||||
private DataTypeEnums dataType;
|
||||
|
||||
private int isTag;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class DomainReq extends SchemaItem {
|
||||
|
||||
private Long parentId = 0L;
|
||||
|
||||
private Integer isOpen = 0;
|
||||
|
||||
private List<String> viewers = new ArrayList<>();
|
||||
|
||||
private List<String> viewOrgs = new ArrayList<>();
|
||||
|
||||
private List<String> admins = new ArrayList<>();
|
||||
|
||||
private List<String> adminOrgs = new ArrayList<>();
|
||||
|
||||
public String getViewer() {
|
||||
return String.join(",", viewers);
|
||||
}
|
||||
|
||||
public String getViewOrg() {
|
||||
return String.join(",", viewOrgs);
|
||||
}
|
||||
|
||||
public String getAdmin() {
|
||||
return String.join(",", admins);
|
||||
}
|
||||
|
||||
public String getAdminOrg() {
|
||||
return String.join(",", adminOrgs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DomainUpdateReq extends DomainReq {
|
||||
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MetaBatchReq {
|
||||
|
||||
private List<Long> ids;
|
||||
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.RelateDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Data
|
||||
public class MetricBaseReq extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String dataFormatType;
|
||||
|
||||
private DataFormat dataFormat;
|
||||
|
||||
private List<String> tags;
|
||||
|
||||
private RelateDimension relateDimension;
|
||||
|
||||
private Map<String, Object> ext = new HashMap<>();
|
||||
|
||||
public String getTag() {
|
||||
if (CollectionUtils.isEmpty(tags)) {
|
||||
return "";
|
||||
}
|
||||
return StringUtils.join(tags, ",");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.MetricTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.MetricTypeParams;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MetricReq extends MetricBaseReq {
|
||||
|
||||
private MetricTypeEnum metricType;
|
||||
|
||||
private MetricTypeParams typeParams;
|
||||
|
||||
public MetricTypeEnum getMetricType() {
|
||||
if (metricType != null) {
|
||||
return metricType;
|
||||
}
|
||||
List<Measure> measureList = typeParams.getMeasures();
|
||||
if (measureList.size() == 1 && typeParams.getExpr().trim().equalsIgnoreCase(measureList.get(0).getBizName())) {
|
||||
return MetricTypeEnum.ATOMIC;
|
||||
} else if (measureList.size() >= 1) {
|
||||
return MetricTypeEnum.DERIVED;
|
||||
}
|
||||
throw new RuntimeException("measure can not be none");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.ModelDetail;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class ModelReq extends SchemaItem {
|
||||
|
||||
private Long databaseId;
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private String filterSql;
|
||||
|
||||
private Integer isOpen;
|
||||
|
||||
private List<DrillDownDimension> drillDownDimensions;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private ModelDetail modelDetail;
|
||||
|
||||
private List<String> viewers = new ArrayList<>();
|
||||
|
||||
private List<String> viewOrgs = new ArrayList<>();
|
||||
|
||||
private List<String> admins = new ArrayList<>();
|
||||
|
||||
private List<String> adminOrgs = new ArrayList<>();
|
||||
|
||||
public List<Dim> getTimeDimension() {
|
||||
if (modelDetail == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return modelDetail.getTimeDims();
|
||||
}
|
||||
|
||||
public String getViewer() {
|
||||
return String.join(",", viewers);
|
||||
}
|
||||
|
||||
public String getViewOrg() {
|
||||
return String.join(",", viewOrgs);
|
||||
}
|
||||
|
||||
public String getAdmin() {
|
||||
return String.join(",", admins);
|
||||
}
|
||||
|
||||
public String getAdminOrg() {
|
||||
return String.join(",", adminOrgs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModelSchemaFilterReq {
|
||||
|
||||
/**
|
||||
* if domainIds is empty, get all domain info
|
||||
*/
|
||||
private List<Long> modelIds;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class PageDimensionReq extends PageSchemaItemReq {
|
||||
|
||||
private Integer isTag;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class PageMetricReq extends PageSchemaItemReq {
|
||||
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.PageBaseReq;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PageSchemaItemReq extends PageBaseReq {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String bizName;
|
||||
private String createdBy;
|
||||
private List<Long> domainIds = Lists.newArrayList();
|
||||
private List<Long> modelIds = Lists.newArrayList();
|
||||
private Integer sensitiveLevel;
|
||||
private Integer status;
|
||||
private String key;
|
||||
private List<Long> ids;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.tencent.supersonic.headless.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 {
|
||||
public static final String LIMIT_WRAPPER = " select * from ( %s ) a limit 1000 ";
|
||||
|
||||
@NotNull(message = "modelId can not be null")
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message = "sql can not be blank")
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.supersonic.headless.api.model.request;
|
||||
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ViewInfoReq {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private String type;
|
||||
|
||||
private Date createdAt;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
private String updatedBy;
|
||||
|
||||
private String config;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class DatabaseResp extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private List<String> admins = Lists.newArrayList();
|
||||
|
||||
private List<String> viewers = Lists.newArrayList();
|
||||
|
||||
private String type;
|
||||
|
||||
private String url;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
private String database;
|
||||
|
||||
private String version;
|
||||
|
||||
private boolean hasPermission = false;
|
||||
|
||||
private boolean hasUsePermission = false;
|
||||
|
||||
private boolean hasEditPermission = false;
|
||||
|
||||
public String getHost() {
|
||||
Pattern p = Pattern.compile("jdbc:(?<db>\\w+):.*((//)|@)(?<host>.+):(?<port>\\d+).*");
|
||||
Matcher m = p.matcher(url);
|
||||
if (m.find()) {
|
||||
return m.group("host");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
Pattern p = Pattern.compile("jdbc:(?<db>\\w+):.*((//)|@)(?<host>.+):(?<port>\\d+).*");
|
||||
Matcher m = p.matcher(url);
|
||||
if (m.find()) {
|
||||
return m.group("port");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class DimSchemaResp extends DimensionResp {
|
||||
|
||||
private Long useCnt = 0L;
|
||||
|
||||
private List<String> entityAlias;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DimValueMap;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class DimensionResp extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private String type;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String fullPath;
|
||||
|
||||
private String modelName;
|
||||
|
||||
private String modelBizName;
|
||||
|
||||
private String modelFilterSql;
|
||||
//DATE ID CATEGORY
|
||||
private String semanticType;
|
||||
|
||||
private String alias;
|
||||
|
||||
private List<String> defaultValues;
|
||||
|
||||
private List<DimValueMap> dimValueMaps;
|
||||
|
||||
private DataTypeEnums dataType;
|
||||
|
||||
private int isTag;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Entity;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class DomainResp extends SchemaItem {
|
||||
|
||||
private Long parentId;
|
||||
|
||||
private String fullPath;
|
||||
|
||||
private List<String> viewers;
|
||||
|
||||
private List<String> viewOrgs;
|
||||
|
||||
private List<String> admins;
|
||||
|
||||
private List<String> adminOrgs;
|
||||
|
||||
private Integer isOpen = 0;
|
||||
|
||||
private Integer dimensionCnt;
|
||||
|
||||
private Integer metricCnt;
|
||||
|
||||
private Entity entity;
|
||||
|
||||
private boolean hasEditPermission = false;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DomainResp that = (DomainResp) o;
|
||||
if (getId() == null || that.getId() == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(getId().intValue(), that.getId().intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (getId() == null) {
|
||||
return 0;
|
||||
}
|
||||
return getId().hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExplainResp implements Serializable {
|
||||
|
||||
private String sql;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class MeasureResp {
|
||||
|
||||
private String name;
|
||||
|
||||
//sum max min avg count distinct
|
||||
private String agg;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String constraint;
|
||||
|
||||
private String alias;
|
||||
|
||||
private Long datasourceId;
|
||||
|
||||
private String datasourceName;
|
||||
|
||||
private String datasourceBizName;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private Long modelId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.RelateDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class MetricResp extends SchemaItem {
|
||||
|
||||
private Long modelId;
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private String modelName;
|
||||
|
||||
//ATOMIC DERIVED
|
||||
private String type;
|
||||
|
||||
private MetricTypeParams typeParams;
|
||||
|
||||
private String dataFormatType;
|
||||
|
||||
private DataFormat dataFormat;
|
||||
|
||||
private String alias;
|
||||
|
||||
private List<String> tags;
|
||||
|
||||
private RelateDimension relateDimension;
|
||||
|
||||
private boolean hasAdminRes = false;
|
||||
|
||||
private Boolean isCollect;
|
||||
|
||||
private Map<String, Object> ext = new HashMap<>();
|
||||
|
||||
public void setTag(String tag) {
|
||||
if (StringUtils.isBlank(tag)) {
|
||||
tags = Lists.newArrayList();
|
||||
} else {
|
||||
tags = Arrays.asList(tag.split(","));
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Long> getNecessaryDimensionIds() {
|
||||
if (relateDimension == null || CollectionUtils.isEmpty(relateDimension.getDrillDownDimensions())) {
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
return relateDimension.getDrillDownDimensions().stream().filter(DrillDownDimension::isNecessary)
|
||||
.map(DrillDownDimension::getDimensionId).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public String getRelaDimensionIdKey() {
|
||||
if (relateDimension == null || CollectionUtils.isEmpty(relateDimension.getDrillDownDimensions())) {
|
||||
return "";
|
||||
}
|
||||
return relateDimension.getDrillDownDimensions().stream()
|
||||
.map(DrillDownDimension::getDimensionId)
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public List<Measure> getMeasures() {
|
||||
if (typeParams == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return typeParams.getMeasures();
|
||||
}
|
||||
|
||||
public String getDefaultAgg() {
|
||||
return typeParams.getMeasures().get(0).getAgg();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class MetricSchemaResp extends MetricResp {
|
||||
|
||||
private Long useCnt = 0L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Identify;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.ModelDetail;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModelResp extends SchemaItem {
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private Long databaseId;
|
||||
|
||||
private ModelDetail modelDetail;
|
||||
|
||||
private String depends;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String filterSql;
|
||||
|
||||
private List<String> viewers = new ArrayList<>();
|
||||
|
||||
private List<String> viewOrgs = new ArrayList<>();
|
||||
|
||||
private List<String> admins = new ArrayList<>();
|
||||
|
||||
private List<String> adminOrgs = new ArrayList<>();
|
||||
|
||||
private Integer isOpen;
|
||||
|
||||
private List<DrillDownDimension> drillDownDimensions;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String fullPath;
|
||||
|
||||
private Integer dimensionCnt;
|
||||
|
||||
private Integer metricCnt;
|
||||
|
||||
public boolean openToAll() {
|
||||
return isOpen != null && isOpen == 1;
|
||||
}
|
||||
|
||||
public Identify getPrimaryIdentify() {
|
||||
if (modelDetail == null) {
|
||||
return null;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(modelDetail.getIdentifiers())) {
|
||||
return null;
|
||||
}
|
||||
for (Identify identify : modelDetail.getIdentifiers()) {
|
||||
if (!CollectionUtils.isEmpty(identify.getEntityNames())) {
|
||||
return identify;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Dim> getTimeDimension() {
|
||||
if (modelDetail == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return modelDetail.getTimeDims();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
ModelResp that = (ModelResp) o;
|
||||
return Objects.equal(getId(), that.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModelSchemaRelaResp {
|
||||
|
||||
private Long domainId;
|
||||
|
||||
private ModelResp model;
|
||||
|
||||
private List<MetricResp> metrics;
|
||||
|
||||
private List<DimensionResp> dimensions;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.ModelRela;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Identify;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ModelSchemaResp extends ModelResp {
|
||||
|
||||
private List<MetricSchemaResp> metrics;
|
||||
private List<DimSchemaResp> dimensions;
|
||||
private List<ModelRela> modelRelas;
|
||||
|
||||
public DimSchemaResp getPrimaryKey() {
|
||||
Identify identify = getPrimaryIdentify();
|
||||
if (identify == null) {
|
||||
return null;
|
||||
}
|
||||
for (DimSchemaResp dimension : dimensions) {
|
||||
if (identify.getBizName().equals(dimension.getBizName())) {
|
||||
dimension.setEntityAlias(identify.getEntityNames());
|
||||
return dimension;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.QueryAuthorization;
|
||||
import com.tencent.supersonic.common.pojo.QueryColumn;
|
||||
import com.tencent.supersonic.headless.api.model.enums.SemanticTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.QueryResult;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryResultWithSchemaResp extends QueryResult<Map<String, Object>> {
|
||||
|
||||
List<QueryColumn> columns = Lists.newArrayList();
|
||||
String sql;
|
||||
QueryAuthorization queryAuthorization;
|
||||
|
||||
public List<QueryColumn> getMetricColumns() {
|
||||
return columns.stream()
|
||||
.filter(queryColumn -> SemanticTypeEnum.NUMBER.name().equals(queryColumn.getShowType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<QueryColumn> getDimensionColumns() {
|
||||
return columns.stream()
|
||||
.filter(queryColumn -> !SemanticTypeEnum.NUMBER.name().equals(queryColumn.getShowType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.tencent.supersonic.headless.api.model.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SqlParserResp {
|
||||
|
||||
private String sql = "";
|
||||
private String sourceId = "";
|
||||
private String errMsg = "";
|
||||
private Boolean ok;
|
||||
|
||||
public boolean isOk() {
|
||||
this.ok = "".equals(errMsg) && !"".equals(sql);
|
||||
return ok;
|
||||
}
|
||||
|
||||
public SqlParserResp error(String msg) {
|
||||
this.setErrMsg(msg);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.ModelSourceTypeEnum;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DataModelYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
private Long sourceId;
|
||||
|
||||
private String sqlQuery;
|
||||
|
||||
private String tableQuery;
|
||||
|
||||
private List<IdentifyYamlTpl> identifiers;
|
||||
|
||||
private List<DimensionYamlTpl> dimensions;
|
||||
|
||||
private List<MeasureYamlTpl> measures;
|
||||
|
||||
private ModelSourceTypeEnum modelSourceTypeEnum;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DimensionTimeTypeParamsTpl {
|
||||
|
||||
private String isPrimary;
|
||||
|
||||
private String timeGranularity;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DimensionYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
private String owners;
|
||||
|
||||
private String type;
|
||||
|
||||
private String expr;
|
||||
|
||||
private DimensionTimeTypeParamsTpl typeParams;
|
||||
|
||||
private DataTypeEnums dataType;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class IdentifyYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 主键 primary 外键 foreign
|
||||
*/
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MeasureYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
private String agg;
|
||||
|
||||
private String expr;
|
||||
|
||||
private String constraint;
|
||||
|
||||
private String alias;
|
||||
|
||||
private String createMetric;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricTypeParamsYamlTpl {
|
||||
|
||||
private List<MeasureYamlTpl> measures;
|
||||
|
||||
private String expr;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.tencent.supersonic.headless.api.model.yaml;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class MetricYamlTpl {
|
||||
|
||||
private String name;
|
||||
|
||||
private List<String> owners;
|
||||
|
||||
private String type;
|
||||
|
||||
private MetricTypeParamsYamlTpl typeParams;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.tencent.supersonic.headless.api.query.enums;
|
||||
|
||||
public enum AggOption {
|
||||
NATIVE,
|
||||
AGGREGATION,
|
||||
DEFAULT;
|
||||
|
||||
public static AggOption getAggregation(boolean isNativeQuery) {
|
||||
return isNativeQuery ? NATIVE : AGGREGATION;
|
||||
}
|
||||
|
||||
public static boolean isAgg(AggOption aggOption) {
|
||||
return NATIVE.equals(aggOption) ? false : true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Cache {
|
||||
|
||||
private Boolean cache = true;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"cache\":")
|
||||
.append(cache);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class DataDownload {
|
||||
|
||||
List<List<String>> headers;
|
||||
|
||||
List<List<String>> data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Materialization {
|
||||
|
||||
private String name;
|
||||
private String destination;
|
||||
private String destinationType;
|
||||
private List<String> depends;
|
||||
private List<String> metrics;
|
||||
private List<String> dimensions;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import com.tencent.supersonic.headless.api.query.enums.AggOption;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricTable {
|
||||
|
||||
private String alias;
|
||||
private List<String> metrics;
|
||||
private List<String> dimensions;
|
||||
private String where;
|
||||
private AggOption aggOption = AggOption.DEFAULT;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.tencent.supersonic.headless.api.query.pojo;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Param {
|
||||
|
||||
@NotBlank(message = "Invald parameter name")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "Invalid parameter value")
|
||||
private String value;
|
||||
|
||||
public Param() {
|
||||
}
|
||||
|
||||
public Param(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"name\":\"")
|
||||
.append(name).append('\"');
|
||||
sb.append(",\"value\":\"")
|
||||
.append(value).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BatchDownloadReq {
|
||||
|
||||
private List<Long> metricIds;
|
||||
|
||||
private DateConf dateInfo;
|
||||
|
||||
private boolean isTransform = true;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DownloadStructReq extends QueryStructReq {
|
||||
|
||||
private boolean isTransform;
|
||||
|
||||
public void setIsTransform(boolean isTransform) {
|
||||
this.isTransform = isTransform;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.headless.api.model.enums.QueryTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExplainSqlReq<T> {
|
||||
|
||||
private QueryTypeEnum queryTypeEnum;
|
||||
|
||||
private T queryReq;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
public class ItemUseReq {
|
||||
|
||||
private String startTime;
|
||||
private Long modelId;
|
||||
private List<Long> modelIds;
|
||||
private Boolean cacheEnable = true;
|
||||
private String metric;
|
||||
|
||||
public ItemUseReq(String startTime, Long modelId) {
|
||||
this.startTime = startTime;
|
||||
this.modelId = modelId;
|
||||
}
|
||||
public ItemUseReq(String startTime, List<Long> modelIds) {
|
||||
this.startTime = startTime;
|
||||
this.modelIds = modelIds;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.ColumnOrder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricReq {
|
||||
|
||||
private List<String> metrics;
|
||||
private List<String> dimensions;
|
||||
private String rootPath = "";
|
||||
private Map<String, String> variables;
|
||||
private String where;
|
||||
private Long limit;
|
||||
private List<ColumnOrder> order;
|
||||
private boolean nativeQuery = false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.headless.api.query.pojo.MetricTable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ParseSqlReq {
|
||||
|
||||
private String rootPath = "";
|
||||
private Map<String, String> variables;
|
||||
private String sql = "";
|
||||
private List<MetricTable> tables;
|
||||
private boolean supportWith = true;
|
||||
private boolean withAlias = true;
|
||||
|
||||
public Map<String, String> getVariables() {
|
||||
if (variables == null) {
|
||||
variables = new HashMap<>();
|
||||
}
|
||||
return variables;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryDimValueReq {
|
||||
|
||||
private Long modelId;
|
||||
private String dimensionBizName;
|
||||
private String value;
|
||||
private DateConf dateInfo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryMultiStructReq {
|
||||
|
||||
|
||||
List<QueryStructReq> queryStructReqs;
|
||||
|
||||
public String toCustomizedString() {
|
||||
return JSONObject.toJSONString(queryStructReqs);
|
||||
}
|
||||
|
||||
public String generateCommandMd5() {
|
||||
return DigestUtils.md5Hex(this.toCustomizedString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class QueryS2SQLReq {
|
||||
|
||||
private Set<Long> modelIds;
|
||||
|
||||
private String sql;
|
||||
|
||||
private Map<String, String> variables;
|
||||
|
||||
public void setModelId(Long modelId) {
|
||||
modelIds = new HashSet<>();
|
||||
modelIds.add(modelId);
|
||||
}
|
||||
|
||||
public List<Long> getModelIds() {
|
||||
return Lists.newArrayList(modelIds);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.tencent.supersonic.headless.api.query.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.Aggregator;
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.Filter;
|
||||
import com.tencent.supersonic.common.pojo.Order;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum;
|
||||
import com.tencent.supersonic.common.util.ContextUtils;
|
||||
import com.tencent.supersonic.common.util.DateModeUtils;
|
||||
import com.tencent.supersonic.common.util.SqlFilterUtils;
|
||||
import com.tencent.supersonic.common.util.jsqlparser.SqlParserAddHelper;
|
||||
import com.tencent.supersonic.headless.api.query.pojo.Cache;
|
||||
import com.tencent.supersonic.headless.api.query.pojo.Param;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.JSQLParserException;
|
||||
import net.sf.jsqlparser.expression.Alias;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.Function;
|
||||
import net.sf.jsqlparser.expression.LongValue;
|
||||
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
|
||||
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
||||
import net.sf.jsqlparser.schema.Column;
|
||||
import net.sf.jsqlparser.schema.Table;
|
||||
import net.sf.jsqlparser.statement.select.GroupByElement;
|
||||
import net.sf.jsqlparser.statement.select.Limit;
|
||||
import net.sf.jsqlparser.statement.select.OrderByElement;
|
||||
import net.sf.jsqlparser.statement.select.PlainSelect;
|
||||
import net.sf.jsqlparser.statement.select.Select;
|
||||
import net.sf.jsqlparser.statement.select.SelectExpressionItem;
|
||||
import net.sf.jsqlparser.statement.select.SelectItem;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
public class QueryStructReq {
|
||||
|
||||
private Set<Long> modelIds;
|
||||
|
||||
private String modelName;
|
||||
private List<String> groups = new ArrayList<>();
|
||||
private List<Aggregator> aggregators = new ArrayList<>();
|
||||
private List<Order> orders = new ArrayList<>();
|
||||
private List<Filter> dimensionFilters = new ArrayList<>();
|
||||
private List<Filter> metricFilters = new ArrayList<>();
|
||||
private List<Param> params = new ArrayList<>();
|
||||
private DateConf dateInfo;
|
||||
private Long limit = 2000L;
|
||||
private QueryType queryType = QueryType.ID;
|
||||
private Cache cacheInfo;
|
||||
|
||||
/**
|
||||
* Later deleted for compatibility only
|
||||
*/
|
||||
private String s2SQL;
|
||||
/**
|
||||
* Later deleted for compatibility only
|
||||
*/
|
||||
private String correctS2SQL;
|
||||
|
||||
public void setModelId(Long modelId) {
|
||||
modelIds = new HashSet<>();
|
||||
modelIds.add(modelId);
|
||||
}
|
||||
|
||||
public List<Long> getModelIds() {
|
||||
return Lists.newArrayList(modelIds);
|
||||
}
|
||||
|
||||
public Set<Long> getModelIdSet() {
|
||||
return modelIds;
|
||||
}
|
||||
|
||||
public List<String> getGroups() {
|
||||
if (!CollectionUtils.isEmpty(this.groups)) {
|
||||
this.groups = groups.stream().filter(group -> !Strings.isEmpty(group)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(this.groups)) {
|
||||
this.groups = Lists.newArrayList();
|
||||
}
|
||||
|
||||
return this.groups;
|
||||
}
|
||||
|
||||
public List<String> getMetrics() {
|
||||
List<String> metrics = Lists.newArrayList();
|
||||
if (!CollectionUtils.isEmpty(this.aggregators)) {
|
||||
metrics = aggregators.stream().map(Aggregator::getColumn).collect(Collectors.toList());
|
||||
}
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public List<Order> getOrders() {
|
||||
if (orders == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return orders;
|
||||
}
|
||||
|
||||
public List<Param> getParams() {
|
||||
if (params == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public String toCustomizedString() {
|
||||
StringBuilder stringBuilder = new StringBuilder("{");
|
||||
stringBuilder.append("\"modelId\":")
|
||||
.append(modelIds);
|
||||
stringBuilder.append(",\"groups\":")
|
||||
.append(groups);
|
||||
stringBuilder.append(",\"aggregators\":")
|
||||
.append(aggregators);
|
||||
stringBuilder.append(",\"orders\":")
|
||||
.append(orders);
|
||||
stringBuilder.append(",\"filters\":")
|
||||
.append(dimensionFilters);
|
||||
stringBuilder.append(",\"dateInfo\":")
|
||||
.append(dateInfo);
|
||||
stringBuilder.append(",\"params\":")
|
||||
.append(params);
|
||||
stringBuilder.append(",\"limit\":")
|
||||
.append(limit);
|
||||
stringBuilder.append('}');
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public String generateCommandMd5() {
|
||||
return DigestUtils.md5Hex(this.toCustomizedString());
|
||||
}
|
||||
|
||||
public List<Filter> getOriginalFilter() {
|
||||
return dimensionFilters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"modelId\":")
|
||||
.append(modelIds);
|
||||
sb.append(",\"groups\":")
|
||||
.append(groups);
|
||||
sb.append(",\"aggregators\":")
|
||||
.append(aggregators);
|
||||
sb.append(",\"orders\":")
|
||||
.append(orders);
|
||||
sb.append(",\"dimensionFilters\":")
|
||||
.append(dimensionFilters);
|
||||
sb.append(",\"metricFilters\":")
|
||||
.append(metricFilters);
|
||||
sb.append(",\"params\":")
|
||||
.append(params);
|
||||
sb.append(",\"dateInfo\":")
|
||||
.append(dateInfo);
|
||||
sb.append(",\"limit\":")
|
||||
.append(limit);
|
||||
sb.append(",\"cacheInfo\":")
|
||||
.append(cacheInfo);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* convert queryStructReq to QueryS2QLReq
|
||||
*
|
||||
* @param queryStructReq
|
||||
* @return
|
||||
*/
|
||||
public QueryS2SQLReq convert(QueryStructReq queryStructReq) {
|
||||
String sql = null;
|
||||
try {
|
||||
sql = buildSql(queryStructReq);
|
||||
} catch (Exception e) {
|
||||
log.error("buildSql error", e);
|
||||
}
|
||||
|
||||
QueryS2SQLReq result = new QueryS2SQLReq();
|
||||
result.setSql(sql);
|
||||
result.setModelIds(queryStructReq.getModelIdSet());
|
||||
result.setVariables(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
private String buildSql(QueryStructReq queryStructReq) throws JSQLParserException {
|
||||
Select select = new Select();
|
||||
//1.Set the select items (columns)
|
||||
PlainSelect plainSelect = new PlainSelect();
|
||||
List<SelectItem> selectItems = new ArrayList<>();
|
||||
List<String> groups = queryStructReq.getGroups();
|
||||
if (!CollectionUtils.isEmpty(groups)) {
|
||||
for (String group : groups) {
|
||||
selectItems.add(new SelectExpressionItem(new Column(group)));
|
||||
}
|
||||
}
|
||||
List<Aggregator> aggregators = queryStructReq.getAggregators();
|
||||
if (!CollectionUtils.isEmpty(aggregators)) {
|
||||
for (Aggregator aggregator : aggregators) {
|
||||
String columnName = aggregator.getColumn();
|
||||
if (queryStructReq.getQueryType().isNativeAggQuery()) {
|
||||
selectItems.add(new SelectExpressionItem(new Column(columnName)));
|
||||
} else {
|
||||
Function sumFunction = new Function();
|
||||
AggOperatorEnum func = aggregator.getFunc();
|
||||
if (AggOperatorEnum.UNKNOWN.equals(func)) {
|
||||
func = AggOperatorEnum.SUM;
|
||||
}
|
||||
sumFunction.setName(func.getOperator());
|
||||
if (AggOperatorEnum.COUNT_DISTINCT.equals(func)) {
|
||||
sumFunction.setName("count");
|
||||
sumFunction.setDistinct(true);
|
||||
}
|
||||
sumFunction.setParameters(new ExpressionList(new Column(columnName)));
|
||||
SelectExpressionItem selectExpressionItem = new SelectExpressionItem(sumFunction);
|
||||
selectExpressionItem.setAlias(new Alias(columnName));
|
||||
selectItems.add(selectExpressionItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
plainSelect.setSelectItems(selectItems);
|
||||
//2.Set the table name
|
||||
Table table = new Table(queryStructReq.getModelName());
|
||||
plainSelect.setFromItem(table);
|
||||
|
||||
//3.Set the order by clause
|
||||
List<Order> orders = queryStructReq.getOrders();
|
||||
if (!CollectionUtils.isEmpty(orders)) {
|
||||
List<OrderByElement> orderByElements = new ArrayList<>();
|
||||
for (Order order : orders) {
|
||||
if (StringUtils.isBlank(order.getColumn())) {
|
||||
continue;
|
||||
}
|
||||
OrderByElement orderByElement = new OrderByElement();
|
||||
orderByElement.setExpression(new Column(order.getColumn()));
|
||||
orderByElement.setAsc(false);
|
||||
if (Constants.ASC_UPPER.equalsIgnoreCase(order.getDirection())) {
|
||||
orderByElement.setAsc(true);
|
||||
}
|
||||
orderByElements.add(orderByElement);
|
||||
}
|
||||
plainSelect.setOrderByElements(orderByElements);
|
||||
}
|
||||
|
||||
//4.Set the group by clause
|
||||
if (!CollectionUtils.isEmpty(groups) && !queryStructReq.getQueryType().isNativeAggQuery()) {
|
||||
GroupByElement groupByElement = new GroupByElement();
|
||||
for (String group : groups) {
|
||||
groupByElement.addGroupByExpression(new Column(group));
|
||||
}
|
||||
plainSelect.setGroupByElement(groupByElement);
|
||||
}
|
||||
|
||||
//5.Set the limit clause
|
||||
if (Objects.nonNull(queryStructReq.getLimit())) {
|
||||
Limit limit = new Limit();
|
||||
limit.setRowCount(new LongValue(queryStructReq.getLimit()));
|
||||
plainSelect.setLimit(limit);
|
||||
}
|
||||
select.setSelectBody(plainSelect);
|
||||
|
||||
//6.Set where
|
||||
List<Filter> dimensionFilters = queryStructReq.getDimensionFilters();
|
||||
SqlFilterUtils sqlFilterUtils = ContextUtils.getBean(SqlFilterUtils.class);
|
||||
String whereClause = sqlFilterUtils.getWhereClause(dimensionFilters, false);
|
||||
|
||||
String sql = select.toString();
|
||||
if (StringUtils.isNotBlank(whereClause)) {
|
||||
Expression expression = CCJSqlParserUtil.parseCondExpression(whereClause);
|
||||
sql = SqlParserAddHelper.addWhere(sql, expression);
|
||||
}
|
||||
|
||||
//7.Set DateInfo
|
||||
DateModeUtils dateModeUtils = ContextUtils.getBean(DateModeUtils.class);
|
||||
String dateWhereStr = dateModeUtils.getDateWhereStr(queryStructReq.getDateInfo());
|
||||
if (StringUtils.isNotBlank(dateWhereStr)) {
|
||||
Expression expression = CCJSqlParserUtil.parseCondExpression(dateWhereStr);
|
||||
sql = SqlParserAddHelper.addWhere(sql, expression);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tencent.supersonic.headless.api.query.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class ItemUseResp {
|
||||
|
||||
private Long domainId;
|
||||
private String type;
|
||||
private Long itemId;
|
||||
private String bizName;
|
||||
private Long useCnt;
|
||||
|
||||
public ItemUseResp(Long domainId, String type, String bizName, Long useCnt) {
|
||||
this.domainId = domainId;
|
||||
this.type = type;
|
||||
this.bizName = bizName;
|
||||
this.useCnt = useCnt;
|
||||
}
|
||||
}
|
||||
35
headless/materialization/pom.xml
Normal file
35
headless/materialization/pom.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>headless</artifactId>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>headless-materialization</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>headless-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>headless-model</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,485 @@
|
||||
package com.tencent.supersonic.headless.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;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import com.tencent.supersonic.common.util.jsqlparser.SqlParserSelectHelper;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementFrequencyEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.enums.ElementTypeEnum;
|
||||
import com.tencent.supersonic.headless.api.materialization.pojo.MaterializationConfFilter;
|
||||
import com.tencent.supersonic.headless.api.materialization.pojo.MaterializationFilter;
|
||||
import com.tencent.supersonic.headless.api.materialization.request.MaterializationElementReq;
|
||||
import com.tencent.supersonic.headless.api.materialization.request.MaterializationReq;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationElementModelResp;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationElementResp;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationResp;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationSourceResp;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.headless.api.model.pojo.SchemaItem;
|
||||
import com.tencent.supersonic.headless.api.model.request.ModelSchemaFilterReq;
|
||||
import com.tencent.supersonic.headless.api.model.response.DimSchemaResp;
|
||||
import com.tencent.supersonic.headless.api.model.response.MeasureResp;
|
||||
import com.tencent.supersonic.headless.api.model.response.MetricSchemaResp;
|
||||
import com.tencent.supersonic.headless.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.headless.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.headless.materialization.domain.MaterializationConfService;
|
||||
import com.tencent.supersonic.headless.materialization.domain.pojo.Materialization;
|
||||
import com.tencent.supersonic.headless.materialization.domain.repository.MaterializationElementRepository;
|
||||
import com.tencent.supersonic.headless.materialization.domain.repository.MaterializationRepository;
|
||||
import com.tencent.supersonic.headless.materialization.domain.utils.MaterializationConverter;
|
||||
import com.tencent.supersonic.headless.materialization.domain.utils.MaterializationZipperUtils;
|
||||
import com.tencent.supersonic.headless.materialization.domain.pojo.MaterializationElement;
|
||||
import com.tencent.supersonic.headless.model.domain.ModelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MaterializationConfServiceImpl implements MaterializationConfService {
|
||||
|
||||
private final MaterializationRepository materializationRepository;
|
||||
private final MaterializationElementRepository materializationElementRepository;
|
||||
private final ModelService modelService;
|
||||
private final MaterializationZipperUtils materializationZipperUtils;
|
||||
private String typeAndIdSplit = "_";
|
||||
|
||||
public MaterializationConfServiceImpl(MaterializationRepository materializationRepository,
|
||||
MaterializationElementRepository materializationElementRepository,
|
||||
ModelService modelService,
|
||||
MaterializationZipperUtils materializationZipperUtils) {
|
||||
this.materializationRepository = materializationRepository;
|
||||
this.materializationElementRepository = materializationElementRepository;
|
||||
this.modelService = modelService;
|
||||
this.materializationZipperUtils = materializationZipperUtils;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addMaterializationConf(MaterializationReq materializationReq, User user) {
|
||||
log.info("materializationReq:{}, user:{}", JsonUtil.toString(materializationReq), JsonUtil.toString(user));
|
||||
Materialization materialization = MaterializationConverter.materializationReq2Bean(materializationReq);
|
||||
RecordInfo recordInfo = new RecordInfo().createdBy(user.getName());
|
||||
BeanUtils.copyProperties(recordInfo, materialization);
|
||||
return materializationRepository.insert(materialization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateMaterializationConf(MaterializationReq materializationReq, User user) {
|
||||
Materialization materialization = MaterializationConverter.materializationReq2Bean(materializationReq);
|
||||
RecordInfo recordInfo = new RecordInfo().updatedBy(user.getName());
|
||||
BeanUtils.copyProperties(recordInfo, materialization);
|
||||
return materializationRepository.update(materialization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterializationResp> getMaterializationResp(MaterializationFilter filter, User user) {
|
||||
return materializationRepository.getMaterializationResp(filter);
|
||||
}
|
||||
|
||||
public MaterializationResp getMaterializationRespById(Long materializationId, User user) {
|
||||
MaterializationResp materializationResp = new MaterializationResp();
|
||||
MaterializationConfFilter filter = new MaterializationConfFilter();
|
||||
filter.setMaterializationId(materializationId);
|
||||
filter.setContainElements(true);
|
||||
List<MaterializationResp> materializationRespList = queryMaterializationConf(filter, user);
|
||||
if (CollectionUtils.isEmpty(materializationRespList)) {
|
||||
return materializationResp;
|
||||
}
|
||||
return materializationRespList.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addMaterializationElementConf(MaterializationElementReq materializationElementReq, User user) {
|
||||
log.info("materializationElementReq:{}, user:{}", JsonUtil.toString(materializationElementReq),
|
||||
JsonUtil.toString(user));
|
||||
MaterializationElement materializationElement = MaterializationConverter
|
||||
.materializationElementReq2Bean(materializationElementReq);
|
||||
RecordInfo recordInfo = new RecordInfo().createdBy(user.getName());
|
||||
BeanUtils.copyProperties(recordInfo, materializationElement);
|
||||
return materializationElementRepository.insert(materializationElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateMaterializationElementConf(MaterializationElementReq materializationElementReq, User user) {
|
||||
MaterializationElement materializationElement = MaterializationConverter
|
||||
.materializationElementReq2Bean(materializationElementReq);
|
||||
RecordInfo recordInfo = new RecordInfo().updatedBy(user.getName());
|
||||
BeanUtils.copyProperties(recordInfo, materializationElement);
|
||||
return materializationElementRepository.update(materializationElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterializationResp> queryMaterializationConf(MaterializationConfFilter filter, User user) {
|
||||
MaterializationFilter materializationFilter = MaterializationFilter.builder().build();
|
||||
BeanUtils.copyProperties(filter, materializationFilter);
|
||||
List<MaterializationResp> materializationRespList = getMaterializationResp(materializationFilter, user);
|
||||
if (!CollectionUtils.isEmpty(materializationRespList) && filter.getContainElements()) {
|
||||
Map<String, SchemaItem> keyAndSchemaItemPair = generateSchemaItem(filter, user);
|
||||
materializationRespList.stream().forEach(materializationResp -> {
|
||||
filter.setMaterializationId(materializationResp.getId());
|
||||
List<MaterializationElementResp> materializationElementRespList = materializationElementRepository
|
||||
.getMaterializationElementResp(filter);
|
||||
fillElementInfo(materializationElementRespList, keyAndSchemaItemPair);
|
||||
materializationResp.setMaterializationElementRespList(materializationElementRespList);
|
||||
});
|
||||
}
|
||||
|
||||
return materializationRespList;
|
||||
}
|
||||
|
||||
private void fillElementInfo(List<MaterializationElementResp> materializationElementRespList,
|
||||
Map<String, SchemaItem> keyAndSchemaItemPair) {
|
||||
if (CollectionUtils.isEmpty(materializationElementRespList) || Objects.isNull(keyAndSchemaItemPair)) {
|
||||
return;
|
||||
}
|
||||
materializationElementRespList.stream().forEach(materializationElementResp -> {
|
||||
String key = materializationElementResp.getType() + typeAndIdSplit + materializationElementResp.getId();
|
||||
SchemaItem schemaItem = keyAndSchemaItemPair.getOrDefault(key, null);
|
||||
if (Objects.nonNull(schemaItem)) {
|
||||
materializationElementResp.setBizName(schemaItem.getBizName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Map<String, SchemaItem> generateSchemaItem(MaterializationConfFilter filter, User user) {
|
||||
return generateSchemaItem(filter);
|
||||
}
|
||||
|
||||
private Map<String, SchemaItem> generateSchemaItem(MaterializationConfFilter filter) {
|
||||
Map<String, SchemaItem> keyAndSchemaItemPair = new HashMap<>();
|
||||
|
||||
ModelSchemaFilterReq modelFilter = new ModelSchemaFilterReq();
|
||||
List<Long> modelIds = new ArrayList<>();
|
||||
if (Objects.nonNull(filter.getModelId())) {
|
||||
modelIds.add(filter.getModelId());
|
||||
}
|
||||
List<ModelSchemaResp> modelSchemaRespList = modelService.fetchModelSchema(modelFilter);
|
||||
if (!CollectionUtils.isEmpty(modelSchemaRespList)) {
|
||||
modelSchemaRespList.stream().forEach(modelSchemaResp -> {
|
||||
List<DimSchemaResp> dimensions = modelSchemaResp.getDimensions();
|
||||
List<MetricSchemaResp> metrics = modelSchemaResp.getMetrics();
|
||||
if (!CollectionUtils.isEmpty(dimensions)) {
|
||||
dimensions.stream().forEach(dimSchemaResp -> {
|
||||
SchemaItem schemaItem = new SchemaItem();
|
||||
BeanUtils.copyProperties(dimSchemaResp, schemaItem);
|
||||
String key = TypeEnums.DIMENSION.name() + typeAndIdSplit + dimSchemaResp.getId();
|
||||
keyAndSchemaItemPair.put(key, schemaItem);
|
||||
});
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(metrics)) {
|
||||
metrics.stream().forEach(metricSchemaResp -> {
|
||||
SchemaItem schemaItem = new SchemaItem();
|
||||
BeanUtils.copyProperties(metricSchemaResp, schemaItem);
|
||||
String key = TypeEnums.METRIC.name() + typeAndIdSplit + metricSchemaResp.getId();
|
||||
keyAndSchemaItemPair.put(key, schemaItem);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return keyAndSchemaItemPair;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterializationResp> getMaterializationByModel(Long modelId) {
|
||||
MaterializationFilter filter = new MaterializationConfFilter();
|
||||
filter.setModelId(modelId);
|
||||
List<MaterializationResp> materializationRespList = materializationRepository.getMaterializationResp(filter);
|
||||
MaterializationConfFilter materializationConfFilter = new MaterializationConfFilter();
|
||||
if (!CollectionUtils.isEmpty(materializationRespList)) {
|
||||
materializationRespList.stream().forEach(materializationResp -> {
|
||||
materializationConfFilter.setMaterializationId(materializationResp.getId());
|
||||
List<MaterializationElementResp> materializationElementRespList = materializationElementRepository
|
||||
.getMaterializationElementResp(materializationConfFilter);
|
||||
materializationResp.setMaterializationElementRespList(materializationElementRespList);
|
||||
});
|
||||
}
|
||||
return materializationRespList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getMaterializationByTable(Long databaseId, String destinationTable) {
|
||||
MaterializationFilter filter = new MaterializationConfFilter();
|
||||
filter.setDestinationTable(destinationTable);
|
||||
filter.setDatabaseId(databaseId);
|
||||
List<MaterializationResp> materializationRespList = materializationRepository.getMaterializationResp(filter);
|
||||
if (!CollectionUtils.isEmpty(materializationRespList)) {
|
||||
return materializationRespList.stream().map(m -> m.getId()).collect(Collectors.toList());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateCreateSql(Long materializationId, User user) {
|
||||
MaterializationConfFilter filter = new MaterializationConfFilter();
|
||||
filter.setMaterializationId(materializationId);
|
||||
filter.setContainElements(true);
|
||||
List<MaterializationResp> materializationRespList = queryMaterializationConf(filter, user);
|
||||
if (CollectionUtils.isEmpty(materializationRespList)) {
|
||||
log.warn("materializationRespList is empty, materializationId:{}", materializationId);
|
||||
return "";
|
||||
}
|
||||
// 获取db 连接信息
|
||||
MaterializationResp materializationResp = materializationRespList.get(0);
|
||||
|
||||
return generateCreateSql(materializationResp);
|
||||
}
|
||||
|
||||
private String generateCreateSql(MaterializationResp materializationResp) {
|
||||
return materializationZipperUtils.generateCreateSql(materializationResp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean initMaterializationElementConf(MaterializationConfFilter filter, User user) {
|
||||
Long materializationId = filter.getMaterializationId();
|
||||
MaterializationResp materializationResp = getMaterializationRespById(materializationId, user);
|
||||
Long modelId = materializationResp.getModelId();
|
||||
ModelSchemaResp modelSchemaResp = modelService.fetchSingleModelSchema(modelId);
|
||||
|
||||
doDimensionMaterializationLogic(modelSchemaResp.getDimensions(), materializationResp, user);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doDimensionMaterializationLogic(List<DimSchemaResp> dimensions,
|
||||
MaterializationResp materializationResp, User user) {
|
||||
if (CollectionUtils.isEmpty(dimensions)) {
|
||||
return;
|
||||
}
|
||||
Long materializationId = materializationResp.getId();
|
||||
cleanMaterializationElement(materializationId, user);
|
||||
for (DimSchemaResp dimSchemaResp : dimensions) {
|
||||
MaterializationElementReq materializationElementReq = MaterializationElementReq.builder()
|
||||
.id(dimSchemaResp.getId())
|
||||
.type(TypeEnums.DIMENSION)
|
||||
.materializationId(materializationId)
|
||||
.elementType(ElementTypeEnum.VARCHAR)
|
||||
.frequency(ElementFrequencyEnum.LOW)
|
||||
.status(StatusEnum.ONLINE)
|
||||
.description(dimSchemaResp.getDescription())
|
||||
.build();
|
||||
|
||||
addMaterializationElementConf(materializationElementReq, user);
|
||||
}
|
||||
MaterializationConfFilter filter = new MaterializationConfFilter();
|
||||
filter.setMaterializationId(materializationId);
|
||||
|
||||
MaterializationResp materializationRespNew = getMaterializationRespById(materializationId, user);
|
||||
String createSql = generateCreateSql(materializationRespNew);
|
||||
log.info("createSql:{}", createSql);
|
||||
|
||||
}
|
||||
|
||||
private Boolean cleanMaterializationElement(Long materializationId, User user) {
|
||||
log.info("cleanMaterializationElement materializationId:{}", materializationId);
|
||||
return materializationElementRepository.cleanMaterializationElement(materializationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterializationElementModelResp> getMaterializationElementModels(Long materializationId, User user) {
|
||||
MaterializationResp materializationResp = materializationRepository.getMaterialization(materializationId);
|
||||
MaterializationConfFilter filter = new MaterializationConfFilter();
|
||||
filter.setMaterializationId(materializationId);
|
||||
List<MaterializationElementResp> materializationElementRespList = materializationElementRepository
|
||||
.getMaterializationElementResp(filter);
|
||||
List<MaterializationElementModelResp> materializationElementModelRespList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(materializationElementRespList)) {
|
||||
ModelSchemaFilterReq modelFilter = new ModelSchemaFilterReq();
|
||||
modelFilter.setModelIds(Arrays.asList(materializationResp.getModelId()));
|
||||
List<ModelSchemaResp> modelSchemaRespList = modelService.fetchModelSchema(modelFilter);
|
||||
List<MeasureResp> measureRespList = modelService.getMeasureListOfModel(
|
||||
Lists.newArrayList(materializationResp.getModelId()));
|
||||
Map<String, DimSchemaResp> dimSchemaRespMap = new HashMap<>();
|
||||
Map<String, MetricSchemaResp> metricSchemaRespHashMap = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(modelSchemaRespList)) {
|
||||
modelSchemaRespList.stream().forEach(modelSchemaResp -> {
|
||||
List<DimSchemaResp> dimensions = modelSchemaResp.getDimensions();
|
||||
List<MetricSchemaResp> metrics = modelSchemaResp.getMetrics();
|
||||
if (!CollectionUtils.isEmpty(dimensions)) {
|
||||
dimensions.stream().forEach(dimSchemaResp -> {
|
||||
String key = TypeEnums.DIMENSION.name() + typeAndIdSplit + dimSchemaResp.getId();
|
||||
dimSchemaRespMap.put(key, dimSchemaResp);
|
||||
});
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(metrics)) {
|
||||
metrics.stream().forEach(metricSchemaResp -> {
|
||||
String key = TypeEnums.METRIC.name() + typeAndIdSplit + metricSchemaResp.getId();
|
||||
metricSchemaRespHashMap.put(key, metricSchemaResp);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
materializationElementRespList.stream().forEach(materializationElementResp -> {
|
||||
String key = materializationElementResp.getType() + typeAndIdSplit + materializationElementResp.getId();
|
||||
DimSchemaResp schemaItem = dimSchemaRespMap.getOrDefault(key, null);
|
||||
MaterializationElementModelResp materializationElementModelResp = MaterializationElementModelResp
|
||||
.builder()
|
||||
.type(materializationElementResp.getType())
|
||||
.id(materializationElementResp.getId())
|
||||
.build();
|
||||
if (Objects.nonNull(schemaItem)) {
|
||||
materializationElementModelResp.setBizName(schemaItem.getBizName());
|
||||
materializationElementModelResp.setExpr(schemaItem.getExpr());
|
||||
materializationElementModelRespList.add(materializationElementModelResp);
|
||||
} else {
|
||||
MetricSchemaResp metricSchemaResp = metricSchemaRespHashMap.getOrDefault(key, null);
|
||||
if (Objects.nonNull(metricSchemaResp)) {
|
||||
materializationElementModelResp.setBizName(metricSchemaResp.getBizName());
|
||||
materializationElementModelResp.setExpr(metricSchemaResp.getTypeParams().getExpr());
|
||||
materializationElementModelResp.setMeasures(metricSchemaResp.getTypeParams().getMeasures());
|
||||
materializationElementModelResp.getMeasures().forEach(m -> {
|
||||
m.setExpr(getDataSourceMeasure(measureRespList, m.getBizName()));
|
||||
});
|
||||
materializationElementModelRespList.add(materializationElementModelResp);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return materializationElementModelRespList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterializationSourceResp> getMaterializationSourceResp(
|
||||
Long materializationId) {
|
||||
MaterializationResp materializationResp = materializationRepository.getMaterialization(
|
||||
materializationId);
|
||||
Long modelId = materializationResp.getModelId();
|
||||
|
||||
Set<Long> modelIds = new HashSet<>();
|
||||
Map<Long, Map<Long, String>> dataSourceDimensions = new HashMap<>();
|
||||
Map<Long, Map<Long, String>> dataSourceMetrics = new HashMap<>();
|
||||
MaterializationConfFilter materializationConfFilter = new MaterializationConfFilter();
|
||||
materializationConfFilter.setMaterializationId(materializationId);
|
||||
List<MaterializationElementResp> materializationElementRespList = materializationElementRepository
|
||||
.getMaterializationElementResp(materializationConfFilter);
|
||||
if (!CollectionUtils.isEmpty(materializationElementRespList)) {
|
||||
ModelSchemaFilterReq modelSchemaFilterReq = new ModelSchemaFilterReq();
|
||||
modelSchemaFilterReq.setModelIds(Arrays.asList(modelId));
|
||||
List<ModelSchemaResp> modelSchemaRespList = modelService.fetchModelSchema(modelSchemaFilterReq);
|
||||
List<MeasureResp> measureRespList = modelService.getMeasureListOfModel(Lists.newArrayList(modelId));
|
||||
Set<Long> dimensionIds = new HashSet<>();
|
||||
Set<Long> metricIds = new HashSet<>();
|
||||
materializationElementRespList.stream().forEach(e -> {
|
||||
if (e.getType().equals(TypeEnums.DIMENSION)) {
|
||||
dimensionIds.add(e.getId());
|
||||
}
|
||||
if (e.getType().equals(TypeEnums.METRIC)) {
|
||||
metricIds.add(e.getId());
|
||||
}
|
||||
});
|
||||
modelSchemaRespList.stream().forEach(m -> {
|
||||
m.getDimensions().stream().filter(mm -> dimensionIds.contains(mm.getId())).forEach(mm -> {
|
||||
if (!dataSourceDimensions.containsKey(mm.getModelId())) {
|
||||
dataSourceDimensions.put(mm.getModelId(), new HashMap<>());
|
||||
}
|
||||
dataSourceDimensions.get(mm.getModelId()).put(mm.getId(), mm.getBizName());
|
||||
modelIds.add(mm.getModelId());
|
||||
});
|
||||
m.getMetrics().stream().filter(mm -> metricIds.contains(mm.getId())).forEach(mm -> {
|
||||
Long sourceId = 0L;
|
||||
for (Measure measure : mm.getTypeParams().getMeasures()) {
|
||||
sourceId = getSourceIdByMeasure(measureRespList, measure.getBizName());
|
||||
if (sourceId > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sourceId > 0) {
|
||||
if (!dataSourceMetrics.containsKey(sourceId)) {
|
||||
dataSourceMetrics.put(sourceId, new HashMap<>());
|
||||
}
|
||||
dataSourceMetrics.get(sourceId).put(mm.getId(), mm.getBizName());
|
||||
modelIds.add(sourceId);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
List<MaterializationSourceResp> materializationSourceResps = new ArrayList<>();
|
||||
for (Long sourceId : modelIds) {
|
||||
//todo
|
||||
// Optional<ModelResp> modelResp = modelSchemaRespList.stream().filter(d -> d.getId().equals(sourceId))
|
||||
// .findFirst();
|
||||
Optional<ModelResp> modelResp = Optional.empty();
|
||||
if (modelResp.isPresent()) {
|
||||
MaterializationSourceResp materializationSourceResp = MaterializationSourceResp.builder()
|
||||
.dataSourceId(sourceId)
|
||||
.materializationId(materializationId)
|
||||
.modelId(modelId)
|
||||
.depends(modelResp.get().getDepends())
|
||||
.materializedType(materializationResp.getMaterializedType())
|
||||
.entities(materializationResp.getEntities())
|
||||
.dateInfo(materializationResp.getDateInfo())
|
||||
.updateCycle(materializationResp.getUpdateCycle())
|
||||
.build();
|
||||
setDataSourceDb(modelResp.get(), materializationSourceResp);
|
||||
materializationSourceResp.setMetrics(
|
||||
dataSourceMetrics.containsKey(sourceId) ? dataSourceMetrics.get(sourceId)
|
||||
: new HashMap<>());
|
||||
materializationSourceResp.setDimensions(
|
||||
dataSourceDimensions.containsKey(sourceId) ? dataSourceDimensions.get(sourceId)
|
||||
: new HashMap<>());
|
||||
materializationSourceResps.add(materializationSourceResp);
|
||||
}
|
||||
}
|
||||
return materializationSourceResps;
|
||||
}
|
||||
|
||||
public Long getSourceIdByMeasure(List<MeasureResp> measureRespList, String bizName) {
|
||||
if (!CollectionUtils.isEmpty(measureRespList)) {
|
||||
Optional<MeasureResp> measure = measureRespList.stream()
|
||||
.filter(m -> m.getBizName().equalsIgnoreCase(bizName)).findFirst();
|
||||
if (measure.isPresent()) {
|
||||
return measure.get().getDatasourceId();
|
||||
}
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
private void setDataSourceDb(ModelResp datasourceResp, MaterializationSourceResp materializationSourceResp) {
|
||||
if (Objects.nonNull(datasourceResp.getModelDetail())) {
|
||||
String dbTable = "";
|
||||
if (Objects.nonNull(datasourceResp.getModelDetail().getTableQuery())
|
||||
&& !datasourceResp.getModelDetail().getTableQuery().isEmpty()) {
|
||||
dbTable = datasourceResp.getModelDetail().getTableQuery();
|
||||
}
|
||||
if (Objects.nonNull(datasourceResp.getModelDetail().getSqlQuery())
|
||||
&& !datasourceResp.getModelDetail().getSqlQuery().isEmpty()) {
|
||||
dbTable = SqlParserSelectHelper.getDbTableName(datasourceResp.getModelDetail().getSqlQuery());
|
||||
}
|
||||
if (!dbTable.isEmpty()) {
|
||||
String[] db = dbTable.split("\\.");
|
||||
if (db.length > 1) {
|
||||
materializationSourceResp.setSourceDb(db[0]);
|
||||
materializationSourceResp.setSourceTable(db[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getDataSourceMeasure(List<MeasureResp> measureRespList, String bizName) {
|
||||
if (!CollectionUtils.isEmpty(measureRespList)) {
|
||||
Optional<MeasureResp> measure = measureRespList.stream()
|
||||
.filter(m -> m.getBizName().equalsIgnoreCase(bizName)).findFirst();
|
||||
if (measure.isPresent()) {
|
||||
return measure.get().getExpr();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.tencent.supersonic.headless.materialization.application;
|
||||
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import com.tencent.supersonic.headless.api.materialization.pojo.MaterializationDateFilter;
|
||||
import com.tencent.supersonic.headless.api.materialization.pojo.MaterializationRecordFilter;
|
||||
import com.tencent.supersonic.headless.api.materialization.request.MaterializationRecordReq;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationDateResp;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationRecordResp;
|
||||
import com.tencent.supersonic.headless.materialization.domain.MaterializationRecordService;
|
||||
import com.tencent.supersonic.headless.materialization.domain.pojo.MaterializationRecord;
|
||||
import com.tencent.supersonic.headless.materialization.domain.repository.MaterializationRecordRepository;
|
||||
import com.tencent.supersonic.headless.materialization.domain.utils.MaterializationRecordConverter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MaterializationRecordServiceImpl implements MaterializationRecordService {
|
||||
|
||||
private final MaterializationRecordRepository repository;
|
||||
|
||||
public MaterializationRecordServiceImpl(MaterializationRecordRepository materializationRecordRepository) {
|
||||
this.repository = materializationRecordRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addMaterializationRecord(MaterializationRecordReq materializationRecordReq, User user) {
|
||||
log.info("materializationRecordReq:{}, user:{}", JsonUtil.toString(materializationRecordReq),
|
||||
JsonUtil.toString(user));
|
||||
MaterializationRecord materializationRecord = MaterializationRecordConverter.req2Bean(materializationRecordReq);
|
||||
RecordInfo recordInfo = new RecordInfo().createdBy(user.getName());
|
||||
BeanUtils.copyProperties(recordInfo, materializationRecord);
|
||||
return repository.insertMaterializationRecord(materializationRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateMaterializationRecord(MaterializationRecordReq materializationRecordReq, User user) {
|
||||
log.info("materializationRecordReq:{}, user:{}", JsonUtil.toString(materializationRecordReq),
|
||||
JsonUtil.toString(user));
|
||||
MaterializationRecord materializationRecord = MaterializationRecordConverter.req2Bean(materializationRecordReq);
|
||||
RecordInfo recordInfo = new RecordInfo().updatedBy(user.getName());
|
||||
BeanUtils.copyProperties(recordInfo, materializationRecord);
|
||||
return repository.updateMaterializationRecord(materializationRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterializationRecordResp> getMaterializationRecordList(MaterializationRecordFilter filter, User user) {
|
||||
return repository.getMaterializationRecordList(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMaterializationRecordCount(MaterializationRecordFilter filter, User user) {
|
||||
return repository.getCount(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterializationDateResp> fetchMaterializationDate(MaterializationDateFilter filter, User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterializationRecordResp> fetchMaterializationDate(List<Long> materializationIds, String elementName,
|
||||
String startTime, String endTime) {
|
||||
MaterializationRecordFilter materializationRecordFilter = MaterializationRecordFilter.builder()
|
||||
.taskStatus(Arrays.asList(TaskStatusEnum.SUCCESS))
|
||||
.elementName(elementName)
|
||||
.materializationIds(materializationIds)
|
||||
.startDataTime(startTime)
|
||||
.endDataTime(endTime).build();
|
||||
return repository.getMaterializationRecordList(materializationRecordFilter);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.tencent.supersonic.headless.materialization.domain;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.headless.api.materialization.pojo.MaterializationConfFilter;
|
||||
import com.tencent.supersonic.headless.api.materialization.pojo.MaterializationFilter;
|
||||
import com.tencent.supersonic.headless.api.materialization.request.MaterializationElementReq;
|
||||
import com.tencent.supersonic.headless.api.materialization.request.MaterializationReq;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationElementModelResp;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationResp;
|
||||
import com.tencent.supersonic.headless.api.materialization.response.MaterializationSourceResp;
|
||||
import com.tencent.supersonic.headless.api.model.response.MeasureResp;
|
||||
import java.util.List;
|
||||
|
||||
public interface MaterializationConfService {
|
||||
|
||||
Boolean addMaterializationConf(MaterializationReq materializationReq, User user);
|
||||
|
||||
Boolean updateMaterializationConf(MaterializationReq materializationReq, User user);
|
||||
|
||||
List<MaterializationResp> getMaterializationResp(MaterializationFilter filter, User user);
|
||||
|
||||
Boolean addMaterializationElementConf(MaterializationElementReq materializationElementReq, User user);
|
||||
|
||||
Boolean updateMaterializationElementConf(MaterializationElementReq materializationElementReq, User user);
|
||||
|
||||
List<MaterializationResp> queryMaterializationConf(MaterializationConfFilter filter, User user);
|
||||
|
||||
List<MaterializationResp> getMaterializationByModel(Long modelId);
|
||||
|
||||
List<Long> getMaterializationByTable(Long databaseId, String destinationTable);
|
||||
|
||||
String generateCreateSql(Long materializationId, User user);
|
||||
|
||||
Boolean initMaterializationElementConf(MaterializationConfFilter filter, User user);
|
||||
|
||||
List<MaterializationElementModelResp> getMaterializationElementModels(Long materializationId, User user);
|
||||
|
||||
List<MaterializationSourceResp> getMaterializationSourceResp(Long materializationId);
|
||||
|
||||
Long getSourceIdByMeasure(List<MeasureResp> measureRespList, String bizName);
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user