mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 13:07:32 +00:00
[improvement][headless]Update the model without updating the names of metrics and dimensions. (#1999)
This commit is contained in:
@@ -465,10 +465,11 @@ public class DimensionServiceImpl extends ServiceImpl<DimensionDOMapper, Dimensi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isChange(DimensionReq dimensionReq, DimensionResp dimensionResp) {
|
private boolean isChange(DimensionReq dimensionReq, DimensionResp dimensionResp) {
|
||||||
|
boolean isNameChange = !dimensionReq.getName().equals(dimensionResp.getName());
|
||||||
boolean isExtChange = !new EqualsBuilder()
|
boolean isExtChange = !new EqualsBuilder()
|
||||||
.append(dimensionReq.getExt(), dimensionResp.getExt()).isEquals();
|
.append(dimensionReq.getExt(), dimensionResp.getExt()).isEquals();
|
||||||
boolean isTypeParamChange =
|
boolean isTypeParamChange =
|
||||||
!Objects.equals(dimensionReq.getTypeParams(), dimensionResp.getTypeParams());
|
!Objects.equals(dimensionReq.getTypeParams(), dimensionResp.getTypeParams());
|
||||||
return isExtChange || isTypeParamChange;
|
return isNameChange || isExtChange || isTypeParamChange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,11 +96,25 @@ public class MetricServiceImpl extends ServiceImpl<MetricDOMapper, MetricDO>
|
|||||||
.collect(Collectors.toMap(MetricResp::getBizName, a -> a, (k1, k2) -> k1));
|
.collect(Collectors.toMap(MetricResp::getBizName, a -> a, (k1, k2) -> k1));
|
||||||
Map<String, MetricResp> nameMap = metricResps.stream()
|
Map<String, MetricResp> nameMap = metricResps.stream()
|
||||||
.collect(Collectors.toMap(MetricResp::getName, a -> a, (k1, k2) -> k1));
|
.collect(Collectors.toMap(MetricResp::getName, a -> a, (k1, k2) -> k1));
|
||||||
List<MetricReq> metricToInsert =
|
List<MetricReq> metricToInsert = Lists.newArrayList();
|
||||||
metricReqs.stream()
|
metricReqs.stream().forEach(metric -> {
|
||||||
.filter(metric -> !bizNameMap.containsKey(metric.getBizName())
|
if (!bizNameMap.containsKey(metric.getBizName())
|
||||||
&& !nameMap.containsKey(metric.getName()))
|
&& !nameMap.containsKey(metric.getName())) {
|
||||||
.collect(Collectors.toList());
|
metricToInsert.add(metric);
|
||||||
|
} else {
|
||||||
|
MetricResp metricRespByBizName = bizNameMap.get(metric.getBizName());
|
||||||
|
MetricResp metricRespByName = nameMap.get(metric.getName());
|
||||||
|
if (null != metricRespByBizName && isChange(metric, metricRespByBizName)) {
|
||||||
|
metric.setId(metricRespByBizName.getId());
|
||||||
|
this.updateMetric(metric, user);
|
||||||
|
} else {
|
||||||
|
if (null != metricRespByName && isChange(metric, metricRespByName)) {
|
||||||
|
metric.setId(metricRespByName.getId());
|
||||||
|
this.updateMetric(metric, user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
if (CollectionUtils.isEmpty(metricToInsert)) {
|
if (CollectionUtils.isEmpty(metricToInsert)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -804,4 +818,9 @@ public class MetricServiceImpl extends ServiceImpl<MetricDOMapper, MetricDO>
|
|||||||
.getAllModelByDomainIds(Collections.singletonList(queryMetricReq.getDomainId()));
|
.getAllModelByDomainIds(Collections.singletonList(queryMetricReq.getDomainId()));
|
||||||
return modelResps.stream().map(ModelResp::getId).collect(Collectors.toSet());
|
return modelResps.stream().map(ModelResp::getId).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isChange(MetricReq metricReq, MetricResp metricResp) {
|
||||||
|
boolean isNameChange = !metricReq.getName().equals(metricResp.getName());
|
||||||
|
return isNameChange;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user