use of com.webank.wedatasphere.qualitis.rule.request.TemplateArgumentRequest in project Qualitis by WeBankFinTech.
the class RuleBatchServiceImpl method getTemplateArgument.
private void getTemplateArgument(List<TemplateArgumentRequest> templateArgumentRequests, ExcelTemplateRuleByProject excelTemplateRule, Template template) throws UnExpectedRequestException {
String argumentKey = excelTemplateRule.getArgumentKey();
if (!StringUtils.isBlank(argumentKey)) {
TemplateArgumentRequest templateArgumentRequest = new TemplateArgumentRequest();
templateArgumentRequest.setArgumentStep(InputActionStepEnum.TEMPLATE_INPUT_META.getCode());
String argumentValue = excelTemplateRule.getArgumentValue();
templateArgumentRequest.setArgumentValue(argumentValue);
TemplateMidTableInputMeta templateMidTableInputMeta = findByTemplateAndName(template, argumentKey);
if (templateMidTableInputMeta == null) {
throw new UnExpectedRequestException("{&TEMPLATE_ARGUMENT}: [" + argumentKey + "] {&DOES_NOT_EXIST}");
}
templateArgumentRequest.setArgumentId(templateMidTableInputMeta.getId());
templateArgumentRequests.add(templateArgumentRequest);
}
}
use of com.webank.wedatasphere.qualitis.rule.request.TemplateArgumentRequest in project Qualitis by WeBankFinTech.
the class AddRuleRequestBuilder method templateArgumentSetting.
private void templateArgumentSetting(List<TemplateArgumentRequest> templateArgumentRequests, String condition1, String condition2) {
List<TemplateMidTableInputMeta> templateMidTableInputMetaList = new ArrayList<>(2);
for (TemplateMidTableInputMeta templateMidTableInputMeta : template.getTemplateMidTableInputMetas()) {
if (TemplateMidTableUtil.shouldResponse(templateMidTableInputMeta)) {
templateMidTableInputMetaList.add(templateMidTableInputMeta);
}
}
Collections.sort(templateMidTableInputMetaList, new Comparator<TemplateMidTableInputMeta>() {
@Override
public int compare(TemplateMidTableInputMeta templateMidTableInputMetaFront, TemplateMidTableInputMeta templateMidTableInputMetaBack) {
return Long.compare(templateMidTableInputMetaFront.getId(), templateMidTableInputMetaBack.getId());
}
});
templateArgumentRequests.add(new TemplateArgumentRequest(templateMidTableInputMetaList.get(0).getId(), InputActionStepEnum.TEMPLATE_INPUT_META.getCode(), condition1));
templateArgumentRequests.add(new TemplateArgumentRequest(templateMidTableInputMetaList.get(1).getId(), InputActionStepEnum.TEMPLATE_INPUT_META.getCode(), condition2));
addRuleRequest.setTemplateArgumentRequests(templateArgumentRequests);
}
use of com.webank.wedatasphere.qualitis.rule.request.TemplateArgumentRequest in project Qualitis by WeBankFinTech.
the class RuleBatchServiceImpl method constructAddRuleRequest.
private List<AddRuleRequest> constructAddRuleRequest(Map<String, List<ExcelTemplateRuleByProject>> partitionedByRuleName, Project project, String localeStr) throws UnExpectedRequestException {
List<AddRuleRequest> addRuleRequests = new ArrayList<>();
for (String ruleName : partitionedByRuleName.keySet()) {
List<ExcelTemplateRuleByProject> ruleInfos = partitionedByRuleName.get(ruleName);
ExcelTemplateRuleByProject firstCommonInfo = ruleInfos.get(0);
AddRuleRequest addRuleRequest = new AddRuleRequest();
String ruleDetail = firstCommonInfo.getRuleDetail();
String ruleCnName = firstCommonInfo.getRuleCnName();
String ruleGroupName = firstCommonInfo.getRuleGroupName();
String ruleTemplateName = firstCommonInfo.getTemplateName();
addRuleRequest.setRuleCnName(ruleCnName);
addRuleRequest.setAbortOnFailure(firstCommonInfo.getAbortOnFailure());
addRuleRequest.setStaticStartupParam(firstCommonInfo.getStaticStartupParam());
addRuleRequest.setDeleteFailCheckResult(firstCommonInfo.getDeleteFailCheckResult());
addRuleRequest.setSpecifyStaticStartupParam(firstCommonInfo.getSpecifyStaticStartupParam());
if (StringUtils.isBlank(ruleGroupName)) {
throw new UnExpectedRequestException("RuleGroupName {&CAN_NOT_BE_NULL_OR_EMPTY}");
}
Template template = findTemplateByName(ruleTemplateName);
if (template == null) {
throw new UnExpectedRequestException("{&TEMPLATE_NAME}: [" + ruleTemplateName + "] {&DOES_NOT_EXIST}");
}
boolean alarm = false;
Long projectId = project.getId();
List<DataSourceRequest> dataSourceRequests = new ArrayList<>();
List<AlarmConfigRequest> alarmConfigRequests = new ArrayList<>();
List<TemplateArgumentRequest> templateArgumentRequests = new ArrayList<>();
for (ExcelTemplateRuleByProject excelTemplateRuleByProject : ruleInfos) {
getDataSourceRequest(dataSourceRequests, excelTemplateRuleByProject);
getTemplateArgument(templateArgumentRequests, excelTemplateRuleByProject, template);
getAlarmConfig(alarmConfigRequests, excelTemplateRuleByProject, template, localeStr);
}
RuleGroup ruleGroupInDb = ruleGroupDao.findByRuleGroupNameAndProjectId(ruleGroupName, projectId);
if (ruleGroupInDb != null) {
addRuleRequest.setRuleGroupId(ruleGroupInDb.getId());
} else {
RuleGroup ruleGroup = ruleGroupDao.saveRuleGroup(new RuleGroup(ruleGroupName, project.getId()));
addRuleRequest.setRuleGroupId(ruleGroup.getId());
}
// Construct addRuleRequest
addRuleRequest.setRuleName(ruleName);
addRuleRequest.setRuleDetail(ruleDetail);
addRuleRequest.setRuleTemplateId(template.getId());
if (!alarmConfigRequests.isEmpty()) {
alarm = true;
}
addRuleRequest.setAlarmVariable(alarmConfigRequests);
addRuleRequest.setDatasource(dataSourceRequests);
addRuleRequest.setProjectId(projectId);
addRuleRequest.setAlarm(alarm);
addRuleRequest.setTemplateArgumentRequests(templateArgumentRequests);
addRuleRequests.add(addRuleRequest);
}
return addRuleRequests;
}
use of com.webank.wedatasphere.qualitis.rule.request.TemplateArgumentRequest in project Qualitis by WeBankFinTech.
the class RuleNodeServiceImpl method constructTemplateArgumentRequest.
private List<TemplateArgumentRequest> constructTemplateArgumentRequest(Rule rule) {
List<TemplateArgumentRequest> templateArgumentRequests = new ArrayList<>(rule.getTemplate().getTemplateMidTableInputMetas().size());
for (TemplateMidTableInputMeta templateMidTableInputMeta : rule.getTemplate().getTemplateMidTableInputMetas()) {
if (TemplateMidTableUtil.shouldResponse(templateMidTableInputMeta)) {
for (RuleVariable ruleVariable : rule.getRuleVariables()) {
TemplateArgumentRequest templateArgumentRequest = new TemplateArgumentRequest();
if (ruleVariable.getTemplateMidTableInputMeta().equals(templateMidTableInputMeta)) {
String value = StringEscapeUtils.unescapeJava(ruleVariable.getValue());
if (templateMidTableInputMeta.getInputType().equals(TemplateInputTypeEnum.REGEXP.getCode())) {
if (templateMidTableInputMeta.getRegexpType() != null) {
value = ruleVariable.getOriginValue();
}
}
templateArgumentRequest.setArgumentStep(InputActionStepEnum.TEMPLATE_INPUT_META.getCode());
templateArgumentRequest.setArgumentId(templateMidTableInputMeta.getId());
templateArgumentRequest.setArgumentValue(value);
templateArgumentRequests.add(templateArgumentRequest);
}
}
}
}
return templateArgumentRequests;
}
Aggregations