mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 14:36:47 +00:00
(feature)(headless) Add a new headless-api module and Change old headless-api module to headless-common (#582)
* (improvement)(headless) Add headless-api module * (improvement)(headless) Change old headless-api module to headless-common --------- Co-authored-by: jolunoluo <jolunoluo@tencent.com>
This commit is contained in:
69
headless/common/pom.xml
Normal file
69
headless/common/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-common</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.common.materialization.enums;
|
||||
|
||||
public enum ElementFrequencyEnum {
|
||||
|
||||
UNKNOWN,
|
||||
HIGH,
|
||||
LOW
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.tencent.supersonic.headless.common.materialization.enums;
|
||||
|
||||
public enum ElementTypeEnum {
|
||||
|
||||
VARCHAR,
|
||||
DOUBLE,
|
||||
BIGINT,
|
||||
INT,
|
||||
DATE,
|
||||
ARRAY
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.tencent.supersonic.headless.common.materialization.enums;
|
||||
|
||||
|
||||
public enum UpdateCycleEnum {
|
||||
DAY,
|
||||
WEEK,
|
||||
MONTH
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.materialization.pojo;
|
||||
|
||||
import com.tencent.supersonic.headless.common.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.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.common.materialization.enums.ElementFrequencyEnum;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.materialization.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.headless.common.materialization.enums.UpdateCycleEnum;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.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.common.materialization.response;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.headless.common.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.common.materialization.response;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.headless.common.materialization.enums.ElementFrequencyEnum;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.materialization.response;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.common.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.common.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.common.materialization.response;
|
||||
|
||||
import com.tencent.supersonic.headless.common.model.enums.ModelSourceTypeEnum;
|
||||
import com.tencent.supersonic.headless.common.model.response.DatabaseResp;
|
||||
import com.tencent.supersonic.headless.common.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,29 @@
|
||||
package com.tencent.supersonic.headless.common.model.enums;
|
||||
|
||||
public enum AppStatusEnum {
|
||||
|
||||
INIT(0),
|
||||
ONLINE(1),
|
||||
OFFLINE(2),
|
||||
DELETED(3),
|
||||
UNKNOWN(4);
|
||||
|
||||
private Integer code;
|
||||
|
||||
AppStatusEnum(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static AppStatusEnum fromCode(Integer code) {
|
||||
for (AppStatusEnum appStatusEnum : AppStatusEnum.values()) {
|
||||
if (appStatusEnum.getCode().equals(code)) {
|
||||
return appStatusEnum;
|
||||
}
|
||||
}
|
||||
return AppStatusEnum.UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.model.enums;
|
||||
|
||||
|
||||
public enum DimensionTypeEnum {
|
||||
|
||||
categorical,
|
||||
time
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.tencent.supersonic.headless.common.model.enums;
|
||||
|
||||
public enum IdentifyTypeEnum {
|
||||
|
||||
primary,
|
||||
|
||||
foreign,
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.tencent.supersonic.headless.common.model.enums;
|
||||
|
||||
|
||||
public enum MetricTypeEnum {
|
||||
|
||||
ATOMIC,
|
||||
DERIVED
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.model.enums;
|
||||
|
||||
public enum QueryOptMode {
|
||||
|
||||
NONE,
|
||||
|
||||
MATERIALIZATION
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.model.enums;
|
||||
|
||||
public enum SemanticTypeEnum {
|
||||
|
||||
CATEGORY,
|
||||
ID,
|
||||
DATE,
|
||||
NUMBER
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.tencent.supersonic.headless.common.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
public class AppConfig {
|
||||
|
||||
private List<Item> items = Lists.newArrayList();
|
||||
|
||||
public Set<Item> getAllItems() {
|
||||
Set<Item> itemSet = new HashSet<>();
|
||||
for (Item item : items) {
|
||||
itemSet.add(item);
|
||||
itemSet.addAll(item.getRelateItems());
|
||||
}
|
||||
return itemSet;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tencent.supersonic.headless.common.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,70 @@
|
||||
package com.tencent.supersonic.headless.common.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"
|
||||
);
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return bizName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.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.common.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,35 @@
|
||||
package com.tencent.supersonic.headless.common.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;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return bizName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tencent.supersonic.headless.common.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.enums.ApiItemType;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Item {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String bizName;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
private ApiItemType type;
|
||||
|
||||
private List<Item> relateItems = Lists.newArrayList();
|
||||
|
||||
public String getValue() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.tencent.supersonic.headless.common.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,35 @@
|
||||
package com.tencent.supersonic.headless.common.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 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;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return expr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.model.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.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.common.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.common.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,29 @@
|
||||
package com.tencent.supersonic.headless.common.model.request;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.PageBaseReq;
|
||||
import com.tencent.supersonic.headless.common.model.enums.AppStatusEnum;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class AppQueryReq extends PageBaseReq {
|
||||
|
||||
private String name;
|
||||
|
||||
private List<AppStatusEnum> appStatus;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
public List<Integer> getStatus() {
|
||||
if (CollectionUtils.isEmpty(appStatus)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return appStatus.stream().map(AppStatusEnum::getCode).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.tencent.supersonic.headless.common.model.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.AppConfig;
|
||||
import lombok.Data;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppReq extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private AppConfig config;
|
||||
|
||||
private Date endDate;
|
||||
|
||||
private Integer qps;
|
||||
|
||||
private List<String> owners;
|
||||
|
||||
public String getOwner() {
|
||||
if (CollectionUtils.isEmpty(owners)) {
|
||||
return "";
|
||||
}
|
||||
return String.join(",", owners);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.tencent.supersonic.headless.common.model.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.model.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.DimValueMap;
|
||||
import com.tencent.supersonic.headless.common.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.common.model.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.headless.common.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.common.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DomainUpdateReq extends DomainReq {
|
||||
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.model.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.RelateDimension;
|
||||
import com.tencent.supersonic.headless.common.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.common.model.request;
|
||||
|
||||
|
||||
import com.tencent.supersonic.headless.common.model.enums.MetricTypeEnum;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.Measure;
|
||||
import com.tencent.supersonic.headless.common.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,76 @@
|
||||
package com.tencent.supersonic.headless.common.model.request;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.ModelDetail;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.SchemaItem;
|
||||
import lombok.Data;
|
||||
|
||||
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;
|
||||
|
||||
private List<String> viewOrgs;
|
||||
|
||||
private List<String> admins;
|
||||
|
||||
private List<String> adminOrgs;
|
||||
|
||||
public List<Dim> getTimeDimension() {
|
||||
if (modelDetail == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return modelDetail.getTimeDims();
|
||||
}
|
||||
|
||||
public String getViewer() {
|
||||
if (viewers == null) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", viewers);
|
||||
}
|
||||
|
||||
public String getViewOrg() {
|
||||
if (viewOrgs == null) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", viewOrgs);
|
||||
}
|
||||
|
||||
public String getAdmin() {
|
||||
if (admins == null) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", admins);
|
||||
}
|
||||
|
||||
public String getAdminOrg() {
|
||||
if (adminOrgs == null) {
|
||||
return null;
|
||||
}
|
||||
return String.join(",", adminOrgs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class PageDimensionReq extends PageSchemaItemReq {
|
||||
|
||||
private Integer isTag;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tencent.supersonic.headless.common.model.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class PageMetricReq extends PageSchemaItemReq {
|
||||
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.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,10 @@
|
||||
package com.tencent.supersonic.headless.common.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppDetailResp extends AppResp {
|
||||
|
||||
private String appSecret;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.tencent.supersonic.headless.common.model.response;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.common.model.enums.AppStatusEnum;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.AppConfig;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AppResp extends RecordInfo {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private AppStatusEnum appStatus;
|
||||
|
||||
private AppConfig config;
|
||||
|
||||
private Date endDate;
|
||||
|
||||
private Integer qps;
|
||||
|
||||
private List<String> owners;
|
||||
|
||||
private boolean hasAdminRes;
|
||||
|
||||
public void setOwner(String owner) {
|
||||
if (StringUtils.isBlank(owner)) {
|
||||
owners = Lists.newArrayList();
|
||||
return;
|
||||
}
|
||||
owners = Arrays.asList(owner.split(","));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.model.response;
|
||||
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.DataTypeEnums;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.DimValueMap;
|
||||
import com.tencent.supersonic.headless.common.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.common.model.response;
|
||||
|
||||
import com.tencent.supersonic.headless.common.model.pojo.Entity;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.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.common.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.common.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.Measure;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.RelateDimension;
|
||||
import com.tencent.supersonic.headless.common.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.common.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class MetricSchemaResp extends MetricResp {
|
||||
|
||||
private Long useCnt = 0L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.tencent.supersonic.headless.common.model.response;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.Identify;
|
||||
import com.tencent.supersonic.headless.common.model.pojo.ModelDetail;
|
||||
import com.tencent.supersonic.headless.common.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;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.model.response;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.ModelRela;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.model.enums.SemanticTypeEnum;
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.model.yaml;
|
||||
|
||||
import com.tencent.supersonic.headless.common.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.common.model.yaml;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class DimensionTimeTypeParamsTpl {
|
||||
|
||||
private String isPrimary;
|
||||
|
||||
private String timeGranularity;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.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.common.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.common.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.common.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,15 @@
|
||||
package com.tencent.supersonic.headless.common.query.pojo;
|
||||
|
||||
|
||||
import com.tencent.supersonic.headless.common.model.pojo.Item;
|
||||
import com.tencent.supersonic.headless.common.model.response.QueryResultWithSchemaResp;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiQuerySingleResult {
|
||||
|
||||
private Item item;
|
||||
|
||||
private QueryResultWithSchemaResp result;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.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.common.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.common.query.pojo;
|
||||
|
||||
import com.tencent.supersonic.headless.common.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.common.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.common.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.common.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.common.query.request;
|
||||
|
||||
import com.tencent.supersonic.headless.common.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.common.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,17 @@
|
||||
package com.tencent.supersonic.headless.common.query.request;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.ApiItemType;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MetaQueryApiReq {
|
||||
|
||||
@NotEmpty(message = "ids不可为空")
|
||||
private List<Long> ids;
|
||||
|
||||
private ApiItemType type = ApiItemType.METRIC;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.tencent.supersonic.headless.common.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.common.query.request;
|
||||
|
||||
import com.tencent.supersonic.headless.common.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;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user