Search in sources :

Example 1 with TemplateOutputMetaRequest

use of com.webank.wedatasphere.qualitis.rule.request.TemplateOutputMetaRequest in project Qualitis by WeBankFinTech.

the class RuleTemplateServiceImpl method createAndSaveTemplateInfo.

private void createAndSaveTemplateInfo(Template savedTemplate, AddRuleTemplateRequest request) {
    // Save template output meta.
    Set<TemplateOutputMeta> templateOutputMetas = new HashSet<>();
    for (TemplateOutputMetaRequest templateOutputMetaRequest : request.getTemplateOutputMetaRequests()) {
        templateOutputMetas.addAll(templateOutputMetaService.getAndSaveTemplateOutputMeta(templateOutputMetaRequest.getOutputName(), FunctionTypeEnum.getFunctionTypeByName(templateOutputMetaRequest.getFieldName()), request.getSaveMidTable(), savedTemplate));
    }
    savedTemplate.setTemplateOutputMetas(templateOutputMetas);
    LOGGER.info("Success to save template output meta. TemplateOutputMetas: {}", savedTemplate.getTemplateOutputMetas());
    // Save template mid_table input meta
    List<TemplateMidTableInputMeta> templateMidTableInputMetas = new ArrayList<>();
    for (TemplateMidTableInputMetaRequest templateMidTableInputMetaRequest : request.getTemplateMidTableInputMetaRequests()) {
        TemplateMidTableInputMeta templateMidTableInputMeta = new TemplateMidTableInputMeta();
        templateMidTableInputMeta.setName(templateMidTableInputMetaRequest.getName());
        templateMidTableInputMeta.setFieldType(templateMidTableInputMetaRequest.getFieldType());
        templateMidTableInputMeta.setInputType(templateMidTableInputMetaRequest.getInputType());
        templateMidTableInputMeta.setPlaceholder(templateMidTableInputMetaRequest.getPlaceholder());
        templateMidTableInputMeta.setPlaceholderDescription(templateMidTableInputMetaRequest.getPlaceholderDescription());
        templateMidTableInputMeta.setRegexpType(templateMidTableInputMetaRequest.getRegexpType());
        templateMidTableInputMeta.setReplaceByRequest(templateMidTableInputMetaRequest.getReplaceByRequest());
        templateMidTableInputMeta.setTemplate(savedTemplate);
        templateMidTableInputMetas.add(templateMidTableInputMeta);
    }
    savedTemplate.setTemplateMidTableInputMetas(templateMidTableInputMetaService.saveAll(templateMidTableInputMetas));
    LOGGER.info("Success to save template mid_table input meta. TemplateMidTableInputMetas: {}", savedTemplate.getTemplateMidTableInputMetas());
    // Save template statistics input meta
    List<TemplateStatisticsInputMeta> templateStatisticsInputMetas = new ArrayList<>();
    for (TemplateStatisticsInputMetaRequest templateStatisticsInputMetaRequest : request.getTemplateStatisticsInputMetaRequests()) {
        TemplateStatisticsInputMeta templateStatisticsInputMeta = new TemplateStatisticsInputMeta();
        templateStatisticsInputMeta.setName(templateStatisticsInputMetaRequest.getName());
        templateStatisticsInputMeta.setFuncName(templateStatisticsInputMetaRequest.getFuncName());
        templateStatisticsInputMeta.setResultType(templateStatisticsInputMetaRequest.getResultType());
        templateStatisticsInputMeta.setValue(templateStatisticsInputMetaRequest.getValue());
        templateStatisticsInputMeta.setValueType(templateStatisticsInputMetaRequest.getValueType());
        templateStatisticsInputMeta.setTemplate(savedTemplate);
        templateStatisticsInputMetas.add(templateStatisticsInputMeta);
    }
    savedTemplate.setStatisticAction(templateStatisticsInputMetaService.saveAll(templateStatisticsInputMetas));
    LOGGER.info("Success to save template statistics input meta. templateStatisticsInputMetas: {}", savedTemplate.getStatisticAction());
}
Also used : TemplateOutputMetaRequest(com.webank.wedatasphere.qualitis.rule.request.TemplateOutputMetaRequest) TemplateStatisticsInputMetaRequest(com.webank.wedatasphere.qualitis.rule.request.TemplateStatisticsInputMetaRequest) TemplateMidTableInputMetaRequest(com.webank.wedatasphere.qualitis.rule.request.TemplateMidTableInputMetaRequest) ArrayList(java.util.ArrayList) TemplateMidTableInputMeta(com.webank.wedatasphere.qualitis.rule.entity.TemplateMidTableInputMeta) TemplateOutputMeta(com.webank.wedatasphere.qualitis.rule.entity.TemplateOutputMeta) HashSet(java.util.HashSet) TemplateStatisticsInputMeta(com.webank.wedatasphere.qualitis.rule.entity.TemplateStatisticsInputMeta)

Aggregations

TemplateMidTableInputMeta (com.webank.wedatasphere.qualitis.rule.entity.TemplateMidTableInputMeta)1 TemplateOutputMeta (com.webank.wedatasphere.qualitis.rule.entity.TemplateOutputMeta)1 TemplateStatisticsInputMeta (com.webank.wedatasphere.qualitis.rule.entity.TemplateStatisticsInputMeta)1 TemplateMidTableInputMetaRequest (com.webank.wedatasphere.qualitis.rule.request.TemplateMidTableInputMetaRequest)1 TemplateOutputMetaRequest (com.webank.wedatasphere.qualitis.rule.request.TemplateOutputMetaRequest)1 TemplateStatisticsInputMetaRequest (com.webank.wedatasphere.qualitis.rule.request.TemplateStatisticsInputMetaRequest)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1