|
|
|
|
@@ -1083,9 +1083,7 @@ public class DataSetTableService {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
|
|
|
|
}
|
|
|
|
|
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
|
|
|
|
if (CollectionUtils.isEmpty(fields)) {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_cst_ds_tb_or_field_deleted") + String.format(":table id [%s]", tableId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] array = fields.stream().map(f -> table + "." + f.getDataeaseName() + " AS " + DorisTableUtils.dorisFieldName(tableId + "_" + f.getDataeaseName())).toArray(String[]::new);
|
|
|
|
|
checkedInfo.put(table, array);
|
|
|
|
|
checkedFields.addAll(fields);
|
|
|
|
|
@@ -1103,7 +1101,7 @@ public class DataSetTableService {
|
|
|
|
|
Map.Entry<String, String[]> next = iterator.next();
|
|
|
|
|
field.append(StringUtils.join(next.getValue(), ",")).append(",");
|
|
|
|
|
}
|
|
|
|
|
String f = field.substring(0, field.length() - 1);
|
|
|
|
|
String f = subPrefixSuffixChar(field.toString());
|
|
|
|
|
// join
|
|
|
|
|
StringBuilder join = new StringBuilder();
|
|
|
|
|
for (UnionParamDTO unionParamDTO : unionList) {
|
|
|
|
|
@@ -1134,13 +1132,13 @@ public class DataSetTableService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(f)) {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_custom_ds_delete"));
|
|
|
|
|
DEException.throwException(Translator.get("i18n_union_ds_no_checked"));
|
|
|
|
|
}
|
|
|
|
|
sql = MessageFormat.format("SELECT {0} FROM {1}", f, DorisTableUtils.dorisName(union.get(0).getCurrentDs().getId())) + join.toString();
|
|
|
|
|
} else {
|
|
|
|
|
String f = StringUtils.join(checkedInfo.get(DorisTableUtils.dorisName(union.get(0).getCurrentDs().getId())), ",");
|
|
|
|
|
if (StringUtils.isEmpty(f)) {
|
|
|
|
|
throw new RuntimeException(Translator.get("i18n_custom_ds_delete"));
|
|
|
|
|
throw new RuntimeException(Translator.get("i18n_union_ds_no_checked"));
|
|
|
|
|
}
|
|
|
|
|
sql = MessageFormat.format("SELECT {0} FROM {1}", f, DorisTableUtils.dorisName(union.get(0).getCurrentDs().getId()));
|
|
|
|
|
}
|
|
|
|
|
@@ -1162,9 +1160,7 @@ public class DataSetTableService {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
|
|
|
|
}
|
|
|
|
|
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
|
|
|
|
if (CollectionUtils.isEmpty(fields)) {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_cst_ds_tb_or_field_deleted") + String.format(":table id [%s]", tableId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] array = fields.stream().map(f -> table + "." + f.getDataeaseName() + " AS " + DorisTableUtils.dorisFieldName(tableId + "_" + f.getDataeaseName())).toArray(String[]::new);
|
|
|
|
|
checkedInfo.put(table, array);
|
|
|
|
|
checkedFields.addAll(fields);
|
|
|
|
|
@@ -1196,9 +1192,7 @@ public class DataSetTableService {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
|
|
|
|
}
|
|
|
|
|
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
|
|
|
|
if (CollectionUtils.isEmpty(fields)) {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_cst_ds_tb_or_field_deleted") + String.format(":table id [%s]", tableId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] array = fields.stream().map(f -> String.format(keyword, table) + "." + String.format(keyword, f.getOriginName()) + " AS " + DorisTableUtils.dorisFieldNameShort(tableId + "_" + f.getOriginName())).toArray(String[]::new);
|
|
|
|
|
checkedInfo.put(table, array);
|
|
|
|
|
checkedFields.addAll(fields);
|
|
|
|
|
@@ -1216,7 +1210,7 @@ public class DataSetTableService {
|
|
|
|
|
Map.Entry<String, String[]> next = iterator.next();
|
|
|
|
|
field.append(StringUtils.join(next.getValue(), ",")).append(",");
|
|
|
|
|
}
|
|
|
|
|
String f = field.substring(0, field.length() - 1);
|
|
|
|
|
String f = subPrefixSuffixChar(field.toString());
|
|
|
|
|
// join
|
|
|
|
|
StringBuilder join = new StringBuilder();
|
|
|
|
|
for (UnionParamDTO unionParamDTO : unionList) {
|
|
|
|
|
@@ -1249,13 +1243,13 @@ public class DataSetTableService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(f)) {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_custom_ds_delete"));
|
|
|
|
|
DEException.throwException(Translator.get("i18n_union_ds_no_checked"));
|
|
|
|
|
}
|
|
|
|
|
sql = MessageFormat.format("SELECT {0} FROM {1}", f, String.format(keyword, tableName)) + join.toString();
|
|
|
|
|
} else {
|
|
|
|
|
String f = StringUtils.join(checkedInfo.get(tableName), ",");
|
|
|
|
|
if (StringUtils.isEmpty(f)) {
|
|
|
|
|
throw new RuntimeException(Translator.get("i18n_custom_ds_delete"));
|
|
|
|
|
throw new RuntimeException(Translator.get("i18n_union_ds_no_checked"));
|
|
|
|
|
}
|
|
|
|
|
sql = MessageFormat.format("SELECT {0} FROM {1}", f, String.format(keyword, tableName));
|
|
|
|
|
}
|
|
|
|
|
@@ -1266,6 +1260,16 @@ public class DataSetTableService {
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String subPrefixSuffixChar(String str) {
|
|
|
|
|
while (StringUtils.startsWith(str, ",")) {
|
|
|
|
|
str = str.substring(1, str.length());
|
|
|
|
|
}
|
|
|
|
|
while (StringUtils.endsWith(str, ",")) {
|
|
|
|
|
str = str.substring(0, str.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 递归计算出所有子级的checkedFields和unionParam
|
|
|
|
|
private void getUnionSQLDatasourceJoin(List<UnionDTO> childrenDs, Map<String, String[]> checkedInfo, List<UnionParamDTO> unionList, String keyword, List<DatasetTableField> checkedFields) {
|
|
|
|
|
for (int i = 0; i < childrenDs.size(); i++) {
|
|
|
|
|
@@ -1279,9 +1283,7 @@ public class DataSetTableService {
|
|
|
|
|
String table = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable();
|
|
|
|
|
|
|
|
|
|
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
|
|
|
|
if (CollectionUtils.isEmpty(fields)) {
|
|
|
|
|
DEException.throwException(Translator.get("i18n_cst_ds_tb_or_field_deleted") + String.format(":table id [%s]", tableId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] array = fields.stream().map(f -> String.format(keyword, table) + "." + String.format(keyword, f.getOriginName()) + " AS " + DorisTableUtils.dorisFieldNameShort(tableId + "_" + f.getOriginName())).toArray(String[]::new);
|
|
|
|
|
checkedInfo.put(table, array);
|
|
|
|
|
checkedFields.addAll(fields);
|
|
|
|
|
|