Search in sources :

Example 11 with TemplateStatisticsInputMeta

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

the class JdbcTranslator method sentenceWithoutRunDate.

private void sentenceWithoutRunDate(Set<TemplateStatisticsInputMeta> templateStatisticsInputMetas, List<RuleVariable> ruleVariables, List<String> list, String applicationId, String createTime, Integer count, Long ruleId, Map<String, Long> ruleMetricMap) throws RuleVariableNotSupportException, RuleVariableNotFoundException {
    for (TemplateStatisticsInputMeta s : templateStatisticsInputMetas) {
        String funcName = s.getFuncName();
        String value = getValue(ruleVariables, s);
        String persistSentence = statisticsAndSaveResultTemplate.replace(STATISTICS_VALUE_PLACEHOLDER, funcName + "(" + value + ")").replace(STATISTICS_APPLICATION_ID_PLACEHOLDER, applicationId).replace(STATISTICS_RESULT_TYPE_PLACEHOLDER, s.getResultType()).replace(STATISTICS_CREATE_TIME_PLACEHOLDER, createTime).replace(SqlTemplateConverter.VARIABLE_NAME_PLACEHOLDER, getVariable(count)).replace(STATISTICS_RULE_ID_PLACEHOLDER, ruleId + "");
        if (ruleMetricMap.get(value) != null) {
            persistSentence = persistSentence.replace(STATISTICS_RULE_METRIC_ID_PLACEHOLDER, ruleMetricMap.get(value) + "");
        } else {
            if (CollectionUtils.isNotEmpty(ruleMetricMap.values())) {
                persistSentence = persistSentence.replace(STATISTICS_RULE_METRIC_ID_PLACEHOLDER, ruleMetricMap.values().iterator().next() + "");
            } else {
                persistSentence = persistSentence.replace(STATISTICS_RULE_METRIC_ID_PLACEHOLDER, "-1");
            }
        }
        persistSentence = persistSentence.replace(STATISTICS_RUN_DATE_PLACEHOLDER, "-1");
        list.add(persistSentence);
        LOGGER.info("Succeed to get persist sentence. sentence: {}", persistSentence);
    }
}
Also used : TemplateStatisticsInputMeta(com.webank.wedatasphere.qualitis.rule.entity.TemplateStatisticsInputMeta)

Aggregations

TemplateStatisticsInputMeta (com.webank.wedatasphere.qualitis.rule.entity.TemplateStatisticsInputMeta)11 TemplateOutputMeta (com.webank.wedatasphere.qualitis.rule.entity.TemplateOutputMeta)7 HashSet (java.util.HashSet)7 Template (com.webank.wedatasphere.qualitis.rule.entity.Template)6 ArrayList (java.util.ArrayList)6 TemplateMidTableInputMeta (com.webank.wedatasphere.qualitis.rule.entity.TemplateMidTableInputMeta)5 RuleMetric (com.webank.wedatasphere.qualitis.entity.RuleMetric)4 AlarmConfig (com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig)3 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)3 RuleDataSource (com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource)3 TemplateDataSourceType (com.webank.wedatasphere.qualitis.rule.entity.TemplateDataSourceType)3 RuleVariableNotSupportException (com.webank.wedatasphere.qualitis.exception.RuleVariableNotSupportException)2 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)2 RuleDataSourceMapping (com.webank.wedatasphere.qualitis.rule.entity.RuleDataSourceMapping)2 RuleVariable (com.webank.wedatasphere.qualitis.rule.entity.RuleVariable)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 List (java.util.List)2 Set (java.util.Set)2 Transactional (org.springframework.transaction.annotation.Transactional)2