Search in sources :

Example 6 with MultiDataSourceJoinColumnRequest

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;
}
Also used : MultiDataSourceJoinConfigRequest(com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinConfigRequest) MultiDataSourceJoinColumnRequest(com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest)

Example 7 with MultiDataSourceJoinColumnRequest

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));
    }
}
Also used : Matcher(java.util.regex.Matcher) MultiDataSourceJoinColumnRequest(com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest)

Example 8 with MultiDataSourceJoinColumnRequest

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;
}
Also used : UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) MultiDataSourceJoinColumnRequest(com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest) ArrayList(java.util.ArrayList)

Example 9 with MultiDataSourceJoinColumnRequest

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;
}
Also used : MultiDataSourceJoinColumnRequest(com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest) ArrayList(java.util.ArrayList)

Aggregations

MultiDataSourceJoinColumnRequest (com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest)9 MultiDataSourceJoinConfigRequest (com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinConfigRequest)6 ArrayList (java.util.ArrayList)5 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)3 TemplateMidTableInputMeta (com.webank.wedatasphere.qualitis.rule.entity.TemplateMidTableInputMeta)2 AlarmConfigRequest (com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest)2 AddMultiSourceRuleRequest (com.webank.wedatasphere.qualitis.rule.request.multi.AddMultiSourceRuleRequest)2 MultiDataSourceConfigRequest (com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceConfigRequest)2 Iterator (java.util.Iterator)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 LocalConfig (com.webank.wedatasphere.qualitis.LocalConfig)1 SpecCharEnum (com.webank.wedatasphere.qualitis.constant.SpecCharEnum)1 RuleMetricDao (com.webank.wedatasphere.qualitis.dao.RuleMetricDao)1 RuleMetricDepartmentUserDao (com.webank.wedatasphere.qualitis.dao.RuleMetricDepartmentUserDao)1 UserDao (com.webank.wedatasphere.qualitis.dao.UserDao)1 UserRoleDao (com.webank.wedatasphere.qualitis.dao.UserRoleDao)1 RuleMetric (com.webank.wedatasphere.qualitis.entity.RuleMetric)1 User (com.webank.wedatasphere.qualitis.entity.User)1 PermissionDeniedRequestException (com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException)1 MetaDataAcquireFailedException (com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException)1