Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(improvement)(chat) Add domain tree for agent and plugin setting #718

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.ExplainResp;
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
Expand Down Expand Up @@ -104,4 +105,9 @@ public PageInfo<MetricResp> getMetricPage(PageMetricReq pageMetricReq, User user
return metricService.queryMetric(pageMetricReq, user);
}

@Override
public List<ItemResp> getDomainViewTree() {
return schemaService.getDomainViewTree();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.ExplainResp;
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
Expand Down Expand Up @@ -253,8 +254,14 @@ protected List<ViewSchemaResp> doFetchViewSchema(List<Long> ids) {
return null;
}

@Override
public List<ItemResp> getDomainViewTree() {
return null;
}

@Override
public List<ViewResp> getViewList(Long domainId) {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.ExplainResp;
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
Expand Down Expand Up @@ -56,4 +57,6 @@ public interface SemanticInterpreter {

List<ViewResp> getViewList(Long domainId);

List<ItemResp> getDomainViewTree();

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.tencent.supersonic.headless.api.pojo.request.PageMetricReq;
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.ViewResp;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -106,4 +107,9 @@ public PageInfo<MetricResp> getMetric(@RequestBody PageMetricReq pageMetricReq,
return semanticInterpreter.getMetricPage(pageMetricReq, user);
}

@GetMapping("/getDomainViewTree")
public List<ItemResp> getDomainViewTree() {
return semanticInterpreter.getDomainViewTree();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.tencent.supersonic.headless.api.pojo.response;

import com.google.common.collect.Lists;
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ItemResp {

private Long id;

private Long parentId;

private String name;

private TypeEnums type;

private List<ItemResp> children = Lists.newArrayList();

public ItemResp(Long id, Long parentId, String name, TypeEnums type) {
this.id = id;
this.parentId = parentId;
this.name = name;
this.type = type;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.tencent.supersonic.headless.api.pojo.request.ViewFilterReq;
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
import com.tencent.supersonic.headless.api.pojo.response.ItemUseResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
Expand Down Expand Up @@ -40,4 +41,6 @@ public interface SchemaService {
SemanticSchemaResp fetchSemanticSchema(SchemaFilterReq schemaFilterReq);

List<ItemUseResp> getStatInfo(ItemUseReq itemUseReq) throws ExecutionException;

List<ItemResp> getDomainViewTree();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.tencent.supersonic.headless.api.pojo.response.DimSchemaResp;
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.ItemResp;
import com.tencent.supersonic.headless.api.pojo.response.ItemUseResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricSchemaResp;
Expand Down Expand Up @@ -307,6 +308,34 @@ public List<ItemUseResp> getStatInfo(ItemUseReq itemUseReq) {
return statUtils.getStatInfo(itemUseReq);
}

@Override
public List<ItemResp> getDomainViewTree() {
List<DomainResp> domainResps = domainService.getDomainList();
List<ItemResp> itemResps = domainResps.stream().map(domain ->
new ItemResp(domain.getId(), domain.getParentId(), domain.getName(), TypeEnums.DOMAIN))
.collect(Collectors.toList());
Map<Long, ItemResp> itemRespMap = itemResps.stream()
.collect(Collectors.toMap(ItemResp::getId, item -> item));
for (ItemResp itemResp : itemResps) {
ItemResp parentItem = itemRespMap.get(itemResp.getParentId());
if (parentItem == null) {
continue;
}
parentItem.getChildren().add(itemResp);
}
List<ViewResp> viewResps = viewService.getViewList(new MetaFilter());
for (ViewResp viewResp : viewResps) {
ItemResp itemResp = itemRespMap.get(viewResp.getDomainId());
if (itemResp != null) {
ItemResp view = new ItemResp(viewResp.getId(), viewResp.getDomainId(),
viewResp.getName(), TypeEnums.VIEW);
itemResp.getChildren().add(view);
}
}
return itemResps.stream().filter(itemResp -> itemResp.getParentId() == 0)
.collect(Collectors.toList());
}

private void fillStaticInfo(List<ViewSchemaResp> viewSchemaResps) throws ExecutionException {
List<Long> viewIds = viewSchemaResps.stream()
.map(ViewSchemaResp::getId).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import com.tencent.supersonic.headless.server.persistence.dataobject.ViewDO;
import com.tencent.supersonic.headless.server.persistence.mapper.ViewDOMapper;
import com.tencent.supersonic.headless.server.pojo.MetaFilter;
import com.tencent.supersonic.headless.server.service.DomainService;
import com.tencent.supersonic.headless.server.service.ViewService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

Expand All @@ -29,6 +31,9 @@
public class ViewServiceImpl
extends ServiceImpl<ViewDOMapper, ViewDO> implements ViewService {

@Autowired
private DomainService domainService;

@Override
public ViewResp save(ViewReq viewReq, User user) {
viewReq.createdBy(user.getName());
Expand Down
Loading