Search in sources :

Example 1 with TemplateRegexpExpr

use of com.webank.wedatasphere.qualitis.rule.entity.TemplateRegexpExpr in project Qualitis by WeBankFinTech.

the class AutoArgumentAdapter method getRegexpValue.

/**
 * If replaceByRequest = true, return value in request
 * Else return value in database
 * @param templateMidTableInputMeta
 * @param templateArgumentRequests
 * @return
 */
private Map<String, String> getRegexpValue(TemplateMidTableInputMeta templateMidTableInputMeta, List<TemplateArgumentRequest> templateArgumentRequests) throws UnExpectedRequestException {
    if (templateMidTableInputMeta.getReplaceByRequest()) {
        // Get value in request
        String regexp = findRequestById(templateMidTableInputMeta.getId(), templateArgumentRequests).getArgumentValue();
        String value = escapeExprSpecialWord(regexp);
        return ImmutableMap.of("value", value);
    } else {
        String key = null;
        // Get value in database
        if (templateMidTableInputMeta.getRegexpType().equals(TemplateRegexpTypeEnum.DATE.getCode())) {
            key = findRequestById(templateMidTableInputMeta.getId(), templateArgumentRequests).getArgumentValue();
        }
        TemplateRegexpExpr templateRegexpExpr = regexpExprMapperRepository.findByRegexpTypeAndKeyName(templateMidTableInputMeta.getRegexpType(), key);
        if (templateRegexpExpr == null) {
            throw new UnExpectedRequestException("KeyName: [" + key + "] is not supported");
        }
        String value = escapeExprSpecialWord(templateRegexpExpr.getRegexpValue());
        Map<String, String> map = new HashMap<>(2);
        map.put("value", value);
        map.put("originValue", key);
        return Collections.unmodifiableMap(map);
    }
}
Also used : UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) TemplateRegexpExpr(com.webank.wedatasphere.qualitis.rule.entity.TemplateRegexpExpr)

Aggregations

UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)1 TemplateRegexpExpr (com.webank.wedatasphere.qualitis.rule.entity.TemplateRegexpExpr)1