use of com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest in project Qualitis by WeBankFinTech.
the class AutoArgumentAdapter method findValueFromMultiDataSourceConfig.
private Map<String, String> findValueFromMultiDataSourceConfig(TemplateMidTableInputMeta templateMidTableInputMeta, String clusterName, MultiDataSourceConfigRequest firstDataSource, MultiDataSourceConfigRequest secondDataSource, List<MultiDataSourceJoinConfigRequest> mappings) {
Map<String, String> map = new HashMap<>(4);
String firstFileType = firstDataSource.getFileType();
String firstDbName = firstDataSource.getDbName();
if (firstFileType != null && !EXCEL_TYPE.contains(firstFileType)) {
firstDbName = "";
}
String secondFileType = secondDataSource.getFileType();
String secondDbName = secondDataSource.getDbName();
if (secondFileType != null && !EXCEL_TYPE.contains(secondFileType)) {
secondDbName = "";
}
Integer inputType = templateMidTableInputMeta.getInputType();
if (inputType.equals(TemplateInputTypeEnum.SOURCE_DB.getCode())) {
map.put("clusterName", clusterName);
map.put("dbName", firstDbName);
map.put("value", firstDbName);
} else if (inputType.equals(TemplateInputTypeEnum.SOURCE_TABLE.getCode())) {
map.put("clusterName", clusterName);
map.put("dbName", firstDbName);
map.put("tableName", firstDataSource.getTableName());
map.put("value", firstDataSource.getTableName());
} else if (inputType.equals(TemplateInputTypeEnum.SOURCE_FIELDS.getCode())) {
List<String> fieldName = new ArrayList<>();
for (MultiDataSourceJoinConfigRequest request : mappings) {
for (MultiDataSourceJoinColumnRequest columnRequest : request.getLeft()) {
if (columnRequest.getColumnName().equals(DIFF_COUNT)) {
continue;
}
fieldName.add(columnRequest.getColumnName().replace("tmp1.", ""));
}
}
map.put("value", String.join(", ", fieldName));
} else if (inputType.equals(TemplateInputTypeEnum.TARGET_DB.getCode())) {
map.put("clusterName", clusterName);
map.put("dbName", secondDbName);
map.put("value", secondDbName);
} else if (inputType.equals(TemplateInputTypeEnum.TARGET_TABLE.getCode())) {
map.put("clusterName", clusterName);
map.put("dbName", secondDbName);
map.put("tableName", secondDataSource.getTableName());
map.put("value", secondDataSource.getTableName());
} else if (inputType.equals(TemplateInputTypeEnum.TARGET_FIELDS.getCode())) {
List<String> fieldName = new ArrayList<>();
for (MultiDataSourceJoinConfigRequest request : mappings) {
for (MultiDataSourceJoinColumnRequest columnRequest : request.getRight()) {
if (columnRequest.getColumnName().equals(DIFF_COUNT)) {
continue;
}
fieldName.add(columnRequest.getColumnName().replace("tmp2.", ""));
}
}
map.put("value", String.join(", ", fieldName));
}
return map;
}
use of com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest in project Qualitis by WeBankFinTech.
the class AddMultiRuleRequestBuilder method parseStatementColumns.
private void parseStatementColumns(List<ColumnInfoDetail> cols, List<MultiDataSourceJoinColumnRequest> joinColumnRequests, String statement) {
Matcher m = STATEMENT_ELEMENT.matcher(statement);
while (m.find()) {
String element = m.group();
String colNameWithOutTmp = element.replace("tmp1.", "").replace("tmp2.", "");
String type = cols.stream().filter(field -> field.getFieldName().equals(colNameWithOutTmp)).map(ColumnInfoDetail::getDataType).collect(Collectors.joining());
joinColumnRequests.add(new MultiDataSourceJoinColumnRequest(element, type));
}
}
use of com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest in project Qualitis by WeBankFinTech.
the class RuleBatchServiceImpl method getMultiDataSourceJoinColumnRequest.
private List<MultiDataSourceJoinColumnRequest> getMultiDataSourceJoinColumnRequest(String names, String types) throws UnExpectedRequestException {
List<MultiDataSourceJoinColumnRequest> joinColumnRequests = new ArrayList<>();
String[] columnNames = names.split(",");
String[] columnTypes = types.split("\\|");
if (columnNames.length != columnTypes.length) {
throw new UnExpectedRequestException("Mapping fields names and types not corrent.");
}
for (int i = 0; i < columnNames.length; i++) {
joinColumnRequests.add(new MultiDataSourceJoinColumnRequest(columnNames[i], columnTypes[i]));
}
return joinColumnRequests;
}
use of com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest in project Qualitis by WeBankFinTech.
the class RuleNodeServiceImpl method getMultiDataSourceJoinColumnRequest.
private List<MultiDataSourceJoinColumnRequest> getMultiDataSourceJoinColumnRequest(String names, String types) {
List<MultiDataSourceJoinColumnRequest> joinColumnRequests = new ArrayList<>();
String[] columnNames = names.split(",");
String[] columnTypes = types.split("\\|");
for (int i = 0; i < columnNames.length; i++) {
joinColumnRequests.add(new MultiDataSourceJoinColumnRequest(columnNames[i], columnTypes[i]));
}
return joinColumnRequests;
}
Aggregations