mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(improvement)(Headless) Put term into dict and let it can be mapped by mapper (#1002)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DataSetSchema {
|
||||
@@ -12,6 +12,7 @@ public class DataSetSchema {
|
||||
private Set<SchemaElement> dimensions = new HashSet<>();
|
||||
private Set<SchemaElement> tags = new HashSet<>();
|
||||
private Set<SchemaElement> dimensionValues = new HashSet<>();
|
||||
private Set<SchemaElement> terms = new HashSet<>();
|
||||
private SchemaElement entity = new SchemaElement();
|
||||
private QueryConfig queryConfig;
|
||||
|
||||
@@ -37,6 +38,9 @@ public class DataSetSchema {
|
||||
case TAG:
|
||||
element = tags.stream().filter(e -> e.getId() == elementID).findFirst();
|
||||
break;
|
||||
case TERM:
|
||||
element = terms.stream().filter(e -> e.getId() == elementID).findFirst();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
@@ -8,5 +8,6 @@ public enum SchemaElementType {
|
||||
ENTITY,
|
||||
ID,
|
||||
DATE,
|
||||
TAG
|
||||
TAG,
|
||||
TERM
|
||||
}
|
||||
|
||||
@@ -44,6 +44,9 @@ public class SemanticSchema implements Serializable {
|
||||
case TAG:
|
||||
element = getElementsById(elementID, getTags());
|
||||
break;
|
||||
case TERM:
|
||||
element = getElementsById(elementID, getTerms());
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -118,6 +121,12 @@ public class SemanticSchema implements Serializable {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public List<SchemaElement> getTerms() {
|
||||
List<SchemaElement> terms = new ArrayList<>();
|
||||
dataSetSchemaList.stream().forEach(d -> terms.addAll(d.getTerms()));
|
||||
return terms;
|
||||
}
|
||||
|
||||
private List<SchemaElement> getElementsByDataSetId(Long dataSetId, List<SchemaElement> elements) {
|
||||
return elements.stream()
|
||||
.filter(schemaElement -> dataSetId.equals(schemaElement.getDataSet()))
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.tencent.supersonic.headless.api.pojo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Term {
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private List<String> similarTerms = Lists.newArrayList();
|
||||
|
||||
}
|
||||
@@ -2,18 +2,23 @@ package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.api.pojo.Term;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TermSetReq extends RecordInfo {
|
||||
public class TermReq extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotNull(message = "主题域ID不可为空")
|
||||
private Long domainId;
|
||||
|
||||
private List<Term> terms = Lists.newArrayList();
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private List<String> alias = Lists.newArrayList();
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class DataSetSchemaResp extends DataSetResp {
|
||||
private List<MetricSchemaResp> metrics = Lists.newArrayList();
|
||||
private List<DimSchemaResp> dimensions = Lists.newArrayList();
|
||||
private List<ModelResp> modelResps = Lists.newArrayList();
|
||||
private List<TermResp> termResps = Lists.newArrayList();
|
||||
|
||||
public DimSchemaResp getPrimaryKey() {
|
||||
for (ModelResp modelResp : modelResps) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tencent.supersonic.headless.api.pojo.response;
|
||||
|
||||
import com.tencent.supersonic.headless.api.pojo.Term;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElementMatch;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -14,6 +14,6 @@ public class MapInfoResp {
|
||||
|
||||
private Map<String, DataSetMapInfo> dataSetMapInfo = new HashMap<>();
|
||||
|
||||
private Map<String, List<Term>> terms = new HashMap<>();
|
||||
private Map<String, List<SchemaElementMatch>> terms = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
@@ -2,23 +2,27 @@ package com.tencent.supersonic.headless.api.pojo.response;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.common.pojo.RecordInfo;
|
||||
import com.tencent.supersonic.headless.api.pojo.Term;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TermSetResp extends RecordInfo {
|
||||
public class TermResp extends RecordInfo {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotNull(message = "主题域ID不可为空")
|
||||
private Long domainId;
|
||||
|
||||
private List<Term> terms = Lists.newArrayList();
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private List<String> alias = Lists.newArrayList();
|
||||
|
||||
public TermSetResp(Long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user